@relation-graph/react 3.0.0 → 3.0.1

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 (234) hide show
  1. package/package.json +2 -2
  2. package/relation-graph.js +251 -23
  3. package/relation-graph.mjs +7368 -5902
  4. package/relation-graph.umd.js +251 -23
  5. package/types/packages/platforms/react/src/index.d.ts +98 -64
  6. package/types/packages/platforms/react/src/relation-graph/RGProvider.d.ts +4 -0
  7. package/types/packages/platforms/react/src/relation-graph/RelationGraph.d.ts +7 -3
  8. package/types/packages/platforms/react/src/relation-graph/RelationLinker.d.ts +4 -5
  9. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvas.d.ts +2 -3
  10. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvasContent.d.ts +10 -3
  11. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvasContent4CreatingLine.d.ts +10 -0
  12. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvasContent4FakeLines.d.ts +11 -0
  13. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvasContent4Lines.d.ts +12 -0
  14. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGCanvasContent4Nodes.d.ts +13 -0
  15. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGFakeNode.d.ts +1 -1
  16. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGGraphRefs.d.ts +0 -1
  17. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLineContent.d.ts +1 -1
  18. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLinePath.d.ts +1 -1
  19. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLinePeel.d.ts +2 -3
  20. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLineText.d.ts +1 -1
  21. package/types/packages/platforms/react/src/relation-graph/src/core4react/RGNodePeel.d.ts +10 -1
  22. package/types/packages/platforms/react/src/relation-graph/src/core4react/RelationGraphUI.d.ts +4 -0
  23. package/types/packages/platforms/react/src/relation-graph/src/core4react/RelationGraphView.d.ts +4 -0
  24. package/types/packages/platforms/react/src/relation-graph/src/core4react/RelationLinkerCanvas.d.ts +4 -5
  25. package/types/packages/platforms/react/src/relation-graph/src/core4react/RelationLinkerUI.d.ts +4 -0
  26. package/types/packages/platforms/react/src/relation-graph/src/core4react/RelationLinkerView.d.ts +4 -0
  27. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGConnectSource.d.ts +1 -1
  28. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGConnectTarget.d.ts +1 -1
  29. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingConnectPoints.d.ts +1 -1
  30. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingLineController.d.ts +1 -1
  31. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingNearNodeWidget.d.ts +1 -1
  32. package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGMiniView.d.ts +1 -1
  33. package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnLine.d.ts +1 -1
  34. package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnLineText.d.ts +1 -1
  35. package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnNode.d.ts +1 -1
  36. package/types/packages/platforms/react/src/relation-graph/src/core4react/store/index.d.ts +3 -2
  37. package/types/packages/platforms/react/src/relation-graph/src/core4react/store/reducers/RGStore.d.ts +10 -0
  38. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphBackground.d.ts +1 -1
  39. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphOperateStuff.d.ts +1 -1
  40. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphToolBar.d.ts +1 -1
  41. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphWatermark.d.ts +1 -1
  42. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphXsToolBar.d.ts +1 -1
  43. package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/RGDebugView.d.ts +3 -0
  44. package/types/packages/platforms/react/src/relation-graph/src/hooks/RGDataProvider.d.ts +17 -0
  45. package/types/packages/platforms/react/src/relation-graph/src/hooks/RGHooks.d.ts +24 -1
  46. package/types/packages/platforms/react/src/relation-graph/src/hooks/useFakeNodesState.d.ts +1 -1
  47. package/types/packages/platforms/react/src/relation-graph/src/hooks/useGraphInstance.d.ts +2 -12
  48. package/types/packages/platforms/react/src/relation-graph/src/hooks/useGraphStore.d.ts +13 -0
  49. package/types/packages/platforms/react/src/relation-graph/src/hooks/useRelationGraph.d.ts +11 -0
  50. package/types/packages/platforms/react/src/relation-graph/src/hooks/useRelationLinker.d.ts +17 -0
  51. package/types/packages/platforms/react/src/types-react.d.ts +24 -24
  52. package/types/packages/platforms/svelte/src/RGProvider.svelte.d.ts +1 -0
  53. package/types/packages/platforms/svelte/src/context.d.ts +4 -0
  54. package/types/packages/platforms/svelte/src/core4svelte/RGCanvas.svelte.d.ts +1 -0
  55. package/types/packages/platforms/svelte/src/core4svelte/RGCanvasContent.svelte.d.ts +1 -0
  56. package/types/packages/platforms/svelte/src/core4svelte/RGCanvasContent4CreatingLine.svelte.d.ts +1 -0
  57. package/types/packages/platforms/svelte/src/core4svelte/RGCanvasContent4FakeLines.svelte.d.ts +1 -0
  58. package/types/packages/platforms/svelte/src/core4svelte/RGCanvasContent4Lines.svelte.d.ts +1 -0
  59. package/types/packages/platforms/svelte/src/core4svelte/RGCanvasContent4Nodes.svelte.d.ts +1 -0
  60. package/types/packages/platforms/svelte/src/core4svelte/RGEasyView.svelte.d.ts +1 -0
  61. package/types/packages/platforms/svelte/src/core4svelte/RGFakeNode.svelte.d.ts +1 -0
  62. package/types/packages/platforms/svelte/src/core4svelte/RGGraphDefs.svelte.d.ts +1 -0
  63. package/types/packages/platforms/svelte/src/core4svelte/RGLineContent.svelte.d.ts +1 -0
  64. package/types/packages/platforms/svelte/src/core4svelte/RGLinePath.svelte.d.ts +1 -0
  65. package/types/packages/platforms/svelte/src/core4svelte/RGLinePeel.svelte.d.ts +1 -0
  66. package/types/packages/platforms/svelte/src/core4svelte/RGLineText.svelte.d.ts +1 -0
  67. package/types/packages/platforms/svelte/src/core4svelte/RGNodeExpandHolder.svelte.d.ts +1 -0
  68. package/types/packages/platforms/svelte/src/core4svelte/RGNodePeel.svelte.d.ts +1 -0
  69. package/types/packages/platforms/svelte/src/core4svelte/RGProvider4Instance.svelte.d.ts +1 -0
  70. package/types/packages/platforms/svelte/src/core4svelte/RelationGraph.svelte.d.ts +1 -0
  71. package/types/packages/platforms/svelte/src/core4svelte/RelationGraphUI.svelte.d.ts +1 -0
  72. package/types/packages/platforms/svelte/src/core4svelte/RelationLinker.svelte.d.ts +1 -0
  73. package/types/packages/platforms/svelte/src/core4svelte/RelationLinkerCanvas.svelte.d.ts +1 -0
  74. package/types/packages/platforms/svelte/src/core4svelte/RelationLinkerUI.svelte.d.ts +1 -0
  75. package/types/packages/platforms/svelte/src/core4svelte/editing/RGConnectSource.svelte.d.ts +1 -0
  76. package/types/packages/platforms/svelte/src/core4svelte/editing/RGConnectTarget.svelte.d.ts +1 -0
  77. package/types/packages/platforms/svelte/src/core4svelte/editing/RGConnectTargetUI.svelte.d.ts +1 -0
  78. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingConnectController.svelte.d.ts +1 -0
  79. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingConnectPoints.svelte.d.ts +1 -0
  80. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingLineController.svelte.d.ts +1 -0
  81. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingLineControllerUI.svelte.d.ts +1 -0
  82. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingNearNodeWidget.svelte.d.ts +1 -0
  83. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingNodeController.svelte.d.ts +1 -0
  84. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingNodeControllerUI.svelte.d.ts +1 -0
  85. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingReferenceLine.svelte.d.ts +1 -0
  86. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingResize.svelte.d.ts +1 -0
  87. package/types/packages/platforms/svelte/src/core4svelte/editing/RGEditingResizeUI.svelte.d.ts +1 -0
  88. package/types/packages/platforms/svelte/src/core4svelte/editing/RGMiniView.svelte.d.ts +1 -0
  89. package/types/packages/platforms/svelte/src/core4svelte/editing/RGMiniViewContent.svelte.d.ts +1 -0
  90. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGConnectTarget.svelte.d.ts +1 -0
  91. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingConnectController.svelte.d.ts +1 -0
  92. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingLineController.svelte.d.ts +1 -0
  93. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingNearNodeWidget.svelte.d.ts +1 -0
  94. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingNodeController.svelte.d.ts +1 -0
  95. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingReferenceLine.svelte.d.ts +1 -0
  96. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGEditingResize.svelte.d.ts +1 -0
  97. package/types/packages/platforms/svelte/src/core4svelte/web-components/RGMiniView.svelte.d.ts +1 -0
  98. package/types/packages/platforms/svelte/src/core4svelte/web-components/RelationGraphWithProvider.svelte.d.ts +1 -0
  99. package/types/packages/platforms/svelte/src/core4svelte/web-components/WebComponentUtils.d.ts +11 -0
  100. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphBackground.svelte.d.ts +1 -0
  101. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphLoading.svelte.d.ts +1 -0
  102. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphMoveOperator.svelte.d.ts +1 -0
  103. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphOperateStuff.svelte.d.ts +1 -0
  104. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphWatermark.svelte.d.ts +1 -0
  105. package/types/packages/platforms/svelte/src/core4svelte/widgets/GraphXsToolBar.svelte.d.ts +1 -0
  106. package/types/packages/platforms/svelte/src/core4svelte/widgets/RGIcons.svelte.d.ts +1 -0
  107. package/types/packages/platforms/svelte/src/hooks/RGHooks.d.ts +27 -0
  108. package/types/packages/platforms/svelte/src/hooks/useGraphInstance.d.ts +2 -0
  109. package/types/packages/platforms/svelte/src/hooks/useGraphStore.d.ts +14 -0
  110. package/types/packages/platforms/svelte/src/hooks/useRGDataProvider.d.ts +19 -0
  111. package/types/packages/platforms/svelte/src/hooks/useRelationGraph.d.ts +48 -0
  112. package/types/packages/platforms/svelte/src/index.d.ts +194 -0
  113. package/types/packages/platforms/svelte/src/types-svelte.d.ts +85 -0
  114. package/types/packages/platforms/vue2/src/core4vue/RGCanvas.vue.d.ts +2 -6
  115. package/types/packages/platforms/vue2/src/core4vue/RGCanvasContent.vue.d.ts +6 -6
  116. package/types/packages/platforms/vue2/src/core4vue/RGCanvasContent4CreatingLine.vue.d.ts +9 -0
  117. package/types/packages/platforms/vue2/src/core4vue/RGCanvasContent4FakeLines.vue.d.ts +9 -0
  118. package/types/packages/platforms/vue2/src/core4vue/RGCanvasContent4Lines.vue.d.ts +9 -0
  119. package/types/packages/platforms/vue2/src/core4vue/RGCanvasContent4Nodes.vue.d.ts +9 -0
  120. package/types/packages/platforms/vue2/src/core4vue/RGEasyView.vue.d.ts +1 -0
  121. package/types/packages/platforms/vue2/src/core4vue/RGGraphDefs.vue.d.ts +1 -0
  122. package/types/packages/platforms/vue2/src/core4vue/RGLineContent.vue.d.ts +18 -18
  123. package/types/packages/platforms/vue2/src/core4vue/RGLinePath.vue.d.ts +4 -28
  124. package/types/packages/platforms/vue2/src/core4vue/RGLinePeel.vue.d.ts +4 -15
  125. package/types/packages/platforms/vue2/src/core4vue/RGNodeExpandHolder.vue.d.ts +3 -9
  126. package/types/packages/platforms/vue2/src/core4vue/RGNodePeel.vue.d.ts +5 -20
  127. package/types/packages/platforms/vue2/src/core4vue/RGProvider.vue.d.ts +50 -0
  128. package/types/packages/platforms/vue2/src/core4vue/RelationGraph.vue.d.ts +5 -773
  129. package/types/packages/platforms/vue2/src/core4vue/RelationGraphUI.vue.d.ts +46 -0
  130. package/types/packages/platforms/vue2/src/core4vue/RelationLinker.vue.d.ts +8 -24
  131. package/types/packages/platforms/vue2/src/core4vue/RelationLinkerCanvas.vue.d.ts +1 -0
  132. package/types/packages/platforms/vue2/src/core4vue/RelationLinkerUI.vue.d.ts +23 -0
  133. package/types/packages/platforms/vue2/src/core4vue/editing/RGConnectSource.vue.d.ts +3 -1
  134. package/types/packages/platforms/vue2/src/core4vue/editing/RGConnectTarget.vue.d.ts +1 -0
  135. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingConnectController.vue.d.ts +2 -1
  136. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingConnectPoints.vue.d.ts +1 -0
  137. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingLineController.vue.d.ts +12 -2
  138. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingNearNodeWidget.vue.d.ts +1 -0
  139. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingNodeController.vue.d.ts +1 -0
  140. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingReferenceLine.vue.d.ts +1 -0
  141. package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingResize.vue.d.ts +1 -0
  142. package/types/packages/platforms/vue2/src/core4vue/editing/RGMiniView.vue.d.ts +3 -1
  143. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphBackground.vue.d.ts +1 -0
  144. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphLoading.vue.d.ts +1 -0
  145. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphMoveOperator.vue.d.ts +1 -1
  146. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphOperateStuff.vue.d.ts +1 -0
  147. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphToolBar.vue.d.ts +1 -1
  148. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphWatermark.vue.d.ts +1 -0
  149. package/types/packages/platforms/vue2/src/core4vue/widgets/GraphXsToolBar.vue.d.ts +1 -1
  150. package/types/packages/platforms/vue2/src/core4vue/widgets/RGDebugView.vue.d.ts +12 -0
  151. package/types/packages/platforms/vue2/src/hooks/GraphStoreMixin.d.ts +40 -0
  152. package/types/packages/platforms/vue2/src/index.d.ts +138 -1692
  153. package/types/packages/platforms/vue2/src/types-vue2.d.ts +3 -0
  154. package/types/packages/platforms/vue3/src/constants.d.ts +0 -1
  155. package/types/packages/platforms/vue3/src/index.d.ts +97 -1404
  156. package/types/packages/platforms/vue3/src/relation-graph/src/core4vue3/editing/RGConnectSource.vue.d.ts +2 -2
  157. package/types/packages/platforms/vue3/src/relation-graph/src/core4vue3/editing/RGConnectTarget.vue.d.ts +4 -4
  158. package/types/packages/platforms/vue3/src/relation-graph/src/core4vue3/editing/RGEditingLineController.vue.d.ts +2 -2
  159. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/RGHooks.d.ts +27 -2
  160. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useGraphData.d.ts +2 -0
  161. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useGraphInstance.d.ts +1 -12
  162. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useGraphStore.d.ts +16 -0
  163. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useRGDataProvider.d.ts +17 -0
  164. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useRelationGraph.d.ts +131 -0
  165. package/types/packages/platforms/vue3/src/relation-graph/src/hooks/useRelationLinker.d.ts +39 -0
  166. package/types/packages/platforms/vue3/src/types-vue3.d.ts +104 -4
  167. package/types/packages/platforms/vue3/src/types.d.ts +3 -1
  168. package/types/packages/relation-graph-models/RGObjectsForExport.d.ts +40 -32
  169. package/types/packages/relation-graph-models/data/RGDataDefine.d.ts +23 -0
  170. package/types/packages/relation-graph-models/data/RGDataGetter.d.ts +36 -0
  171. package/types/packages/relation-graph-models/data/RGDataProvider.d.ts +66 -0
  172. package/types/packages/relation-graph-models/data/RGDataProvider4React.d.ts +9 -0
  173. package/types/packages/relation-graph-models/data/RGDataProvider4Svelte.d.ts +10 -0
  174. package/types/packages/relation-graph-models/data/RGDataProvider4Vue2.d.ts +9 -0
  175. package/types/packages/relation-graph-models/data/RGDataProvider4Vue3.d.ts +10 -0
  176. package/types/packages/relation-graph-models/data/RGDataProvider4Vue3V1.d.ts +10 -0
  177. package/types/packages/relation-graph-models/data/RGLineDataUtils.d.ts +9 -0
  178. package/types/packages/relation-graph-models/data/RGNodeDataUtils.d.ts +14 -0
  179. package/types/packages/relation-graph-models/data/RGOptionsDataUtils.d.ts +9 -0
  180. package/types/packages/relation-graph-models/data/utils/EdgeCounter.d.ts +8 -0
  181. package/types/packages/relation-graph-models/layouts/RGBaseLayout.d.ts +37 -0
  182. package/types/packages/relation-graph-models/layouts/RGCenterLayout.d.ts +9 -0
  183. package/types/packages/relation-graph-models/layouts/RGCircleLayout.d.ts +7 -0
  184. package/types/packages/relation-graph-models/layouts/RGFixedLayout.d.ts +10 -0
  185. package/types/packages/relation-graph-models/layouts/RGFolderLayout.d.ts +15 -0
  186. package/types/packages/relation-graph-models/layouts/RGForceLayout.d.ts +77 -0
  187. package/types/packages/relation-graph-models/layouts/RGIOTreeLayout.d.ts +18 -0
  188. package/types/packages/relation-graph-models/layouts/RGSmartTreeLayout.d.ts +14 -0
  189. package/types/packages/relation-graph-models/layouts/RGTreeLayout.d.ts +17 -0
  190. package/types/packages/relation-graph-models/layouts/analyzers/BasicNetworkAnalyzer.d.ts +27 -0
  191. package/types/packages/relation-graph-models/layouts/analyzers/RGNetworkAnalyzer.d.ts +27 -0
  192. package/types/packages/relation-graph-models/models/RelationGraphBase.d.ts +31 -18
  193. package/types/packages/relation-graph-models/models/RelationGraphCore.d.ts +46 -0
  194. package/types/packages/relation-graph-models/models/RelationGraphWith1View.d.ts +91 -0
  195. package/types/packages/relation-graph-models/models/RelationGraphWith2Data.d.ts +34 -381
  196. package/types/packages/relation-graph-models/models/RelationGraphWith2Data1Getter.d.ts +77 -0
  197. package/types/packages/relation-graph-models/models/RelationGraphWith2Data2Analysis.d.ts +172 -0
  198. package/types/packages/relation-graph-models/models/RelationGraphWith2Data3Update.d.ts +257 -0
  199. package/types/packages/relation-graph-models/models/RelationGraphWith2Data4ConnectTarget.d.ts +85 -0
  200. package/types/packages/relation-graph-models/models/RelationGraphWith2Data5LineConfig.d.ts +35 -0
  201. package/types/packages/relation-graph-models/models/RelationGraphWith3Options1Update.d.ts +75 -0
  202. package/types/packages/relation-graph-models/models/RelationGraphWith3Options2API.d.ts +39 -0
  203. package/types/packages/relation-graph-models/models/RelationGraphWith4Line.d.ts +81 -21
  204. package/types/packages/relation-graph-models/models/RelationGraphWith5Zoom.d.ts +19 -21
  205. package/types/packages/relation-graph-models/models/RelationGraphWith6Effect.d.ts +56 -4
  206. package/types/packages/relation-graph-models/models/RelationGraphWith6Layout.d.ts +60 -12
  207. package/types/packages/relation-graph-models/models/RelationGraphWith7Event.d.ts +233 -36
  208. package/types/packages/relation-graph-models/models/RelationGraphWith91Editing.d.ts +176 -25
  209. package/types/packages/relation-graph-models/models/RelationGraphWith92MiniView.d.ts +70 -13
  210. package/types/packages/relation-graph-models/models/RelationGraphWith93Image.d.ts +36 -0
  211. package/types/packages/relation-graph-models/models/RelationGraphWith93Image_codes.d.ts +36 -0
  212. package/types/packages/relation-graph-models/models/RelationGraphWith95Dom.d.ts +108 -0
  213. package/types/packages/relation-graph-models/models/RelationGraphWith99API.d.ts +125 -0
  214. package/types/packages/relation-graph-models/models/RelationGraphWith9EasyView.d.ts +57 -11
  215. package/types/packages/relation-graph-models/utils/RGCanvasImpl2D.d.ts +2 -3
  216. package/types/packages/relation-graph-models/utils/RGCommon.d.ts +6 -1
  217. package/types/packages/relation-graph-models/utils/RGDragUtils.d.ts +14 -11
  218. package/types/packages/relation-graph-models/utils/RGFullscreenUtils.d.ts +1 -1
  219. package/types/packages/relation-graph-models/utils/RGGraphMath.d.ts +27 -0
  220. package/types/packages/relation-graph-models/utils/RGIntergration.d.ts +32 -34
  221. package/types/packages/relation-graph-models/utils/RGNodesAnalytic.d.ts +6 -15
  222. package/types/packages/relation-graph-models/utils/RGTips.d.ts +7 -0
  223. package/types/packages/relation-graph-models/utils/line/RGLinePath.d.ts +16 -1
  224. package/types/packages/relation-graph-models/utils/line/RGLinePathUtils.d.ts +1 -1
  225. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor1.d.ts +1 -1
  226. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor4.d.ts +1 -1
  227. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor44.d.ts +1 -1
  228. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor49.d.ts +1 -1
  229. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorFor6.d.ts +1 -1
  230. package/types/packages/relation-graph-models/utils/line/RGPathGeneratorForCurve.d.ts +1 -1
  231. package/types/packages/types.d.ts +1467 -0
  232. package/types/packages/types.ts +1472 -0
  233. package/types/react.d.ts +38 -38
  234. package/types/vue3.d.ts +229 -229
package/relation-graph.js CHANGED
@@ -1,20 +1,15 @@
1
- (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("@charset \"UTF-8\";.relation-graph{box-sizing:border-box;position:relative;min-width:300px;min-height:300px;--rg-node-opacity: 1;--editor-main-color: rgb(64, 165, 248);--editor-light-color: rgb(125, 192, 248);--editor-light2-color: rgb(168, 212, 248);--editor-light-opacity: rgba(57, 144, 216, .1);--rg-node-font-size: 12px;--rg-node-font-color: #000000;--rg-node-color: #eeeeee;--rg-node-border-color: #333333;--rg-node-border-width: 1px;--rg-node-width: fit-content;--rg-node-height: fit-content;--rg-node-text-px: 10px;--rg-node-text-py: 3px;--rg-background-color: transparent;--rg-line-color: #888888;--rg-line-width: 2px;--rg-checked-line-bg-color: rgba(150,150,150,.2)}.relation-graph:focus{outline:none}.relation-graph .rg-graph-plugs{position:absolute;left:0px;top:0px;z-index:90;width:100%;height:100%;pointer-events:none;user-select:none}.relation-graph .rg-graph-plugs .rg-graph-slot{position:relative;width:100%;height:100%}.relation-graph .rg-background{position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:0}.relation-graph .rg-watermark{position:absolute;--watermark-width: 200px;--watermark-height: 100px;z-index:1200;overflow:visible;min-height:100px;min-width:100px;width:var(--watermark-width);height:var(--watermark-height);box-sizing:border-box}.relation-graph .rg-watermark div{box-sizing:border-box}.relation-graph .rg-watermark.rg-watermark-top{left:calc((100% - var(--watermark-width)) / 2);top:10px}.relation-graph .rg-watermark.rg-watermark-bottom{left:calc((100% - var(--watermark-width)) / 2);bottom:10px}.relation-graph .rg-watermark.rg-watermark-left{left:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-right{right:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-tl{left:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-tr{right:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-bl{left:10px;bottom:10px}.relation-graph .rg-watermark.rg-watermark-br{right:10px;bottom:10px}.relation-graph .rg-lines-container svg{overflow:visible}.relation-graph .rg-lines-svg{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-lines-container{overflow:visible;position:absolute;z-index:40;width:100%;top:0px;left:0px;pointer-events:none}.relation-graph .rg-lines-container-el-lines{z-index:80;pointer-events:none}.relation-graph .rg-lines-container-el-lines .rg-line-bg{pointer-events:stroke}.relation-graph .rg-lines-container-el-lines .rg-line-text{pointer-events:all}.relation-graph .rg-lines-svg-el-lines{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-nodes-container{position:absolute;width:100%;top:0px;left:0px;z-index:50}.relation-graph .rg-map{--rg-line-width: 1px;--rg-line-color: #666666;--rg-line-fontsize: 12px;--rg-line-opacity: 1;background-color:var(--bg-background-color);overflow:hidden;cursor:default;user-select:none;opacity:.01;transition:none;width:100%;height:100%;position:relative}.relation-graph.rg-move-mode .rg-map{cursor:grab}.relation-graph .rg-map-ready{opacity:1;transition:opacity .5s ease}.relation-graph .rg-map-background-norepeat{background-repeat:no-repeat;background-position:right bottom}.relation-graph .rg-map-canvas{position:relative;user-select:none;pointer-events:none;top:0px;left:0px;border:0px;z-index:3;overflow:visible;white-space:nowrap;transform-origin:0 0}.relation-graph .rg-map-canvas .rg-events-all{pointer-events:all}.relation-graph.rg-enable-node-xy-animation .rg-node-peel{transition:transform .3s ease,top .3s ease}.relation-graph.rg-enable-node-xy-animation .rg-line-peel{opacity:0;transition:none}.relation-graph.rg-enable-node-xy-animation .rg-map-canvas{transition:transform .4s ease-in-out}.relation-graph.rg-enable-canvas-animation .rg-map-canvas{transition:transform .5s ease}.relation-graph.rg-enable-canvas-animation .rg-editing-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-line-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-connect-ctrl{opacity:0}.relation-graph .rg-canvas-behind{z-index:2;position:absolute}.relation-graph .rg-canvas-above{z-index:5;position:absolute}.relation-graph .rg-canvas-slot{overflow:visible;position:absolute;margin-top:0;margin-left:0}.relation-graph .rg-canvas-slot-behind{z-index:30;overflow:visible}.relation-graph .rg-canvas-slot-above{z-index:70;overflow:visible}.relation-graph .rg-single-graph{position:relative}.relation-graph .rg-map ::v-deep img{-webkit-user-drag:none;-webkit-user-select:none}.relation-graph .rg-line-text{fill:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);paint-order:stroke;pointer-events:all}.relation-graph .rg-linetext-container{position:absolute;pointer-events:none;user-select:none;overflow:visible;left:0;top:0;z-index:45;display:block}.relation-graph .rg-linetext-container .rg-line-peel{width:fit-content;--rg-line-fontcolor: var(--rg-line-color)}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label{display:block;color:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);transform-origin:0 0;position:absolute;user-select:none;pointer-events:all;box-sizing:border-box;padding:2px 6px;border-radius:5px}.relation-graph .rg-linetext-container .rg-line-peel-checked .rg-line-label{background-color:var(--rg-checked-line-bg-color)}.relation-graph .rg-line-peel{--rg-line-fontcolor: var(--rg-line-color);pointer-events:none;cursor:default;transition:opacity .2s ease-in;opacity:var(--rg-line-opacity, 1)}.relation-graph .rg-line{fill-rule:nonzero;stroke-linecap:round;stroke:var(--rg-line-color);stroke-width:var(--rg-line-width);pointer-events:none;fill:none;marker-end:var(--rg-line-marker-end);marker-start:var(--rg-line-marker-start)}.relation-graph .rg-line-bg{stroke:#fff;opacity:.01;fill:none;fill-rule:nonzero;stroke-linecap:round;pointer-events:stroke;stroke-width:calc(var(--rg-line-width) + 6px)}.relation-graph .rg-line-bg:hover{opacity:.1;stroke:var(--rg-line-color)}.relation-graph .rg-line-peel-checked .rg-line-bg{stroke:var(--rg-checked-line-bg-color);opacity:1}.relation-graph .rg-line-peel-checked .rg-line{z-index:100}.relation-graph .rg-line-peel-checked .rg-line-text{stroke:var(--rg-checked-line-bg-color);stroke-width:2}.relation-graph .rg-line-peel-disable-events{pointer-events:none!important}.relation-graph .rg-line-peel-disable-events .rg-line-bg,.relation-graph .rg-line-peel-disable-events .rg-line-text,.relation-graph .rg-linetext-container .rg-line-peel-disable-events .rg-line-bg,.relation-graph .rg-linetext-container .rg-line-peel-disable-events .rg-line-label{pointer-events:none}.relation-graph .rg-line-dashtype-1{stroke-dasharray:2,2,2;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-2{stroke-dasharray:5,5,5;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-3{stroke-dasharray:9,9,9;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-4{stroke-dasharray:5,5,15;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}@keyframes ACTRGLineChecked{0%{stroke-dashoffset:352px;stroke-dasharray:5,5,5}50%{stroke-dasharray:5,5,5;stroke-dashoffset:3px}to{stroke-dashoffset:352px;stroke-dasharray:5,5,5}}@keyframes rg-line-anm1{0%{stroke-dashoffset:100px;stroke-dasharray:5,5,5}to{stroke-dasharray:5,5,5;stroke-dashoffset:3px}}@keyframes rg-line-anm2{0%{stroke-dashoffset:0;stroke-dasharray:4,4,4}to{stroke-dashoffset:10px;stroke-dasharray:20,20,20}}@keyframes rg-line-anm3{0%{stroke-opacity:1}50%{stroke-opacity:.2}to{stroke-opacity:1}}@keyframes rg-line-anm4{0%{stroke-dasharray:0,100%}to{stroke-dasharray:100%,0}}.relation-graph .rg-line-anm-1{animation:rg-line-anm1 10s infinite;animation-fill-mode:forwards;animation-timing-function:linear}.relation-graph .rg-line-anm-2{animation:rg-line-anm2 3s infinite}.relation-graph .rg-line-anm-3{animation:rg-line-anm3 1s infinite}.relation-graph .rg-line-anm-4{animation:rg-line-anm4 3s infinite}@keyframes deform1{0%{stroke-dashoffset:0}to{stroke-dashoffset:100%}}.relation-graph .rg-icon{width:19px;height:19px;vertical-align:0px;fill:currentColor;overflow:hidden}.relation-graph .rg-node-peel{padding:0;position:absolute;pointer-events:all;font-size:14px;box-sizing:border-box;opacity:var(--rg-node-opacity);z-index:var(--rg-node-z-index);transform-origin:0 0;cursor:default}.relation-graph .rg-node-peel-checked{z-index:9999}.relation-graph .rg-node-peel-disable-events{pointer-events:none}.relation-graph .rg-node{text-align:center;border-style:solid;box-sizing:border-box;transform-origin:0 0;font-size:var(--rg-node-font-size);color:var(--rg-node-font-color);background-color:var(--rg-node-color);border-color:var(--rg-node-border-color);border-width:var(--rg-node-border-width);width:var(--rg-node-width);height:var(--rg-node-height)}.relation-graph .rg-node-shape-0{border-radius:50%}.relation-graph .rg-node-shape-1{border-radius:var(--rg-node-border-radius, 3px)}.relation-graph img,.relation-graph svg,.relation-graph video,.relation-graph canvas,.relation-graph audio,.relation-graph iframe,.relation-graph embed,.relation-graph object{display:unset;vertical-align:unset}.relation-graph .rg-node-text{color:var(--rg-node-font-color);font-size:var(--rg-node-font-size);padding:var(--rg-node-text-py) var(--rg-node-text-px);height:100%;width:100%;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.relation-graph .rg-node-type-button{border-radius:25px;color:#00f;cursor:pointer}.relation-graph .rg-node-checked{transition:background-color .2s ease,outline .2s ease,color .2s ease,-webkit-box-shadow .2s ease;box-shadow:0 0 0 8px var(--rg-checked-line-bg-color)}.relation-graph .rg-node-dragging{z-index:400}.relation-graph .rg-node-selected{box-shadow:0 0 0 2px var(--editor-main-color);z-index:400}.relation-graph .rg-editing-referline{user-select:none;position:absolute;z-index:999;pointer-events:none;width:100%;height:100%;left:0px;top:0px}.relation-graph .rg-editing-referline .rg-referline{position:absolute;display:flex;place-items:center;justify-content:center;overflow:visible;transform-origin:0 0}.relation-graph .rg-editing-referline .rg-referline .referline{display:flex;place-items:center;justify-content:center}.relation-graph .rg-editing-referline .rg-referline .referline>div{background-color:var(--editor-main-color);font-size:8px;border-radius:3px;color:#fff;width:fit-content;height:fit-content;padding:2px 5px}.relation-graph .rg-editing-referline .rg-referline-v{top:0px;width:6px;height:100%;transform:translate(-3px);border-top:var(--editor-main-color) solid 6px;border-bottom:var(--editor-main-color) solid 6px}.relation-graph .rg-editing-referline .rg-referline-v .referline{width:1px;height:100%;border-left:var(--editor-main-color) solid 1px}.relation-graph .rg-editing-referline .rg-referline-h{left:0px;width:100%;height:6px;transform:translateY(-3px);border-left:var(--editor-main-color) solid 6px;border-right:var(--editor-main-color) solid 6px}.relation-graph .rg-editing-referline .rg-referline-h .referline{width:100%;height:1px;border-top:var(--editor-main-color) solid 1px}.relation-graph .rg-editing-line-ctrl{position:absolute;left:0px;top:0px;z-index:500;pointer-events:none;user-select:none;width:100%;height:100%}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg{position:absolute;pointer-events:none;left:0px;top:0px;overflow:visible}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg path{stroke:var(--editor-main-color);stroke-width:1px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-dot{--rg-ctl-x: 0px;--rg-ctl-y: 0px;pointer-events:auto;user-select:none;width:10px;height:10px;background-color:#fff;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:50%;cursor:move;z-index:1;transform-origin:0 0}.relation-graph .rg-editing-line-ctrl .start-dot,.relation-graph .rg-editing-line-ctrl .end-dot,.relation-graph .rg-editing-line-ctrl .ctrl-dot{transform-origin:0 0;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split,.relation-graph .rg-editing-line-ctrl .ctrl-split-core{background-color:#fff}.relation-graph .rg-editing-line-ctrl .ctrl-split-h{width:12px;height:5px;border-radius:3px;cursor:row-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split-v{width:5px;height:12px;border-radius:3px;cursor:col-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text{--rg-ctl-x: 0px;--rg-ctl-y: 0px;--font-size: 12px;pointer-events:auto;background-color:#fffc;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:3px;cursor:move;z-index:1;white-space:nowrap;color:#000;padding:3px 10px;display:flex;place-items:center;justify-content:center;box-sizing:border-box;text-shadow:none;font-size:var(--font-size, 12px);min-height:20px;max-height:30px;transform-origin:0 0;transform:translate(-50%,-50%) translate(10px,3px) translate(var(--rg-ctl-x),var(--rg-ctl-y));min-width:50px;max-width:220px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p{font-size:var(--font-size, 12px);color:#333}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p.empty-text{font-size:10px;color:#888}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text .rg-line-text-input{white-space:nowrap;pointer-events:auto;user-select:auto;background-color:transparent;color:#000;border-radius:3px;height:100%;padding:3px 0;width:100px;text-shadow:none;font-size:var(--font-size, 12px);text-align:center;box-sizing:border-box;border:none;outline:none}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text-editing{background-color:#faf191;--font-size: 12px}.relation-graph .rg-editing-ctrl,.relation-graph .rg-editing-connect-ctrl{user-select:none;position:absolute;z-index:500;box-shadow:0 0 0 1px var(--editor-main-color);border-radius:0;pointer-events:none;transform-origin:0 0}.relation-graph .rg-editing-bar{user-select:none;pointer-events:none;position:absolute;border-radius:5px;padding:3px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;flex-wrap:wrap;gap:5px}.relation-graph .rg-editing-bar .rg-gee-icon{background-color:#d603f680;pointer-events:auto;min-width:20px;min-height:20px;border-radius:5px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;cursor:pointer}.relation-graph .rg-editing-bar .rg-gee-icon:hover{background-color:#d603f6;color:#fff}.relation-graph .rg-connect-source-handle{pointer-events:auto;width:fit-content;height:fit-content}.relation-graph .rg-editing-bar-top{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(-100%);top:-15px}.relation-graph .rg-editing-bar-bottom{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(100%);bottom:-15px}.relation-graph .rg-editing-bar-left{width:fit-content;height:fit-content;left:-15px;top:50%;transform:translate(-100%) translateY(-50%)}.relation-graph .rg-editing-bar-right{width:fit-content;height:fit-content;right:-15px;top:50%;transform:translate(100%) translateY(-50%)}.relation-graph .rg-editing-bar-tl{width:30px;height:30px;right:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-tr{width:30px;height:30px;left:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-bl{width:30px;height:30px;right:calc(100% + 10px);bottom:-40px}.relation-graph .rg-editing-bar-br{width:30px;height:30px;left:calc(100% + 10px);bottom:-40px}.relation-graph .rg-resize-ctl{user-select:none;position:relative;height:100%;width:100%;--resize-handler-size: 10px;--resize-handler-offset: -5px}.relation-graph .rg-resize-ctl .rg-resize-ctl-handler{pointer-events:auto;width:var(--resize-handler-size);height:var(--resize-handler-size);background-color:#fff;position:absolute;border-radius:2px;box-shadow:inset 0 0 0 1px var(--editor-main-color)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tl{cursor:nwse-resize;left:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tr{cursor:nesw-resize;right:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-bl{cursor:nesw-resize;left:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-br{cursor:nwse-resize;right:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-t{cursor:n-resize;top:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-b{cursor:s-resize;bottom:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-l{cursor:w-resize;left:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-r{cursor:e-resize;right:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-editing-connect-ctrl{position:absolute;user-select:none;pointer-events:none;z-index:1400;box-shadow:0 0 0 1px var(--editor-main-color);--hander-border-radius: 5px;border-radius:var(--hander-border-radius);--border-handler-width: 8px;--hv-handler-width: 10px;--center-handler-width: 10px;--border-point-width: 10px;--border-point-height: 10px;--hander-color: var(--editor-light2-color);--hander-border-color: var(--editor-main-color)}.relation-graph .rg-connect-ctl{width:100%;height:100%;pointer-events:none;user-select:none}.relation-graph .rg-connect-ctl-handler{pointer-events:auto;user-select:none;z-index:20;cursor:crosshair}.relation-graph .rg-connect-target{width:fit-content;height:fit-content;pointer-events:auto;display:flex;place-items:center;justify-content:center}.relation-graph .rg-connect-ctl-handler-style{background-color:var(--hander-color);border:var(--hander-border-color) solid 1px;position:absolute;border-radius:3px}.relation-graph .rg-connect-ctl-handler-style:hover{background-color:#fbe691}.relation-graph .rg-connect-ctl-center{width:var(--center-handler-width);height:var(--center-handler-width);border-radius:50%;top:calc((100% - var(--center-handler-width)) / 2);left:calc((100% - var(--center-handler-width)) / 2)}.relation-graph .rg-connect-ctl-t{width:var(--border-point-width);height:var(--border-point-height);top:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-b{width:var(--border-point-width);height:var(--border-point-height);bottom:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-l{width:var(--border-point-height);height:var(--border-point-width);left:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-r{width:var(--border-point-height);height:var(--border-point-width);right:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-lr{width:100%;height:var(--hv-handler-width);right:0px;top:calc((100% - var(--hv-handler-width)) / 2);z-index:11;opacity:.01}.relation-graph .rg-connect-ctl-lr:hover{opacity:1}.relation-graph .rg-connect-ctl-tb{width:var(--hv-handler-width);height:100%;top:0px;left:calc((100% - var(--hv-handler-width)) / 2);z-index:10;opacity:.01}.relation-graph .rg-connect-ctl-tb:hover{opacity:1}.relation-graph .rg-connect-ctl-bottom-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:calc(100% - var(--border-handler-width));z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-top-left-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-bottom-bar:hover{border-top:var(--hander-border-color) solid 1px;opacity:1;box-shadow:none;scale:1}.relation-graph .rg-connect-ctl-top-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-top-bar:hover{border-bottom:var(--hander-border-color) solid 1px;opacity:1;box-shadow:none;scale:1}.relation-graph .rg-connect-ctl-left-bar{border:0px;border:none;width:var(--border-handler-width);height:100%;left:0px;top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-right-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-left-bar:hover{border-right:var(--hander-border-color) solid 1px;opacity:1;box-shadow:none;scale:1}.relation-graph .rg-connect-ctl-right-bar{border:0px;width:var(--border-handler-width);height:100%;right:0px;top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-top-left-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-right-bar:hover{border-left:var(--hander-border-color) solid 1px;opacity:1;box-shadow:none;scale:1}.relation-graph .rg-miniview{pointer-events:all;position:absolute;user-select:none;overflow:hidden;z-index:1100;min-height:100px;min-width:100px;--miniview-width: 200px;--miniview-height: 200px;height:var(--miniview-height);width:var(--miniview-width);border-radius:3px;display:flex;place-items:center;justify-content:center;background-color:#fff;box-shadow:0 0 0 1px #ccc;border:none}.relation-graph .rg-miniview .rg-miniview-container{position:absolute;width:100%;height:100%;display:flex;place-items:center;justify-content:center}.relation-graph .rg-miniview canvas{background-color:#fff;opacity:.7}.relation-graph .rg-miniview .rg-mv-canvas-reset{cursor:pointer}.relation-graph .rg-miniview .rg-mv-canvas-reset:hover{background-color:#bbf54794}.relation-graph .rg-miniview .rg-mv-visible-area{z-index:2;position:absolute;cursor:move;transform-origin:0 0;box-shadow:0 0 0 9999px #0000001a;border:1px solid #cccccc;border-radius:3px;display:grid;place-items:center;color:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.5)}.relation-graph .rg-miniview.rg-miniview-top{left:calc((100% - var(--miniview-width)) / 2);top:10px}.relation-graph .rg-miniview.rg-miniview-bottom{left:calc((100% - var(--miniview-width)) / 2);bottom:10px}.relation-graph .rg-miniview.rg-miniview-left{left:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-right{right:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-tl{left:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-tr{right:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-bl{left:10px;bottom:10px}.relation-graph .rg-miniview.rg-miniview-br{right:10px;bottom:10px}.relation-graph .rg-node-flashing{animation:ACTRGNodeFlashing 2s infinite}.relation-graph .rg-node-vtree-2{transform-origin:0 0;transform:rotate(30deg) translate(0)}.relation-graph .rg-node-vtree{width:130px;height:45px;text-align:left}.relation-graph .rg-node-expand-holder{position:absolute;height:fit-content;width:fit-content;display:flex;align-items:center;justify-content:center;user-select:none;pointer-events:none;cursor:pointer}.relation-graph .rg-node-expand-holder>span{width:16px;height:16px;display:block;text-align:center;border-radius:15px;cursor:pointer;font-size:19px;background-size:100% 100%;pointer-events:all;border:#aaaaaa solid .5px;background-color:#fff}.relation-graph .c-expanded{background-image:url(data:image/svg+xml;%20charset=utf8,%3Csvg%20t=%221606310217820%22%20viewBox=%220%200%201024%201024%22%20version=%221.1%22%20xmlns=%22http://www.w3.org/2000/svg%22%20p-id=%223373%22%20width=%2232%22%20height=%2232%22%3E%3Cpath%20d=%22M853.333333%20480H544V170.666667c0-17.066667-14.933333-32-32-32s-32%2014.933333-32%2032v309.333333H170.666667c-17.066667%200-32%2014.933333-32%2032s14.933333%2032%2032%2032h309.333333V853.333333c0%2017.066667%2014.933333%2032%2032%2032s32-14.933333%2032-32V544H853.333333c17.066667%200%2032-14.933333%2032-32s-14.933333-32-32-32z%22%20p-id=%223374%22%20fill=%22%23666666%22%3E%3C/path%3E%3C/svg%3E)}.relation-graph .c-collapsed{background-image:url(data:image/svg+xml;%20charset=utf8,%3Csvg%20t=%221606310454619%22%20class=%22icon%22%20viewBox=%220%200%201024%201024%22%20version=%221.1%22%20xmlns=%22http://www.w3.org/2000/svg%22%20p-id=%223662%22%20width=%22128%22%20height=%22128%22%3E%3Cpath%20d=%22M853.333333%20554.666667H170.666667c-23.466667%200-42.666667-19.2-42.666667-42.666667s19.2-42.666667%2042.666667-42.666667h682.666666c23.466667%200%2042.666667%2019.2%2042.666667%2042.666667s-19.2%2042.666667-42.666667%2042.666667z%22%20p-id=%223663%22%20fill=%22%23666666%22%3E%3C/path%3E%3C/svg%3E)}.relation-graph .c-expand-positon-left{transform:translate(-100%) translateY(-50%);left:-5px;top:50%}.relation-graph .c-expand-positon-right{transform:translate(5px) translateY(-50%);left:100%;top:50%}.relation-graph .c-expand-positon-bottom{transform:translate(-50%);left:50%;top:calc(100% + 5px)}.relation-graph .c-expand-positon-top{transform:translate(-50%) translateY(-100%);left:50%;top:-5px}.relation-graph .rg-setting-panel{--height: 300px;--width: 200px;width:300px;height:200px;position:absolute;margin-left:10px;margin-top:5px;font-size:12px;color:#3a5bb2;padding:60px 10px 10px;overflow:hidden;box-shadow:0 0 5px #999;border-radius:5px;z-index:1000;background-color:#fff;border:#999999 solid 1px}.relation-graph .rg-setting-panel-button{height:35px;width:35px;font-size:8px;line-height:35px;text-align:center;border-radius:50%;position:absolute;margin-left:25px;margin-top:20px;background-color:#3a5bb2;color:#fff;cursor:pointer;z-index:1001;box-shadow:0 0 8px #999}.relation-graph .rg-setting-panel-button:hover{box-shadow:0 0 20px #ffa20a;border:#ffffff solid 1px;color:#ffa20a;-moz-transform:rotate(-89deg) translateX(-190px);animation-timing-function:linear;animation:flashButton 2s infinite}@keyframes flashButton{0%{box-shadow:0 0 8px #2e4e8f}30%{box-shadow:0 0 20px #ffa20a}to{box-shadow:0 0 8px #2e4e8f}}.relation-graph .c-debug-tools-row{text-align:left}.relation-graph .rg-operate{pointer-events:none;user-select:none;position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:180}.relation-graph .rg-operate .rg-node{cursor:move}.relation-graph .rg-operate .rg-creating-container{pointer-events:none;position:relative}.relation-graph .rg-operate .rg-creating-container .rg-node-peel,.relation-graph .rg-operate .rg-creating-container .rg-events-all{pointer-events:none!important}.relation-graph .rg-selection{pointer-events:none;position:absolute;user-select:none;background-color:var(--editor-light-opacity);border:var(--editor-main-color) solid 1px;transform-origin:0 0}.relation-graph .rg-graph-loading{position:absolute;z-index:1600;left:0px;top:0px;height:100%;width:100%;background-color:#fff}.relation-graph .rg-graph-loading .rg-graph-loading-icon{width:16px;height:16px;vertical-align:-3px;fill:currentColor;overflow:hidden;animation:turn 1s linear infinite}.relation-graph .rg-graph-loading .rg-graph-loading-message{position:absolute;width:200px;height:30px;line-height:30px;text-align:center;left:calc((100% - 200px)/2);top:calc((100% - 30px)/2);border-radius:5px;background-color:#00000080;color:#fff;display:flex;place-items:center;justify-content:center;gap:8px}.relation-graph .rg-graph-loading-hide{display:none}@keyframes slowHide{0%{opacity:1}to{opacity:0;display:none}}.relation-graph .rg-easy-view{overflow:visible;height:100%;width:100%;background-color:transparent;position:absolute;left:0px;top:0px;z-index:3;pointer-events:none}.relation-graph .rg-easy-view canvas{opacity:0;width:100%;height:100%}.relation-graph .rg-easy-view-active{pointer-events:all}.relation-graph .rg-easy-view-active canvas{opacity:1}.relation-graph .rg-move-operator{position:absolute;width:100%;height:100%;pointer-events:none;user-select:none;left:0px;top:0px;z-index:6666}.relation-graph .rg-move-operator .rg-move-touchpad{display:none;background-color:var(--edit-ctl-light2-color);height:100%;width:100%;pointer-events:all}.relation-graph .rg-move-operator.rg-move-operator-active{pointer-events:all;cursor:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4Ij48aW1hZ2UgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFFQUFBQUJBQ0FZQUFBQ3FhWEhlQUFBQUFYTlNSMElBcnM0YzZRQUFDWlpKUkVGVWVGN3RXZ3RNVk5rWi9xYThabkZ4QkVIQWlCV3lFa0drUEcwRW1paWdGVVZzcFZxTmlsSmZRVEV4c2k2eDFqZHRMVnVEeGpoTlJDc0JzeHBOZktEV0J4Q05QTFFpaUNoRzBTQkxKZHBTYUFWNXlHaW4rOTNjdzQ2enVEc0Rkd1lUT01uSm5XRXU5NTcvKy8vLyt4L25xRERJaDJxUXk0OGhBSVlzWUpBak1PUUNnOXdBaGtod3lBV0dYR0NRSXpEa0FnTmtBQUo0UXdYbzViV0lxMVdXWm0wTDRQdCtCTUJHdnZJN0o0WG0vQitBZC9MVktrQllBd0FocEJEY3RyS3lNc3pYMTNlcG5aMWRvTDI5ZlhoM2QzZTVUcWVycnEydHpRc0pDYmtENEswUkVCWUR3NUlBR0dxYkdyY0ZZSGYvL3YxWkV5Wk0rTE90cmEyN3NZMi9mZnYybjQ4ZVBmcDgwcVJKZndPZ2s0RWdHTFFNVHNXQnNBUUFRdU1VMkxhc3JDekF6ODh2U2ExV0I2dlY2Z2doOUtWTGw4QjU0TUFCckYrL0huRnhjZElVUTZmVFBlN3M3THgyK1BEaFA2U2xwZjNieUNvVTR3ZExBRUJ0YzlxM3RMUnNkWFoyL3NKNHRRME5EUWdNRE1TclY2OTZmdEpvTktpdXJzYllzV1BmdTEybjB6MjRjZVBHNnRqWTJHb0EzUWF1b1FnSVNnUEE1OWxSZUsxVzY1T1NrbktQcXp4eTVBaU9IajJLMHRKU1RKMDZGY09HRGNQRml4ZXhZOGNPYk4rK0hUdDM3cFErejU0OUcrM3Q3YmgrL1RvaUl5T1JuSnlNRlN0V29MdTd1elkzTjNmK3FsV3I2bVFRaEZ2MEd3U2xBYURtSFFBNHZuang0azhlSGg2L29URFRwazNyZGFGNi9iY3VyVkwxdnBScjE2NUpvTDE4K2ZLdm5wNmV2d1hRQ2VDTjdCTDk1Z1dsQWFEMkhRRTR0YmEyWG5CeWN2cEpSRVFFYnQ2OCtSMXRFNUhlQURDMmlpbFRwcUNzckV3Q3NLT2o0MjVYVjFkNWZuNStWbkp5Y29OTWxDSnM5c2thbEFTQXo2TDJod0VZb2Rmcm4zSkZRck85Q2R1WHYvR1pPcDN1SC9YMTllbSt2cjc1QnRHQzFtRDJVQklBeG5rMXRRL0FSYS9YUDFRS2dISGp4cUcrdnY0N3ZKQ2Vudjd6ZmZ2Mk5SbndndGxoVWtrQTZQK2ZBQmdPWUtSZXJ5ZHJLMklCeG1vVnZORFkyTGh2ekpneHUyVmVFQkhDTEN0UUVnREdmZnEvUmdiZ3JsSUFmSWdYMnRyYWJnOGZQdnlYQU5vQWRNbnVZSFVBYVBvRTB0NElnTnRLQWZCOVhLRlNxWHdBTUtGb2wxM0JMRGZvandWUWNKSGYyeFFWRlFXTUh6OStiazFOemRkeGNYRVA5WHA5c1pVQThBUFFBdUMxYkFWbWtXRmZBYURnVXFwYlYxY1g3Kzd1L2l0SFI4ZjV2ZG1lMGxIQStIa3FsU29RUURPQVZwa0xHQlpOSG4wQlFBaHZYMUZSTVRVa0pPUVUyWjhzZmV2V0xYUjFkU0VoSVFFdUxpN1NJcXdBUUpBTUFOMmdRMDZWTFFZQUFaT3l2ZFRVMUZGNzkrNHR0TGUzOThuSnlVRnFhcXFVeG5Jd245KzBhWlAwTnlzQUVBS0F4WklBZ0dteXljTmNDNkQyU1hhZkZCY1h4MGRGUmVVMk5UVmg4dVRKVXB4ZXVIQWgzcjE3aDFPbmFCVEF5Wk1uc1dEQkF1bXpJWkd4NkhuOCtESG16Ly9XYTBTNnpCQW5oaW5ncVZTcVVBRE1CYXdDQUxYUFpPZlR1cnE2MzNsN2U2ZHF0VnFzVzdjT3k1Y3Zsd29lamtPSERtSE5talVZT1hJa21wdnBudThEWUtwNkJKQ0dRUFhDQVFTQUZ2QmYyUVVzYWdITTlhVmtwN2k0ZUZsVVZGVEdpUk1uc0dqUklrbjd4NDhmNzVHTkdtVWhKSWFoQlpnS2dDbWtLbHVBVlFGZ3JxODVkdXhZM09MRmkvOUMwdzhJQ0lDTmpRMEtDd3NSSGg3ZXMrNVpzMlpKVFErUnlQUkg4QSs1eFlBQkFNQzFvYUhob0plWDEwODNidHlJckt3c1RKOCtIVmV2WGxWQ3pnOCs0d011WURVT0VPa3U4MzNYN096c09TdFhydHoxK3ZWclJFZEhvN3k4SEZ1M2JzV3VYYnNzQnNKQUF5QklrQldmTTRCUnQyL2Yvanc4UER6K3lwVXJtRGx6cGlUNGhRc1hwTzZPMHFPcXFnckJ3Y0VZUFhvMEdoc2I4ZWJObTFkcXRacmRGcXVIUVJZOUkxajBCQVVGalNzb0tQalMxZFgxeDl1MmJjUHUzYnVsUmJLSm9WWXpZQ2czbUcrd1RSWWFHb283ZCs2Z3RiWDFhNDFHOHdzREFOZ3RzbWdVb0RTTUJHeDhTSFUvWFVHcjFjYWxwS1NrODBmMjhpaDhSa1lHdG16Wm9wejAzK1M1NmVucHlNek14TnExYTNIdzRFRTBOVFhkR3pWcVZKSkJKa2dBckpJS2k5WVhTMStDNEZaWldmbEZjSEJ3OUprelp6QnYzanhKOEljUEg4TFBqN1dLTW1QdTNMbkl6OC9IK2ZQbkVSOGZqOU9uVC84eE1USHhLNk5hd0NyRkVNbVFWdkNwY0lVTkd6Wk16c3pNM0dOblorZVFsSlNFdkx3OGFaRmNyQkpEY0F6OW44QTZPanAyUmtkSEx5Z3BLV0hyamRVZ2V3SnNsbG9GQU5IK1psTFU0d3FGaFlXclkySmlmczFVbDY3QTZFQ056Wmt6cDk4WWVIbDU0Zm56NXowNVJVMU56WldBZ0lDZEFQNGxaNEVzaDlrVnNtby9RR3FCaXk2UWs1T1RlMjF0YlphSGg4ZG5vdGRQeWZ1YkJTNWJ0Z3k1dWJtWU9IRWlDZ29LNE9ucGljMmJONi9mczJkUHFVeUFMSVZaQ1hJN3pheGhiakZrK0hCUkdZcEdLS09DSU1UTnZKRmNRRTVnVkNncEthSFptclU0M2h3Ykc0dWlvaUpKZUJaWC92Nyt1SGZ2WGtGUVVGQ0dYQVFaTmtQTUlrQSt2ejhBOFA5WkhmYlVCd3lMbktXbHBlc2pJaUlTZUFQMyt5NWZ2Z3huWjJka1oyY2pNVEhSSkJBWTh0TFMwdERTMHZLZThNM056UTJ1cnE1clpPRlphWWtxMEd6elZ3SUFQa1BzQmtrMWdnQ2hycTd1OTk3ZTNteFc5R3g5OFhOWVdCaVdMbDBLYm5pNHVibEprMXRsRHg0OGtHWk5UWTEwUFh2MnJBU1VvZWFsQmF0VWpQc1VYQlJBb2hWbVZ2d1hXdWl2QlFnUUdSV2tNbGxFQlliSGtwS1NsTWpJU0NrOUpDZWNPM2NPZCs5S3plSWZIR1Q3MWF0WFM1TSsvK3paczJvZkh4K1NIazJlOHo4eTh6UDIwL2ZOWW44bEFUQjJCVVlGa1IrTXlNdkxTMWl5Wk1rSzhVSUN3TWp3NU1rVFBIMzZWTHJTekNrd0JRMEtDcEtLcWhrelpraHV3L0ZONisxNldGallBWm50S1RocmYwRjhmZG9QVUJvQTRRcFN0MGkyQklKQVl0UmtabWIrTENZbVpvcS92MytvV3EwMmlRbDFPdDJicXFxcXYrZms1RnpWYXJYM1pZSHA3NXlNK1dSOUNrL1ROeXYwR1RQNUQ1cWppVGVJcUVBUWhEdlFHbGc1OGtyM1VPL2Z2ejh5SkNURTE4M056ZFhaMmRsVm85RzRPRGc0T0haMmRyWjFkSFMwdGJlM3R4VVhGNWRuWldXVlZWUlVNTWF6MFVpQk9hbDFmaGZDOTJ0alZDa1NOQVpVT2h3aHRzbmx6VklLVDVLa2RSQWNSZzd5aGpnc3hXZUlRMUxVS0RYTHJJNkNVbUF4K1owN1FJb2RsRkNDQkkwTlJGaUNTSmVaTEZGd0lUeS9Fd0FCQWtPcEFJQWFGUUJRVUU2U25EZ1RRRkFFNGZXSjlIcGJySWtXYnRadGhnZWtwQk1qOGhTZnBVMFZPWThRQVBBRkJJQ1RRbkpTWUdwYmZCY25RL3JzODlZQ1FMem52ZTB6c1p0a1lQcmlkMkVCRkV5QVFHSEZGTDZ1aU5ZdFJZTGZaeUxDSW9UQVlrTlZhSisvaThPU3ZSMllWRnh3UzRSQlUzMUU4STQ0VG1mOGY0WkFtUHJNUHQ5bkNSTHM4MklHNGgrSEFCZ0kxRCttZHc1WndNZWtqWUZZeTVBRkRBVHFIOU03QjcwRi9COEJrUXA5WU5iRzJRQUFBQUJKUlU1RXJrSmdnZz09IiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz48L3N2Zz4=) 16 16,auto!important;cursor:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 2x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 1x) 16 16,auto!important}.relation-graph .rg-move-operator.rg-move-operator-active .rg-move-touchpad{display:flex}.relation-graph.rg-creating-line .rg-connect-source-handle{pointer-events:none;opacity:.5}.relation-graph .rg-toolbar{user-select:none;pointer-events:all;display:flex;position:absolute;z-index:300;background-color:#fff;color:#999;box-shadow:0 1px 3px #00000026,0 0 .5px #0000004d;border:1px solid rgb(204,203,203);box-sizing:border-box;border-radius:5px;width:fit-content;height:fit-content;place-items:center;justify-content:center;gap:3px}.relation-graph .rg-toolbar .rg-icon{flex-grow:1;width:16px;height:16px;fill:currentColor;overflow:hidden}.relation-graph .rg-toolbar .rg-mb-button svg{margin:auto}.relation-graph .rg-toolbar .rg-mb-button-on{color:#2e74b5}.relation-graph .rg-toolbar .rg-mb-button:hover{background-color:#dcdcdc80}.relation-graph .rg-toolbar .rg-loading-icon{animation:turn 1s linear infinite}@keyframes turn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}to{-webkit-transform:rotate(360deg)}}.relation-graph .rg-toolbar .rg-current-zoom{margin-top:0;color:#262626;font-size:10px;text-align:center;border-radius:3px;cursor:pointer}.relation-graph .rg-toolbar .rg-current-zoom:hover{background-color:#dcdcdc80}.relation-graph .rg-toolbar .rg-mb-button{width:35px;height:35px;margin-top:0;opacity:1;text-align:center;cursor:pointer;font-size:18px;box-sizing:border-box;display:flex;align-items:center;justify-items:center;border-radius:3px}.relation-graph .rg-toolbar-v{flex-flow:column;padding:10px 3px}.relation-graph .rg-toolbar-v .rg-current-zoom{width:35px;height:25px;line-height:25px}.relation-graph .rg-toolbar-h{padding:3px 10px}.relation-graph .rg-toolbar-h .rg-current-zoom{width:fit-content;padding:0 5px;height:35px;line-height:35px}.relation-graph .rg-toolbar-h-right{right:15px}.relation-graph .rg-toolbar-h-left{left:15px}.relation-graph .rg-toolbar-h-center{left:50%;transform:translate(-50%)}.relation-graph .rg-toolbar-v-top{top:15px}.relation-graph .rg-toolbar-v-bottom{bottom:15px}.relation-graph .rg-toolbar-v-center{top:50%;transform:translateY(-50%)}.relation-graph .rg-xs-toolbar{background-color:#fff;color:#333}.relation-graph .rg-xs-toolbar .rg-mb-button{width:25px;height:25px}.relation-graph .rg-xs-toolbar.rg-toolbar-v{padding:3px}.relation-graph .rg-xs-toolbar.rg-toolbar-v .rg-current-zoom{width:30px;height:25px;line-height:25px}.relation-graph .rg-xs-toolbar.rg-toolbar-h{padding:3px}.relation-graph .rg-xs-toolbar.rg-toolbar-h .rg-current-zoom{width:35px;height:25px;line-height:25px}.relation-graph .rg-xs-toolbar.rg-toolbar-h .rg-mb-button{width:25px;height:25px}.relation-graph .rg-xs-toolbar.rg-toolbar-h-right{right:10px}.relation-graph .rg-xs-toolbar.rg-toolbar-h-left{left:10px}.relation-graph .rg-xs-toolbar.rg-toolbar-h-center{top:50%;transform:translate(-50%)}.relation-graph .rg-xs-toolbar.rg-toolbar-v-top{top:10px}.relation-graph .rg-xs-toolbar.rg-toolbar-v-bottom{bottom:10px}.relation-graph .rg-xs-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();"use strict";var be=Object.defineProperty;var Oe=(i,a,t)=>a in i?be(i,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[a]=t;var S=(i,a,t)=>(Oe(i,typeof a!="symbol"?a+"":a,t),t);/*!
2
- * relation-graph v3.0.0
1
+ (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("@charset \"UTF-8\";.relation-graph{box-sizing:border-box;position:relative;min-width:300px;min-height:300px;--editor-main-color: rgb(64, 165, 248);--editor-light-color: rgb(125, 192, 248);--editor-light2-color: rgb(168, 212, 248);--editor-light-opacity: rgba(57, 144, 216, .1);--rg-node-opacity: 1;--rg-node-font-size: 1rem;--rg-node-font-color: #000000;--rg-node-color: #eeeeee;--rg-node-border-color: #333333;--rg-node-border-width: 1px;--rg-node-border-radius: 3px;--rg-node-width: fit-content;--rg-node-height: fit-content;--rg-node-text-px: 10px;--rg-node-text-py: 3px;--rg-background-color: transparent;--rg-line-color: #888888;--rg-line-width: 1px;--rg-line-fontcolor: #666;--rg-line-fontsize: 12px;--rg-line-opacity: 1;--rg-checked-item-bg-color: rgba(150, 150, 150, .2);--rg-checked-line-text-bg-color: rgb(234, 232, 232)}.relation-graph:focus{outline:none}.relation-graph .rg-graph-plugs{position:absolute;left:0px;top:0px;z-index:90;width:100%;height:100%;pointer-events:none;user-select:none}.relation-graph .rg-graph-plugs .rg-view-slot{position:relative;width:100%;height:100%}.relation-graph .rg-watermark{position:absolute;--watermark-width: 200px;--watermark-height: 100px;z-index:1200;overflow:visible;min-height:100px;min-width:100px;width:var(--watermark-width);height:var(--watermark-height);box-sizing:border-box}.relation-graph .rg-watermark div{box-sizing:border-box}.relation-graph .rg-watermark.rg-watermark-top{left:calc((100% - var(--watermark-width)) / 2);top:10px}.relation-graph .rg-watermark.rg-watermark-bottom{left:calc((100% - var(--watermark-width)) / 2);bottom:10px}.relation-graph .rg-watermark.rg-watermark-left{left:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-right{right:10px;top:calc((100% - var(--watermark-height)) / 2)}.relation-graph .rg-watermark.rg-watermark-tl{left:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-tr{right:10px;top:10px}.relation-graph .rg-watermark.rg-watermark-bl{left:10px;bottom:10px}.relation-graph .rg-watermark.rg-watermark-br{right:10px;bottom:10px}.relation-graph .rg-lines-container svg{overflow:visible}.relation-graph .rg-lines-svg{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-lines-container{overflow:visible;position:absolute;z-index:40;width:100%;top:0px;left:0px;pointer-events:none}.relation-graph .rg-lines-container-el-lines{z-index:80;pointer-events:none}.relation-graph .rg-lines-container-el-lines .rg-line-bg{pointer-events:stroke}.relation-graph .rg-lines-container-el-lines .rg-line-text{pointer-events:all}.relation-graph .rg-lines-svg-el-lines{overflow:visible;width:10px;height:10px;position:absolute;left:0px;top:0px}.relation-graph .rg-nodes-container-wrapper{position:absolute;width:100%;top:0px;left:0px;z-index:50}.relation-graph .rg-nodes-container{position:relative;overflow:visible}.relation-graph .rg-map{background-color:var(--rg-background-color);overflow:hidden;cursor:default;user-select:none;opacity:.01;transition:none;width:100%;height:100%;position:relative}.relation-graph.rg-move-mode .rg-map{cursor:grab}.relation-graph .rg-map-ready{opacity:1;transition:opacity .5s ease;will-change:opacity}.relation-graph .rg-map-background-norepeat{background-repeat:no-repeat;background-position:right bottom}.relation-graph .rg-map-canvas{position:relative;user-select:none;pointer-events:none;top:0;left:0;border:none;z-index:3;overflow:visible;white-space:nowrap;transform-origin:0 0;will-change:transform}.relation-graph .rg-map-canvas .rg-events-all{pointer-events:all}.relation-graph.rg-enable-node-xy-animation .rg-node-peel{transition:transform .3s ease}.relation-graph.rg-enable-node-xy-animation .rg-line-peel{opacity:0;transition:none}.relation-graph.rg-enable-node-xy-animation .rg-map-canvas{transition:transform .4s ease-in-out}.relation-graph.rg-enable-canvas-animation .rg-map-canvas{transition:transform .5s ease}.relation-graph.rg-enable-canvas-animation .rg-editing-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-line-ctrl,.relation-graph.rg-enable-canvas-animation .rg-editing-connect-ctrl{opacity:0}.relation-graph .rg-canvas-behind{z-index:2;position:absolute}.relation-graph .rg-canvas-above{z-index:5;position:absolute}.relation-graph .rg-canvas-slot{overflow:visible;position:absolute;margin-top:0;margin-left:0}.relation-graph .rg-canvas-slot-behind{z-index:30;overflow:visible}.relation-graph .rg-canvas-slot-above{z-index:70;overflow:visible}.relation-graph .rg-single-graph{position:relative;overflow:visible}.relation-graph .rg-map img{-webkit-user-drag:none;-webkit-user-select:none}.relation-graph .rg-line-text{fill:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);paint-order:stroke;pointer-events:all}.relation-graph .rg-linetext-container{position:absolute;pointer-events:none;user-select:none;overflow:visible;left:0;top:0;z-index:45;display:block}.relation-graph .rg-linetext-container .rg-line-peel{width:fit-content}.relation-graph .rg-linetext-container .rg-line-peel .rg-line-label{display:block;color:var(--rg-line-fontcolor, #888888);font-size:var(--rg-line-fontsize);transform-origin:0 0;position:absolute;user-select:none;pointer-events:all;box-sizing:border-box;padding:2px 6px;border-radius:5px}.relation-graph .rg-linetext-container .rg-line-peel-checked .rg-line-label{background-color:var(--rg-checked-line-text-bg-color)}.relation-graph .rg-line-peel{pointer-events:none;cursor:default;transition:opacity .2s ease-in;opacity:var(--rg-line-opacity, 1)}.relation-graph .rg-line{fill-rule:nonzero;stroke-linecap:round;stroke:var(--rg-line-color);stroke-width:var(--rg-line-width);pointer-events:none;fill:none;marker-end:var(--rg-line-marker-end);marker-start:var(--rg-line-marker-start)}.relation-graph .rg-line-bg{stroke:#fff;opacity:.01;fill:none;fill-rule:nonzero;stroke-linecap:round;pointer-events:stroke;stroke-width:calc(var(--rg-line-width) + 6px)}.relation-graph .rg-line-bg:hover{opacity:.1;stroke:var(--rg-line-color)}.relation-graph .rg-line-peel-checked .rg-line-bg{stroke:var(--rg-checked-item-bg-color);opacity:1}.relation-graph .rg-line-peel-checked .rg-line{z-index:100}.relation-graph .rg-line-peel-checked .rg-line-text{stroke:var(--rg-checked-item-bg-color);stroke-width:2}.relation-graph .rg-line-peel-disable-events{pointer-events:none!important}.relation-graph .rg-line-peel-disable-events .rg-line-bg,.relation-graph .rg-line-peel-disable-events .rg-line-text,.relation-graph .rg-linetext-container .rg-line-peel-disable-events .rg-line-bg,.relation-graph .rg-linetext-container .rg-line-peel-disable-events .rg-line-label{pointer-events:none}.relation-graph .rg-line-dashtype-1{stroke-dasharray:2,2,2;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-2{stroke-dasharray:5,5,5;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-3{stroke-dasharray:9,9,9;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}.relation-graph .rg-line-dashtype-4{stroke-dasharray:5,5,15;stroke-dashoffset:3px;stroke-linecap:butt;stroke-linejoin:bevel}@keyframes ACTRGLineChecked{0%{stroke-dashoffset:352px;stroke-dasharray:5,5,5}50%{stroke-dasharray:5,5,5;stroke-dashoffset:3px}to{stroke-dashoffset:352px;stroke-dasharray:5,5,5}}@keyframes rg-line-anm1{0%{stroke-dashoffset:100px;stroke-dasharray:5,5,5}to{stroke-dasharray:5,5,5;stroke-dashoffset:3px}}@keyframes rg-line-anm2{0%{stroke-dashoffset:0;stroke-dasharray:4,4,4}to{stroke-dashoffset:10px;stroke-dasharray:20,20,20}}@keyframes rg-line-anm3{0%{stroke-opacity:1}50%{stroke-opacity:.2}to{stroke-opacity:1}}@keyframes rg-line-anm4{0%{stroke-dasharray:0,100%}to{stroke-dasharray:100%,0}}.relation-graph .rg-line-anm-1{animation:rg-line-anm1 10s infinite;animation-fill-mode:forwards;animation-timing-function:linear}.relation-graph .rg-line-anm-2{animation:rg-line-anm2 3s infinite}.relation-graph .rg-line-anm-3{animation:rg-line-anm3 1s infinite}.relation-graph .rg-line-anm-4{animation:rg-line-anm4 3s infinite}@keyframes deform1{0%{stroke-dashoffset:0}to{stroke-dashoffset:100%}}.relation-graph .rg-icon{width:19px;height:19px;vertical-align:0px;fill:currentColor;overflow:hidden}.relation-graph .rg-node-peel{padding:0;position:absolute;pointer-events:none;box-sizing:border-box;opacity:var(--rg-node-opacity);z-index:var(--rg-node-z-index);will-change:transform;transform-origin:0 0;cursor:default}.relation-graph .rg-node-peel .rg-node{pointer-events:all;text-align:center;border-style:solid;box-sizing:border-box;overflow:visible;transform-origin:0 0;font-size:var(--rg-node-font-size);color:var(--rg-node-font-color);background-color:var(--rg-node-color);border-color:var(--rg-node-border-color);border-width:var(--rg-node-border-width);width:var(--rg-node-width);height:var(--rg-node-height)}.relation-graph .rg-node-disable-events{pointer-events:none}.relation-graph .rg-node-shape-0>.rg-node{border-radius:50%}.relation-graph .rg-node-shape-1>.rg-node{border-radius:var(--rg-node-border-radius)}.relation-graph .rg-node-checked{z-index:800}.relation-graph .rg-node-checked>.rg-node{box-shadow:0 0 0 4px var(--rg-checked-item-bg-color)}.relation-graph .rg-node-selected>.rg-node{box-shadow:0 0 0 2px var(--editor-main-color)}.relation-graph img,.relation-graph svg,.relation-graph video,.relation-graph canvas,.relation-graph audio,.relation-graph iframe,.relation-graph embed,.relation-graph object{display:unset;vertical-align:unset}.relation-graph .rg-node-text{color:var(--rg-node-font-color);font-size:var(--rg-node-font-size);padding:var(--rg-node-text-py) var(--rg-node-text-px);height:100%;width:100%;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.relation-graph .rg-node-type-button{border-radius:25px;color:#00f;cursor:pointer}.relation-graph .rg-editing-referline{user-select:none;position:absolute;z-index:999;pointer-events:none;width:100%;height:100%;left:0px;top:0px}.relation-graph .rg-editing-referline .rg-referline{position:absolute;display:flex;place-items:center;justify-content:center;overflow:visible;transform-origin:0 0;--rg-refer-offset: -3px}.relation-graph .rg-editing-referline .rg-referline .referline{display:flex;place-items:center;justify-content:center}.relation-graph .rg-editing-referline .rg-referline .referline>div{background-color:var(--editor-main-color);font-size:8px;border-radius:3px;color:#fff;width:fit-content;height:fit-content;padding:2px 5px}.relation-graph .rg-editing-referline .rg-referline-v{top:0px;width:6px;height:100%}.relation-graph .rg-editing-referline .rg-referline-v .referline{width:1px;height:100%;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-v:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;top:0;transform:translateY(-50%)}.relation-graph .rg-editing-referline .rg-referline-v:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;bottom:0;transform:translateY(50%)}.relation-graph .rg-editing-referline .rg-referline-h{left:0px;width:100%;height:6px}.relation-graph .rg-editing-referline .rg-referline-h .referline{width:100%;height:1px;background-color:var(--editor-main-color)}.relation-graph .rg-editing-referline .rg-referline-h:before{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;left:0;transform:translate(-50%)}.relation-graph .rg-editing-referline .rg-referline-h:after{content:\"\";position:absolute;width:5px;height:5px;background-color:var(--editor-main-color);border-radius:50%;right:0;transform:translate(50%)}.relation-graph .rg-editing-line-ctrl{position:absolute;left:0px;top:0px;z-index:500;pointer-events:none;user-select:none;width:100%;height:100%}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg{position:absolute;pointer-events:none;left:0px;top:0px;overflow:visible}.relation-graph .rg-editing-line-ctrl .rg-edt-ctrl-svg path{stroke:var(--editor-main-color);stroke-width:1px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-dot{--rg-ctl-x: 0px;--rg-ctl-y: 0px;pointer-events:auto;user-select:none;width:10px;height:10px;background-color:#fff;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:50%;cursor:move;z-index:1;transform-origin:0 0}.relation-graph .rg-editing-line-ctrl .start-dot,.relation-graph .rg-editing-line-ctrl .end-dot,.relation-graph .rg-editing-line-ctrl .ctrl-dot{transform-origin:0 0;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split,.relation-graph .rg-editing-line-ctrl .ctrl-split-core{background-color:#fff}.relation-graph .rg-editing-line-ctrl .ctrl-split-h{width:12px;height:5px;border-radius:3px;cursor:row-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .ctrl-split-v{width:5px;height:12px;border-radius:3px;cursor:col-resize;transform:translate(-50%,-50%) translate(var(--rg-ctl-x),var(--rg-ctl-y))}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text{--rg-ctl-x: 0px;--rg-ctl-y: 0px;--font-size: .8rem;pointer-events:auto;background-color:#fffc;box-shadow:0 0 0 1px var(--editor-main-color);position:absolute;border-radius:3px;cursor:move;z-index:1;white-space:nowrap;color:#000;padding:3px 10px;display:flex;place-items:center;justify-content:center;box-sizing:border-box;text-shadow:none;font-size:var(--font-size, 12px);min-height:20px;max-height:30px;transform-origin:0 0;transform:translate(-50%,-50%) translate(10px,3px) translate(var(--rg-ctl-x),var(--rg-ctl-y));min-width:50px;max-width:220px}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p{font-size:var(--font-size, 12px);color:#333}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text p.empty-text{font-size:10px;color:#888}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text .rg-line-text-input{white-space:nowrap;pointer-events:auto;user-select:auto;background-color:transparent;color:#000;border-radius:3px;height:100%;padding:3px 0;width:100px;text-shadow:none;font-size:var(--font-size, 12px);text-align:center;box-sizing:border-box;border:none;outline:none}.relation-graph .rg-editing-line-ctrl .rg-line-ctrl-text-editing{background-color:#faf191}.relation-graph .rg-editing-ctrl,.relation-graph .rg-editing-connect-ctrl{user-select:none;position:absolute;z-index:500;box-shadow:0 0 0 1px var(--editor-main-color);border-radius:0;pointer-events:none;transform-origin:0 0}.relation-graph .rg-editing-bar{user-select:none;pointer-events:none;position:absolute;border-radius:5px;padding:3px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;flex-wrap:wrap;gap:5px}.relation-graph .rg-editing-bar .rg-gee-icon{background-color:#d603f680;pointer-events:auto;min-width:20px;min-height:20px;border-radius:5px;box-sizing:border-box;display:flex;place-items:center;justify-content:center;cursor:pointer}.relation-graph .rg-editing-bar .rg-gee-icon:hover{background-color:#d603f6;color:#fff}.relation-graph .rg-connect-source-handle{pointer-events:auto;width:fit-content;height:fit-content}.relation-graph .rg-editing-bar-top{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(-100%);top:-15px}.relation-graph .rg-editing-bar-bottom{width:fit-content;height:fit-content;left:50%;transform:translate(-50%) translateY(100%);bottom:-15px}.relation-graph .rg-editing-bar-left{width:fit-content;height:fit-content;left:-15px;top:50%;transform:translate(-100%) translateY(-50%)}.relation-graph .rg-editing-bar-right{width:fit-content;height:fit-content;right:-15px;top:50%;transform:translate(100%) translateY(-50%)}.relation-graph .rg-editing-bar-tl{width:30px;height:30px;right:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-tr{width:30px;height:30px;left:calc(100% + 10px);top:-40px}.relation-graph .rg-editing-bar-bl{width:30px;height:30px;right:calc(100% + 10px);bottom:-40px}.relation-graph .rg-editing-bar-br{width:30px;height:30px;left:calc(100% + 10px);bottom:-40px}.relation-graph .rg-resize-ctl{user-select:none;position:relative;height:100%;width:100%;--resize-handler-size: 10px;--resize-handler-offset: -5px}.relation-graph .rg-resize-ctl .rg-resize-ctl-handler{pointer-events:auto;width:var(--resize-handler-size);height:var(--resize-handler-size);background-color:#fff;position:absolute;border-radius:2px;box-shadow:inset 0 0 0 1px var(--editor-main-color)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tl{cursor:nwse-resize;left:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-tr{cursor:nesw-resize;right:var(--resize-handler-offset);top:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-bl{cursor:nesw-resize;left:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-br{cursor:nwse-resize;right:var(--resize-handler-offset);bottom:var(--resize-handler-offset)}.relation-graph .rg-resize-ctl .rg-resize-ctl-t{cursor:n-resize;top:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-b{cursor:s-resize;bottom:var(--resize-handler-offset);left:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-l{cursor:w-resize;left:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-resize-ctl .rg-resize-ctl-r{cursor:e-resize;right:var(--resize-handler-offset);top:calc((100% - var(--resize-handler-size)) / 2)}.relation-graph .rg-editing-connect-ctrl{position:absolute;user-select:none;pointer-events:none;left:0;top:0;z-index:1400;--hander-border-radius: 5px;border-radius:var(--hander-border-radius);--border-handler-width: 8px;--hv-handler-width: 10px;--center-handler-width: 10px;--border-point-width: 10px;--border-point-height: 10px;--hander-color: var(--editor-light2-color);--hander-border-color: var(--editor-main-color);--hander-shadow-color: rgba(57, 144, 216, .1);box-shadow:0 0 0 var(--border-handler-width) var(--hander-shadow-color)}.relation-graph .rg-connect-ctl{width:100%;height:100%;pointer-events:none;user-select:none;border:none;position:relative}.relation-graph .rg-connect-ctl-handler{pointer-events:auto;user-select:none;z-index:20;cursor:crosshair}.relation-graph .rg-connect-target{width:fit-content;height:fit-content;pointer-events:auto;display:flex;place-items:center;justify-content:center}.relation-graph .rg-connect-ctl-handler-style{background-color:var(--hander-color);border:var(--hander-border-color) solid 1px;position:absolute;border-radius:3px}.relation-graph .rg-connect-ctl-handler-style:hover{background-color:#fbe691}.relation-graph .rg-connect-ctl-center{width:var(--center-handler-width);height:var(--center-handler-width);border-radius:50%;top:calc((100% - var(--center-handler-width)) / 2);left:calc((100% - var(--center-handler-width)) / 2)}.relation-graph .rg-connect-ctl-t{width:var(--border-point-width);height:var(--border-point-height);top:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-b{width:var(--border-point-width);height:var(--border-point-height);bottom:calc(var(--border-point-height) / -2);left:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-l{width:var(--border-point-height);height:var(--border-point-width);left:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-r{width:var(--border-point-height);height:var(--border-point-width);right:calc(var(--border-point-height) / -2);top:calc((100% - var(--border-point-width)) / 2)}.relation-graph .rg-connect-ctl-lr{width:100%;height:var(--hv-handler-width);right:0px;top:calc((100% - var(--hv-handler-width)) / 2);z-index:11;opacity:.01}.relation-graph .rg-connect-ctl-lr:hover{opacity:1}.relation-graph .rg-connect-ctl-tb{width:var(--hv-handler-width);height:100%;top:0px;left:calc((100% - var(--hv-handler-width)) / 2);z-index:10;opacity:.01}.relation-graph .rg-connect-ctl-tb:hover{opacity:1}.relation-graph .rg-connect-ctl-bottom-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:100%;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-top-left-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-bottom-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-top-bar{border:0px;border:none;width:100%;height:var(--border-handler-width);right:0px;top:calc(var(--border-handler-width) * -1);z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-top-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-left-bar{border:0px;border:none;width:var(--border-handler-width);height:100%;left:calc(var(--border-handler-width) * -1);top:0;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-right-radius:0;border-top-right-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-left-bar:hover{opacity:1}.relation-graph .rg-connect-ctl-right-bar{border:0px;width:var(--border-handler-width);height:100%;right:calc(var(--border-handler-width) * -1);top:0px;z-index:5;opacity:.1;box-shadow:none;background-color:var(--edit-ctl-light-color);border-radius:var(--hander-border-radius);border-bottom-left-radius:0;border-top-left-radius:0;overflow:hidden}.relation-graph .rg-connect-ctl-right-bar:hover{opacity:1}.relation-graph .rg-miniview{pointer-events:all;position:absolute;user-select:none;overflow:hidden;z-index:1100;min-height:100px;min-width:100px;--miniview-width: 200px;--miniview-height: 120px;height:var(--miniview-height);width:var(--miniview-width);border-radius:3px;display:flex;place-items:center;justify-content:center;background-color:#fff;box-shadow:0 0 0 1px #ccc;border:none}.relation-graph .rg-miniview .rg-miniview-container{position:relative;width:100%;height:100%;display:flex;place-items:center;justify-content:center}.relation-graph .rg-miniview canvas{opacity:1}.relation-graph .rg-miniview .rg-mv-canvas-reset{cursor:pointer}.relation-graph .rg-miniview .rg-mv-canvas-reset:hover{background-color:#bbf54794}.relation-graph .rg-miniview .rg-mv-visible-area{z-index:2;position:absolute;left:0;top:0;cursor:move;transform-origin:0 0;box-shadow:0 0 0 9999px #0003;border:#888 solid 1px;border-radius:3px;display:grid;place-items:center;color:#fff;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.5)}.relation-graph .rg-miniview.rg-miniview-top{left:calc((100% - var(--miniview-width)) / 2);top:10px}.relation-graph .rg-miniview.rg-miniview-bottom{left:calc((100% - var(--miniview-width)) / 2);bottom:10px}.relation-graph .rg-miniview.rg-miniview-left{left:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-right{right:10px;top:calc((100% - var(--miniview-height)) / 2)}.relation-graph .rg-miniview.rg-miniview-tl{left:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-tr{right:10px;top:10px}.relation-graph .rg-miniview.rg-miniview-bl{left:10px;bottom:10px}.relation-graph .rg-miniview.rg-miniview-br{right:10px;bottom:10px}.relation-graph .rg-node-flashing{animation:ACTRGNodeFlashing 2s infinite}.relation-graph .rg-node-vtree-2{transform-origin:0 0;transform:rotate(30deg) translate(0)}.relation-graph .rg-node-vtree{width:130px;height:45px;text-align:left}.relation-graph .rg-node-expand-holder{position:absolute;height:fit-content;width:fit-content;display:flex;align-items:center;justify-content:center;user-select:none;pointer-events:none;cursor:pointer}.relation-graph .rg-node-expand-holder>span{width:16px;height:16px;display:block;text-align:center;border-radius:15px;cursor:pointer;background-size:100% 100%;pointer-events:all;border:#aaaaaa solid .5px;background-color:#fff}.relation-graph .c-expanded{background-image:url(data:image/svg+xml;%20charset=utf8,%3Csvg%20t=%221606310217820%22%20viewBox=%220%200%201024%201024%22%20version=%221.1%22%20xmlns=%22http://www.w3.org/2000/svg%22%20p-id=%223373%22%20width=%2232%22%20height=%2232%22%3E%3Cpath%20d=%22M853.333333%20480H544V170.666667c0-17.066667-14.933333-32-32-32s-32%2014.933333-32%2032v309.333333H170.666667c-17.066667%200-32%2014.933333-32%2032s14.933333%2032%2032%2032h309.333333V853.333333c0%2017.066667%2014.933333%2032%2032%2032s32-14.933333%2032-32V544H853.333333c17.066667%200%2032-14.933333%2032-32s-14.933333-32-32-32z%22%20p-id=%223374%22%20fill=%22%23666666%22%3E%3C/path%3E%3C/svg%3E)}.relation-graph .c-collapsed{background-image:url(data:image/svg+xml;%20charset=utf8,%3Csvg%20t=%221606310454619%22%20class=%22icon%22%20viewBox=%220%200%201024%201024%22%20version=%221.1%22%20xmlns=%22http://www.w3.org/2000/svg%22%20p-id=%223662%22%20width=%22128%22%20height=%22128%22%3E%3Cpath%20d=%22M853.333333%20554.666667H170.666667c-23.466667%200-42.666667-19.2-42.666667-42.666667s19.2-42.666667%2042.666667-42.666667h682.666666c23.466667%200%2042.666667%2019.2%2042.666667%2042.666667s-19.2%2042.666667-42.666667%2042.666667z%22%20p-id=%223663%22%20fill=%22%23666666%22%3E%3C/path%3E%3C/svg%3E)}.relation-graph .c-expand-positon-left{transform:translate(-100%) translateY(-50%);left:-5px;top:50%}.relation-graph .c-expand-positon-right{transform:translate(5px) translateY(-50%);left:100%;top:50%}.relation-graph .c-expand-positon-bottom{transform:translate(-50%);left:50%;top:calc(100% + 5px)}.relation-graph .c-expand-positon-top{transform:translate(-50%) translateY(-100%);left:50%;top:-5px}.relation-graph .rg-setting-panel{--height: 300px;--width: 200px;width:300px;height:200px;position:absolute;left:10px;top:5px;font-size:12px;color:#3a5bb2;padding:60px 10px 10px;overflow:hidden;box-shadow:0 0 5px #999;border-radius:5px;z-index:1000;background-color:#fff;border:#999999 solid 1px}.relation-graph .rg-setting-panel-button{height:35px;width:35px;font-size:8px;line-height:35px;text-align:center;border-radius:50%;position:absolute;margin-left:25px;margin-top:20px;background-color:#3a5bb2;color:#fff;cursor:pointer;z-index:1001;box-shadow:0 0 8px #999}.relation-graph .rg-setting-panel-button:hover{box-shadow:0 0 20px #ffa20a;border:#ffffff solid 1px;color:#ffa20a;-moz-transform:rotate(-89deg) translateX(-190px);animation-timing-function:linear;animation:flashButton 2s infinite}@keyframes flashButton{0%{box-shadow:0 0 8px #2e4e8f}30%{box-shadow:0 0 20px #ffa20a}to{box-shadow:0 0 8px #2e4e8f}}.relation-graph .c-debug-tools-row{text-align:left}.relation-graph .rg-operate{pointer-events:none;user-select:none;position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:180}.relation-graph .rg-operate .rg-node{cursor:move}.relation-graph .rg-operate .rg-creating-container{pointer-events:none;position:relative}.relation-graph .rg-operate .rg-creating-container *{pointer-events:none!important}.relation-graph .rg-selection{pointer-events:none;position:absolute;user-select:none;background-color:var(--editor-light-opacity);border:var(--editor-main-color) solid 1px;transform-origin:0 0}.relation-graph .rg-graph-loading{position:absolute;z-index:1600;left:0px;top:0px;height:100%;width:100%;background-color:#fff}.relation-graph .rg-graph-loading .rg-graph-loading-icon{width:16px;height:16px;vertical-align:-3px;fill:currentColor;overflow:hidden;animation:turn 1s linear infinite}.relation-graph .rg-graph-loading .rg-graph-loading-message{position:absolute;width:200px;height:30px;line-height:30px;text-align:center;left:calc((100% - 200px)/2);top:calc((100% - 30px)/2);border-radius:5px;background-color:#00000080;color:#fff;display:flex;place-items:center;justify-content:center;gap:8px}.relation-graph .rg-graph-loading-hide{display:none}@keyframes slowHide{0%{opacity:1}to{opacity:0;display:none}}.relation-graph .rg-easy-view{overflow:visible;height:100%;width:100%;background-color:transparent;position:absolute;left:0px;top:0px;z-index:3;pointer-events:none}.relation-graph .rg-easy-view canvas{opacity:0;width:100%;height:100%}.relation-graph .rg-easy-view-active{pointer-events:all}.relation-graph .rg-easy-view-active canvas{opacity:1}.relation-graph .rg-move-operator{position:absolute;width:100%;height:100%;pointer-events:none;user-select:none;left:0px;top:0px;z-index:6666}.relation-graph .rg-move-operator .rg-move-touchpad{display:none;background-color:var(--edit-ctl-light2-color);height:100%;width:100%;pointer-events:all}.relation-graph .rg-move-operator.rg-move-operator-active{pointer-events:all;cursor:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzJweCIgaGVpZ2h0PSIzMnB4Ij48aW1hZ2UgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFFQUFBQUJBQ0FZQUFBQ3FhWEhlQUFBQUFYTlNSMElBcnM0YzZRQUFDWlpKUkVGVWVGN3RXZ3RNVk5rWi9xYThabkZ4QkVIQWlCV3lFa0drUEcwRW1paWdGVVZzcFZxTmlsSmZRVEV4c2k2eDFqZHRMVnVEeGpoTlJDc0JzeHBOZktEV0J4Q05QTFFpaUNoRzBTQkxKZHBTYUFWNXlHaW4rOTNjdzQ2enVEc0Rkd1lUT01uSm5XRXU5NTcvKy8vLyt4L25xRERJaDJxUXk0OGhBSVlzWUpBak1PUUNnOXdBaGtod3lBV0dYR0NRSXpEa0FnTmtBQUo0UXdYbzViV0lxMVdXWm0wTDRQdCtCTUJHdnZJN0o0WG0vQitBZC9MVktrQllBd0FocEJEY3RyS3lNc3pYMTNlcG5aMWRvTDI5ZlhoM2QzZTVUcWVycnEydHpRc0pDYmtENEswUkVCWUR3NUlBR0dxYkdyY0ZZSGYvL3YxWkV5Wk0rTE90cmEyN3NZMi9mZnYybjQ4ZVBmcDgwcVJKZndPZ2s0RWdHTFFNVHNXQnNBUUFRdU1VMkxhc3JDekF6ODh2U2ExV0I2dlY2Z2doOUtWTGw4QjU0TUFCckYrL0huRnhjZElVUTZmVFBlN3M3THgyK1BEaFA2U2xwZjNieUNvVTR3ZExBRUJ0YzlxM3RMUnNkWFoyL3NKNHRRME5EUWdNRE1TclY2OTZmdEpvTktpdXJzYllzV1BmdTEybjB6MjRjZVBHNnRqWTJHb0EzUWF1b1FnSVNnUEE1OWxSZUsxVzY1T1NrbktQcXp4eTVBaU9IajJLMHRKU1RKMDZGY09HRGNQRml4ZXhZOGNPYk4rK0hUdDM3cFErejU0OUcrM3Q3YmgrL1RvaUl5T1JuSnlNRlN0V29MdTd1elkzTjNmK3FsV3I2bVFRaEZ2MEd3U2xBYURtSFFBNHZuang0azhlSGg2L29URFRwazNyZGFGNi9iY3VyVkwxdnBScjE2NUpvTDE4K2ZLdm5wNmV2d1hRQ2VDTjdCTDk1Z1dsQWFEMkhRRTR0YmEyWG5CeWN2cEpSRVFFYnQ2OCtSMXRFNUhlQURDMmlpbFRwcUNzckV3Q3NLT2o0MjVYVjFkNWZuNStWbkp5Y29OTWxDSnM5c2thbEFTQXo2TDJod0VZb2Rmcm4zSkZRck85Q2R1WHYvR1pPcDN1SC9YMTllbSt2cjc1QnRHQzFtRDJVQklBeG5rMXRRL0FSYS9YUDFRS2dISGp4cUcrdnY0N3ZKQ2Vudjd6ZmZ2Mk5SbndndGxoVWtrQTZQK2ZBQmdPWUtSZXJ5ZHJLMklCeG1vVnZORFkyTGh2ekpneHUyVmVFQkhDTEN0UUVnREdmZnEvUmdiZ3JsSUFmSWdYMnRyYWJnOGZQdnlYQU5vQWRNbnVZSFVBYVBvRTB0NElnTnRLQWZCOVhLRlNxWHdBTUtGb2wxM0JMRGZvandWUWNKSGYyeFFWRlFXTUh6OStiazFOemRkeGNYRVA5WHA5c1pVQThBUFFBdUMxYkFWbWtXRmZBYURnVXFwYlYxY1g3Kzd1L2l0SFI4ZjV2ZG1lMGxIQStIa3FsU29RUURPQVZwa0xHQlpOSG4wQlFBaHZYMUZSTVRVa0pPUVUyWjhzZmV2V0xYUjFkU0VoSVFFdUxpN1NJcXdBUUpBTUFOMmdRMDZWTFFZQUFaT3l2ZFRVMUZGNzkrNHR0TGUzOThuSnlVRnFhcXFVeG5Jd245KzBhWlAwTnlzQUVBS0F4WklBZ0dteXljTmNDNkQyU1hhZkZCY1h4MGRGUmVVMk5UVmg4dVRKVXB4ZXVIQWgzcjE3aDFPbmFCVEF5Wk1uc1dEQkF1bXpJWkd4NkhuOCtESG16Ly9XYTBTNnpCQW5oaW5ncVZTcVVBRE1CYXdDQUxYUFpPZlR1cnE2MzNsN2U2ZHF0VnFzVzdjT3k1Y3Zsd29lamtPSERtSE5talVZT1hJa21wdnBudThEWUtwNkJKQ0dRUFhDQVFTQUZ2QmYyUVVzYWdITTlhVmtwN2k0ZUZsVVZGVEdpUk1uc0dqUklrbjd4NDhmNzVHTkdtVWhKSWFoQlpnS2dDbWtLbHVBVlFGZ3JxODVkdXhZM09MRmkvOUMwdzhJQ0lDTmpRMEtDd3NSSGg3ZXMrNVpzMlpKVFErUnlQUkg4QSs1eFlBQkFNQzFvYUhob0plWDEwODNidHlJckt3c1RKOCtIVmV2WGxWQ3pnOCs0d011WURVT0VPa3U4MzNYN096c09TdFhydHoxK3ZWclJFZEhvN3k4SEZ1M2JzV3VYYnNzQnNKQUF5QklrQldmTTRCUnQyL2Yvanc4UER6K3lwVXJtRGx6cGlUNGhRc1hwTzZPMHFPcXFnckJ3Y0VZUFhvMEdoc2I4ZWJObTFkcXRacmRGcXVIUVJZOUkxajBCQVVGalNzb0tQalMxZFgxeDl1MmJjUHUzYnVsUmJLSm9WWXpZQ2czbUcrd1RSWWFHb283ZCs2Z3RiWDFhNDFHOHdzREFOZ3RzbWdVb0RTTUJHeDhTSFUvWFVHcjFjYWxwS1NrODBmMjhpaDhSa1lHdG16Wm9wejAzK1M1NmVucHlNek14TnExYTNIdzRFRTBOVFhkR3pWcVZKSkJKa2dBckpJS2k5WVhTMStDNEZaWldmbEZjSEJ3OUprelp6QnYzanhKOEljUEg4TFBqN1dLTW1QdTNMbkl6OC9IK2ZQbkVSOGZqOU9uVC84eE1USHhLNk5hd0NyRkVNbVFWdkNwY0lVTkd6Wk16c3pNM0dOblorZVFsSlNFdkx3OGFaRmNyQkpEY0F6OW44QTZPanAyUmtkSEx5Z3BLV0hyamRVZ2V3SnNsbG9GQU5IK1psTFU0d3FGaFlXclkySmlmczFVbDY3QTZFQ056Wmt6cDk4WWVIbDU0Zm56NXowNVJVMU56WldBZ0lDZEFQNGxaNEVzaDlrVnNtby9RR3FCaXk2UWs1T1RlMjF0YlphSGg4ZG5vdGRQeWZ1YkJTNWJ0Z3k1dWJtWU9IRWlDZ29LNE9ucGljMmJONi9mczJkUHFVeUFMSVZaQ1hJN3pheGhiakZrK0hCUkdZcEdLS09DSU1UTnZKRmNRRTVnVkNncEthSFptclU0M2h3Ykc0dWlvaUpKZUJaWC92Nyt1SGZ2WGtGUVVGQ0dYQVFaTmtQTUlrQSt2ejhBOFA5WkhmYlVCd3lMbktXbHBlc2pJaUlTZUFQMyt5NWZ2Z3huWjJka1oyY2pNVEhSSkJBWTh0TFMwdERTMHZLZThNM056UTJ1cnE1clpPRlphWWtxMEd6elZ3SUFQa1BzQmtrMWdnQ2hycTd1OTk3ZTNteFc5R3g5OFhOWVdCaVdMbDBLYm5pNHVibEprMXRsRHg0OGtHWk5UWTEwUFh2MnJBU1VvZWFsQmF0VWpQc1VYQlJBb2hWbVZ2d1hXdWl2QlFnUUdSV2tNbGxFQlliSGtwS1NsTWpJU0NrOUpDZWNPM2NPZCs5S3plSWZIR1Q3MWF0WFM1TSsvK3paczJvZkh4K1NIazJlOHo4eTh6UDIwL2ZOWW44bEFUQjJCVVlGa1IrTXlNdkxTMWl5Wk1rSzhVSUN3TWp3NU1rVFBIMzZWTHJTekNrd0JRMEtDcEtLcWhrelpraHV3L0ZONisxNldGallBWm50S1RocmYwRjhmZG9QVUJvQTRRcFN0MGkyQklKQVl0UmtabWIrTENZbVpvcS92MytvV3EwMmlRbDFPdDJicXFxcXYrZms1RnpWYXJYM1pZSHA3NXlNK1dSOUNrL1ROeXYwR1RQNUQ1cWppVGVJcUVBUWhEdlFHbGc1OGtyM1VPL2Z2ejh5SkNURTE4M056ZFhaMmRsVm85RzRPRGc0T0haMmRyWjFkSFMwdGJlM3R4VVhGNWRuWldXVlZWUlVNTWF6MFVpQk9hbDFmaGZDOTJ0alZDa1NOQVpVT2h3aHRzbmx6VklLVDVLa2RSQWNSZzd5aGpnc3hXZUlRMUxVS0RYTHJJNkNVbUF4K1owN1FJb2RsRkNDQkkwTlJGaUNTSmVaTEZGd0lUeS9Fd0FCQWtPcEFJQWFGUUJRVUU2U25EZ1RRRkFFNGZXSjlIcGJySWtXYnRadGhnZWtwQk1qOGhTZnBVMFZPWThRQVBBRkJJQ1RRbkpTWUdwYmZCY25RL3JzODlZQ1FMem52ZTB6c1p0a1lQcmlkMkVCRkV5QVFHSEZGTDZ1aU5ZdFJZTGZaeUxDSW9UQVlrTlZhSisvaThPU3ZSMllWRnh3UzRSQlUzMUU4STQ0VG1mOGY0WkFtUHJNUHQ5bkNSTHM4MklHNGgrSEFCZ0kxRCttZHc1WndNZWtqWUZZeTVBRkRBVHFIOU03QjcwRi9COEJrUXA5WU5iRzJRQUFBQUJKUlU1RXJrSmdnZz09IiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiLz48L3N2Zz4=) 16 16,auto!important;cursor:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 2x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACZZJREFUeF7tWgtMVNkZ/qa8ZnFxBEHAiBWyEkGkPG0EmiigFUVspVqNilJfQTExsi6x1jdtLVuDxjhNRCsBsxpNfKDWBxCNPLQiiChG0SBLJdpSaAV5yGin+93cw46zuDsDdwYTOMnJnWEu957/+///+x/nqDDIh2qQy48hAIYsYJAjMOQCg9wAhkhwyAWGXGCQIzDkAgNkAAJ4QwXo5bWIq1WWZm0L4Pt+BMBGvvI7J4Xm/B+Ad/LVKkBYAwAhpBDctrKyMszX13epnZ1doL29fXh3d3e5Tqerrq2tzQsJCbkD4K0REBYDw5IAGGqbGrcFYHf//v1ZEyZM+LOtra27sY2/ffv2n48ePfp80qRJfwOgk4EgGLQMTsWBsAQAQuMU2LasrCzAz88vSa1WB6vV6ggh9KVLl8B54MABrF+/HnFxcdIUQ6fTPe7s7Lx2+PDhP6Slpf3byCoU4wdLAEBtc9q3tLRsdXZ2/sJ4tQ0NDQgMDMSrV696ftJoNKiursbYsWPfu12n0z24cePG6tjY2GoA3QauoQgISgPA59lReK1W65OSknKPqzxy5AiOHj2K0tJSTJ06FcOGDcPFixexY8cObN++HTt37pQ+z549G+3t7bh+/ToiIyORnJyMFStWoLu7uzY3N3f+qlWr6mQQhFv0GwSlAaDmHQA4vnjx4k8eHh6/oTDTpk3rdaF6/bcurVL1vpRr165JoL18+fKvnp6evwXQCeCN7BL95gWlAaD2HQE4tba2XnBycvpJREQEbt68+R1tE5HeADC2iilTpqCsrEwCsKOj425XV1d5fn5+VnJycoNMlCJs9skalASAz6L2hwEYodfrn3JFQrO9CduXv/GZOp3uH/X19em+vr75BtGC1mD2UBIAxnk1tQ/ARa/XP1QKgHHjxqG+vv47vJCenv7zffv2NRnwgtlhUkkA6P+fABgOYKRerydrK2IBxmoVvNDY2LhvzJgxu2VeEBHCLCtQEgDGffq/RgbgrlIAfIgX2trabg8fPvyXANoAdMnuYHUAaPoE0t4IgNtKAfB9XKFSqXwAMKFol13BLDfojwVQcJHf2xQVFQWMHz9+bk1NzddxcXEP9Xp9sZUA8APQAuC1bAVmkWFfAaDgUqpbV1cX7+7u/itHR8f5vdme0lHA+HkqlSoQQDOAVpkLGBZNHn0BQAhvX1FRMTUkJOQU2Z8sfevWLXR1dSEhIQEuLi7SIqwAQJAMAN2gQ06VLQYAAZOyvdTU1FF79+4ttLe398nJyUFqaqqUxnIwn9+0aZP0NysAEAKAxZIAgGmyycNcC6D2SXafFBcXx0dFReU2NTVh8uTJUpxeuHAh3r17h1OnaBTAyZMnsWDBAumzIZGx6Hn8+DHmz//Wa0S6zBAnhingqVSqUADMBawCALXPZOfTurq633l7e6dqtVqsW7cOy5cvlwoejkOHDmHNmjUYOXIkmpvpnu8DYKp6BJCGQPXCAQSAFvBf2QUsagHM9aVkp7i4eFlUVFTGiRMnsGjRIkn7x48f75GNGmUhJIahBZgKgCmkKluAVQFgrq85duxY3OLFi/9C0w8ICICNjQ0KCwsRHh7es+5Zs2ZJTQ+RyPRH8A+5xYABAMC1oaHhoJeX1083btyIrKwsTJ8+HVevXlVCzg8+4wMuYDUOEOku833X7OzsOStXrtz1+vVrREdHo7y8HFu3bsWuXbssBsJAAyBIkBWfM4BRt2/f/jw8PDz+ypUrmDlzpiT4hQsXpO6O0qOqqgrBwcEYPXo0Ghsb8ebNm1dqtZrdFquHQRY9I1j0BAUFjSsoKPjS1dX1x9u2bcPu3bulRbKJoVYzYCg3mG+wTRYaGoo7d+6gtbX1a41G8wsDANgtsmgUoDSMBGx8SHU/XUGr1calpKSk80f28ih8RkYGtmzZopz03+S56enpyMzMxNq1a3Hw4EE0NTXdGzVqVJJBJkgArJIKi9YXS1+C4FZZWflFcHBw9JkzZzBv3jxJ8IcPH8LPj7WKMmPu3LnIz8/H+fPnER8fj9OnT/8xMTHxK6NawCrFEMmQVvCpcIUNGzZMzszM3GNnZ+eQlJSEvLw8aZFcrBJDcAz9n8A6Ojp2RkdHLygpKWHrjdUgewJslloFANH+ZlLU4wqFhYWrY2Jifs1Ul67A6ECNzZkzp98YeHl54fnz5z05RU1NzZWAgICdAP4lZ4Esh9kVsmo/QGqBiy6Qk5OTe21tbZaHh8dnotdPyfubBS5btgy5ubmYOHEiCgoK4Onpic2bN6/fs2dPqUyALIVZCXI7zaxhbjFk+HBRGYpGKKOCIMTNvJFcQE5gVCgpKaHZmrU43hwbG4uioiJJeBZX/v7+uHfvXkFQUFCGXAQZNkPMIkA+vz8A8P9ZHfbUBwyLnKWlpesjIiISeAP3+y5fvgxnZ2dkZ2cjMTHRJBAY8tLS0tDS0vKe8M3NzQ2urq5rZOFZaYkq0GzzVwIAPkPsBkk1ggChrq7u997e3mxW9Gx98XNYWBiWLl0Kbni4ublJk1tlDx48kGZNTY10PXv2rASUoealBatUjPsUXBRAohVmVvwXWuivBQgQGRWkMllEBYbHkpKSlMjISCk9JCecO3cOd+9KzeIfHGT71atXS5M+/+zZs2ofHx+SHk2e8z8y8zP20/fNYn8lATB2BUYFkR+MyMvLS1iyZMkK8UICwMjw5MkTPH36VLrSzCkwBQ0KCpKKqhkzZkhuw/FN6+16WFjYAZntKThrf0F8fdoPUBoA4QpSt0i2BIJAYtRkZmb+LCYmZoq/v3+oWq02iQl1Ot2bqqqqv+fk5FzVarX3ZYHp75yM+WR9Ck/TNyv0GTP5D5qjiTeIqEAQhDvQGlg58kr3UO/fvz8yJCTE183NzdXZ2dlVo9G4ODg4OHZ2drZ1dHS0tbe3txUXF5dnZWWVVVRUMMaz0UiBOal1fhfC92tjVCkSNAZUOhwhtsnlzVIKT5KkdRAcRg7yhjgsxWeIQ1LUKDXLrI6CUmAx+Z07QIodlFCCBI0NRFiCSJeZLFFwITy/EwABAkOpAIAaFQBQUE6SnDgTQFAE4fWJ9HpbrIkWbtZthgekpBMj8hSfpU0VOY8QAPAFBICTQnJSYGpbfBcnQ/rs89YCQLznve0zsZtkYPrid2EBFEyAQGHFFL6uiNYtRYLfZyLCIoTAYkNVaJ+/i8OSvR2YVFxwS4RBU31E8I44Tmf8f4ZAmPrMPt9nCRLs82IG4h+HABgI1D+mdw5ZwMekjYFYy5AFDATqH9M7B70F/B8BkQp9YNbG2QAAAABJRU5ErkJggg==) 1x) 16 16,auto!important}.relation-graph .rg-move-operator.rg-move-operator-active .rg-move-touchpad{display:flex}.relation-graph.rg-creating-line .rg-connect-source-handle{pointer-events:none;opacity:.5}.rg-background{position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:0;pointer-events:none}.rg-toolbar{user-select:none;pointer-events:all;display:flex;position:absolute;z-index:300;background-color:#fff;color:#333;--rg-toolbar-hover-bg-color: rgba(220, 220, 220, .5);box-shadow:0 1px 3px #0003,0 0 1px #0006;box-sizing:border-box;border-radius:5px;width:fit-content;height:fit-content;place-items:center;justify-content:center;gap:3px;backdrop-filter:blur(5px)}.rg-toolbar .rg-icon{flex-grow:1;width:16px;height:16px;fill:currentColor;overflow:hidden}.rg-toolbar .rg-mb-button svg{margin:auto}.rg-toolbar .rg-mb-button:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-loading-icon{animation:turn 1s linear infinite}@keyframes turn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}to{-webkit-transform:rotate(360deg)}}.rg-toolbar .rg-current-zoom{margin-top:0;font-size:10px;text-align:center;border-radius:3px;cursor:pointer}.rg-toolbar .rg-current-zoom:hover{background-color:var(--rg-toolbar-hover-bg-color)}.rg-toolbar .rg-mb-button{width:35px;height:35px;margin-top:0;opacity:1;cursor:pointer;font-size:18px;box-sizing:border-box;display:flex;align-items:center;justify-items:center;border-radius:3px}.rg-toolbar.rg-toolbar-v{flex-flow:column;padding:10px 3px}.rg-toolbar.rg-toolbar-v .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-toolbar-h{padding:3px 10px}.rg-toolbar.rg-toolbar-h .rg-current-zoom{width:fit-content;padding:0 5px;height:35px;line-height:35px}.rg-toolbar.rg-toolbar-h-right{right:15px}.rg-toolbar.rg-toolbar-h-left{left:15px}.rg-toolbar.rg-toolbar-h-center{left:50%;transform:translate(-50%)}.rg-toolbar.rg-toolbar-v-top{top:15px}.rg-toolbar.rg-toolbar-v-bottom{bottom:15px}.rg-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}.rg-toolbar.rg-xs-toolbar .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar .rg-icon{width:14px;height:14px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v .rg-current-zoom{width:30px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h{padding:3px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-current-zoom{width:35px;height:25px;line-height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h .rg-mb-button{width:25px;height:25px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-right{right:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-left{left:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-h-center{top:50%;transform:translate(-50%)}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-top{top:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-bottom{bottom:10px}.rg-toolbar.rg-xs-toolbar.rg-toolbar-v-center{top:50%;transform:translateY(-50%)}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();"use strict";var At=Object.defineProperty;var Vt=(s,o,e)=>o in s?At(s,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[o]=e;var N=(s,o,e)=>(Vt(s,typeof o!="symbol"?o+"":o,e),e);/*!
2
+ * relation-graph v3.0.1
3
3
  * (c) 2025 WanLian <seeksdream@qq.com>
4
4
  * Released under the MIT License.
5
5
  * Repository: https://github.com/seeksdream/relation-graph
6
- */Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react/jsx-runtime"),k=require("react"),Se=require("react-dom"),Me=i=>i&&typeof i=="object"&&"default"in i?i:{default:i},lt=Me(k),Kt="3.0.0";const it=i=>{try{if("touches"in i&&i.touches||"targetTouches"in i&&i.targetTouches)return!0}catch{}return!1},xt=i=>{if(it(i)){const a=i.touches||i.targetTouches;if(!a)throw new Error("error targetTouches");return{clientX:a[0].clientX,clientY:a[0].clientY}}else return{clientX:i.clientX,clientY:i.clientY}},v=(...i)=>{typeof window<"u"&&window.relationGraphDebug&&console.log("[relation-graph:debug]",...i)},_t=(i,a,t)=>{if(!i)return null;if(i.classList){if(i.classList.contains(a))return i;if(i.classList.contains(t))return null}return _t(i.parentElement,a,t)},ft=async i=>new Promise((a,t)=>{setTimeout(()=>{a()},i)}),rt=i=>typeof i=="string"?Number.parseInt(i):i,Ne=()=>{const i="l",a="o",t="g",e=new Date().getFullYear(),n=[];return e>1&&n.push(i),e>201&&n.push(a),e>1113&&n.push(t),n.join("")},Te=()=>{const i="c",a="o",t="n",e="s",n="o",o="l",s="e",r=new Date().getFullYear(),l=[];return r>1&&l.push(i),r>21&&l.push(a),r>35&&l.push(t),r>55&&l.push(e),r>189&&l.push(n),r>231&&l.push(o),r>1234&&l.push(s),l.join("")},jt=i=>i.replace(/-/g,"").replace(/\*/g,"-"),te=i=>{const a=Te(),t=Ne(),e="r-e-l-a-t-i-o-n*g-r-a-p-h",n="h-t-t-p-s-:-/-/-g-i-t-h-u-b-.-c-o-m-/-s-e-e-k-s-d-r-e-a-m-/-r-e-l-a-t-i-o-n-*-g-r-a-p-h";window&&window[a]&&window[a][t](`%c ${jt(e)} %c Version v${Kt}(${i}) %c More info: ${jt(n)} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#fff ; padding: 1px; border-radius: 0 3px 3px 0; color: #41b883","background:transparent")},Ee=(i,a)=>{typeof a=="string"&&(a=[a]);for(const e of a)if(i.classList.contains(e))return!0;let t=i.parentElement;for(;t;){for(const e of a)if(t.classList.contains(e))return!0;t=t.parentElement}return!1},vt=i=>{const a=i.target;return Ee(a,"rel-text-editing")?!0:["input","textarea"].includes(document.activeElement.tagName.toLowerCase())},H=k.createContext(null),gt=k.createContext(null),q=k.createContext(0),De=()=>{const i=k.useContext(H),a=k.useContext(gt),t=i.options,[e,n]=k.useState(!1),o=()=>{n(!e)},s=()=>{i.printOptions()},r=()=>{i.getGraphJsonData()},l=()=>{i.enableDebugLog(!t.debug),v("debugLog:",t.debug),a()};return C.jsxs("div",{children:[C.jsx("div",{className:"rg-setting-panel-button",onClick:()=>{o()},children:"Debug"}),e&&C.jsxs("div",{className:"rg-setting-panel",children:[C.jsx("div",{className:"c-debug-tools-row",children:C.jsx("button",{onClick:()=>{s()},children:"print options in console"})}),C.jsx("div",{className:"c-debug-tools-row",children:C.jsx("button",{onClick:()=>{r()},children:"print json data in console"})}),C.jsxs("div",{className:"c-debug-tools-row",children:["debug log status: ",t.debug?"true":"false",C.jsxs("button",{onClick:()=>{l()},children:[t.debug?"disable":"enable"," debug log"]})]})]})]})},A={getDescendantNodes(i,a=[]){return i.lot&&i.lot.childs&&i.lot.childs.forEach(t=>{a.push(t),A.getDescendantNodes(t,a)}),a},conductStrengthToParents(i){i.lot.parent&&Math.abs(i.lot.level)-1===Math.abs(i.lot.parent.lot.level)&&(i.lot.parent.lot.strengthWithChilds+=1,A.conductStrengthToParents(i.lot.parent))},analysisDataTree(i,a,t=1){const e=[];let n=0;i.forEach(o=>{(o.lot.level===0||t===(o.lot.level<0?-1:1))&&(o.lot.childs_size>0&&o.lot.childs.forEach(s=>{e.push(s)}),o.lot.parent&&n<o.lot.parent.lot.strengthWithChilds_from&&(n=o.lot.parent.lot.strengthWithChilds_from),o.lot.strengthWithChilds_from=n,n+=o.lot.strengthWithChilds)}),e.length>0&&A.analysisDataTree(e,a+(t<0?-1:1),t)},conductStrengthToParents4Folder(i){i.lot.parent&&(i.lot.parent.lot.strengthWithChilds+=1,A.conductStrengthToParents4Folder(i.lot.parent))},analysisDataFolder(i,a,t){const e=[];let n=0,o;i.forEach(s=>{(s.lot.level===0||t===(s.lot.level<0?-1:1))&&(s.lot.childs_size>0&&s.lot.childs.forEach(r=>{e.push(r)}),s.lot.parent&&(o?o!==s.lot.parent&&(o=s.lot.parent,n=o.lot.strengthWithChilds_from):(o=s.lot.parent,n=o.lot.strengthWithChilds_from)),s.lot.strengthWithChilds_from=1+n,n+=s.lot.strengthWithChilds)}),e.length>0&&A.analysisDataFolder(e,a+t,t)},isVisibleNode(i,a=0){return typeof a!="number"&&(a=0),a>18?!0:i.hidden?!1:i.lot&&i.lot.parent?i.lot.parent.expanded===!1?!1:A.isVisibleNode(i.lot.parent,a+1):!0},isAllowShowNode(i,a=0){return A.isVisibleNode(i,a=0)},getNodeWidth(i){var a;return((a=i.el)==null?void 0:a.offsetWidth)||i.width||50},getNodeHeight(i){var a;return((a=i.el)==null?void 0:a.offsetHeight)||i.height||50},getNodeXByLotX(i,a){const t=a.lot.x||0;return i.alignItemsX==="end"?t-A.getNodeWidth(a):i.alignItemsX==="start"?t:t-A.getNodeWidth(a)/2},getNodeYByLotY(i,a){const t=a.lot.y||0;return i.alignItemsY==="end"?t-A.getNodeHeight(a):i.alignItemsY==="start"?t:t-A.getNodeHeight(a)/2},getNodeLotXY(i,a){let t=a.x||0,e=a.y||0;return i.alignItemsX==="end"?t=t+A.getNodeWidth(a):i.alignItemsX==="start"||(t=t+A.getNodeWidth(a)/2),i.alignItemsY==="end"?e=e+A.getNodeHeight(a):i.alignItemsY==="start"||(e=e+A.getNodeHeight(a)/2),{x:t,y:e}},isRectangleOverlap(i,a){const t=i.x,e=a.x,n=i.el.offsetWidth,o=a.el.offsetWidth,s=i.y,r=a.y,l=i.el.offsetHeight,c=a.el.offsetHeight;return!(e>=t+n||e+o<=t||r>=s+l||r+c<=s)},isXOverlap(i,a,t,e){return!(a>=i+t||a+e<=i)},isYOverlap(i,a,t,e){return!(a>=i+t||a+e<=i)},shapesOverlap(i,a,t=1,e=1){return this.isRectangleOverlap(i,a)},getNoOverlapLimitedPosition(i,a,t,e){const n=i.x,o=i.y,s=a,r=e.x,l=i.el.offsetWidth,c=e.el.offsetWidth,h=t,d=e.y,f=i.el.offsetHeight,p=e.el.offsetHeight;let u=i.x,g=i.y;const x=this.isXOverlap(n,r,l,c),y=this.isYOverlap(o,d,f,p);return x?h<d?(u=a,g=d-f):h>d&&(u=a,g=d+p):y&&(s<r?(u=r-l,g=t):s>r&&(u=r+c,g=t)),{x:u,y:g}},flatNodeData(i,a,t,e){i.forEach(n=>{t.push(n),a&&e.push({from:a.id,to:n.id});const o=n.children||n.childs;o&&o.length>0&&this.flatNodeData(o,n,t,e)})}},ee=({expandButtonClass:i,expandOrCollapseNode:a,expandHolderPosition:t})=>C.jsx("div",{className:`rg-node-expand-holder c-expand-positon-${t}`,children:C.jsx("span",{className:i,onClickCapture:e=>{a(e)},onTouchEnd:e=>{a(e)}})}),ne=({nodeProps:i,nodeSlot:a,expandHolderSlot:t})=>{const e=k.useContext(H);k.useContext(gt);const n=k.useRef();k.useEffect(()=>(e.addNodeResizeListener(n.current,i),()=>{n.current&&e.removeNodeResizeListener(n.current)}),[]);const o=async y=>{await e.expandOrCollapseNode(i,y.nativeEvent)},s=y=>{y.type==="mousedown"&&y.button!==0||(y.stopPropagation(),e.onNodeDragStart(i,y.nativeEvent))},r=y=>{y.stopPropagation(),e.onNodeClick(i,y.nativeEvent)},l=e.options,c=()=>{if(i.width===0)return;const y=i.width||0;if(!!y)return y+"px"},h=()=>{if(i.height===0)return;const y=i.height||0;if(!!y)return y+"px"},d=i.borderWidth===void 0?void 0:i.borderWidth+"px",f=i.borderColor,p=i.opacity,u=A.isVisibleNode(i);let g=l.defaultExpandHolderPosition&&l.defaultExpandHolderPosition!=="hide"&&i.lot.childs&&i.lot.childs.length>0;i.expandHolderPosition&&(g=i.expandHolderPosition!=="hide");const x=i.expanded===!1?"c-expanded":"c-collapsed";return C.jsxs("div",{ref:n,style:{display:u?void 0:"none","--rg-node-z-index":i.zIndex?i.zIndex:void 0,pointerEvents:p===0?"none":void 0,transform:`translate(${i.x}px, ${i.y}px)`,"--rg-node-color":i.color,"--rg-node-font-color":i.fontColor,"--rg-node-font-size":i.fontSize?i.fontSize+"px":void 0,"--rg-node-border-width":d,"--rg-node-border-radius":i.borderRadius&&i.borderRadius+"px","--rg-node-border-color":f,"--rg-node-opacity":i.opacity===void 0?void 0:i.opacity},className:["rg-node-peel",i.selected&&"rg-node-selected",i.dragging&&"rg-node-dragging",i.id===l.checkedNodeId&&"rg-node-peel-checked",i.className,(i.disablePointEvent||i.opacity===0)&&"rg-node-peel-disable-events"].filter(Boolean).join(" "),"data-id":i.id,children:[g&&(t?t({node:i,expandButtonClass:x,expandOrCollapseNode:y=>{o(y)},expandHolderPosition:i.expandHolderPosition||l.defaultExpandHolderPosition,color:l.defaultExpandHolderColor||i.color||l.defaultNodeColor}):C.jsx(ee,{node:i,expandButtonClass:x,expandOrCollapseNode:y=>{o(y)},expandHolderPosition:i.expandHolderPosition||l.defaultExpandHolderPosition})),C.jsx("div",{className:`rg-node rg-node-shape-${i.nodeShape===void 0?1:i.nodeShape} rg-node-type-${i.type} ${i.id===l.checkedNodeId?"rg-node-checked":""}`,style:{width:c(),height:h()},onClick:y=>{r(y)},onMouseDown:y=>{s(y)},onTouchStart:y=>{s(y)},children:a?a({node:i,graphInstance:e}):C.jsx("div",{className:"rg-node-text",children:C.jsx("span",{children:i.text})})})]})},Yt=({forElementLines:i,svgDefs:a})=>{const e=k.useContext(H).options;return C.jsxs("defs",{children:[C.jsx("marker",{id:`${e.instanceId}-arrow-default`,markerWidth:e.defaultLineMarker.markerWidth,markerHeight:e.defaultLineMarker.markerHeight,refX:e.defaultLineMarker.refX,refY:e.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:e.defaultLineMarker.viewBox,children:C.jsx("path",{style:{fill:"context-stroke"},d:e.defaultLineMarker.data})}),C.jsx("marker",{id:`${e.instanceId}-start-arrow-default`,markerWidth:e.defaultLineMarker.markerWidth,markerHeight:e.defaultLineMarker.markerHeight,refX:e.defaultLineMarker.refX,refY:e.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:e.defaultLineMarker.viewBox,children:C.jsx("path",{style:{fill:"context-stroke"},d:e.defaultLineMarker.data})}),a]})},oe=({children:i,lineConfig:a})=>{const t=k.useContext(H);if(!t)return null;const e=t.getLineTextContainer(a==null?void 0:a.line);if(!e)return null;const n=a.line,o=t.options,s=n.id===o.checkedLineId,r=n.selected;return Se.createPortal(C.jsx("div",{className:["rg-line-peel",n.className,s&&"rg-line-peel-checked",n.disablePointEvent&&"rg-line-peel-disable-events",r&&"rg-line-peel-selected"].filter(Boolean).join(" "),"data-id":n.id+"-text",style:{"--rg-line-color":n.color,"--rg-line-fontsize":a.line.fontSize?`${a.line.fontSize}px`:void 0,"--rg-line-opacity":n.opacity,"--rg-line-fontcolor":n.fontColor,...n.cssVars||{}},children:i}),e)},ie=({lineConfig:i,linePathInfo:a,onLineClick:t})=>{const e=k.useContext(H),n=i.line,o=e.options,s=n.id===o.checkedLineId,r=n.selected,l=e.getArrowMarkerId(n,!0),c=e.getArrowMarkerId(n,!1),h=n.lineWidth?n.lineWidth+"px":void 0,f=n.useTextPath||o.lineUseTextPath?e.generateLineTextStyle4TextPath(i):null,p=o.instanceId+"-"+n.id;return C.jsxs("g",{className:["rg-line-peel",n.className,s&&"rg-line-peel-checked",r&&"rg-line-peel-selected",n.disablePointEvent&&"rg-line-peel-disable-events"].filter(Boolean).join(" "),"data-id":n.id,style:{"--rg-line-width":h,"--rg-line-color":n.color,"--rg-line-opacity":n.opacity,"--rg-line-fontcolor":n.fontColor,"--rg-line-marker-end":c,"--rg-line-marker-start":l,...n.cssVars||{}},children:[C.jsx("path",{d:a.pathData,className:"rg-line-bg",onTouchStart:t,onClick:t}),C.jsx("path",{id:p,d:a.pathData,className:["rg-line",n.dashType?"rg-line-dashtype-"+n.dashType:void 0,n.animation?"rg-line-anm-"+n.animation:void 0].filter(Boolean).join(" ")}),f&&o.canvasZoom>40&&C.jsx("g",{children:C.jsx("text",{className:"rg-line-text rg-line-text-on-path",dy:"-6px",onTouchStart:t,onClick:t,children:C.jsx("textPath",{xlinkHref:`#${p}`,startOffset:f.onPathStartOffset,textAnchor:f.textAnchor,method:"align",spacing:"auto",children:f.text})})})]})},se=({lineConfig:i})=>{const a=k.useContext(H),t=k.useMemo(()=>a.generateLinePath(i),[i]),e=s=>{console.log("onLineClick",i.line),a.onLineClick(i.line,null,s.nativeEvent)},n=!(i.line.useTextPath||a.options.lineUseTextPath)&&a.options.canvasZoom>40,o=a.generateLineTextStyle(i,t);return C.jsxs(C.Fragment,{children:[C.jsx(ie,{lineConfig:i,linePathInfo:t,onLineClick:e}),n&&C.jsx(oe,{lineConfig:i,linePathInfo:t,children:C.jsx("div",{className:"rg-line-label",style:{...o.cssStyles},onTouchStart:e,onClick:e,children:o.text})})]})},Wt=({line:i,lineSlot:a})=>{const t=k.useContext(H);k.useContext(gt);const e=i.isFakeLine?t.generateFakeLineConfig(i):t.generateLineConfig(i);return e&&C.jsx(C.Fragment,{children:a?a({config:e}):C.jsx(se,{lineConfig:e})})},ae=i=>{const a=k.useContext(H);k.useEffect(()=>{},[]);const t=a.options,e=a.getShouldRenderNodes(),n=a.getShouldRenderLines(),o=a.getShouldRenderFakeLines();return C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"rg-lines-container rg-lines-container-normal-lines",children:[C.jsxs("svg",{className:"rg-lines-svg",style:{width:`${t.canvasSize.width}px`,height:`${t.canvasSize.height}px`},xmlns:"http://www.w3.org/2000/svg",children:[C.jsx(Yt,{svgDefs:i.svgDefs}),!t.showEasyView&&n.map(s=>s.hidden!==!0&&C.jsx(Wt,{line:s,lineSlot:i.lineSlot},s.id))]}),C.jsx("div",{className:"rg-linetext-container"})]}),C.jsx("div",{className:"rg-nodes-container",children:e.map(s=>!t.showEasyView&&C.jsx(ne,{nodeProps:s,nodeSlot:i.nodeSlot,expandHolderSlot:i.expandHolderSlot},s.id))}),C.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[C.jsx("div",{className:"rg-linetext-container"}),C.jsxs("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx(Yt,{forElementLines:!0}),!t.showEasyView&&o.map(s=>s.hidden!==!0&&C.jsx(Wt,{line:s,lineSlot:i.lineSlot},s.id)),t.creatingLinePlot&&t.newLinkTemplate.fromNode&&(i.lineSlot?i.lineSlot({lineConfig:a.generateCreatingLineConfig()}):C.jsx(se,{lineConfig:a.generateCreatingLineConfig()}))]})]})]})},ke=i=>{const a=k.useContext(H),t=a.options,e=k.useRef();return k.useEffect(()=>{v("[RGEasyView mounted]"),a.setEasyViewCanvas(e.current)},[]),C.jsx("div",{className:`rg-easy-view ${t.showEasyView?"rg-easy-view-active":""}`,children:C.jsx("canvas",{ref:e})})},Re=i=>{const a=k.useContext(H),t=k.useRef(),e=k.useRef(),n={width:`${a.options.canvasSize.width}px`,height:`${a.options.canvasSize.height}px`,backgroundColor:"transparent",transform:`translate(${a.options.canvasOffset.x}px, ${a.options.canvasOffset.y}px) scale(${a.options.canvasZoom/100},${a.options.canvasZoom/100})`};k.useEffect(()=>{v("[RGCanvas mounted]"),a.setCanvasDom(t.current)},[]);const o=r=>{r.type==="mousedown"&&r.button!==0||a.onCanvasDragStart(r.nativeEvent)},s=r=>{r.preventDefault(),a.onContextmenu(r.nativeEvent)};return C.jsxs("div",{style:{"--bg-background-color":a.options.backgroundColor,"--rg-node-color":a.options.defaultNodeColor,"--rg-line-color":a.options.defaultLineColor},ref:e,className:["rg-map",a.options.canvasOpacity===1?"rg-map-ready":""].join(" "),onContextMenu:r=>{s(r)},onMouseDown:r=>{o(r)},onTouchStart:r=>{o(r)},children:[C.jsx(ke,{}),C.jsx("div",{style:n,className:"rg-map-canvas rg-canvas-behind",children:C.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-behind",children:i.canvasPlugSlot&&(typeof i.canvasPlugSlot=="function"?C.jsx(i.canvasPlugSlot,{}):i.canvasPlugSlot)})}),C.jsx("div",{ref:t,style:n,className:"rg-map-canvas",children:C.jsx(ae,{svgDefs:i.svgDefs,nodeSlot:i.nodeSlot,lineSlot:i.lineSlot,expandHolderSlot:i.expandHolderSlot})}),C.jsx("div",{style:n,className:"rg-map-canvas rg-canvas-above",children:C.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-above",children:i.canvasPlugAboveSlot})})]})},Pe=()=>{const i=k.useContext(H),a=(i==null?void 0:i.options.canvasMoveMode)||!1,t=e=>{i&&i.startMoveCanvas(e.nativeEvent,!0)};return C.jsx("div",{className:`rg-move-operator ${a?"rg-move-operator-active":""}`,children:C.jsx("div",{className:"rg-move-touchpad",onMouseDown:t,onTouchStart:t})})},Ie={"icon-quanping":{data:`
7
- <path d="M298.666667 597.333333H213.333333v213.333334h213.333334v-85.333334H298.666667v-128z m-85.333334-170.666666h85.333334V298.666667h128V213.333333H213.333333v213.333334z m512 298.666666h-128v85.333334h213.333334v-213.333334h-85.333334v128zM597.333333 213.333333v85.333334h128v128h85.333334V213.333333h-213.333334z"/>
8
- `},"icon-fangda":{data:`
9
- <path d="M768 448a320 320 0 1 0-320 320 320 320 0 0 0 320-320z m64 0A384 384 0 1 1 448 64a384 384 0 0 1 384 384z"></path>
10
- <path d="M681.28 726.72a32 32 0 0 1 45.44-45.44l160 160a32 32 0 0 1-45.44 45.44zM320 480a32 32 0 0 1 0-64h256a32 32 0 0 1 0 64z"></path>
11
- <path d="M480 576a32 32 0 0 1-64 0V320a32 32 0 0 1 64 0z"></path>
6
+ */Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("react/jsx-runtime"),I=require("react"),Xt=require("react-dom"),zt=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},pe=zt(I),et="3.0.1",ce=s=>{try{if("touches"in s&&s.touches||"targetTouches"in s&&s.targetTouches)return!0}catch{}return!1},Ce=s=>{if(ce(s)){const o=s.touches||s.targetTouches;if(!o)throw new Error("error targetTouches");return{clientX:o[0].clientX,clientY:o[0].clientY}}else return{clientX:s.clientX,clientY:s.clientY}},C=(...s)=>{typeof window<"u"&&window.relationGraphDebug&&console.log("[relation-graph:debug]",...s)},Le=(s,o,e)=>{if(!s)return null;if(s.classList){if(s.classList.contains(o))return s;if(s.classList.contains(e))return null}let t=null;if(s.assignedSlot?t=s.assignedSlot:t=s.parentElement,!t){const n=s.parentNode;n instanceof ShadowRoot&&(t=n.host)}return Le(t,o,e)},Xe=s=>new Promise(o=>setTimeout(o,s)),Bt=()=>{const s="l",o="o",e="g",t=new Date().getFullYear(),n=[];return t>1&&n.push(s),t>201&&n.push(o),t>1113&&n.push(e),n.join("")},Gt=()=>{const s="c",o="o",e="n",t="s",n="o",i="l",a="e",r=new Date().getFullYear(),l=[];return r>1&&l.push(s),r>21&&l.push(o),r>35&&l.push(e),r>55&&l.push(t),r>189&&l.push(n),r>231&&l.push(i),r>1234&&l.push(a),l.join("")},Ue=s=>s.replace(/-/g,"").replace(/\*/g,"-"),tt=s=>{const o=Gt(),e=Bt(),t="r-e-l-a-t-i-o-n*g-r-a-p-h",n="h-t-t-p-s-:-/-/-g-i-t-h-u-b-.-c-o-m-/-s-e-e-k-s-d-r-e-a-m-/-r-e-l-a-t-i-o-n-*-g-r-a-p-h";window&&window[o]&&window[o][e](`%c ${Ue(t)} %c Version v${et}(${s}) %c More info: ${Ue(n)} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#fff ; padding: 1px; border-radius: 0 3px 3px 0; color: #41b883","background:transparent")},Ft=(s,o)=>{typeof o=="string"&&(o=[o]);for(const t of o)if(s.classList.contains(t))return!0;let e=s.parentElement;for(;e;){for(const t of o)if(e.classList.contains(t))return!0;e=e.parentElement}return!1},we=s=>{const o=s.target;return Ft(o,"rel-text-editing")?!0:["input","textarea"].includes(document.activeElement.tagName.toLowerCase())},Be=(s=5)=>{const o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let e="";const t=s>30?30:s;for(let n=0;n<t;n++)e+=o[Math.floor(Math.random()*o.length)];return e},nt=s=>({onReady:s.onReady,onNodeClick:s.onNodeClick,onNodeExpand:s.onNodeExpand,onNodeCollapse:s.onNodeCollapse,onLineClick:s.onLineClick,onNodeDragStart:s.onNodeDragStart,onNodeDragEnd:s.onNodeDragEnd,onNodeDragging:s.onNodeDragging,onCanvasDragEnd:s.onCanvasDragEnd,onCanvasDragging:s.onCanvasDragging,onContextmenu:s.onContextmenu,onFullscreen:s.onFullscreen,onCanvasClick:s.onCanvasClick,onCanvasSelectionEnd:s.onCanvasSelectionEnd,beforeZoomStart:s.beforeZoomStart,onZoomEnd:s.onZoomEnd,onViewResize:s.onViewResize,onResizeStart:s.onResizeStart,beforeNodeResize:s.beforeNodeResize,onResizeEnd:s.onResizeEnd,onLineVertexDropped:s.onLineVertexDropped,beforeCreateLine:s.beforeCreateLine,onLineBeCreated:s.onLineBeCreated,beforeAddNodes:s.beforeAddNodes,beforeAddLines:s.beforeAddLines,onKeyboardDown:s.onKeyboardDown,onKeyboardUp:s.onKeyboardUp,onCanvasDragStart:s.onCanvasDragStart,onForceLayoutFinish:s.onForceLayoutFinish,beforeScrollStart:s.beforeScrollStart});var B=(s=>(s.Node="node",s.NodePoint="NodePoint",s.HTMLElementId="HTMLElementId",s.CanvasPoint="CanvasPoint",s.ViewPoint="ViewPoint",s))(B||{}),U=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(U||{}),_e=(s=>(s[s.circle=0]="circle",s[s.rect=1]="rect",s))(_e||{}),F=(s=>(s[s.StandardStraight=1]="StandardStraight",s[s.StandardCurve=6]="StandardCurve",s[s.Curve2=2]="Curve2",s[s.Curve3=3]="Curve3",s[s.Curve5=5]="Curve5",s[s.Curve7=7]="Curve7",s[s.Curve8=8]="Curve8",s[s.SimpleOrthogonal=4]="SimpleOrthogonal",s[s.StandardOrthogonal=44]="StandardOrthogonal",s[s.HardOrthogonal=49]="HardOrthogonal",s))(F||{}),it=(s=>(s.Left="left",s.Top="top",s.Right="right",s.Bottom="bottom",s))(it||{}),A=(s=>(s.onReady="onReady",s.onNodeClick="onNodeClick",s.onNodeExpand="onNodeExpand",s.onNodeCollapse="onNodeCollapse",s.onLineClick="onLineClick",s.onNodeDragStart="onNodeDragStart",s.onNodeDragEnd="onNodeDragEnd",s.onNodeDragging="onNodeDragging",s.onCanvasDragEnd="onCanvasDragEnd",s.onCanvasDragging="onCanvasDragging",s.onContextmenu="onContextmenu",s.onFullscreen="onFullscreen",s.onCanvasClick="onCanvasClick",s.onCanvasSelectionEnd="onCanvasSelectionEnd",s.beforeZoomStart="beforeZoomStart",s.onZoomEnd="onZoomEnd",s.onViewResize="onViewResize",s.onResizeStart="onResizeStart",s.beforeNodeResize="beforeNodeResize",s.onResizeEnd="onResizeEnd",s.onLineVertexDropped="onLineVertexDropped",s.beforeCreateLine="beforeCreateLine",s.onLineBeCreated="onLineBeCreated",s.beforeAddNodes="beforeAddNodes",s.beforeAddLines="beforeAddLines",s.onKeyboardDown="onKeyboardDown",s.onKeyboardUp="onKeyboardUp",s.onCanvasDragStart="onCanvasDragStart",s.onForceLayoutFinish="onForceLayoutFinish",s.beforeScrollStart="beforeScrollStart",s))(A||{});const he=(s,o)=>{if(s.from===void 0)throw console.log("error,line must has option[from](nodeId):",s),new Error("error,line must has option[from]:");if(s.to===void 0)throw console.log("error,line must has option[to](nodeId):",s),new Error("error,line must has option[to]:");if(typeof s.from!="string")throw console.log("error line from, must be string(nodeId):",s),new TypeError("error line from, must be string:");if(typeof s.to!="string")throw console.log("error line to, must be string(nodeId):",s),new TypeError("error line to, must be string:");return s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),s.placeText!==void 0&&(s.onPathStartOffset=s.placeText,console.warn("[relation-graph Warning] line option[placeText] is deprecated, please use [onPathStartOffset] instead.")),{id:s.id,from:s.from,to:s.to,type:s.type!==void 0?s.type:"line",isFakeLine:s.isFakeLine!==void 0?s.isFakeLine:!1,fromType:s.fromType!==void 0?s.fromType:s.isFakeLine?B.CanvasPoint:B.Node,toType:s.toType!==void 0?s.toType:s.isFakeLine?B.CanvasPoint:B.Node,selected:!1,text:s.text!==void 0?s.text:"",textOffset_x:s.textOffset_x!==void 0?s.textOffset_x:void 0,textOffset_y:s.textOffset_y!==void 0?s.textOffset_y:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,lineWidth:s.lineWidth!==void 0?s.lineWidth:void 0,lineShape:s.lineShape||o.defaultLineShape||1,className:s.className!==void 0?s.className:void 0,animation:s.animation!==void 0?s.animation:0,dashType:s.dashType!==void 0?s.dashType:0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:!1,showStartArrow:s.showStartArrow!==void 0?s.showStartArrow:!1,showEndArrow:s.showEndArrow!==void 0?s.showEndArrow:!0,useTextPath:s.useTextPath!==void 0?s.useTextPath:void 0,onPathStartOffset:s.onPathStartOffset!==void 0?s.onPathStartOffset:void 0,startMarkerId:s.startMarkerId||"",endMarkerId:s.endMarkerId||"",textAnchor:s.textAnchor!==void 0?s.textAnchor:void 0,junctionOffset:s.junctionOffset,fromJunctionPoint:s.fromJunctionPoint,toJunctionPoint:s.toJunctionPoint,fromJuctionPointOffsetX:s.fromJuctionPointOffsetX||0,fromJuctionPointOffsetY:s.fromJuctionPointOffsetY||0,toJuctionPointOffsetX:s.toJuctionPointOffsetX||0,toJuctionPointOffsetY:s.toJuctionPointOffsetY||0,lineRadius:s.lineRadius,force_elastic:s.force_elastic,polyLineStartDistance:s.polyLineStartDistance,ctrlPointsFor49:s.ctrlPointsFor49,ctrlPointsFor44:s.ctrlPointsFor44,ctrlPoints:s.ctrlPoints,lineDirection:s.lineDirection!==void 0?s.lineDirection:void 0,forDisplayOnly:s.forDisplayOnly||s.from===s.to,hidden:s.hidden!==void 0?s.hidden:!1,cssVars:s.cssVars!==void 0?s.cssVars:void 0,data:s.data!==void 0?s.data:{}}},Yt=["arrow","isReverse","selected","shouldRender","rgCalcedVisibility"],Re=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!Yt.includes(e)){const t=s[e];t!==void 0&&(e==="isFakeLine"&&t===!1||e==="fromType"&&t===B.Node||e==="toType"&&t===B.Node||e==="animation"&&t===0||e==="text"&&t===""||e==="dashType"&&t===0||e==="disablePointEvent"&&t===!1||e==="showStartArrow"&&t===!1||e==="showEndArrow"&&t===!0||e==="startMarkerId"&&t===""||e==="endMarkerId"&&t===""||e==="forDisplayOnly"&&t===!1||e==="fromJuctionPointOffsetX"&&t===0||e==="fromJuctionPointOffsetY"&&t===0||e==="toJuctionPointOffsetX"&&t===0||e==="toJuctionPointOffsetY"&&t===0||e==="opacity"&&t===1||e==="hidden"&&t===!1||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=s[e]))}}),o},Ge=s=>{if(!!s)return Re(s.line)},Ht={json2Line:he,transLinkToJson:Ge},jt=Object.freeze(Object.defineProperty({__proto__:null,json2Line:he,transLineToJson:Re,transLinkToJson:Ge,default:Ht},Symbol.toStringTag,{value:"Module"})),z={getDescendantNodes(s,o=[]){return s.lot&&s.lot.childs&&s.lot.childs.forEach(e=>{o.push(e),z.getDescendantNodes(e,o)}),o},isVisibleNode(s,o=0){return typeof o!="number"&&(o=0),o>18?!0:s.hidden?!1:s.lot&&s.lot.parent?s.lot.parent.expanded===!1?!1:z.isVisibleNode(s.lot.parent,o+1):!0},isAllowShowNode(s,o=0){return z.isVisibleNode(s,o=0)},getNodeWidth(s){return s.el_W||s.width||50},getNodeHeight(s){return s.el_H||s.height||50},getNodeXByLotX(s,o){const e=o.lot.x||0;return s.alignItemsX==="end"?e-z.getNodeWidth(o):s.alignItemsX==="start"?e:e-z.getNodeWidth(o)/2},getNodeYByLotY(s,o){const e=o.lot.y||0;return s.alignItemsY==="end"?e-z.getNodeHeight(o):s.alignItemsY==="start"?e:e-z.getNodeHeight(o)/2},getNodeLotXY(s,o){let e=o.x||0,t=o.y||0;return s.alignItemsX==="end"?e=e+z.getNodeWidth(o):s.alignItemsX==="start"||(e=e+z.getNodeWidth(o)/2),s.alignItemsY==="end"?t=t+z.getNodeHeight(o):s.alignItemsY==="start"||(t=t+z.getNodeHeight(o)/2),{x:e,y:t}},isRectangleOverlap(s,o){const e=s.x,t=o.x,n=s.el_W,i=o.el_W,a=s.y,r=o.y,l=s.el_H,c=o.el_H;return!(t>=e+n||t+i<=e||r>=a+l||r+c<=a)},isXOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},isYOverlap(s,o,e,t){return!(o>=s+e||o+t<=s)},shapesOverlap(s,o,e=1,t=1){return this.isRectangleOverlap(s,o)},getNoOverlapLimitedPosition(s,o,e,t){const n=s.x,i=s.y,a=o,r=t.x,l=s.el_W,c=t.el_W,d=e,h=t.y,f=s.el_H,y=t.el_H;let u=s.x,g=s.y;const m=this.isXOverlap(n,r,l,c),p=this.isYOverlap(i,h,f,y);return m?d<h?(u=o,g=h-f):d>h&&(u=o,g=h+y):p&&(a<r?(u=r-l,g=e):a>r&&(u=r+c,g=e)),{x:u,y:g}},flatNodeData(s,o,e,t){s.forEach(n=>{e.push(n),o&&t.push({from:o.id,to:n.id});const i=n.children||n.childs;i&&i.length>0&&this.flatNodeData(i,n,e,t)})}},Ne=(s,o)=>s||s===0?s:o,Fe={id:"rg-newNodeTemplate",x:0,y:0,text:""},be=(s,o)=>{if(s.id===void 0)throw console.log("node must has id:",s),new Error("node must has option[id]:");s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead."));const e=s.width||s.width===0?s.width:o==null?void 0:o.defaultNodeWidth,t=s.height||s.height===0?s.height:o==null?void 0:o.defaultNodeHeight,n={id:s.id,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"node",targetType:s.targetType!==void 0?s.targetType:B.Node,expanded:s.expanded!==void 0?s.expanded:!0,selected:s.selected!==void 0?s.selected:!1,className:s.className!==void 0?s.className:"",nodeShape:Ne(s.nodeShape,o==null?void 0:o.defaultNodeShape),borderWidth:s.borderWidth!==void 0?s.borderWidth:void 0,borderRadius:s.borderRadius!==void 0?s.borderRadius:void 0,borderColor:s.borderColor!==void 0?s.borderColor:void 0,fontColor:s.fontColor!==void 0?s.fontColor:void 0,fontSize:s.fontSize!==void 0?s.fontSize:void 0,color:s.color!==void 0?s.color:void 0,opacity:s.opacity!==void 0?s.opacity:void 0,fixed:s.fixed!==void 0?s.fixed:!1,width:e,height:t,force_weight:s.force_weight,x:s.x!==void 0?s.x:0,y:s.y!==void 0?s.y:0,expandHolderPosition:s.expandHolderPosition!==void 0?s.expandHolderPosition:void 0,disablePointEvent:s.disablePointEvent!==void 0?s.disablePointEvent:void 0,disableDrag:s.disableDrag!==void 0?s.disableDrag:!1,hidden:s.hidden!==void 0?s.hidden:!1,rgCalcedVisibility:!0,rgShouldRender:!0,rgChildrenSize:0,zIndex:s.zIndex||0,el_W:s.el_W||e||50,el_H:s.el_H||t||50,data:s.data!==void 0?s.data:{}};return n.lot={childs:[],parent:void 0,eached:!1,strength:0},n.width&&(n.el_W=n.width),n.height&&(n.el_H=n.height),n},Wt=["Fx","Fy","appended","dragging","el","el_W","el_H","targetFrom","targetNodes","targetTo","lot","seeks_id","shouldRender","rgCalcedVisibility","rgShouldRender","rgChildrenSize","origin_x","origin_y","selected"],Te=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!Wt.includes(e)){const t=s[e];t!==void 0&&(e==="offset_x"&&t===0||e==="nodeShape"&&t===1||e==="offset_y"&&t===0||e==="zIndex"&&t===0||e==="width"&&!t||e==="height"&&!t||e==="fixed"&&t===!1||e==="className"&&t===""||e==="hidden"&&t===!1||e==="disableDrag"&&t===!1||e==="expanded"&&t===!0||e==="opacity"&&t===1||e==="type"&&t==="node"||e==="targetType"&&t===B.Node||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=t))}}),o},$t={json2Node:be,transNodeToJson:Te},Ut=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:Fe,json2Node:be,transNodeToJson:Te,default:$t},Symbol.toStringTag,{value:"Module"})),Oe=(s={})=>{const o={definitelyNoDataProviderNeeded:!1,instanceId:"",debug:!0,graphLoading:!1,graphLoadingText:"",showToolBar:!0,backgroundColor:"transparent",checkedItemBackgroundColor:void 0,selectionMode:!1,disableWheelEvent:!1,wheelEventAction:"zoom",dragEventAction:"move",fullscreenElementXPath:"",disableDragNode:!1,disableDragLine:!0,canvasMoveMode:!1,disableNodePointEvent:!1,disableLinePointEvent:!1,enableNodeXYAnimation:!1,enableCanvasTransformAnimation:!1,reLayoutWhenExpandedOrCollapsed:!1,defaultExpandHolderPosition:"hide",toolBarDirection:"v",toolBarPositionH:"right",toolBarPositionV:"center",defaultNodeColor:"#ffffff",defaultNodeBorderColor:"#666666",defaultNodeBorderWidth:1,defaultNodeBorderRadius:3,defaultNodeShape:_e.rect,defaultNodeWidth:void 0,defaultNodeHeight:void 0,defaultLineColor:"#cccccc",defaultLineWidth:2,defaultLineShape:F.StandardStraight,defaultLineTextOffset_x:void 0,defaultLineTextOffset_y:void 0,defaultJunctionPoint:void 0,defaultLineJunctionOffset:3,defaultPolyLineRadius:5,placeOtherGroup:!0,lineUseTextPath:!1,lineTextMaxLength:66,multiLineDistance:50,defaultLineMarker:{viewBox:"0 0 12 12",markerWidth:20,markerHeight:20,refX:3,refY:3,data:"M 0 0, V 6, L 4 3, Z"},viewSize:{width:300,height:300},canvasSize:{width:300,height:300},canvasOffset:{x:25,y:27},fullscreen:!1,checkedNodeId:"",checkedLineId:"",draggingNodeId:"",layout:{layoutName:"center"},canvasZoom:100,mouseWheelSpeed:10,minCanvasZoom:5,maxCanvasZoom:500,showEasyView:!1,performanceMode:!1,viewHeight:"100%",canvasOpacity:1,creatingSelection:!1,selectionView:{x:25,y:27,width:0,height:0},creatingNodePlot:!1,showTemplateNode:!0,newNodeTemplate:be(JSON.parse(JSON.stringify(Fe))),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"},newLinkTemplate:{fromNode:null,toNodeObject:null,toNode:{nothing:!0,x:400,y:400,el_W:30,el_H:30},totalLinesBetweenNodes:1,currentLineIndex:0,line:{}},data:{},editingLineController:{show:!1,line:null,startPoint:{x:0,y:0},endPoint:{x:0,y:0},text:{show:!0,x:0,y:0,width:10,height:10},ctrlPoints:[],selectedLines:[],line44Splits:[],line49Points:[],ctrlPoint1:{x:0,y:0},ctrlPoint2:{x:0,y:0},toolbar:{x:0,y:0}},editingController:{show:!1,nodes:[],x:0,y:0,width:100,height:100},nodeConnectController:{show:!1,node:void 0,x:0,y:0,width:100,height:100},showReferenceLine:!1,referenceLineAdsorption:!1,editingReferenceLine:{show:!1,directionV:!1,directionH:!1,v_x:0,v_y:0,v_height:0,h_x:0,h_y:0,h_width:0},showMiniView:!1,miniViewVisibleHandle:{x:0,y:0,width:100,height:100,emptyContent:!1},snapshotting:!1};o.newLineTemplate=he(o.newLineTemplate,o);const e=Object.keys(o);return s&&Object.keys(s).forEach(t=>{const n=s[t];if(!e.includes(t)){C("RGOptions: unknow option key:",t);return}if(typeof n=="object"){C("RGOptions:user setting object:",t,n);const i=o[t];if(t==="layout")o[t]=JSON.parse(JSON.stringify(n));else if(i&&!Array.isArray(i)&&n)Object.keys(i).forEach(a=>{i[a]=n[a]});else if(Array.isArray(i)){const a=[];n.forEach(r=>{r&&typeof r=="object"?a.push(JSON.parse(JSON.stringify(r))):a.push(r)}),o[t]=a}else o[t]=n}else o[t]=n}),o},Ye=(s,o)=>{C("applyDefaultOptionsByLayout",s.layoutName,o);const e=s.layoutName||"";e==="center"||e.includes("tree")&&(s.from==="top"||s.from,s.from==="left"||s.from),o.defaultJunctionPoint===void 0&&(o.defaultJunctionPoint=U.border)},He=s=>{const o=s.layoutName||"";if(o==="center"){const e=s;e.layoutDirection===void 0&&(e.layoutDirection="h"),e.layoutDirection=void 0}else if(o.includes("tree")){const e=s;e.layoutDirection===void 0&&(e.layoutDirection="h"),e.from===void 0&&(e.from="left"),e.levelGaps===void 0&&(e.levelGaps=[]),(e.from==="top"||e.from==="bottom")&&(e.layoutDirection="v",C("set layoutDirection=v"),C("set defaultJunctionPoint=tb")),(e.from==="left"||e.from==="right")&&(e.layoutDirection="h",C("set defaultJunctionPoint=lr"))}else(o==="fixed"||o==="force")&&(s.layoutDirection=void 0);s.supportAutoLayout=!1,s.autoLayouting=!1},qt={createDefaultConfig:Oe,applyDefaultOptionsByLayout:Ye},Jt=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:Oe,applyDefaultOptionsByLayout:Ye,appendDefaultOptions4Layout:He,default:qt},Symbol.toStringTag,{value:"Module"})),ye=I.createContext(null),ot=I.createContext(null),Ee=I.createContext(0),re=I.createContext({shouldRenderLines:[],shouldRenderNodes:[],shouldRenderFakeLines:[],options:Oe({})});function W(){const s=I.useContext(ye);if(!s)throw new Error("'useGraphInstance' must be used within 'RGProvider'");return s}function oe(){const s=I.useContext(Ee);if(s===void 0)throw new Error("'useAutoUpdateView' must be used within 'RGProvider'");return s}function q(){const s=I.useContext(re);if(s===void 0)throw new Error("'useGraphStore' must be used within 'RGProvider'");return s}function Zt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");const o=W();return I.useMemo(()=>{if(!s.options||!s.options.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=o.generateCreatingLineConfig(s.options);return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}},[s.options.creatingLinePlot,s.options.newLinkTemplate,s.options.newLineTemplate])}function Qt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCreatingLine' must be used within 'RGProvider'");return I.useMemo(()=>!s.options||!s.options.creatingNodePlot?{creating:!1}:{creating:!0,nodeJson:s.options.newNodeTemplate},[s.options.creatingNodePlot,s.options.newNodeTemplate])}function Kt(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingNodes' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingController,[s.options.editingController])}function en(){const s=I.useContext(re);if(s===void 0)throw new Error("'useEditingLine' must be used within 'RGProvider'");return I.useMemo(()=>s.options.editingLineController,[s.options.editingLineController])}function tn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useConnectingNode' must be used within 'RGProvider'");return I.useMemo(()=>s.options.nodeConnectController,[s.options.nodeConnectController])}function nn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useViewInformation' must be used within 'RGProvider'");return I.useMemo(()=>{const{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}=s.options;return{viewSize:o,canvasSize:e,canvasOffset:t,canvasZoom:n,fullscreen:i,showEasyView:a}},[s.options.viewSize,s.options.canvasSize,s.options.canvasOffset,s.options.canvasZoom,s.options.fullscreen,s.options.showEasyView])}function on(){const s=I.useContext(re);if(s===void 0)throw new Error("'useSelection' must be used within 'RGProvider'");return I.useMemo(()=>({...s.options.selectionView,show:s.options.creatingSelection}),[s.options.selectionView,s.options.creatingSelection])}function sn(){const s=I.useContext(re);if(s===void 0)throw new Error("'useCheckedItem' must be used within 'RGProvider'");return I.useMemo(()=>({checkedLineId:s.options.checkedLineId,checkedNodeId:s.options.checkedNodeId,draggingNodeId:s.options.draggingNodeId}),[s.options.checkedLineId,s.options.checkedNodeId,s.options.draggingNodeId])}const st=({forElementLines:s})=>{const{options:o}=q();return x.jsxs("defs",{children:[x.jsx("marker",{id:`${o.instanceId}-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})}),x.jsx("marker",{id:`${o.instanceId}-start-arrow-default`,markerWidth:o.defaultLineMarker.markerWidth,markerHeight:o.defaultLineMarker.markerHeight,refX:o.defaultLineMarker.refX,refY:o.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:o.defaultLineMarker.viewBox,children:x.jsx("path",{style:{fill:"context-stroke"},d:o.defaultLineMarker.data})})]})},at=({children:s,lineConfig:o,checked:e})=>{const t=W();if(!t)return null;const n=t.getLineTextContainer(o==null?void 0:o.line);if(!n)return null;const i=o.line,a=i.selected;return Xt.createPortal(x.jsx("div",{className:["rg-line-peel",i.className,e&&"rg-line-peel-checked",(i.disablePointEvent||i.opacity===0)&&"rg-line-peel-disable-events",a&&"rg-line-peel-selected"].filter(Boolean).join(" "),"data-id":i.id,style:{"--rg-line-color":i.color,"--rg-line-fontsize":o.line.fontSize?`${o.line.fontSize}px`:void 0,"--rg-line-opacity":i.opacity,"--rg-line-fontcolor":i.fontColor,...i.cssVars||{}},children:s}),n)},rt=({lineConfig:s,linePathInfo:o,lineUseTextPath:e,checked:t,graphInstanceId:n,onLineClick:i})=>{const a=W(),r=s.line,l=r.selected,c=a.getArrowMarkerId(r,!0),d=a.getArrowMarkerId(r,!1),h=r.lineWidth?r.lineWidth+"px":void 0,y=r.useTextPath||e?a.generateLineTextStyle4TextPath(s):null,u=n+"-"+r.id;return x.jsxs("g",{className:["rg-line-peel",r.className,t&&"rg-line-peel-checked",l&&"rg-line-peel-selected",(r.disablePointEvent||r.opacity===0)&&"rg-line-peel-disable-events"].filter(Boolean).join(" "),"data-id":r.id,style:{"--rg-line-width":h,"--rg-line-color":r.color,"--rg-line-opacity":r.opacity,"--rg-line-fontcolor":r.fontColor,"--rg-line-marker-end":d,"--rg-line-marker-start":c,...r.cssVars||{}},children:[x.jsx("path",{d:o.pathData,className:"rg-line-bg",onTouchStart:i,onClick:i}),x.jsx("path",{id:u,d:o.pathData,className:["rg-line",r.dashType?"rg-line-dashtype-"+r.dashType:void 0,r.animation?"rg-line-anm-"+r.animation:void 0].filter(Boolean).join(" ")}),y&&x.jsx("g",{children:x.jsx("text",{className:"rg-line-text rg-line-text-on-path",dy:"-6px",onTouchStart:i,onClick:i,children:x.jsx("textPath",{xlinkHref:`#${u}`,startOffset:y.onPathStartOffset,textAnchor:y.textAnchor,method:"align",spacing:"auto",children:y.text})})})]})},lt=({lineConfig:s,lineUseTextPath:o,graphInstanceId:e,checked:t})=>{const n=W(),i=I.useMemo(()=>n.generateLinePath(s),[s]),a=c=>{console.log("onLineClick",s.line),n.onLineClick(s.line,null,c.nativeEvent)},r=!(s.line.useTextPath||o),l=n.generateLineTextStyle(s,i);return x.jsxs(x.Fragment,{children:[x.jsx(rt,{lineConfig:s,linePathInfo:i,onLineClick:a,lineUseTextPath:o,checked:t,graphInstanceId:e}),s.line.text&&r&&x.jsx(at,{lineConfig:s,linePathInfo:i,checked:t,children:x.jsx("div",{className:"rg-line-label",style:{...l.cssStyles},onTouchStart:a,onClick:a,children:l.text})})]})},dt=({line:s,lineUseTextPath:o,graphInstanceId:e,checked:t,lineSlot:n})=>{const i=W();oe();const a=s.isFakeLine?i.generateFakeLineConfig(s):i.generateLineConfig(s);return x.jsx(x.Fragment,{children:a&&(n?n({lineConfig:a}):x.jsx(lt,{lineConfig:a,lineUseTextPath:o,graphInstanceId:e,checked:t}))})},ct=({showEasyView:s,lineSlot:o,lineUseTextPath:e,checkedLineId:t,graphInstanceId:n,allLineConfigList:i})=>x.jsxs("div",{className:"rg-lines-container rg-lines-container-normal-lines",children:[x.jsxs("svg",{className:"rg-lines-svg",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{}),!s&&i.map(a=>a.hidden!==!0&&x.jsx(dt,{line:a,lineSlot:o,lineUseTextPath:e,checked:a.id===t,graphInstanceId:n},a.id))]}),x.jsx("div",{className:"rg-linetext-container"})]});pe.default.memo(ct,(s,o)=>s.allLineConfigList!==o.allLineConfigList||s.graphInstanceId!==o.graphInstanceId||s.checkedLineId!==o.checkedLineId||s.lineSlot!==o.lineSlot?!1:s.lineUseTextPath===o.lineUseTextPath);const ht=({node:s,expandOrCollapseNode:o,expandHolderPosition:e})=>{const t=s.expanded===!1?"c-expanded":"c-collapsed";return x.jsx("div",{className:`rg-node-expand-holder c-expand-positon-${e}`,children:x.jsx("span",{className:t,onClickCapture:o,onTouchEnd:o})})},ut=({nodeProps:s,nodeSlot:o,nodeExpandButtonSlot:e,defaultExpandHolderPosition:t,dragging:n,checked:i})=>{const a=W(),r=I.useRef();I.useEffect(()=>(a.addNodeResizeListener(r.current,s),()=>{r.current&&a.removeNodeResizeListener(r.current)}),[]);const l=async v=>{a.expandOrCollapseNode(s,v.nativeEvent)},c=v=>{v.type==="mousedown"&&v.button!==0||(v.stopPropagation(),a.onNodeDragStart(s,v.nativeEvent))},d=s.width?s.width+"px":void 0,h=s.height?s.height+"px":void 0,f=s.borderWidth===void 0?void 0:s.borderWidth+"px",y=s.borderColor,u=s.opacity,g=s.rgCalcedVisibility,m=s.expandHolderPosition||t||"hide",p=m!=="hide"&&s.rgChildrenSize>0;return x.jsxs("div",{ref:r,style:{display:g?void 0:"none","--rg-node-z-index":s.zIndex?s.zIndex:void 0,pointerEvents:u===0?"none":void 0,transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-color":s.color,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?s.fontSize+"px":void 0,"--rg-node-border-width":f,"--rg-node-border-radius":s.borderRadius&&s.borderRadius+"px","--rg-node-border-color":y,"--rg-node-width":d,"--rg-node-height":h,"--rg-node-opacity":s.opacity===void 0?void 0:s.opacity},className:["rg-node-peel",s.selected&&"rg-node-selected",n&&"rg-node-dragging",i&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className,(s.disablePointEvent||s.opacity===0)&&"rg-node-disable-events"].filter(Boolean).join(" "),"data-id":s.id,children:[p&&(e?e({node:s,expandOrCollapseNode:l,expandHolderPosition:m}):x.jsx(ht,{node:s,expandOrCollapseNode:l,expandHolderPosition:m})),x.jsx("div",{className:"rg-node",onMouseDown:v=>{c(v)},onTouchStart:v=>{c(v)},children:o?o({node:s,defaultExpandHolderPosition:t,checked:i,dragging:n}):x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})]})},ft=({nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,draggingNodeId:t,checkedNodeId:n,allNodeConfigList:i})=>x.jsx("div",{className:"rg-nodes-container",children:i.map(a=>x.jsx(ut,{nodeProps:a,nodeSlot:s,nodeExpandButtonSlot:o,defaultExpandHolderPosition:e,dragging:a.id===t,checked:a.id===n},a.id))});pe.default.memo(ft,(s,o)=>s.allNodeConfigList!==o.allNodeConfigList||s.draggingNodeId!==o.draggingNodeId||s.checkedNodeId!==o.checkedNodeId||s.nodeSlot!==o.nodeSlot||s.nodeExpandButtonSlot!==o.nodeExpandButtonSlot?!1:s.defaultExpandHolderPosition===o.defaultExpandHolderPosition);const an=({showEasyView:s,lineSlot:o,lineUseTextPath:e,checkedLineId:t,graphInstanceId:n})=>{const i=W(),{shouldRenderFakeLines:a}=q(),r=s?[]:i.getShouldRenderFakeLines(a);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsxs("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx(st,{forElementLines:!0}),!s&&r.map(l=>l.hidden!==!0&&x.jsx(dt,{line:l,lineSlot:o,lineUseTextPath:e,checked:l.id===t,graphInstanceId:n},l.id))]})]})},rn=({lineSlot:s,lineUseTextPath:o,graphInstanceId:e})=>{const t=W(),{options:n}=q(),i=t.generateCreatingLineConfig(n);return x.jsxs("div",{className:"rg-lines-container rg-lines-container-el-lines",children:[x.jsx("div",{className:"rg-linetext-container"}),x.jsx("svg",{className:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg",children:s?s({lineConfig:i}):x.jsx(lt,{lineConfig:i,lineUseTextPath:o,graphInstanceId:e})})]})},ln=({nodeSlot:s,lineSlot:o,nodeExpandButtonSlot:e,showEasyView:t,creatingLine:n,defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,checkedLineId:l,graphInstanceId:c,lineUseTextPath:d})=>{const h=W(),{shouldRenderNodes:f,shouldRenderLines:y}=q(),u=I.useMemo(()=>t?[]:h.getShouldRenderNodes(f),[h,f,t]),g=I.useMemo(()=>t?[]:h.getShouldRenderLines(y),[h,y,t]);return x.jsxs("div",{className:"rg-single-graph",children:[x.jsx(ct,{graphInstanceId:c,showEasyView:t,lineUseTextPath:d,checkedLineId:l,lineSlot:o,allLineConfigList:g}),x.jsx("div",{className:"rg-nodes-container-wrapper",children:!t&&x.jsx(ft,{defaultExpandHolderPosition:i,draggingNodeId:a,checkedNodeId:r,nodeSlot:s,nodeExpandButtonSlot:e,allNodeConfigList:u})}),x.jsx(an,{graphInstanceId:c,showEasyView:t,lineUseTextPath:d,checkedLineId:l,lineSlot:o}),n&&x.jsx(rn,{lineUseTextPath:d,checkedLineId:l,lineSlot:o})]})},dn=s=>{const o=W(),{options:e}=q(),t=I.useRef();return I.useEffect(()=>(C("[RGEasyView mounted]"),o.setEasyViewCanvas(t.current),()=>{C("[RGEasyView UnMounted]")}),[]),x.jsx("div",{className:`rg-easy-view ${e.showEasyView?"rg-easy-view-active":""}`,children:x.jsx("canvas",{ref:t})})},cn=s=>{const o=W(),{options:e}=q();oe();const t=I.useRef(),n=I.useRef(),i=I.useMemo(()=>e.canvasSize,[e.canvasSize]),a=I.useMemo(()=>e.canvasOffset,[e.canvasOffset]),r=I.useMemo(()=>e.canvasZoom/100,[e.canvasZoom]),l={width:`${i.width}px`,height:`${i.height}px`,backgroundColor:"transparent",transform:`translate(${a.x}px, ${a.y}px) scale(${r},${r})`};I.useEffect(()=>(C("[RGCanvas mounted]"),o.setCanvasDom(t.current),()=>{C("[RGCanvas UnMounted]")}),[]);const c=h=>{h.type==="mousedown"&&h.button!==0||o.onCanvasDragStart(h.nativeEvent)},d=h=>{h.preventDefault(),o.onContextmenu(h.nativeEvent)};return x.jsxs("div",{ref:n,className:["rg-map",e.canvasOpacity===1?"rg-map-ready":""].join(" "),onContextMenu:h=>{d(h)},onMouseDown:h=>{c(h)},onTouchStart:h=>{c(h)},children:[x.jsx(dn,{}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-behind",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-behind",children:s.canvasPlugSlot&&(typeof s.canvasPlugSlot=="function"?x.jsx(s.canvasPlugSlot,{}):s.canvasPlugSlot)})}),x.jsx("div",{ref:t,style:l,className:"rg-map-canvas",children:x.jsx(ln,{nodeSlot:s.nodeSlot,lineSlot:s.lineSlot,nodeExpandButtonSlot:s.nodeExpandButtonSlot,showEasyView:e.showEasyView,creatingLine:e.creatingLinePlot&&e.newLinkTemplate.fromNode,defaultExpandHolderPosition:e.defaultExpandHolderPosition,draggingNodeId:e.draggingNodeId,checkedNodeId:e.checkedNodeId,lineUseTextPath:e.lineUseTextPath,checkedLineId:e.checkedLineId,graphInstanceId:e.instanceId})}),x.jsx("div",{style:l,className:"rg-map-canvas rg-canvas-above",children:x.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-above",children:s.canvasPlugAboveSlot})})]})},hn=()=>{const s=W(),o=(s==null?void 0:s.options.canvasMoveMode)||!1,e=t=>{s&&s.startMoveCanvas(t.nativeEvent,!0)};return x.jsx("div",{className:`rg-move-operator ${o?"rg-move-operator-active":""}`,children:x.jsx("div",{className:"rg-move-touchpad",onMouseDown:e,onTouchStart:e})})},un={"icon-quanping":{data:`
7
+ <path d="M921.6 358.4h-76.8V179.2h-179.2V102.4h256v256zM102.4 358.4h76.8V179.2h179.2V102.4H102.4v256z m0 307.2h76.8v179.2h179.2v76.8H102.4V665.6z m819.2 0h-76.8v179.2h-179.2v76.8h256V665.6z"></path>`},"icon-fangda":{data:`
8
+ <path d="M853.333333 480H544V170.666667c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v309.333333H170.666667c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h309.333333V853.333333c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V544H853.333333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z"></path>
12
9
  `},"icon-suoxiao":{data:`
13
- <path d="M768 448a320 320 0 1 0-320 320 320 320 0 0 0 320-320z m64 0A384 384 0 1 1 448 64a384 384 0 0 1 384 384z"></path>
14
- <path d="M681.28 726.72a32 32 0 0 1 45.44-45.44l160 160a32 32 0 0 1-45.44 45.44zM288 480a32 32 0 0 1 0-64h320a32 32 0 0 1 0 64z"></path>
15
- `},"icon-zidong":{data:`
16
- <path d="M131.3 363.3c-19.2 47.3-28.9 97.3-28.9 148.7 0 51.3 9.7 101.3 28.9 148.7 7 17.2 15.1 33.8 24.3 49.7l15.8-49.1 42.8 13.8-39.8 123.8-42.8-13.9-80.9-26 13.8-42.8 52.3 16.8c-98-168.4-74.8-387.9 69.4-532.1C342.4 44.7 586.9 30.5 759.1 158.3l-32.2 32.2c-25.1-18-52.1-32.9-80.9-44.6-47.3-19.2-97.3-28.9-148.7-28.9-51.3 0-101.3 9.7-148.7 28.9-49 19.9-92.9 49.1-130.6 86.8s-66.9 81.7-86.7 130.6z m828.3-60.2l13.8-42.8-80.9-26-42.8-13.8-39.8 123.8 42.8 13.8 15-46.7c9.8 16.6 18.4 34 25.8 52.1 19.2 47.3 28.9 97.3 28.9 148.7 0 51.3-9.7 101.3-28.9 148.7-19.9 49-49.1 92.9-86.8 130.6C768.9 829 725 858.2 676 878.1c-47.3 19.2-97.3 28.9-148.7 28.9-51.3 0-101.3-9.7-148.7-28.9-28.8-11.7-55.9-26.6-80.9-44.6l-32.2 32.2c126.3 93.7 382.6 147.7 572.9-42.6 145.8-145.8 167.9-368.6 66.1-537.7l55.1 17.7zM474 241.2L295 730.4h64.8l50.5-148.2h195.3l54 148.2h70.3L539.6 241.2H474z m-45.9 288.3L479.8 386c11-30.9 19.4-62.1 25.4-93.4 6.9 26 17.9 59.9 32.8 101.5l48.2 135.5H428.1z"></path>
17
-
10
+ <path d="M853.333333 544H170.666667c-17.066667 0-32-14.933333-32-32s14.933333-32 32-32h682.666666c17.066667 0 32 14.933333 32 32s-14.933333 32-32 32z"></path> `},"icon-zidong":{data:`
11
+ <path d="M633.6 467.2 512 467.2l64-352c0-12.8-12.8-12.8-19.2-6.4L211.2 537.6c-6.4 6.4 0 19.2 6.4 19.2l121.6 0-64 352c0 12.8 12.8 12.8 19.2 6.4L640 486.4C646.4 480 646.4 467.2 633.6 467.2z"></path>
12
+ <path d="M793.6 902.4l-38.4 0L736 832 627.2 832l-25.6 70.4L569.6 902.4l89.6-249.6L704 652.8 793.6 902.4zM723.2 806.4l-44.8-121.6-44.8 121.6L723.2 806.4z"></path>
18
13
  `},"icon-yuanquanfenxiang":{data:`
19
14
  <path d="M751.148705 578.773799c-61.987796 0-117.066229 30.121018-151.388942 76.488045L398.287145 536.382317c1.991354-10.171664 3.046383-20.673855 3.046383-31.419594 0-18.776645-3.196809-36.817534-9.058306-53.621245l193.486736-107.492176c31.949666 58.566884 94.104261 98.391914 165.386748 98.391914 103.803157 0 188.254571-84.450391 188.254571-188.254571S854.951863 65.73105 751.148705 65.73105c-103.804181 0-188.255595 84.450391-188.255595 188.254571 0 14.246469 1.600451 28.125571 4.613064 41.4746L368.032074 406.279167c-29.841655-39.193651-76.976162-64.544015-129.927141-64.544015-90.004897 0-163.228595 73.223698-163.228595 163.228595 0 90.003873 73.223698 163.228595 163.228595 163.228595 60.882626 0 114.078175-33.510208 142.134161-83.049484L575.173808 700.16452c-7.925507 20.788465-12.280698 43.325761-12.280698 66.86385 0 103.803157 84.450391 188.254571 188.255595 188.254571 103.803157 0 188.254571-84.450391 188.254571-188.254571S854.951863 578.773799 751.148705 578.773799zM751.148705 116.89636c75.590606 0 137.089261 61.498656 137.089261 137.089261s-61.498656 137.089261-137.089261 137.089261c-75.591629 0-137.090285-61.498656-137.090285-137.089261S675.557076 116.89636 751.148705 116.89636zM238.105956 617.026008c-61.791321 0-112.063285-50.27094-112.063285-112.063285 0-61.791321 50.27094-112.063285 112.063285-112.063285s112.063285 50.27094 112.063285 112.063285C350.168218 566.755068 299.897278 617.026008 238.105956 617.026008zM751.148705 904.117632c-75.591629 0-137.090285-61.498656-137.090285-137.089261s61.498656-137.089261 137.090285-137.089261c75.590606 0 137.089261 61.498656 137.089261 137.089261S826.739311 904.117632 751.148705 904.117632z"></path>
20
15
 
@@ -22,8 +17,7 @@
22
17
  <path d="M963.66 256.607c0-0.244 0-0.607-0.126-0.851 0-0.369 0-0.614-0.119-0.978 0-0.369-0.119-0.733-0.119-1.104 0-0.244 0-0.487-0.126-0.725 0-0.369-0.119-0.859-0.244-1.222 0-0.244-0.119-0.369-0.119-0.613-0.126-0.365-0.126-0.852-0.245-1.216 0-0.244-0.126-0.369-0.126-0.613-0.119-0.365-0.244-0.734-0.364-1.222-0.126-0.244-0.126-0.49-0.244-0.609l-0.369-1.095c-0.119-0.245-0.119-0.49-0.244-0.734-0.121-0.369-0.245-0.613-0.365-0.978-0.126-0.244-0.244-0.613-0.369-0.851-0.119-0.244-0.238-0.613-0.364-0.859-0.119-0.364-0.244-0.607-0.364-0.977l-0.371-0.734c-0.119-0.364-0.364-0.725-0.487-0.971-0.119-0.245-0.244-0.371-0.364-0.614-0.244-0.364-0.369-0.733-0.614-1.097-0.119-0.126-0.244-0.369-0.364-0.487l-0.733-1.097c-0.119-0.126-0.244-0.369-0.365-0.487-0.244-0.369-0.487-0.733-0.733-0.978-0.126-0.244-0.244-0.369-0.487-0.613-0.245-0.238-0.49-0.607-0.734-0.851-0.244-0.245-0.487-0.49-0.607-0.734-0.244-0.244-0.369-0.487-0.614-0.733-0.851-0.972-1.829-1.83-2.681-2.682-0.245-0.244-0.49-0.369-0.734-0.614-0.244-0.244-0.487-0.487-0.733-0.607-0.245-0.244-0.614-0.487-0.859-0.733-0.238-0.121-0.364-0.365-0.607-0.49-0.365-0.244-0.734-0.487-0.978-0.733-0.119-0.119-0.364-0.244-0.487-0.365l-1.097-0.733c-0.119-0.119-0.364-0.244-0.487-0.364-0.365-0.244-0.734-0.369-1.097-0.614-0.244-0.119-0.369-0.244-0.613-0.364-0.365-0.126-0.734-0.369-0.972-0.487l-0.734-0.369c-0.369-0.121-0.613-0.245-0.977-0.365-0.244-0.126-0.614-0.244-0.859-0.369-0.244-0.119-0.607-0.238-0.851-0.364-0.365-0.119-0.609-0.244-0.978-0.364-0.244-0.126-0.487-0.126-0.733-0.245l-1.097-0.369c-0.244-0.119-0.487-0.119-0.609-0.244-0.369-0.119-0.733-0.244-1.22-0.364-0.245 0-0.371-0.126-0.614-0.126-0.364-0.119-0.851-0.244-1.216-0.244-0.244 0-0.487-0.121-0.613-0.121-0.364-0.126-0.852-0.126-1.222-0.244-0.244 0-0.482-0.126-0.725-0.126-0.369 0-0.734-0.119-1.104-0.119-0.364 0-0.607 0-0.978-0.126-0.244 0-0.607 0-0.851-0.119h-242.407c-21.604 0-39.062 17.456-39.062 39.062 0 21.604 17.458 39.055 39.062 39.055h146.102l-3.171 3.177-217.27 217.265 0.369 0.369-49.676 49.676-155.87-155.87c-7.694-7.689-17.827-11.472-27.953-11.472-10.13-0.126-20.263 3.659-27.952 11.472l-282.446 282.322c-15.258 15.258-15.258 40.041 0 55.298 15.258 15.258 40.033 15.258 55.291 0l255.108-255.11 155.746 155.751c7.813 7.815 17.945 11.593 28.076 11.474 10.126 0.119 20.382-3.659 28.070-11.474l182.964-182.969c0.734-0.734 1.347-1.342 1.956-2.075l111.564-111.564v146.109c0 21.604 17.451 39.060 39.055 39.060s39.062-17.456 39.062-39.060v-235.085c0-0.244 0.126-0.49 0.126-0.614 0-0.244 0.119-0.487 0.119-0.733 0-0.364 0.119-0.734 0.119-1.097s0-0.607 0.126-0.977c0-0.245 0-0.609 0.119-0.852-0.122-1.466-0.122-2.807-0.122-4.030v0zM963.66 256.607z"></path>
23
18
 
24
19
  `},"icon-lianjie_connecting5":{data:`
25
- <path d="M801.25952 251.74016l-28.9792-28.99968-150.79424 150.8352-35.1232-35.10272-99.14368 99.16416 99.14368 99.16416 99.16416-99.16416-35.10272-35.1232zM487.19872 476.8768l-29.94176 29.94176-19.61984-19.61984-99.16416 99.16416 35.10272 35.1232-150.8352 150.79424 28.95872 28.95872 150.8352-150.79424 35.10272 35.10272 99.14368-99.14368-19.61984-19.64032 29.96224-29.96224-59.92448-59.92448z m-15.48288 44.4416l15.4624-15.4624 30.98624 30.98624-15.4624 15.44192-30.98624-30.96576z"
26
- fill=""></path>
20
+ <path d="M801.25952 251.74016l-28.9792-28.99968-150.79424 150.8352-35.1232-35.10272-99.14368 99.16416 99.14368 99.16416 99.16416-99.16416-35.10272-35.1232zM487.19872 476.8768l-29.94176 29.94176-19.61984-19.61984-99.16416 99.16416 35.10272 35.1232-150.8352 150.79424 28.95872 28.95872 150.8352-150.79424 35.10272 35.10272 99.14368-99.14368-19.61984-19.64032 29.96224-29.96224-59.92448-59.92448z m-15.48288 44.4416l15.4624-15.4624 30.98624 30.98624-15.4624 15.44192-30.98624-30.96576z"></path>
27
21
  `},"icon-ico_reset":{data:`
28
22
  <path d="M925.97087933 277.33133334a479.997 479.997 0 1 0 54.33566 255.9984H916.05094133a415.9974 415.9974 0 1 1-64.191599-255.9984h74.047537z"></path>
29
23
  <path d="M978.64255033 61.01268534L725.33213333 371.09074734h297.59814z"></path>
@@ -43,14 +37,248 @@ fill=""></path>
43
37
  <path d="M513.266174 1024a27.500417 27.500417 0 0 1-19.366491-8.037094L342.260061 864.129619a27.500417 27.500417 0 1 1 38.732981-38.732981L513.266174 957.766602l130.530147-130.336483a27.500417 27.500417 0 0 1 38.732981 38.732982L532.632664 1015.962906a27.403584 27.403584 0 0 1-19.36649 8.037094z"></path>
44
38
 
45
39
  `},"icon-lianjiezhong":{data:`
46
- <path d="M883.396923 298.141538a99.721846 99.721846 0 0 1-142.414769 0 103.187692 103.187692 0 0 1 0-144.423384 99.721846 99.721846 0 0 1 142.414769 0 103.187692 103.187692 0 0 1 0 144.423384zM285.144615 760.438154a87.276308 87.276308 0 0 0-124.652307 0 90.269538 90.269538 0 0 0 0 126.385231c34.422154 34.894769 90.230154 34.894769 124.652307 0a90.269538 90.269538 0 0 0 0-126.424616z m482.579693 108.307692a64.472615 64.472615 0 0 1 0-90.269538 62.345846 62.345846 0 0 1 89.00923 0c24.576 24.930462 24.576 65.378462 0 90.269538a62.345846 62.345846 0 0 1-89.00923 0zM294.006154 298.141538a103.187692 103.187692 0 0 0 0-144.423384 99.721846 99.721846 0 0 0-142.454154 0 103.187692 103.187692 0 0 0 0 144.423384 99.721846 99.721846 0 0 0 142.454154 0z m324.214154-196.01723c0 56.438154-45.095385 102.163692-100.745846 102.163692-55.611077 0-100.706462-45.725538-100.706462-102.163692C416.768 45.725538 461.863385 0 517.474462 0c55.650462 0 100.745846 45.725538 100.745846 102.124308zM517.474462 870.793846c-41.747692 0-75.539692 34.264615-75.539693 76.603077 0 42.299077 33.831385 76.603077 75.539693 76.603077 41.747692 0 75.539692-34.264615 75.539692-76.603077 0-42.299077-33.792-76.603077-75.539692-76.603077z m416.768-294.990769c-27.805538 0-50.333538-22.843077-50.333539-51.042462 0-28.199385 22.528-51.042462 50.333539-51.042461 27.844923 0 50.412308 22.843077 50.372923 51.042461 0 28.199385-22.567385 51.081846-50.372923 51.081847zM201.452308 524.8c0-56.398769-45.095385-102.124308-100.745846-102.124308C45.095385 422.596923 0 468.283077 0 524.760615c0 56.398769 45.095385 102.124308 100.706462 102.124308 55.650462 0 100.745846-45.686154 100.745846-102.124308z"></path>
40
+ <path d="M512 907c-24.852 0-45-20.148-45-45s20.148-45 45-45c168.446 0 305-136.554 305-305S680.446 207 512 207 207 343.554 207 512c0 24.852-20.148 45-45 45S117 536.852 117 512c0-218.152 176.848-395 395-395S907 293.848 907 512 730.152 907 512 907z"></path>
47
41
 
48
- `}},Q=({iconName:i,className:a})=>{const t=Ie[i];return C.jsx("svg",{className:`rg-icon ${a}`,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:t.data}})},Ae=()=>{const i=k.useContext(H),a=i&&i.options,t=e=>{i.clearLoading()};return C.jsx(C.Fragment,{children:a&&C.jsx("div",{className:`rg-graph-loading ${a.graphLoading?"":"rg-graph-loading-hide"}`,onClick:e=>{t()},children:C.jsxs("div",{className:"rg-graph-loading-message",children:[C.jsx(Q,{iconName:"icon-lianjiezhong",className:"rg-graph-loading-icon"}),"Loading..."]})})})},re=({nodeSlot:i})=>{const a=k.useContext(H),t=a&&a.options;return t&&C.jsxs("div",{className:"rg-operate",children:[C.jsxs("div",{className:"rg-creating-container",children:[t.creatingNodePlot&&t.showTemplateNode&&C.jsx(ne,{nodeProps:t.newNodeTemplate,nodeSlot:i}),t.creatingSelection&&C.jsx("div",{className:"rg-selection",style:{transform:`translate(${t.selectionView.x}px, ${t.selectionView.y}px)`,width:t.selectionView.width+"px",height:t.selectionView.height+"px"}})]}),C.jsx(Pe,{}),C.jsx(Ae,{})]})},le=({direction:i="h",positionH:a="left",positionV:t="bottom",children:e})=>{const n=k.useContext(H);k.useContext(q);const o=n&&n.options,s=()=>{n==null||n.toggleAutoLayout()},r=async()=>{n&&(n.setZoom(100),n.moveToCenter(),n.enableCanvasAnimation(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300))},l=async h=>{await(n==null?void 0:n.zoom(h))},c=async()=>{await(n==null?void 0:n.fullscreen())};return k.useEffect(()=>{},[]),C.jsxs("div",{className:`rg-toolbar rg-xs-toolbar rg-toolbar-h-${a||o.toolBarPositionH} rg-toolbar-v-${t||o.toolBarPositionV} rg-toolbar-${i||o.toolBarDirection}`,children:[C.jsx("div",{title:"Full Screen",className:"rg-mb-button",style:{marginTop:0},onClick:c,children:C.jsx(Q,{iconName:"icon-quanping"})}),C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"rg-mb-button",onClick:()=>l(20),children:C.jsx(Q,{iconName:"icon-fangda"})}),C.jsx("div",{className:"rg-current-zoom",onClick:r,children:`${Math.round(o.canvasZoom)}%`}),C.jsx("div",{className:"rg-mb-button",style:{marginTop:0},onClick:()=>l(-20),children:C.jsx(Q,{iconName:"icon-suoxiao"})})]}),o.layout.supportAutoLayout&&C.jsx("div",{title:o.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",className:`rg-mb-button ${o.layout.autoLayouting?"rg-mb-button-on":""}`,onClick:s,children:o.layout.autoLayouting?C.jsx(Q,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):C.jsx(Q,{iconName:"icon-zidong"})}),e]})},It=({children:i})=>C.jsx(C.Fragment,{}),Mt=({children:i})=>C.jsx(C.Fragment,{}),At=({children:i})=>C.jsx(C.Fragment,{}),Vt=({children:i})=>C.jsx(C.Fragment,{}),ce=i=>({onReady:i.onReady,onNodeClick:i.onNodeClick,onNodeExpand:i.onNodeExpand,onNodeCollapse:i.onNodeCollapse,onLineClick:i.onLineClick,onImageDownload:i.onImageDownload,onImageSaveAsFile:i.onImageSaveAsFile,onNodeDragStart:i.onNodeDragStart,onNodeDragEnd:i.onNodeDragEnd,onNodeDragging:i.onNodeDragging,onCanvasDragEnd:i.onCanvasDragEnd,onCanvasDragging:i.onCanvasDragging,onContextmenu:i.onContextmenu,onFullscreen:i.onFullscreen,onCanvasClick:i.onCanvasClick,onCanvasSelectionEnd:i.onCanvasSelectionEnd,beforeZoomStart:i.beforeZoomStart,onZoomEnd:i.onZoomEnd,onViewResize:i.onViewResize,onResizeStart:i.onResizeStart,beforeNodeResize:i.beforeNodeResize,onResizeEnd:i.onResizeEnd,onLineVertexDropped:i.onLineVertexDropped,beforeCreateLine:i.beforeCreateLine,onLineBeCreated:i.onLineBeCreated,beforeAddNodes:i.beforeAddNodes,beforeAddLines:i.beforeAddLines,onKeyboardDown:i.onKeyboardDown,onKeyboardUp:i.onKeyboardUp,onCanvasDragStart:i.onCanvasDragStart,onForceLayoutFinish:i.onForceLayoutFinish,beforeScrollStart:i.beforeScrollStart}),he=({children:i})=>C.jsx(C.Fragment,{}),Ut=i=>{const a=k.useContext(H);k.useContext(q);const t=k.useRef(),[e,n]=k.useState(!1);k.useEffect(()=>{te("React"),a.setOptions(i.options);const m=ce(i);v("[RelationGraph]mounted:listeners:",m),a.setListeners(m),v("[RelationGraph]setDom:",t.current),a.setDom(t.current),n(!0),a.ready(),a.dataUpdated(),i.initialData&&(v("[RelationGraph] apply data"),a.applyInitialData(i.initialData));const w=b=>{a.onMouseWheel(b)};return t.current.addEventListener("wheel",w,{passive:!1}),()=>{t.current.removeEventListener("wheel",w),a.beforeUnmount()}},[]);const o=a&&a.options;let s,r;const l=[],c=[],h=[],d=[],f=lt.default.Children.toArray(i.children).filter(m=>{if(m&&lt.default.isValidElement(m))if(m.type===we){const w=m.props.children;if(typeof w=="function")s=w;else throw new Error("RGSlotOnNode children must be a function, e.g. <RGSlotOnNode>{ (node: RGNode) => <div>{node.text}</div> }</RGSlotOnNode>")}else if(m.type===It){const w=m.props.children;if(typeof w=="function")r=w;else throw new Error('RGSlotOnLine children must be a function, e.g. <RGSlotOnLine>{ (line: RGLine) => <g><path d="..." /><text>{line.text}</text></g> }</RGSlotOnLine>')}else{if(m.type===Mt)return l.push(m.props.children),!1;if(m.type===At)return c.push(m.props.children),!1;if(m.type===Vt)return h.push(m.props.children),!1;if(m.type===he)return d.push(m.props.children),!1}return!0}),p=l,u=h,g=c.concat(...f);if(s&&i.nodeSlot)throw new Error("You can only provide nodeSlot or RGSlotOnNode, but not both.");if(r&&i.lineSlot)throw new Error("You can only provide lineSlot or RGSlotOnLine, but not both.");const x=s||i.nodeSlot,y=r||i.lineSlot,L=i.expandHolderSlot;return C.jsx("div",{ref:t,id:`relation-graph-ins-${o==null?void 0:o.instanceId}`,className:["relation-graph",(o==null?void 0:o.creatingLinePlot)&&"rg-creating-line",o&&!o.selectionMode&&!o.disableDragCanvas?"rg-move-mode":"",o!=null&&o.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",(o==null?void 0:o.enableCanvasTransformAnimation)&&"rg-enable-canvas-animation"].filter(Boolean).join(" "),tabIndex:1,style:{width:"100%",height:o!=null&&o.viewHeight?o==null?void 0:o.viewHeight:"100%",opacity:e?1:0,"--rg-checked-line-bg-color":o==null?void 0:o.checkedItemBackgroundColor},children:e&&o&&C.jsxs(C.Fragment,{children:[o.showDebugPanel&&C.jsx(De,{}),o.showToolBar&&C.jsx(le,{}),C.jsx(Re,{nodeSlot:x,lineSlot:y,svgDefs:d,canvasPlugSlot:g,canvasPlugAboveSlot:u,expandHolderSlot:L}),C.jsx(re,{nodeSlot:x}),C.jsx("div",{className:"rg-graph-plugs",children:C.jsx("div",{className:"rg-graph-slot",children:p})})]})})},Ve=H.Provider,ze=gt.Provider,Be=q.Provider;var B=(i=>(i.Node="node",i.NodePoint="NodePoint",i.HTMLElementId="HTMLElementId",i.CanvasPoint="CanvasPoint",i.ViewPoint="ViewPoint",i))(B||{}),U=(i=>(i.border="border",i.ltrb="ltrb",i.tb="tb",i.lr="lr",i.left="left",i.right="right",i.top="top",i.bottom="bottom",i))(U||{}),zt=(i=>(i[i.circle=0]="circle",i[i.rect=1]="rect",i))(zt||{}),G=(i=>(i[i.StandardStraight=1]="StandardStraight",i[i.StandardCurve=6]="StandardCurve",i[i.Curve2=2]="Curve2",i[i.Curve3=3]="Curve3",i[i.Curve5=5]="Curve5",i[i.Curve7=7]="Curve7",i[i.Curve8=8]="Curve8",i[i.SimpleOrthogonal=4]="SimpleOrthogonal",i[i.StandardOrthogonal=44]="StandardOrthogonal",i[i.HardOrthogonal=49]="HardOrthogonal",i))(G||{}),de=(i=>(i.Left="left",i.Top="top",i.Right="right",i.Bottom="bottom",i))(de||{}),I=(i=>(i.onReady="onReady",i.onNodeClick="onNodeClick",i.onNodeExpand="onNodeExpand",i.onNodeCollapse="onNodeCollapse",i.onLineClick="onLineClick",i.onImageDownload="onImageDownload",i.onImageSaveAsFile="onImageSaveAsFile",i.onNodeDragStart="onNodeDragStart",i.onNodeDragEnd="onNodeDragEnd",i.onNodeDragging="onNodeDragging",i.onCanvasDragEnd="onCanvasDragEnd",i.onCanvasDragging="onCanvasDragging",i.onContextmenu="onContextmenu",i.onFullscreen="onFullscreen",i.onCanvasClick="onCanvasClick",i.onCanvasSelectionEnd="onCanvasSelectionEnd",i.beforeZoomStart="beforeZoomStart",i.onZoomEnd="onZoomEnd",i.onViewResize="onViewResize",i.onResizeStart="onResizeStart",i.beforeNodeResize="beforeNodeResize",i.onResizeEnd="onResizeEnd",i.onLineVertexDropped="onLineVertexDropped",i.beforeCreateLine="beforeCreateLine",i.onLineBeCreated="onLineBeCreated",i.beforeAddNodes="beforeAddNodes",i.beforeAddLines="beforeAddLines",i.onKeyboardDown="onKeyboardDown",i.onKeyboardUp="onKeyboardUp",i.onCanvasDragStart="onCanvasDragStart",i.onForceLayoutFinish="onForceLayoutFinish",i.beforeScrollStart="beforeScrollStart",i))(I||{});const Bt={id:"rg-newNodeTemplate",x:0,y:0,text:""},Ct=(i,a)=>{var e,n;if(i.id===void 0)throw console.log("node must has id:",i),new Error("node must has option[id]:");i.isShow!==void 0&&(i.hidden=!i.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),i.isHide!==void 0&&(i.hidden=i.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead."));const t={id:i.id,text:i.text!==void 0?i.text:"",type:i.type!==void 0?i.type:"node",targetType:i.targetType!==void 0?i.targetType:B.Node,expanded:i.expanded!==void 0?i.expanded:!0,selected:i.selected!==void 0?i.selected:!1,dragging:!1,className:i.className!==void 0?i.className:"",nodeShape:i.nodeShape!==void 0?i.nodeShape:1,borderWidth:i.borderWidth!==void 0?i.borderWidth:void 0,borderRadius:i.borderRadius!==void 0?i.borderRadius:void 0,borderColor:i.borderColor!==void 0?i.borderColor:void 0,fontColor:i.fontColor!==void 0?i.fontColor:void 0,fontSize:i.fontSize!==void 0?i.fontSize:void 0,color:i.color!==void 0?i.color:void 0,opacity:i.opacity!==void 0?i.opacity:void 0,fixed:i.fixed!==void 0?i.fixed:!1,width:i.width!==void 0?i.width:void 0,height:i.height!==void 0?i.height:void 0,force_weight:i.force_weight,x:i.x!==void 0?i.x:0,y:i.y!==void 0?i.y:0,Fx:0,Fy:0,expandHolderPosition:i.expandHolderPosition!==void 0?i.expandHolderPosition:void 0,disablePointEvent:i.disablePointEvent!==void 0?i.disablePointEvent:void 0,disableDrag:i.disableDrag!==void 0?i.disableDrag:!1,hidden:i.hidden!==void 0?i.hidden:!1,rgCalcedVisible:!0,rgShouldRender:!0,zIndex:i.zIndex||0,data:i.data!==void 0?i.data:{}};return t.lot={childs:[],parent:void 0,eached:!1,strength:0},t.el={offsetWidth:((e=i.el)==null?void 0:e.offsetWidth)||50,offsetHeight:((n=i.el)==null?void 0:n.offsetHeight)||50},t.width&&(t.el.offsetWidth=t.width),t.height&&(t.el.offsetHeight=t.height),t},Xe=["Fx","Fy","appended","dragging","el","targetFrom","targetNodes","targetTo","lot","seeks_id","shouldRender","rgCalcedVisible","rgShouldRender","origin_x","origin_y","selected"],Lt=i=>{if(!i)return;const a={};return Object.keys(i).forEach(t=>{if(!Xe.includes(t)){const e=i[t];e!==void 0&&(t==="offset_x"&&e===0||t==="offset_y"&&e===0||t==="zIndex"&&e===0||t==="fixed"&&e===!1||t==="className"&&e===""||t==="hidden"&&e===!1||t==="disableDrag"&&e===!1||t==="expanded"&&e===!0||t==="opacity"&&e===1||t==="type"&&e==="node"||t==="targetType"&&e===B.Node||t==="data"&&(!e||Object.keys(e).length===0)||(a[t]=e))}}),a},Fe={json2Node:Ct,transNodeToJson:Lt},He=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:Bt,json2Node:Ct,transNodeToJson:Lt,default:Fe},Symbol.toStringTag,{value:"Module"}));let yt={x:0,y:0};const mt={x:0,y:0},nt={x:0,y:0};let Dt,kt;const Rt=i=>{const a={clientX:0,clientY:0};if(it(i)){const t=i.touches||i.targetTouches;if(!t)throw new Error("error targetTouches");a.clientX=t[0].clientX,a.clientY=t[0].clientY}else a.clientX=i.clientX,a.clientY=i.clientY;return a},W={startDrag(i,a,t,e){e?Dt=(n,o,s)=>{const r=n-nt.x,l=o-nt.y;e(r,l,mt,nt,s)}:Dt=(n,o)=>{yt.x=mt.x+(n-nt.x),yt.y=mt.y+(o-nt.y)},kt=t,yt=a,mt.x=yt.x,mt.y=yt.y;try{const n=Rt(i);nt.x=n.clientX,nt.y=n.clientY,it(i)?(document.body.addEventListener("touchmove",W.onNodeMove),document.body.addEventListener("touchend",W.onNodeDragend),document.body.addEventListener("mousemove",W.onNodeMove),document.body.addEventListener("mouseup",W.onNodeDragend),i.preventDefault()):(document.body.addEventListener("mousemove",W.onNodeMove),document.body.addEventListener("mouseup",W.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(i){const a=Rt(i);Dt(a.clientX,a.clientY,i)},onNodeDragend(i){if(it(i)?(document.body.removeEventListener("touchmove",W.onNodeMove),document.body.removeEventListener("touchend",W.onNodeDragend),document.body.removeEventListener("mousemove",W.onNodeMove),document.body.removeEventListener("mouseup",W.onNodeDragend)):(document.body.removeEventListener("mousemove",W.onNodeMove),document.body.removeEventListener("mouseup",W.onNodeDragend)),kt){const a=Rt(i),t=a.clientX,e=a.clientY,n=t-nt.x,o=e-nt.y;kt(n,o,i)}}},ct=i=>{if(i.from===void 0)throw console.log("error,line must has option[from](nodeId):",i),new Error("error,line must has option[from]:");if(i.to===void 0)throw console.log("error,line must has option[to](nodeId):",i),new Error("error,line must has option[to]:");if(typeof i.from!="string")throw console.log("error line from, must be string(nodeId):",i),new TypeError("error line from, must be string:");if(typeof i.to!="string")throw console.log("error line to, must be string(nodeId):",i),new TypeError("error line to, must be string:");return i.isShow!==void 0&&(i.hidden=!i.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),i.isHide!==void 0&&(i.hidden=i.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),i.placeText!==void 0&&(i.onPathStartOffset=i.placeText,console.warn("[relation-graph Warning] line option[placeText] is deprecated, please use [onPathStartOffset] instead.")),{id:i.id,from:i.from,to:i.to,type:i.type!==void 0?i.type:"line",isFakeLine:i.isFakeLine!==void 0?i.isFakeLine:!1,fromType:i.fromType!==void 0?i.fromType:i.isFakeLine?B.CanvasPoint:B.Node,toType:i.toType!==void 0?i.toType:i.isFakeLine?B.CanvasPoint:B.Node,selected:!1,text:i.text!==void 0?i.text:"",textOffset_x:i.textOffset_x!==void 0?i.textOffset_x:void 0,textOffset_y:i.textOffset_y!==void 0?i.textOffset_y:void 0,color:i.color!==void 0?i.color:void 0,opacity:i.opacity!==void 0?i.opacity:void 0,fontSize:i.fontSize!==void 0?i.fontSize:void 0,fontColor:i.fontColor!==void 0?i.fontColor:void 0,lineWidth:i.lineWidth!==void 0?i.lineWidth:void 0,lineShape:i.lineShape!==void 0?i.lineShape:void 0,className:i.className!==void 0?i.className:void 0,animation:i.animation!==void 0?i.animation:0,dashType:i.dashType!==void 0?i.dashType:0,disablePointEvent:i.disablePointEvent!==void 0?i.disablePointEvent:!1,showStartArrow:i.showStartArrow!==void 0?i.showStartArrow:!1,showEndArrow:i.showEndArrow!==void 0?i.showEndArrow:!0,useTextPath:i.useTextPath!==void 0?i.useTextPath:void 0,onPathStartOffset:i.onPathStartOffset!==void 0?i.onPathStartOffset:void 0,startMarkerId:i.startMarkerId||"",endMarkerId:i.endMarkerId||"",textAnchor:i.textAnchor!==void 0?i.textAnchor:void 0,junctionOffset:i.junctionOffset,fromJunctionPoint:i.fromJunctionPoint,toJunctionPoint:i.toJunctionPoint,fromJuctionPointOffsetX:i.fromJuctionPointOffsetX||0,fromJuctionPointOffsetY:i.fromJuctionPointOffsetY||0,toJuctionPointOffsetX:i.toJuctionPointOffsetX||0,toJuctionPointOffsetY:i.toJuctionPointOffsetY||0,lineRadius:i.lineRadius,force_elastic:i.force_elastic,polyLineStartDistance:i.polyLineStartDistance,ctrlPointsFor49:i.ctrlPointsFor49,ctrlPointsFor44:i.ctrlPointsFor44,ctrlPoints:i.ctrlPoints,lineDirection:i.lineDirection!==void 0?i.lineDirection:void 0,reverseText:i.reverseText!==void 0?i.reverseText:void 0,forDisplayOnly:i.forDisplayOnly||i.from===i.to,hidden:i.hidden!==void 0?i.hidden:!1,cssVars:i.cssVars!==void 0?i.cssVars:void 0,data:i.data!==void 0?i.data:{}}},$e=["arrow","reverseText","isReverse","selected","shouldRender","rgCalcedVisible"],Xt=i=>{if(!i)return;const a={};return Object.keys(i).forEach(t=>{if(!$e.includes(t)){const e=i[t];e!==void 0&&(t==="isFakeLine"&&e===!1||t==="fromType"&&e===B.Node||t==="toType"&&e===B.Node||t==="animation"&&e===0||t==="dashType"&&e===0||t==="disablePointEvent"&&e===!1||t==="showStartArrow"&&e===!1||t==="showEndArrow"&&e===!0||t==="startMarkerId"&&e===""||t==="endMarkerId"&&e===""||t==="forDisplayOnly"&&e===!1||t==="fromJuctionPointOffsetX"&&e===0||t==="fromJuctionPointOffsetY"&&e===0||t==="toJuctionPointOffsetX"&&e===0||t==="toJuctionPointOffsetY"&&e===0||t==="opacity"&&e===1||t==="hidden"&&e===!1||t==="data"&&(!e||Object.keys(e).length===0)||(a[t]=i[t]))}}),a},wt=(i,a)=>{if(!i)return;const t=Xt(i.line);t&&a.push(t)},Ge={json2Line:ct,transLinkToJson:wt},je=Object.freeze(Object.defineProperty({__proto__:null,json2Line:ct,transLineToJson:Xt,transLinkToJson:wt,default:Ge},Symbol.toStringTag,{value:"Module"}));function Ye(i,a,t,e,n,o,s,r,l){const c=n-i,h=o-a,d=Math.sqrt(c*c+h*h);if(d===0)return{x:i,y:a};const f=l*h/d,p=-(l*c)/d,u=i+f,g=a+p,x=i-t/2,y=i+t/2,L=a-e/2,m=a+e/2;let w=[];if(c!==0){let N=(x-u)/c,O=g+N*h;O>=L&&O<=m&&w.push({x,y:O});let E=(y-u)/c,T=g+E*h;T>=L&&T<=m&&w.push({x:y,y:T})}if(h!==0){let N=(L-g)/h,O=u+N*c;O>=x&&O<=y&&w.push({x:O,y:L});let E=(m-g)/h,T=u+E*c;T>=x&&T<=y&&w.push({x:T,y:m})}if(w.length===0&&c===0&&h===0)return{x:u,y:g};let b=null,M=1/0;return w.forEach(N=>{const O=Math.sqrt((N.x-n)**2+(N.y-o)**2);O<M&&(M=O,b=N)}),b}const Z={getRectPoint(i,a,t,e,n,o,s,r,l=!1,c=1,h=0,d=14,f=!1){const p=i+n/2,u=a+o/2,g=t+s/2,x=e+r/2;if(c>1){const E=Math.min(d,n,o),T=-E/2,D=E/(c-1),R=l&&f||!l&&!f?T*-1-h*D:T+h*D,_=Ye(p,u,n,o,g,x,s,r,R);if(_)return _}const y=p<g?1:-1,L=u<x?1:-1;if(x===u)return{x:p+y*n/2,y:u};const m=Math.abs((g-p)/(x-u)),w=n/o;let b=0,M=0;m<w?(b=y*o/2*m,M=L*o/2):(b=y*n/2,M=L*n/2/m);const N=p+b,O=u+M;return{x:N,y:O}},getRectPointBasic(i,a,t,e,n,o,s,r){const l=i+n/2,c=a+o/2,h=t+s/2,d=e+r/2;let f=d===c?0:(h-l)/(d-c);f===0&&d===c&&h===l?f=1:f===0&&(f=(h-l)/(d-c+(d>c?-1:1)*1e-4));const p=n/o;let u=0,g=0,x="1";return Math.abs(f)<p?(x="2",c<=d?(g=o/2,u=g*f):(g=-o/2,u=g*f)):(x="3",l<=h?(u=n/2,g=f===0&&h===l?0:u/f):(u=-n/2,g=f===0&&h===l?0:u/f)),{x:l+u,y:c+g,_case:x}},getRectJoinPoint(i){const{from_x:a,from_y:t,to_x:e,to_y:n,f_W:o,f_H:s,t_W:r,t_H:l}=i,c=a+o/2,h=t+s/2,d=e+r/2,f=n+l/2,p=Math.atan2(f-h,d-c)*180/Math.PI,u=p<0?p+360:p;return u>45&&u<=135?{x:a+o+5,y:t+s/2}:u>135&&u<=225?{x:a+o/2,y:t+s+5}:u>225&&u<=315?{x:a-5,y:t+s/2}:{x:a+o/2,y:t-5}},getRectHJoinPoint(i){const{from_x:a,from_y:t,to_x:e,f_W:n,f_H:o,t_W:s}=i,r=o/2;return a+n<e?{x:a+n+5,y:t+r}:{x:a-5,y:t+r}},getRectLeftJoinPoint(i){const{from_x:a,from_y:t,f_H:e}=i;return{x:a,y:t+e/2}},getRectRightJoinPoint(i){const{from_x:a,from_y:t,f_W:e,f_H:n}=i;return{x:a+e,y:t+n/2}},getRectTopJoinPoint(i){const{from_x:a,from_y:t,f_W:e}=i;return{x:a+e/2,y:t}},getRectBottomJoinPoint(i){const{from_x:a,from_y:t,f_W:e,f_H:n}=i;return{x:a+e/2,y:t+n}},getRectHorizontalLineJoinPoint(i){const{from_x:a,from_y:t,f_W:e,f_H:n,to_x:o,t_W:s}=i;return{x:o+s/2,y:t+n/2}},getRectVJoinPoint(i){const{from_x:a,from_y:t,to_y:e,f_W:n,f_H:o,t_H:s}=i,r=n/2;return t+o<e?{y:t+o+5,x:a+r}:{y:t-5,x:a+r}},getBorderPoint(i,a,t,e,n,o,s,r,l){return l===0?this.getCirclePoint(i,a,t,e,n,o,s,r):this.getRectPoint(i,a,t,e,n,o,s,r)},getBorderPoint4MultiLine(i){const{from_x:a,from_y:t,to_x:e,to_y:n,f_W:o,f_H:s,t_W:r,t_H:l,nodeShape:c,isReverse:h=!1,isEndPoint:d,totalLinesBetweenNodes:f=1,currentLineIndex:p=0,lineDistance:u=50}=i;return c===0?this.getCirclePoint4MultiLine(a,t,e,n,o,s,r,l,h,f,p,u,d):this.getRectPoint(a,t,e,n,o,s,r,l,h,f,p,u,d)},getCirclePoint(i,a,t,e,n,o,s,r){const l=t+s/2,c=e+r/2,h=i+n/2,d=a+o/2,f=l-h;if(f===0)return{x:h,y:d-o/2*(c<d?1:-1)};const u=(c-d)/f,g=Math.sqrt(1/(1/(n/2)**2+u**2/(o/2)**2))*(l<h?1:-1),x=u*g;return{x:h-g,y:d-x}},getCirclePoint4MultiLine(i,a,t,e,n,o,s,r,l,c,h,d,f){let p=t+s/2;const u=e+r/2;let g=i+n/2;const x=a+o/2;let y=p-g;y>-1&&y<1&&(p=p-.5,g=g+.5,y=-1);let m=0;if(c>1){const R=Math.min(d,n,o),_=-R/2,z=R/(c-1);m=l&&f||!l&&!f?_*-1-h*z:_+h*z}const w=u-x,b=Math.sqrt(y**2+w**2)*m/y,M=w/y,N=n/2,O=o/2,E=g<p?-1:1,T=(-1*N**2*M*b+N*O*Math.sqrt(Math.abs(O**2+M**2*N**2-b**2))/E)/(O**2+N**2*M**2),D=M*T+b;return{x:g-T,y:x-D}},getCirclePointBasic(i,a,t,e,n,o,s,r,l){const c=i+n/2,h=a+o/2,d=t+s/2,f=e+r/2,p=d-c,u=f-h,g=Math.sqrt(p*p+u*u),x=g-l,y=x*p/g*-1,L=x*u/g*-1;return{x:d+y,y:f+L}},getCirclePointPlus(i,a,t,e,n,o,s,r){const l=i+n/2,c=a+o/2,h=t+s/2,d=e+r/2,f=h-l,p=d-c,u=Math.sqrt(f*f+p*p),g=(u-n/2)*f/u*-1,x=(u-o/2)*p/u*-1;return{x:h+g,y:d+x}},getOvalPoint(i,a,t,e,n,o=180){const s=e*(360/n),r=(180-o+s)*Math.PI/180;return{x:i+t*Math.sin(r),y:a+t*Math.cos(r)*-1}},getAngleType(i,a){if(i>=0&&a>=0)return 1;if(i<0&&a>=0)return 2;if(i<0&&a<0)return 3;if(i>=0&&a<0)return 4},getTextAngle(i,a,t,e){let n=Math.atan2(e-a,t-i)*180/Math.PI;return n<0&&(n+=360),n>90&&n<=270&&(n+=180),n>=360&&(n-=360),Math.round(n)}},dt=(i,a,t,e)=>{const n=i-t,o=a-e;return Math.sqrt(n**2+o**2)};class pt{constructor(a,t,e){S(this,"graphOptions");S(this,"layoutOptions");S(this,"graphInstance");S(this,"allNodes",[]);S(this,"isMainLayouer",!0);S(this,"requireLinks",!1);S(this,"allLinks",[]);S(this,"rootNode");this.layoutOptions=a,this.graphOptions=t,this.graphInstance=e}setLinks(a){v("setLinks:",a.length),this.allLinks=a}placeNodes(a,t){this.allNodes=a,this.rootNode=t}doLayout(a,t){this.placeNodes(a,t)}analysisNodes(a,t,e,n){t.length>n.max_length&&(n.max_length=t.length),e>n.max_deep&&(n.max_deep=e);const o={level:e,all_size:t.length,all_strength:0};e===0&&t.forEach(r=>{r.lot.parent=void 0});const s=[];for(const r of t){a.includes(r)||(r.lot.level=e,a.push(r));for(const l of this.graphInstance.getNodeRelatedNodes(r))a.includes(l)||(a.push(l),l.lot.parent=r,r.lot.childs.push(l),s.push(l))}o.all_strength>n.max_strength&&(n.max_strength=o.all_strength),s.length>0&&this.analysisNodes(a,s,e+1,n)}generateCalcNodes(a){const t=[],e=new Map;for(const n of a){const o={rgNode:n,x:n.x,y:n.y,width:n.el.offsetWidth,height:n.el.offsetHeight};t.push(o),e.set(n.id,o)}return{calcNodes:t,calcNodeMap:e}}generateLevels(a){const t=[],e=new Map;for(const n of a){if(!n.lot||typeof n.lot.level!="number")continue;const o=n.lot.level;t.includes(o)||(t.push(o),e.set(o,[])),e.get(o).push(n)}return t.sort((n,o)=>n-o),{levels:t,levelNodesMap:e}}adjustNodePositions(a,t,e){if(!a||a.length===0)return[];for(let n=1;n<a.length;n++){const o=a[n],s=a[n-1];switch(t){case"right":o.x<s.x+s.width+e&&(o.x=s.x+s.width+e);break;case"left":o.x+o.width>s.x-e&&(o.x=s.x-o.width-e);break;case"bottom":o.y<s.y+s.height+e&&(o.y=s.y+s.height+e);break;case"top":o.y+o.height>s.y-e&&(o.y=s.y-o.height-e);break}}return a}getReverseAlignItems(a){return We[a]}}const We={start:"end",end:"start",center:"center"};class ut extends pt{constructor(t,e,n){super(t,e,n);S(this,"layoutOptions");S(this,"fastStart",!1);S(this,"skipInitLayout",!1);S(this,"maxLayoutTimes",300);S(this,"byNode",!0);S(this,"byLine",!0);S(this,"lockX",!1);S(this,"lockY",!1);S(this,"force_node_repulsion",1);S(this,"force_line_elastic",1);S(this,"stopWhenBalanced",!1);S(this,"calcNodes",[]);S(this,"_graphEventHandler");S(this,"layoutTimes",0);S(this,"prev10",[]);S(this,"visibleNodes",[]);S(this,"_onFinishCallback");S(this,"_onTickCallback");S(this,"calcNodeMap",new WeakMap);S(this,"forCalcNodes",[]);S(this,"recentGraphVelocity",[]);S(this,"graphVelocityBalancedValue",.1);S(this,"animationFrameTimer",0);S(this,"prevNodeLevel1Index",0);S(this,"prevNodeLevel2Index",0);S(this,"maxVaildLineLength",300);S(this,"minVaildLineLength",30);S(this,"zeroEffectNodeDistance",400);S(this,"minNodeDistance",30);S(this,"maxMoveSpeed",100);S(this,"n2nMaxForce",50);this.layoutOptions=t,this.layoutOptions.fastStart!==void 0&&(this.fastStart=this.layoutOptions.fastStart),this.layoutOptions.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=this.layoutOptions.maxLayoutTimes),this.layoutOptions.byNode!==void 0&&(this.byNode=this.layoutOptions.byNode),this.layoutOptions.byLine!==void 0&&(this.byLine=this.layoutOptions.byLine),this.layoutOptions.force_node_repulsion!==void 0&&(this.force_node_repulsion=this.layoutOptions.force_node_repulsion),this.layoutOptions.force_line_elastic!==void 0&&(this.force_line_elastic=this.layoutOptions.force_line_elastic),this.layoutOptions.force_x_coefficient===void 0&&(this.layoutOptions.force_x_coefficient=1),this.layoutOptions.force_y_coefficient===void 0&&(this.layoutOptions.force_y_coefficient=1),this.layoutOptions.disableLiveChanges===void 0&&(this.layoutOptions.disableLiveChanges=!1),this.layoutOptions.stopWhenBalanced&&(this.stopWhenBalanced=!0),this.layoutOptions.skipInitLayout!==void 0&&(this.skipInitLayout=this.layoutOptions.skipInitLayout),this.requireLinks=!0}placeNodes(t,e){if(v("!!!RGForceLayouter.placeNodes"),this.calcNodes=t,this.allNodes.length===0&&(this.allNodes=t),this.rootNode=e,this.fastStart)v("!!!initNodesPosition fastStart"),this.calcNodes.forEach(n=>{n.fixed!==!0&&((!n.lot||!n.lot.placed)&&((Number.isNaN(n.x)||n.x===void 0)&&(n.x=Math.floor(Math.random()*200)-100),(Number.isNaN(n.y)||n.y===void 0)&&(n.y=Math.floor(Math.random()*200)-100),n!==e&&n.x===0&&n.y===0&&(n.x=Math.floor(Math.random()*200)-100,n.y=Math.floor(Math.random()*200)-100)),n.lot.placed=!0)});else if(!this.skipInitLayout){if(v("!!!initNodesPosition....."),e){v("layout by root:",e),(Number.isNaN(e.x)||e.x===void 0)&&(e.x=0,e.y=0);const n=this.easyAnalysisNodes(e);e.fixed||this.layoutOptions.fixedRootNode||(e.x=0,e.y=0);const o=this.layoutOptions.centerOffset_x||0,s=this.layoutOptions.centerOffset_y||0,r=A.getNodeLotXY({alignItemsX:"center",alignItemsY:"center"},e);e.lot.x=r.x+o,e.lot.y=r.y+s,this.easyPlaceRelativePosition(e,n),v("!!!initNodesPosition fixedRootNode:2:",e.x,e.y),n.forEach(l=>{l.fixed!==!0&&(!l.rgCalcedVisible||l!==e&&(l.x=l.lot.x-A.getNodeWidth(l)/2,l.y=l.lot.y-A.getNodeHeight(l)/2,l.lot.placed=!0))})}}if(this.allNodes.forEach(n=>{(Number.isNaN(n.x)||n.x===void 0)&&(n.x=0),(Number.isNaN(n.y)||n.y===void 0)&&(n.y=0)}),v("Start Auto Layout....."),this.updateVisibleNodes(),this.isMainLayouer&&this.layoutOptions.autoLayouting){v("!!!autoLayouting.....");return}this.start()}easyAnalysisNodes(t){this.allNodes.forEach(o=>{o.lot.eached=!1,o.lot.notLeafNode=!1,o.lot.childs=[],o.lot.parent=void 0,o.lot.index_of_parent=0,o.lot.strength=0,o.lot.placed=!1});const e=[],n={max_deep:1,max_length:1,max_strength:1};return this.analysisNodes4Didirectional(e,[t],0,n,0),e}easyPlaceRelativePosition(t,e){e.forEach(o=>{if(o.lot.subling.level===1){const s=o.lot.subling;if(s){const r=Z.getOvalPoint(t.lot.x,t.lot.y,s.level*50,o.lot.strength_plus-o.lot.strength/2,s.all_strength,this.layoutOptions.startAngle);o.lot.x=r.x,o.lot.y=r.y}}}),e.forEach(o=>{const s=o.lot.subling;if(s&&s.level>1){const r=o.lot.parent.lot.strength_plus-o.lot.parent.lot.strength,c=(o.lot.parent.lot.strength_plus-r)/(o.lot.parent.lot.childs.length+1)*(o.lot.index_of_parent+1),h=Z.getOvalPoint(t.lot.x,t.lot.y,(s.level-1)*(100+(s.level-1)*60)+50,r+c,o.lot.parent.lot.subling.all_strength,this.layoutOptions.startAngle);o.lot.x=h.x,o.lot.y=h.y}})}graphEventHandle(t,...e){if(t===I.onNodeDragStart){const n=e[0],o=this.calcNodeMap.get(n);o&&(o.dragging=!0)}else if(t===I.onNodeDragging){const n=e[0],o=e[1],s=e[2],r=this.calcNodeMap.get(n);r&&(r.x=o,r.y=s)}else if(t===I.onNodeDragEnd){const n=e[0],o=this.calcNodeMap.get(n);o&&(o.dragging=!1)}}connectToGraphInstance(){this._graphEventHandler=this.graphEventHandle.bind(this),this.graphInstance.addEventHandler(this._graphEventHandler)}disConnectToGraphInstance(){this.graphInstance.removeEventHandler(this._graphEventHandler)}updateVisibleNodes(t){this.visibleNodes=[],t&&(this.allNodes=t),this.allNodes.forEach(e=>{e.lot?e.lot.placed=!0:(v("node miss lot:",e.text),e.lot={x:e.x,y:e.y,placed:!0,childs:[]}),this.visibleNodes.push(e)}),this.resetCalcNodes(),v("visibleNodes:",this.visibleNodes.length)}viewUpdate(){this.graphInstance&&this.graphInstance.dataUpdated()}autoLayout(t=!1){this.layoutTimes=0,this.updateVisibleNodes(),v("Layout set viewUpdate:",this.viewUpdate),this.isMainLayouer&&(this.layoutOptions.autoLayouting=!0),this.doForceLayout(0)}onFinish(t){this._onFinishCallback=t}onTick(t){this._onTickCallback=t}applyFBuffToNodes(){for(const t of this.forCalcNodes)this.applyToNodePosition(t)}applyPositionToNodes(){this.visibleNodes.forEach(t=>{if(t.fixed)return;const e=this.calcNodeMap.get(t);e&&(t.x=e.x,t.y=e.y)}),this.viewUpdate()}layoutFinished(){cancelAnimationFrame(this.animationFrameTimer),this.isMainLayouer&&(this.layoutOptions.autoLayouting=!1),v("Layout finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(t){console.error(t)}}resetCalcNodes(){v("resetCalcNodes:",this.visibleNodes.length),this.forCalcNodes=[],this.calcNodeMap=new WeakMap,this.visibleNodes.forEach(t=>{const e={rgNode:t,Fx:0,Fy:0,x:t.x,y:t.y,dragging:t.dragging||!1,force_weight:t.force_weight||1,forceCenterOffset_X:(t.width||t.el.offsetWidth||60)/2,forceCenterOffset_Y:(t.height||t.el.offsetHeight||60)/2,fixed:t.fixed||!1};this.forCalcNodes.push(e),this.calcNodeMap.set(t,e)})}start(){if(this.layoutOptions.autoLayouting){v("stop layout:already autoLayouting");return}this.connectToGraphInstance(),this.autoLayout(!0)}doForceLayout(t){if(this.graphOptions.instanceDestroyed){v("stop layout:instanceDestroyed"),this.layoutFinished();return}let e="0";t>0?(this.prev10.length>=10&&(this.prev10.splice(0,1),e=(1e3/((this.prev10[this.prev10.length-1]-this.prev10[0])/10)).toFixed(1)),this.prev10.push(t)):this.visibleNodes.length===0&&this.updateVisibleNodes(),this.layoutTimes++,this.calcNodesPosition(),this.applyFBuffToNodes(),this._onTickCallback&&this._onTickCallback(),this.layoutOptions.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),v("this.layoutTimes:",this.layoutTimes,"of",this.maxLayoutTimes,"Current refresh rate:",e,"Hz",this.visibleNodes.length),this.layoutTimes<=this.maxLayoutTimes?this.animationFrameTimer=requestAnimationFrame(this.doForceLayout.bind(this)):this.layoutFinished()}calcNodesPosition(){if(this.byNode)for(let t=this.prevNodeLevel1Index;t<this.forCalcNodes.length;t++){const e=this.forCalcNodes[t];if(!e.dragging&&!e.fixed){for(let n=this.prevNodeLevel2Index;n<this.forCalcNodes.length;n++)if(t!==n){const o=this.forCalcNodes[n];if(o.dragging)continue;this.addGravityByNode(e,o)}}}if(this.byLine){if(this.allLinks&&this.allLinks.length>0){for(const t of this.allLinks)if(!t.forDisplayOnly){let e=t.line.force_elastic===void 0?1:t.line.force_elastic;if(this.visibleNodes.includes(t.fromNode)&&this.visibleNodes.includes(t.toNode)){const n=this.calcNodeMap.get(t.fromNode),o=this.calcNodeMap.get(t.toNode);this.addElasticByLine(n,o,e)}}}else for(const t of this.visibleNodes)if(t.lot&&t.lot.parent){const e=this.calcNodeMap.get(t.lot.parent),n=this.calcNodeMap.get(t);this.addElasticByLine(e,n,1)}}return!0}stop(){v("[RGForceLayouter]stop:",this.layoutOptions.autoLayouting),this.layoutTimes=Number.MAX_VALUE,this.layoutFinished()}addElasticByLine(t,e,n=1){const o=t.x,s=t.y,r=e.x,l=e.y;let c=Math.sqrt((s-l)**2+(o-r)**2);if(c<this.minVaildLineLength)return;c>this.maxVaildLineLength&&(c=this.maxVaildLineLength);const h=(c-this.minVaildLineLength)*.05*this.force_line_elastic*n,d=h,f=h,p=(o-r)/c,u=(s-l)/c;this.addFtoNode(t,p*d*-1,u*d*-1),this.addFtoNode(e,p*f,u*f)}addGravityByNode(t,e,n=1){const o=t.x,s=t.y,r=e.x,l=e.y;if(n===1&&(Math.abs(o-r)>this.zeroEffectNodeDistance||Math.abs(s-l)>this.zeroEffectNodeDistance))return;const c=Math.sqrt((s-l)**2+(o-r)**2);if(n===1&&c>this.zeroEffectNodeDistance)return;let h=(this.zeroEffectNodeDistance-c)*.05*this.force_node_repulsion*n;c<this.minNodeDistance&&(h=h*2);const d=(o-r)/c,f=(s-l)/c;this.addFtoNode(t,d*h,f*h)}addFtoNode(t,e,n){if(t.fixed||t.dragging||Number.isNaN(e)||Number.isNaN(n))return;e>this.n2nMaxForce&&(e=this.n2nMaxForce),n>this.n2nMaxForce&&(n=this.n2nMaxForce),e<-this.n2nMaxForce&&(e=-this.n2nMaxForce),n<-this.n2nMaxForce&&(n=-this.n2nMaxForce);const o=t.force_weight||1;this.lockX||(t.Fx+=e*(1/o)),this.lockY||(t.Fy+=n*(1/o))}applyToNodePosition(t){if(t.fixed)return 0;if(t.dragging){const o=t.rgNode;return o.x=t.x,o.y=t.y,0}if(this.calcNodes!==this.allNodes&&!this.calcNodes.includes(t.rgNode))return 0;let e=t.Fx,n=t.Fy;if(e>this.maxMoveSpeed&&(e=this.maxMoveSpeed),n>this.maxMoveSpeed&&(n=this.maxMoveSpeed),e<-this.maxMoveSpeed&&(e=-this.maxMoveSpeed),n<-this.maxMoveSpeed&&(n=-this.maxMoveSpeed),t.x=t.x+e*this.layoutOptions.force_x_coefficient,t.y=t.y+n*this.layoutOptions.force_y_coefficient,!this.layoutOptions.disableLiveChanges){const o=t.rgNode;o.x=t.x,o.y=t.y}t.Fx=0,t.Fy=0}analysisNodes4Didirectional(t,e,n,o,s){e.length>o.max_length&&(o.max_length=e.length),n>o.max_deep&&(o.max_deep=n);const r={level:n,all_size:e.length,all_strength:0},l=[];e.forEach(h=>{h.lot||(h.lot={childs:[]}),h.lot.eached=!0,h.lot.subling=r,h.lot.level=n,t.push(h)});let c=0;e.forEach(h=>{let d=0;if(s===0){let f=0;this.graphInstance.getNodeRelatedNodes(h).forEach(p=>{p.lot||(p.lot={eached:!1,childs:[]}),p.lot.eached||(p.rgCalcedVisible?(p.lot.eached=!0,p.lot.parent=h,p.lot.index_of_parent=f++,h.lot.childs.push(p),l.push(p),d++):h.lot.childs.push(p))})}else if(s===-1){let f=0;this.graphInstance.getNodeRelatedNodes4From(h).forEach(p=>{p.lot||(p.lot={eached:!1,childs:[]}),p.lot.eached||(p.rgCalcedVisible?(p.lot.eached=!0,p.lot.parent=h,p.lot.index_of_parent=f++,h.lot.childs.push(p),l.push(p),d++):h.lot.childs.push(p))})}else{let f=0;this.graphInstance.getNodeRelatedNodes4To(h).forEach(p=>{p.lot||(p.lot={eached:!1,childs:[]}),p.lot.eached||(p.rgCalcedVisible?(p.lot.eached=!0,p.lot.parent=h,p.lot.index_of_parent=f++,h.lot.childs.push(p),l.push(p),d++):h.lot.childs.push(p))})}h.lot.strength=d>0?d:1,r.all_strength+=h.lot.strength,h.lot.strength_plus=r.all_strength,h.lot.index_of_level=c,h.lot.childs_size=d,c++}),r.all_strength>o.max_strength&&(o.max_strength=r.all_strength),l.length>0?this.analysisNodes4Didirectional(t,l,n+(s===-1?-1:1),o,s):(t.forEach(h=>{h.lot.childs_size>0&&(h.lot.strengthWithChilds=0)}),t.forEach(h=>{h.lot.childs_size===0&&(h.lot.strengthWithChilds=1,A.conductStrengthToParents(h))}),A.analysisDataTree([t[0]],0,s))}}class fe extends pt{constructor(t,e,n){super(t,e,n);S(this,"enableGatherNodes",!1);S(this,"layoutOptions");this.layoutOptions=t,v("new RGTreeLayouter:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const o=this.layoutOptions.from;console.log("this.layoutOptions.alignItemsX:1:",this.layoutOptions.alignItemsX),o==="top"||o==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),o==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):o==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):o==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const s=this.layoutOptions.layoutExpansionDirection,r=s==="start"||s==="left"||s==="top"?"start":s==="end"||s==="right"||s==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps or treeNodeGapH,treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes}analysisNodes4Didirectional(t,e,n,o,s){v(`${s} level ${n} size: ${e.length}`),e.length>o.max_length&&(o.max_length=e.length),n>o.max_deep&&(o.max_deep=n);const r={level:n,all_size:e.length,all_strength:0},l=[];e.forEach(h=>{h.lot||(h.lot={childs:[]}),h.lot.eached=!0,h.lot.subling=r,h.lot.level=n,t.push(h)});let c=0;e.forEach(h=>{let d=0,f;n===0?s===-1?f=this.graphInstance.getNodeRelatedNodes4From(h):s===1?f=this.graphInstance.getNodeRelatedNodes4To(h):f=this.graphInstance.getNodeRelatedNodes(h):f=this.graphInstance.getNodeRelatedNodes(h);let p=0;f.forEach(u=>{u.lot||(u.lot={eached:!1,childs:[]}),u.lot.eached||(u.lot.parent=h,A.isVisibleNode(u)?(u.lot.eached=!0,u.lot.index_of_parent=p++,h.lot.childs.push(u),l.push(u),d++):h.lot.childs.push(u))}),h.lot.strength=d>0?d:1,r.all_strength+=h.lot.strength,h.lot.strength_plus=r.all_strength,h.lot.index_of_level=c,h.lot.childs_size=d,c++}),r.all_strength>o.max_strength&&(o.max_strength=r.all_strength),l.length>0?this.analysisNodes4Didirectional(t,l,n+(s===-1?-1:1),o,s):(t.forEach(h=>{h.lot.childs_size>0&&(h.lot.strengthWithChilds=0)}),t.forEach(h=>{h.lot.childs_size===0&&(h.lot.strengthWithChilds=1,A.conductStrengthToParents(h))}),A.analysisDataTree([t[0]],0,s===-1?-1:1))}placeNodes(t,e){if(console.log("tree:placeNodes:rootNode",e.id,e),v("RGTreeLayouter:placeNodes"),e)v("layout by root:",e);else{console.error("root is null");return}v("allNodes:",t.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};this.rootNode=e;let s=[];this.allNodes&&this.allNodes.length>0?(s.push(this.rootNode),A.getDescendantNodes(this.rootNode,s),v("groupNodes:1:",s.length)):s=t,s.forEach(d=>{d.lot.eached=!1,d.lot.notLeafNode=!1,d.lot.childs=[],d.lot.parent=void 0,d.lot.index_of_parent=0,d.lot.strength=0,d.lot.strengthWithChilds_from=0,d.lot.strengthWithChilds=0,d.lot.placed=!1}),this.allNodes=t;let r={max_deep:1,max_length:1,max_strength:1};s=[],this.analysisNodes(s,[this.rootNode],0,r),s.forEach(d=>{d.lot.eached=!1,d.lot.notLeafNode=!1,d.lot.childs=[],d.lot.index_of_parent=0,d.lot.strength=0,d.lot.strengthWithChilds_from=0,d.lot.strengthWithChilds=0,d.lot.placed=!1}),e.fixed||this.layoutOptions.fixedRootNode||(e.x=0,e.y=0);const l=this.layoutOptions.centerOffset_x||0,c=this.layoutOptions.centerOffset_y||0,h=A.getNodeLotXY(n,e);e.lot.x=h.x+l,e.lot.y=h.y+c,v("groupNodes:2:",s.length,s.map(d=>d.text).join(",")),s=[],r={max_deep:1,max_length:1,max_strength:1},this.layoutOptions.simpleTree===!0?(this.analysisNodes4Didirectional(s,[this.rootNode],0,r,0),this.placeNodesPosition(this.rootNode,s,r)):(this.analysisNodes4Didirectional(s,[this.rootNode],0,r,-1),v("groupNodes:L:",s.length),this.placeNodesPosition(this.rootNode,s,r),s=[],r={max_deep:1,max_length:1,max_strength:1},this.analysisNodes4Didirectional(s,[this.rootNode],0,r,1),v("groupNodes:R:",s.length),this.placeNodesPosition(this.rootNode,s,r)),this.allNodes.forEach(d=>{if(d.fixed===!0){d.lot.placed=!0;return}if(!!A.isVisibleNode(d)){if(Number.isNaN(d.lot.x)&&(v("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(v("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==e){const f=d.lot.level<0?o:n;d.x=A.getNodeXByLotX(f,d),d.y=A.getNodeYByLotY(f,d)}d.lot.placed=!0}}),v("create rootNode coordinates:1",e.x,e.y)}placeNodesPosition(t,e,n){t.lot.placed=!0,this.placeRelativePosition(t,e,n)}placeRelativePosition(t,e,n){const o=this.layoutOptions.layoutExpansionDirection;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const s=this.layoutOptions.treeNodeGapH||20,r=this.layoutOptions.treeNodeGapV||20,{levels:l,levelNodesMap:c}=this.generateLevels(e),h=new Map;for(const g of l){const x=c.get(g);h.set(g,Math.max(...x.map(y=>y.el.offsetHeight)))}let d=0,f=0;for(const g of e){const x=g.el.offsetWidth;d+=x,f++}const u=d/f+s;e.forEach(g=>{g.fixed!==!0&&g.lot.placed!==!0&&g!==t&&(this.layoutOptions.from==="bottom"?g.lot.y=t.lot.y-this.getLevelDistance(g.lot.level,h,r+10):g.lot.y=t.lot.y+this.getLevelDistance(g.lot.level,h,r+10))}),e.forEach(g=>{g.fixed!==!0&&g.lot.level!==0&&(o==="start"?g.lot.x=t.lot.x-u*g.lot.strengthWithChilds_from:o==="end"?g.lot.x=t.lot.x+u*g.lot.strengthWithChilds_from:g.lot.x=t.lot.x+u*(n.max_strength/-2+g.lot.strengthWithChilds_from+g.lot.strengthWithChilds/2))}),this.applyNodesGap(e,"v"),this.gatherNodes(e,"v",u)}else{const s=this.layoutOptions.treeNodeGapH||20,r=this.layoutOptions.treeNodeGapV||20,{levels:l,levelNodesMap:c}=this.generateLevels(e),h=new Map;for(const g of l){const x=c.get(g);h.set(g,Math.max(...x.map(y=>y.el.offsetWidth)))}let d=0,f=0;for(const g of e){const x=g.el.offsetHeight;d+=x,f++}if(f===0)return;const u=d/f+r;e.forEach(g=>{g.fixed!==!0&&g.lot.placed!==!0&&g!==t&&(this.layoutOptions.from==="right"?g.lot.x=t.lot.x-this.getLevelDistance(g.lot.level,h,s+50):g.lot.x=t.lot.x+this.getLevelDistance(g.lot.level,h,s+50))}),e.forEach(g=>{g.fixed!==!0&&g.lot.level!==0&&(o==="start"?g.lot.y=t.lot.y-u*g.lot.strengthWithChilds_from:o==="end"?g.lot.y=t.lot.y+u*g.lot.strengthWithChilds_from:g.lot.y=t.lot.y+u*(n.max_strength/-2+g.lot.strengthWithChilds_from+g.lot.strengthWithChilds/2))}),console.log("levelMaxWidthMap:",t.id,h),this.applyNodesGap(e,"h"),this.gatherNodes(e,"h",u)}}getLevelDistance(t,e,n){if(t===0)return 0;if(t>0){let o=0;for(let s=0;s<t;s++)o+=e.get(s)+this.getLevelGap(s,n);return o}else{let o=0;for(let s=0;s>t;s--)o+=e.get(s)+this.getLevelGap(s,n);return-o}}getLevelGap(t,e){var o;let n=e;if(((o=this.layoutOptions.levelGaps)==null?void 0:o.length)>0){const s=this.layoutOptions.levelGaps[Math.abs(t)];s&&(n=s)}return n}applyNodesGap(t,e){if(this.layoutOptions.ignoreNodeSize)return;const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},s=this.layoutOptions.layoutExpansionDirection,{levels:r,levelNodesMap:l}=this.generateLevels(t),c=new Map;for(const f of r){const p=l.get(f);c.set(f,Math.max(...p.map(u=>u.el.offsetWidth)))}const{calcNodes:h,calcNodeMap:d}=this.generateCalcNodes(t);h.forEach(f=>{const p=f.rgNode.lot.level<0?o:n;f.x=A.getNodeXByLotX(p,f.rgNode),f.y=A.getNodeYByLotY(p,f.rgNode),f.width=f.rgNode.el.offsetWidth,f.height=f.rgNode.el.offsetHeight,f.buffY=0});for(const f of r){const p=l.get(f)||[];if(e==="h")if(s==="end"){p.sort((g,x)=>g.lot.y-x.lot.y);const u=p.map(g=>d.get(g.id));this.adjustNodePositions(u,"bottom",this.layoutOptions.treeNodeGapV);for(const g of u){const x=g.rgNode.lot.level<0?o:n;g.rgNode.lot.y=A.getNodeLotXY(x,g).y}}else{p.sort((g,x)=>x.lot.y-g.lot.y);const u=p.map(g=>d.get(g.id));this.adjustNodePositions(u,"top",this.layoutOptions.treeNodeGapV);for(const g of u){const x=g.rgNode.lot.level<0?o:n;g.rgNode.lot.y=A.getNodeLotXY(x,g).y}}else if(s==="end"){p.sort((g,x)=>g.lot.x-x.lot.x);const u=p.map(g=>d.get(g.id));this.adjustNodePositions(u,"right",this.layoutOptions.treeNodeGapH);for(const g of u){const x=g.rgNode.lot.level<0?o:n,y=A.getNodeLotXY(x,g);g.rgNode.lot.x=y.x}}else{p.sort((g,x)=>x.lot.x-g.lot.x);const u=p.map(g=>d.get(g.id));this.adjustNodePositions(u,"left",this.layoutOptions.treeNodeGapH);for(const g of u){const x=g.rgNode.lot.level<0?o:n;g.rgNode.lot.x=A.getNodeLotXY(x,g).x}}console.log("levelNodes:",f,p)}if(e==="h"){const f=new Map,p=new Map;for(const m of r){const b=l.get(m).map(M=>d.get(M.id));f.set(m,Math.max(...b.map(M=>M.width))),p.set(m,Math.min(...b.map(M=>M.x)))}const u=this.layoutOptions.treeNodeGapH;let g=r.filter(m=>m>0).sort((m,w)=>m-w),x=r.filter(m=>m<0).sort((m,w)=>w-m),y=1;this.layoutOptions.from==="right"&&([x,g]=[g,x],y=-1);let L=0;for(const m of g){const w=m-y,b=p.get(w),M=f.get(w),N=p.get(m)+L;f.get(m);const O=b+M+u;if(O>N){const E=O-N;console.log("[xxxxx]move",w,m,O,N,E),L=E;const T=l.get(m);for(const D of T)D.lot.x+=L;p.set(m,N+E)}else console.log("[xxxxx]goon",w,m,O,N),p.set(m,N)}L=0;for(const m of x){const w=m+y,b=p.get(w);f.get(w);const M=p.get(m)+L,N=f.get(m),O=b-u;if(M+N>O){const E=O-(M+N);L=E;const T=l.get(m);for(const D of T)D.lot.x+=L;p.set(m,M+E)}else p.set(m,M)}}else{const f=new Map,p=new Map;for(const m of r){const b=l.get(m).map(M=>d.get(M.id));f.set(m,Math.max(...b.map(M=>M.height))),p.set(m,Math.min(...b.map(M=>M.y)))}const u=this.layoutOptions.treeNodeGapV;let g=r.filter(m=>m>0).sort((m,w)=>m-w),x=r.filter(m=>m<0).sort((m,w)=>w-m),y=1;this.layoutOptions.from==="bottom"&&([x,g]=[g,x],y=-1);let L=0;for(const m of g){const w=m-y,b=p.get(w),M=f.get(w),N=p.get(m)+L;f.get(m);const O=b+M+u;if(O>N){const E=O-N;console.log("[xxxxx]move",w,m,O,N,E),L=E;const T=l.get(m);for(const D of T)D.lot.y+=L;p.set(m,N+E)}else console.log("[xxxxx]goon",w,m,O,N),p.set(m,N)}L=0;for(const m of x){const w=m+y,b=p.get(w);f.get(w);const M=p.get(m)+L,N=f.get(m),O=b-u;if(M+N>O){const E=O-(M+N);L=E;const T=l.get(m);for(const D of T)D.lot.y+=L;p.set(m,M+E)}else p.set(m,M)}}}gatherNodes(t,e,n){if(!this.enableGatherNodes)return;const{calcNodes:o,calcNodeMap:s}=this.generateCalcNodes(t);o.forEach(l=>{l.movedNodeSizeBefore=1,l.movedNodeSizeAfter=1});const{levelNodesMap:r}=this.generateLevels(t);t.forEach(l=>{if(l.fixed!==!0&&l.lot.level!==0){const c=r.get(l.lot.level)||[];if(l.lot.strengthWithChilds===1&&l.lot.childs_size<=1){const h=this.getBloomingNearByParent(l,l.lot.parent,c,e);if(h){const d=s.get(l.id);e==="h"?l.lot.y-h.lot.y>0?(l.lot.y=h.lot.y+n*d.movedNodeSizeAfter,d.movedNodeSizeAfter++):(l.lot.y=h.lot.y-n*d.movedNodeSizeBefore,d.movedNodeSizeBefore++):l.lot.x-h.lot.x>0?(l.lot.x=h.lot.x+n*d.movedNodeSizeAfter,d.movedNodeSizeAfter++):(l.lot.x=h.lot.x-n*d.movedNodeSizeBefore,d.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(t,e,n,o){let s=9999,r;for(const l of n)if(l.lot.childs_size>1&&l.lot.parent===e){const c=o==="h"?l.lot.y-e.lot.y:l.lot.x-e.lot.x;Math.abs(c)<s&&(s=Math.abs(c),r=l)}if(r&&r!==t)return r}}class ue extends ut{constructor(t,e,n){super(t,e,n);S(this,"layoutOptions");this.layoutOptions=t}placeNodes(t,e){if(v("RGCenterLayouter:placeNodes"),!e){v("root is null:",e);return}v("layout by root:",e),this.allNodes=t,this.calcNodes=t,this.rootNode=e,t.forEach(h=>{h.lot.eached=!1,h.lot.notLeafNode=!1,h.lot.childs=[],h.lot.parent=void 0,h.lot.index_of_parent=0,h.lot.strength=0,h.lot.placed=!1});let n=[],o={max_deep:1,max_length:1,max_strength:1};if(this.analysisNodes(n,[this.rootNode],0,o),n=[],o={max_deep:1,max_length:1,max_strength:1},this.analysisNodes4Didirectional(n,[this.rootNode],0,o,0),this.layoutOptions.genLotInfoOnly){v("only gen lot info, return"),t.forEach(h=>{h.lot.placed=!0});return}e.fixed||this.layoutOptions.fixedRootNode||(e.x=0,e.y=0);const s={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},r=this.layoutOptions.centerOffset_x||0,l=this.layoutOptions.centerOffset_y||0,c=A.getNodeLotXY(s,e);e.lot.x=c.x+r,e.lot.y=c.y+l,v("root position:",e.lot.x,e.lot.y),this.placeRelativePosition(this.rootNode,n,o),n.forEach(h=>{if(h.fixed!==!0&&!!h.rgCalcedVisible){if(h!==e){const d=s;h.x=A.getNodeXByLotX(d,h),h.y=A.getNodeYByLotY(d,h)}h.lot.placed=!0}})}getLevelDistanceArr(){let t=[];if(this.layoutOptions.levelDistance&&(Array.isArray(this.layoutOptions.levelDistance)?t=this.layoutOptions.levelDistance:console.error("Error levelDistance, levelDistance must is Array"),t.length>0&&t.length<10))for(let e=t.length;e<10;e++)t.push(t[t.length-1]);return t}getLevelR(t,e){if(t.length===0)return;let n=0;for(let o=0;o<e;o++)n+=t[o]||t[t.length-1];return n}placeRelativePosition(t,e,n){const o=this.layoutOptions.distance_coefficient===void 0?1:this.layoutOptions.distance_coefficient,s=this.getLevelDistanceArr(),r=Math.min(this.graphOptions.viewSize.height,this.graphOptions.viewSize.width)*.4;let l=Math.min(Math.max(r,150),400)*o;v("analyticResult:",this.layoutOptions,n,r,l,o,s);let c=0;e.forEach(d=>{const f=d.lot.subling;if(f&&f.level===1){c=Math.round(f.all_size*60/Math.PI/2),c<l&&(c=l);const p=this.getLevelR(s,f.level)||f.level*c,u=Z.getOvalPoint(t.lot.x,t.lot.y,p,d.lot.strength_plus-d.lot.strength/2,f.all_strength,this.layoutOptions.startAngle);d.lot.x=u.x,d.lot.y=u.y}});const h=Math.round(300*o);e.forEach(d=>{const f=d.lot.subling;if(f&&f.level>1){const p=d.lot.parent.lot.strength_plus-d.lot.parent.lot.strength,g=(d.lot.parent.lot.strength_plus-p)/(d.lot.parent.lot.childs_size+1)*(d.lot.index_of_parent+1),x=this.getLevelR(s,f.level)||(f.level-1)*h+c,y=Z.getOvalPoint(t.lot.x,t.lot.y,x,p+g,d.lot.parent.lot.subling.all_strength,this.layoutOptions.startAngle);d.lot.x=y.x,d.lot.y=y.y}})}}class ge extends ut{constructor(a,t,e){super(a,t,e)}refresh(){this.placeNodes(this.allNodes,this.rootNode)}placeNodes(a,t){if(t)v("layout by root:",t);else{v("root is null:",t);return}this.allNodes=a,this.rootNode=t,a.forEach(c=>{c.lot.eached=!1,c.lot.notLeafNode=!1,c.lot.childs=[],c.lot.parent=void 0,c.lot.index_of_p_childs=0,c.lot.strength=0}),t.fixed||this.layoutOptions.fixedRootNode||(t.x=0,t.y=0);const e={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},n=this.layoutOptions.centerOffset_x||0,o=this.layoutOptions.centerOffset_y||0,s=A.getNodeLotXY(e,t);t.lot.x=s.x+n,t.lot.y=s.y+o;const r=this.allNodes.length;let l=r*90/Math.PI/2;l<200&&(l=200),l>800&&(l=800),this.allNodes.forEach((c,h)=>{const d=Z.getOvalPoint(t.lot.x,t.lot.y,l,h,r);c.lot.x=d.x,c.lot.y=d.y}),this.allNodes.forEach(c=>{if(c.fixed!==!0&&!!c.rgCalcedVisible){if(c===t){const h=e;c.x=A.getNodeXByLotX(h,c),c.y=A.getNodeYByLotY(h,c)}c.lot.placed=!0}})}}class pe extends pt{constructor(t,e,n){super(t,e,n);S(this,"graphOptions");S(this,"layoutOptions");S(this,"allNodes",[]);S(this,"__origin_nodes",[]);this.layoutOptions=t,this.graphOptions=e}placeNodes(t,e){if(e)v("layout by root:",e);else{v("root is null:",e);return}v("allNodes:",t.length),this.__origin_nodes=t,this.rootNode=e,t.forEach(o=>{o.lot.eached=!1,o.lot.notLeafNode=!1,o.lot.childs=[],o.lot.parent=void 0,o.lot.index_of_parent=0,o.lot.strength=0,o.lot.placed=!1,o.x||(o.x=0),o.y||(o.y=0),Number.isNaN(o.x)&&(o.x=0),Number.isNaN(o.y)&&(o.y=0)}),this.allNodes=[];const n={max_strength:1,max_deep:1,max_length:1};this.analysisNodes(this.allNodes,[this.rootNode],0,n),v("[layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize)}}class Ue extends pt{constructor(t,e,n){super(t,e,n);S(this,"graphInstance");S(this,"layoutOptions");S(this,"levelDistanceArr",[]);this.layoutOptions=t,v("new RGSmartTreeLayouter:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelDistance&&(Array.isArray(this.layoutOptions.levelDistance)?this.levelDistanceArr=this.layoutOptions.levelDistance:console.error("Error levelDistance, levelDistance must is Array")),this.requireLinks=!0,this.graphInstance=n}analysisNodes4Didirectional(t,e,n,o){this.analysisBothWay(t,e,n,o);const s={};t.forEach(c=>{const h=c.lot.level+"";s[h]||(s[h]=[]),s[h].push(c),c.lot.subling={level:c.lot.level,all_size:0,all_strength:0}}),t.forEach(c=>{const h=c.lot.level+"",d=s[h],f=d.length;c.lot.index_of_level=d.indexOf(c),c.lot.subling.all_size=f,c.lot.subling.all_strength+=c.lot.strength||1,c.lot.strength_plus=c.lot.subling.all_strength}),t.forEach(c=>{c.lot.childs_size>0&&(c.lot.strengthWithChilds=0)}),t.forEach(c=>{c.lot.childs_size===0&&(c.lot.strengthWithChilds=1,A.conductStrengthToParents(c))});const r=Object.keys(s).map(c=>Number.parseInt(c)).sort(),l=c=>{const h=c+"",d=s[h];let f=0;d.forEach(p=>{p.lot.parent&&f<p.lot.parent.lot.strengthWithChilds_from&&(f=p.lot.parent.lot.strengthWithChilds_from),c===0?f+=1:p.lot.strengthWithChilds_from=f,v("levels:",c,f,p.text,p.lot.strengthWithChilds),f+=p.lot.strengthWithChilds})};[0].forEach(l),r.filter(c=>c>0).forEach(l),r.filter(c=>c<0).forEach(l)}analysisBothWay(t,e,n,o){v(`level ${n} size: ${e.length}`),e.length>o.max_length&&(o.max_length=e.length),n>o.max_deep&&(o.max_deep=n);const s={level:n,all_size:e.length,all_strength:0};e.forEach(l=>{l.lot||(l.lot={childs:[]}),l.lot.eached=!0,l.lot.subling=s,l.lot.level=n,t.push(l)});let r=0;e.forEach(l=>{let c=0,h=0,d=[];this.graphInstance.getNodeRelatedNodes4From(l).forEach(f=>{f.lot||(f.lot={eached:!1,childs:[]}),f.lot.eached||(f.lot.parent=l,f.rgCalcedVisible?(f.lot.eached=!0,f.lot.index_of_parent=h++,l.lot.childs.push(f),d.push(f),c++):l.lot.childs.push(f))}),this.analysisBothWay(t,d,n-1,o),d=[],this.graphInstance.getNodeRelatedNodes4To(l).forEach(f=>{f.lot||(f.lot={eached:!1,childs:[]}),f.lot.eached||(f.lot.parent=l,f.rgCalcedVisible?(f.lot.eached=!0,f.lot.index_of_parent=h++,l.lot.childs.push(f),d.push(f),c++):l.lot.childs.push(f))}),this.analysisBothWay(t,d,n+1,o),l.lot.strength=c>0?c:1,s.all_strength+=l.lot.strength,l.lot.strength_plus=s.all_strength,l.lot.index_of_level=r,l.lot.childs_size=c,r++}),s.all_strength>o.max_strength&&(o.max_strength=s.all_strength)}placeNodes(t,e){if(v("RGSmartTreeLayouter:placeNodes"),e)v("layout by root:",e);else{console.error("root is null");return}this.rootNode=e,this.allNodes=t,v("allNodes:",t.length),t.forEach(c=>{c.lot.eached=!1,c.lot.notLeafNode=!1,c.lot.childs=[],c.lot.parent=void 0,c.lot.index_of_parent=0,c.lot.strength=0,c.lot.strengthWithChilds_from=0,c.lot.strengthWithChilds=0,c.lot.placed=!1});let n=[],o={max_deep:1,max_length:1,max_strength:1};this.analysisNodes(n,[this.rootNode],0,o),n=[],o={max_deep:1,max_length:1,max_strength:1},this.analysisNodes4Didirectional(n,[this.rootNode],0,o),this.placeNodesPosition(this.rootNode,n,o),v("allNodes:",n.length),this.allNodes.forEach(c=>{if(c.fixed===!0){c.lot.placed=!0;return}!c.rgCalcedVisible||(Number.isNaN(c.lot.x)&&(v("bad lot x:",c.text,c.lot.x),c.lot.x=0),Number.isNaN(c.lot.y)&&(v("bad lot y:",c.text,c.lot.y),c.lot.y=0),c.x=A.getNodeXByLotX(this.layoutOptions,c),c.y=A.getNodeYByLotY(this.layoutOptions,c),c.lot.placed=!0)}),v("create rootNode coordinates:1",e.x,e.y);const s=n.filter(c=>c.lot.level===0),r=[];this.allLinks.forEach(c=>{s.includes(c.fromNode)&&!s.includes(c.toNode)&&r.push(c.toNode),s.includes(c.toNode)&&!s.includes(c.fromNode)&&r.push(c.fromNode)}),r.forEach(c=>{c.fixed=!0}),s.push(...r);const l=new ut({layoutName:"force",maxLayoutTimes:100,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0},this.graphOptions,this.graphInstance);l.isMainLayouer=!1,l.requireLinks=!0,this.layoutOptions.from==="left"||this.layoutOptions.from==="right"?l.lockX=!0:l.lockY=!0,l.visibleNodes=s,l.setLinks(this.allLinks),l.resetCalcNodes(),l.doForceLayout(0)}placeNodesPosition(t,e,n){t.fixed||this.layoutOptions.fixedRootNode||(t.x=0,t.y=0);const o=this.layoutOptions.centerOffset_x||0,s=this.layoutOptions.centerOffset_y||0,r=A.getNodeLotXY(childrenTreeAlign,t);t.lot.x=r.x+o,t.lot.y=r.y+s,t.lot.placed=!0,this.placeRelativePosition(t,e,n)}placeRelativePosition(t,e,n){const o=this.graphOptions.viewSize;if(this.layoutOptions.from==="left"||this.layoutOptions.from==="right"){const s=rt(this.layoutOptions.min_per_height)||80,r=rt(this.layoutOptions.max_per_height)||400,l=rt(this.layoutOptions.min_per_width)||430,c=rt(this.layoutOptions.max_per_width)||650;let h=Math.round((o.width-10)/(n.max_deep+2));h<l&&(h=l),h>c&&(h=c);let d=Math.round(o.height/(n.max_strength+1));d<s&&(d=s),d>r&&(d=r),e.forEach(f=>{f.fixed!==!0&&f.lot.placed!==!0&&f!==t&&(this.layoutOptions.from==="right"?f.lot.x=t.lot.x-this.getLevelDistance(f,f.lot.subling.level,h):f.lot.x=t.lot.x+this.getLevelDistance(f,f.lot.subling.level,h))}),e.forEach(f=>{f.fixed!==!0&&(f.lot.level===0?f!==t&&(f.lot.y=t.lot.y+d*f.lot.index_of_level):f.lot.y=t.lot.y+d*(n.max_strength/-2+f.lot.strengthWithChilds_from+f.lot.strengthWithChilds/2))})}else{const s=rt(this.layoutOptions.min_per_height)||350,r=rt(this.layoutOptions.max_per_height)||400,l=rt(this.layoutOptions.min_per_width)||250,c=rt(this.layoutOptions.max_per_width)||500;let h=Math.round((o.width-10)/(n.max_strength+2));h<l&&(h=l),h>c&&(h=c);let d=Math.round((o.height-10)/(n.max_deep+2));d<s&&(d=s),d>r&&(d=r),e.forEach(f=>{f.fixed!==!0&&f.lot.placed!==!0&&f!==t&&(this.layoutOptions.from==="bottom"?f.lot.y=t.lot.y-this.getLevelDistance(f,f.lot.subling.level,d):f.lot.y=t.lot.y+this.getLevelDistance(f,f.lot.subling.level,d))}),e.forEach(f=>{f.fixed!==!0&&f.lot.level!==0&&(f.lot.x=t.lot.x+h*(n.max_strength/-2+f.lot.strengthWithChilds_from+f.lot.strengthWithChilds/2))})}}getLevelDistance(t,e,n){const o=Math.abs(e);if(this.levelDistanceArr&&this.levelDistanceArr.length>0){let s=0;for(let r=0;r<o;r++){const l=this.levelDistanceArr[r]||100;s+=l}return e>0?s:s*-1}else return e*n}}class ye extends pt{constructor(t,e,n){super(t,e,n);S(this,"enableGatherNodes",!1);S(this,"layoutOptions");this.layoutOptions=t,v("new RGFolderLayouter:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.bottomJuctionPointOffsetX===void 0&&(this.layoutOptions.bottomJuctionPointOffsetX=-50);const o=this.layoutOptions.from;o==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):o==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):o==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps, treeNodeGapH, treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes}analysisNodes4Didirectional(t,e,n,o,s){v(`${s} level ${n} size: ${e.length}`),e.length>o.max_length&&(o.max_length=e.length),n>o.max_deep&&(o.max_deep=n);const r={level:n,all_size:e.length,all_strength:0},l=[];e.forEach(h=>{h.lot||(h.lot={childs:[]}),h.lot.eached=!0,h.lot.subling=r,h.lot.level=n,t.push(h)});let c=0;e.forEach(h=>{let d=0;const f=this.graphInstance.getNodeRelatedNodes(h);let p=0;f.forEach(u=>{u.lot||(u.lot={eached:!1,childs:[]}),u.lot.eached||(u.lot.parent=h,u.rgCalcedVisible?(u.lot.eached=!0,u.lot.index_of_parent=p++,h.lot.childs.push(u),l.push(u),d++):h.lot.childs.push(u))}),h.lot.strength=d>0?d:1,r.all_strength+=h.lot.strength,h.lot.strength_plus=r.all_strength,h.lot.index_of_level=c,h.lot.childs_size=d,c++}),r.all_strength>o.max_strength&&(o.max_strength=r.all_strength),l.length>0?this.analysisNodes4Didirectional(t,l,n+s,o,s):(t.forEach(h=>{h.lot.strengthWithChilds=1,A.conductStrengthToParents4Folder(h)}),A.analysisDataFolder([t[0]],0,s))}placeNodes(t,e){if(v("RGFolderLayouter:placeNodes"),e)v("layout by root:",e);else{console.error("root is null");return}this.rootNode=e,this.allNodes=t,console.log("fixedRootNode:",this.layoutOptions.fixedRootNode);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};e.fixed||this.layoutOptions.fixedRootNode||(e.x=0,e.y=0);const s=this.layoutOptions.centerOffset_x||0,r=this.layoutOptions.centerOffset_y||0,l=A.getNodeLotXY(n,e);e.lot.x=l.x+s,e.lot.y=l.y+r,v("allNodes:",t.length),t.forEach(d=>{d.lot||(d.lot={}),d.lot.eached=!1,d.lot.notLeafNode=!1,d.lot.childs=[],d.lot.parent=void 0,d.lot.index_of_parent=0,d.lot.strength=0,d.lot.strengthWithChilds_from=0,d.lot.strengthWithChilds=0,d.lot.placed=!1});let c=[],h={max_deep:1,max_length:1,max_strength:1};this.analysisNodesForFolder(c,[this.rootNode],0,h),c=[],h={max_deep:1,max_length:1,max_strength:1},this.analysisNodes4Didirectional(c,[this.rootNode],0,h,1),this.placeRelativePosition(e,c,h),v("allNodes:",c.length),this.allNodes.forEach(d=>{if(d.fixed===!0){d.lot.placed=!0;return}if(Number.isNaN(d.lot.x)&&(v("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(v("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==e){const f=d.lot.level<0?o:n;d.x=A.getNodeXByLotX(f,d),d.y=A.getNodeYByLotY(f,d)}d.lot.placed=!0}),v("create rootNode coordinates:1",e.x,e.y)}placeRelativePosition(t,e,n){const o=this.layoutOptions.treeNodeGapH||20,s=this.layoutOptions.treeNodeGapV||20,r=new Map;let l=0,c=0;for(const f of e){const p=f.lot.level,u=f.el.offsetWidth,g=f.el.offsetHeight;l+=g,c++;const x=r.get(p);x===void 0?r.set(p,u):u>x&&r.set(p,x)}if(c===0)return;console.log("levelMaxWidthMap:",r);const d=l/c+s;e.forEach(f=>{f.fixed!==!0&&f.lot.placed!==!0&&f!==t&&(this.layoutOptions.from==="right"?f.lot.x=t.lot.x-this.getLevelDistance(f.lot.level,r,o+50):f.lot.x=t.lot.x+this.getLevelDistance(f.lot.level,r,o+50))}),e.forEach(f=>{f.fixed!==!0&&f!==t&&f.lot.level!==0&&(f.lot.y=t.lot.y+d*(f.lot.strengthWithChilds_from-1))}),this.gatherNodes(e,"h",d)}gatherNodes(t,e,n){if(!this.enableGatherNodes)return;const o={};t.forEach(s=>{if(s.lot.level!==0)return;const r=s.lot.level+"";o[r]||(o[r]=[]),o[r].push(s),s.lot.movedNodeSizeBefore=1,s.lot.movedNodeSizeAfter=1}),t.forEach(s=>{if(s.fixed!==!0&&s.lot.level!==0){const r=s.lot.level+"",l=o[r];if(s.lot.strengthWithChilds===1&&s.lot.childs_size<=1){const c=this.getBloomingNearByParent(s,s.lot.parent,l,e);c&&(e==="h"?s.lot.y-c.lot.y>0?(s.lot.y=c.lot.y+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(s.lot.y=c.lot.y-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++):s.lot.x-c.lot.x>0?(s.lot.x=c.lot.x+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(s.lot.x=c.lot.x-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++))}}})}getBloomingNearByParent(t,e,n,o){let s=9999,r;for(const l of n)if(l.lot.childs_size>1&&l.lot.parent===e){const c=o==="h"?l.lot.y-e.lot.y:l.lot.x-e.lot.x;Math.abs(c)<s&&(s=Math.abs(c),r=l)}if(r&&r!==t)return r}getLevelDistance(t,e,n){if(t===0)return 0;if(t>0){let o=0;for(let s=0;s<t;s++)o+=e.get(s)+this.getLevelGap(s,n);return o}else{let o=t<-1?0:-e.get(t)/2;for(let s=t;s<0;s++)o+=e.get(s)+this.getLevelGap(s,n)+50;return-o}}getLevelGap(t,e){var o;let n=e;if(((o=this.layoutOptions.levelGaps)==null?void 0:o.length)>0){const s=this.layoutOptions.levelGaps[Math.abs(t)];s&&(n=s)}return n}analysisNodesForFolder(t,e,n,o){e.length>o.max_length&&(o.max_length=e.length),n>o.max_deep&&(o.max_deep=n);const s={level:n,all_size:e.length,all_strength:0};n===0&&e.forEach(l=>{l.lot.parent=void 0});const r=[];for(const l of e){t.push(l);for(const c of this.graphInstance.getNodeRelatedNodes(l))t.includes(c)||(t.push(c),c.lot.parent=l,r.push(c))}s.all_strength>o.max_strength&&(o.max_strength=s.all_strength),r.length>0&&this.analysisNodesForFolder(t,r,n+1,o)}}let Ze=0;const Ft=i=>{typeof i.graphOffset_x=="string"&&(i.graphOffset_x=parseInt(i.graphOffset_x)),typeof i.graphOffset_y=="string"&&(i.graphOffset_y=parseInt(i.graphOffset_y)),i.defaultPloyLineRadius&&(i.defaultPolyLineRadius=i.defaultPloyLineRadius);const a={instanceId:"",debug:!0,graphLoading:!1,graphLoadingText:"",instanceDestroyed:!1,useHorizontalView:!1,showDebugPanel:!1,showToolBar:!0,backgroundColor:"transparent",checkedItemBackgroundColor:void 0,downloadImageFileName:"",selectionMode:!1,disableWheelEvent:!1,wheelEventAction:"zoom",disableDragNode:!1,disableDragLine:!0,disableDragCanvas:!1,canvasMoveMode:!1,disableNodePointEvent:!1,disableLinePointEvent:!1,enableNodeXYAnimation:!1,enableCanvasTransformAnimation:!1,reLayoutWhenExpandedOrCollapsed:!1,defaultExpandHolderPosition:"hide",defaultExpandHolderColor:void 0,toolBarDirection:"v",toolBarPositionH:"right",toolBarPositionV:"center",defaultNodeColor:"#ffffff",defaultLineColor:"#cccccc",defaultLineShape:void 0,defaultLineTextOffset_x:void 0,defaultLineTextOffset_y:void 0,defaultJunctionPoint:void 0,defaultPolyLineRadius:5,placeSingleNode:!0,placeOtherGroup:!0,lineUseTextPath:!1,lineTextMaxLength:66,multiLineDistance:50,graphOffset_x:0,graphOffset_y:0,defaultLineMarker:{viewBox:"0 0 12 12",markerWidth:20,markerHeight:20,refX:3,refY:3,data:"M 0 0, V 6, L 4 3, Z"},viewSize:{width:300,height:300},viewELSize:{width:1300,height:800,left:0,top:100},canvasSize:{width:1e3,height:1e3},canvasOffset:{x:25,y:27,zoom_buff_x:0,zoom_buff_y:0},fullscreen:!1,checkedNodeId:"",checkedLineId:"",checkedLinkId:"",layout:{label:"\u4E2D\u5FC3",layoutName:"fixed",layoutDirection:"v"},canvasZoom:100,mouseWheelSpeed:10,minCanvasZoom:5,maxCanvasZoom:500,showEasyView:!1,performanceMode:!1,viewHeight:"100%",canvasOpacity:1,creatingSelection:!1,selectionView:{x:25,y:27,width:0,height:0},creatingNodePlot:!1,showTemplateNode:!0,newNodeTemplate:Ct(JSON.parse(JSON.stringify(Bt))),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"},newLinkTemplate:{fromNode:null,toNodeObject:null,toNode:{nothing:!0,x:400,y:400,el:{offsetWidth:30,offsetHeight:30}},totalLinesBetweenNodes:1,currentLineIndex:0,line:{}},data:{},editingLineController:{show:!1,link:null,line:null,startPoint:{x:0,y:0},endPoint:{x:0,y:0},text:{show:!0,x:0,y:0,width:10,height:10},ctrlPoints:[],selectedLines:[],line44Splits:[],line49Points:[],ctrlPoint1:{x:0,y:0},ctrlPoint2:{x:0,y:0},toolbar:{x:0,y:0}},editingController:{show:!1,nodes:[],x:0,y:0,width:100,height:100},nodeConnectController:{show:!1,node:null,x:0,y:0,width:100,height:100},showReferenceLine:!1,referenceLineAdsorption:!1,editingReferenceLine:{show:!1,directionV:!1,directionH:!1,v_x:0,v_y:0,v_height:0,h_x:0,h_y:0,h_width:0},showMiniView:!1,miniViewVisibleHandle:{x:0,y:0,width:100,height:100,emptyContent:!1},snapshotting:!1};if(a.newLineTemplate=ct(a.newLineTemplate),i.layouts)throw new Error("Graph options do not support setting layouts properties !");const t=i.debug===!0;t&&v("RGOptions:user instance options:",i),window&&(window.relationGraphDebug=t);const e=Object.keys(a);return i&&Object.keys(i).forEach(n=>{const o=i[n];if(!e.includes(n)){v("RGOptions: unknow option key:",n);return}if(typeof o=="object"){v("RGOptions:user setting object:",n,o);const s=a[n];if(n==="layout")a[n]=JSON.parse(JSON.stringify(o));else if(s&&!Array.isArray(s)&&o)Object.keys(s).forEach(r=>{s[r]=o[r]});else if(Array.isArray(s)){const r=[];o.forEach(l=>{l&&typeof l=="object"?r.push(JSON.parse(JSON.stringify(l))):r.push(l)}),a[n]=r}else a[n]=o}else a[n]=o}),v("final layout:",a.layout),$t(a.layout),Ht(a.layout,a),a},Ht=(i,a)=>{v("applyDefaultOptionsByLayout",i.layoutName,a),i.layoutName==="center"?a.defaultJunctionPoint===void 0&&(a.defaultJunctionPoint=U.border):i.layoutName.includes("tree")?((i.from==="top"||i.from==="bottom")&&(v("set layoutDirection=v"),a.defaultJunctionPoint===void 0&&(a.defaultJunctionPoint=U.tb),v("set defaultJunctionPoint=tb")),(i.from==="left"||i.from==="right")&&(v("set layoutDirection=h"),a.defaultJunctionPoint===void 0&&(a.defaultJunctionPoint=U.lr),v("set defaultJunctionPoint=lr"))):i.layoutName==="fixed"||i.layoutName,a.defaultJunctionPoint===void 0&&(a.defaultJunctionPoint=U.border)},$t=i=>{if(typeof i.centerOffset_x=="string"&&(i.centerOffset_x=parseInt(i.centerOffset_x)),typeof i.centerOffset_y=="string"&&(i.centerOffset_y=parseInt(i.centerOffset_y)),i.layoutName==="center"){const a=i;a.layoutDirection===void 0&&(a.layoutDirection="h"),a.centerOffset_x===void 0&&(a.centerOffset_x=0),a.centerOffset_y===void 0&&(a.centerOffset_y=0),a.layoutDirection=void 0}else if(i.layoutName.includes("tree")){const a=i;a.layoutDirection===void 0&&(a.layoutDirection="h"),a.centerOffset_x===void 0&&(a.centerOffset_x=0),a.centerOffset_y===void 0&&(a.centerOffset_y=0),a.from===void 0&&(a.from="top"),a.levelGaps===void 0&&(a.levelGaps=[]),(a.from==="top"||a.from==="bottom")&&(a.layoutDirection="v",v("set layoutDirection=v"),v("set defaultJunctionPoint=tb")),(a.from==="left"||a.from==="right")&&(a.layoutDirection="h",v("set defaultJunctionPoint=lr"))}else(i.layoutName==="fixed"||i.layoutName==="force")&&(i.layoutDirection=void 0);i.supportAutoLayout=!1,i.autoLayouting=!1},Nt=i=>{const a=Ft(i);return v("RGOptions:new RGOptions:by:",i),v("RGOptions:new RGOptions:",a),a.instanceId||(a.instanceId=`rg-ins-${Ze++}`),a},Je={newInstanceOptions:Nt,createDefaultConfig:Ft,applyDefaultOptionsByLayout:Ht},qe=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:Ft,applyDefaultOptionsByLayout:Ht,appendDefaultOptions4Layout:$t,newInstanceOptions:Nt,default:Je},Symbol.toStringTag,{value:"Module"}));class Qe{constructor(a,t){S(this,"options");S(this,"listeners");S(this,"isReact",!1);S(this,"updateViewHook",()=>{});S(this,"_dataUpdating",!1);S(this,"_dataUpdatingNext",!1);S(this,"eventHandlers",[]);S(this,"_emitHook");this.listeners=t||{},this.options=a?Nt(a):{}}enableDebugLog(a){this.options.debug=a,window&&(window.relationGraphDebug=a)}setUpdateViewHook(a){this.isReact=!0,this.updateViewHook=a}_dataUpdated(){!window||!window.requestAnimationFrame||requestAnimationFrame(this._doSomethingAfterDataUpdated.bind(this))}_doSomethingAfterDataUpdated(){v("_dataUpdated:"),this.updateShouldRenderGraphData(),this.updateEasyView(),this.updateViewHook()}addEventHandler(a){this.eventHandlers.includes(a)||this.eventHandlers.push(a)}removeEventHandler(a){const t=this.eventHandlers.indexOf(a);t!==-1&&this.eventHandlers.splice(t,1)}setEventEmitHook(a){this._emitHook=a}emitEvent(a,...t){let{result:e,handled:n}=this.defaultEventHandler(a,...t);for(const o of this.eventHandlers){const s=o(a,...t);s!==void 0&&(e=s,n=!0)}if(n||this._emitHook&&this._emitHook(a,...t,o=>{o!==void 0&&(e=o)}),e!==void 0)return v("[custom event hook]Event:",a," => returnValue:",e),e}defaultEventHandler(a,...t){let e,n=!1;if(a===I.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(a===I.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(t[0],t[1]));else if(a===I.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const o=t[0],s=t[1],r=t[2],l=t[3],c=t[4],h=t[5];e=this.listeners.onNodeDragging(o,s,r,l,c,h)}}else if(a===I.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const o=t[0],s=t[1],r=t[2],l=t[3];e=this.listeners.onCanvasDragging(o,s,r,l)}}else if(a===I.onNodeDragEnd){const o=t[0],s=t[1],r=t[2],l=t[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(o,s,r,l))}else if(a===I.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(a===I.onNodeClick){if(this.listeners.onNodeClick){n=!0;const o=t[0],s=t[1];this.listeners.onNodeClick(o,s)}}else if(a===I.onImageDownload){if(this.listeners.onImageDownload){n=!0;const o=t[0],s=t[1];e=this.listeners.onImageDownload(o,s)}}else if(a===I.onImageSaveAsFile){if(this.listeners.onImageSaveAsFile){n=!0;const o=t[0],s=t[1],r=t[2];e=this.listeners.onImageSaveAsFile(o,s,r)}}else if(a===I.onLineClick){if(this.listeners.onLineClick){n=!0;const o=t[0],s=t[1],r=t[2];this.listeners.onLineClick(o,s,r)}}else if(a===I.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const o=t[0],s=t[1];this.listeners.onNodeExpand(o,s)}}else if(a===I.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const o=t[0],s=t[1];this.listeners.onNodeCollapse(o,s)}}else if(a===I.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const o=t[0];this.listeners.onCanvasDragEnd(o)}}else if(a===I.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const o=t[0];this.listeners.onCanvasClick(o)}}else if(a===I.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const o=t[0],s=t[1];this.listeners.onCanvasSelectionEnd(o,s)}}else if(a===I.onContextmenu){if(this.listeners.onContextmenu){n=!0;const o=t[0],s=t[1],r=t[2];this.listeners.onContextmenu(o,s,r)}}else if(a===I.onFullscreen){if(this.listeners.onFullscreen){n=!0;const o=t[0],s=t[1];e=this.listeners.onFullscreen(o,s)}}else if(a===I.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const o=t[0];e=this.listeners.beforeAddNodes(o)}}else if(a===I.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const o=t[0];e=this.listeners.beforeAddLines(o)}}else if(a===I.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const o=t[0];e=this.listeners.onKeyboardDown(o)}}else if(a===I.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const o=t[0];e=this.listeners.onKeyboardUp(o)}}else if(a===I.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const o=t[0];e=this.listeners.onLineBeCreated(o)}}else if(a===I.onCanvasDragStart&&this.listeners.onCanvasDragStart){n=!0;const o=t[0],s=t[1],r=t[2];e=this.listeners.onCanvasDragStart(o,s,r)}return{result:e,handled:n}}setEventListener(a){Object.assign(this.listeners,a)}}class Ke extends Qe{constructor(t,e){super(t,e);S(this,"$dom");S(this,"$canvasDom");S(this,"resizeObserver");S(this,"resizeListenerMap",new WeakMap);S(this,"domToNodeIdMap",new WeakMap);S(this,"_rgAsConnectArea",!1);S(this,"onKeyDownHanlder");S(this,"onKeyUpHanlder");S(this,"$lineTextContainer4NormalLine");S(this,"$lineTextContainer4FakeLine")}initDom(){this.resizeObserver=new ResizeObserver((t,e)=>{for(const n of t){const o=this.resizeListenerMap.get(n.target);o?n.borderBoxSize?o(n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):o(n.target.clientWidth,n.target.clientHeight):n.borderBoxSize?this._onNodeDomResize(n.target,n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):this._onNodeDomResize(n.target,n.target.clientWidth,n.target.clientHeight)}})}setDom(t){this.$dom=t,this.addResizeListener(this.$dom,(e,n)=>{v("resizeListener:this.$dom"),this.resetViewSize(),this.updateViewBoxInfo(),this.updateEasyView(),this._rgAsConnectArea&&(this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-above"))),this.updateEditingControllerView(),this.updateEditingLineView(),setTimeout(()=>{v("resizeListener:updateShouldRenderGraphData"),this.emitEvent(I.onViewResize,{width:e,height:n})},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener())}addKeyboardListener(){this.onKeyDownHanlder=t=>{vt(t)||(t.code==="Space"&&(t.preventDefault(),this.setCanvasMoveMode(!0)),this.emitEvent(I.onKeyboardDown,t))},this.onKeyUpHanlder=t=>{vt(t)||(t.code==="Space"&&(t.preventDefault(),this.setCanvasMoveMode(!1)),this.emitEvent(I.onKeyboardUp,t))},this.$dom.addEventListener("keydown",this.onKeyDownHanlder),this.$dom.addEventListener("keyup",this.onKeyUpHanlder)}removeKeyboardListener(){this.onKeyDownHanlder&&this.$dom.removeEventListener("keydown",this.onKeyDownHanlder),this.onKeyUpHanlder&&this.$dom.removeEventListener("keyup",this.onKeyUpHanlder)}setCanvasDom(t){this.$canvasDom=t,this.reinitMutationObservers(),this.getLineTextContainer({isFakeLine:!0}),this.getLineTextContainer({isFakeLine:!1})}getLineTextContainer(t){if(!(!t||!this.$canvasDom))return t.isFakeLine?(this.$lineTextContainer4NormalLine||(this.$lineTextContainer4NormalLine=this.$canvasDom.querySelector(".rg-lines-container-el-lines .rg-linetext-container")),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container")),this.$lineTextContainer4FakeLine)}getBoundingClientRect(){var t;return(t=this.$dom)==null?void 0:t.getBoundingClientRect()}addResizeListener(t,e){this.resizeListenerMap.set(t,e),this.resizeObserver||this.initDom(),this.resizeObserver.observe(t)}_onNodeDomResize(t,e,n){if(e===0||n===0)return;const o=this.domToNodeIdMap.get(t);this._onNodeResize(t,o,e,n)}_onNodeResize(t,e,n,o){n===0||o===0||(this.updateConnectTargetsOnNode("Node-Created",e,t),this.updateNodeOffsetSize(e,n,o))}addNodeResizeListener(t,e){this.domToNodeIdMap.set(t,e.id),this.resizeObserver||this.initDom(),this._onNodeResize(t,e.id,t.offsetWidth,t.offsetHeight),this.resizeObserver.observe(t)}removeNodeResizeListener(t){this.domToNodeIdMap.delete(t),t?this.resizeObserver.unobserve(t):v("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(t){this.resizeListenerMap.delete(t),this.resizeObserver.unobserve(t)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}}class tn extends Ke{constructor(t,e){super(t,e);S(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],elementLines:[],fakeLines:[]});S(this,"runtimeDATA4Links",[]);S(this,"runtimeDATA4NodeMap",{});S(this,"runtimeDATA4ConnectTargets",[]);S(this,"reactiveData");S(this,"runtimeDATA4ShouldRenderGraphData",{nodes:[],lines:[]});S(this,"prevAddNodeTimestamp",0);S(this,"mutationObserver4Nodes");S(this,"mutationObserver4CanvasSlotBehind");S(this,"mutationObserver4CanvasSlotAbove");S(this,"canvasConnectTargetsMap",new Map);S(this,"nodeConnectTargetsMap",new Map);S(this,"fakeLineTargetRender");S(this,"runtimeDATA4ElLineTargets",[]);S(this,"elLineUpdating",!1);S(this,"_canvasBoxXY",{x:0,y:0});S(this,"canvasDragging",!1)}setReactiveData4Vue2(t,e,n){this.reactiveData=e,this.graphData=t,this.runtimeDATA4ShouldRenderGraphData=n.runtimeDATA4ShouldRenderGraphData,this.runtimeDATA4ConnectTargets=n.runtimeDATA4ConnectTargets,this.runtimeDATA4ElLineTargets=n.runtimeDATA4ElLineTargets,Object.assign(e.options,this.options),this.options=e.options}setReactiveData4Vue3(t,e,n){this.reactiveData=e,this.graphData=t,this.options.performanceMode||(this.runtimeDATA4Links=n.runtimeDATA4Links),this.runtimeDATA4ShouldRenderGraphData=n.runtimeDATA4ShouldRenderGraphData,this.runtimeDATA4ConnectTargets=n.runtimeDATA4ConnectTargets,this.runtimeDATA4ElLineTargets=n.runtimeDATA4ElLineTargets,Object.assign(e.options,this.options||{}),this.options=e.options}_setOptions(t){const e=this.options.instanceId;t.instanceId||(t.instanceId=e);const n=Nt(t);this.reactiveData?Object.assign(this.reactiveData.options,n):Object.assign(this.options,n)}_setJsonData(t,e=!1){this.clearGraph(),v("set jsonData:",t),this.loadGraphJsonData(t)}clearGraph(){this.graphData.nodes=[],this.graphData.normalLines=[],this.graphData.elementLines=[],this.graphData.fakeLines=[],this.runtimeDATA4Links.splice(0,this.runtimeDATA4Links.length),this.runtimeDATA4ElLineTargets.splice(0,this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4NodeMap={},this.graphData.rootNode=void 0,this.clearChecked(),this.setEditingLine(null,null),this.setEditingNodes([])}clearFakeLines(){this.graphData.fakeLines.splice(0,this.graphData.fakeLines.length)}clearElementLines(){for(const t of this.getFakeLines())(t.fromType===B.HTMLElementId||t.toType===B.HTMLElementId)&&this.removeFakeLine(t)}generateNewNodeId(t=5){const e=this.generateNewUUID(t);return this.getNodeById(e)?this.generateNewNodeId(t+1):e}generateNewUUID(t=5){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let n="";const o=t>30?30:t;for(let s=0;s<o;s++)n+=e[Math.floor(Math.random()*e.length)];return n}loadNodes(t){this.emitEvent(I.beforeAddNodes,t);const e={};this.graphData.nodes.forEach(o=>{e[o.id]=o});const n=[];t.forEach(o=>{let s=e[o.id];if(!s){let{text:r,id:l}=o;!r&&o.label&&(r=o.label,console.warn('Use "label" as "text":',o.label)),!r&&l&&(r=l,console.warn('Use "id" as "text":',l)),s=Ct(Object.assign({},o,{text:r}),this.options),s&&(e[s.id]=s,n.push(s))}}),this.graphData.nodes.push(...n);for(const o of n)this.runtimeDATA4NodeMap[o.id]=o;n.length>0&&(this.prevAddNodeTimestamp=Date.now())}loadLines(t){this.emitEvent(I.beforeAddLines,t);const e=[],n=[];t.forEach(o=>{let{from:s,to:r,text:l}=o;if(!s)if(o.source)s=o.source,console.warn('Use "source" as "from":',o.source);else{console.error('JsonLine Must have field:"from"',o);return}if(!r)if(o.target)r=o.target,console.warn('Use "target" as "to":',o.target);else{console.error('JsonLine Must have field:"to"',o);return}l||o.label&&(l=o.label,console.warn('Use "label" as "text":',o.label));const c=this.getNodeById(s);if(!c){console.error("Can not found from node:",o);return}const h=this.getNodeById(r);if(!h){console.error("Can not found to node:",o);return}if(o.id){if(this.getLineById(o.id)){console.warn("loadLines:skip duplicate line id:",o.id);return}else if(n.some(g=>g.id===o.id)){console.warn("Duplicate line id in new lines:",o.id);return}}else o.id="L-"+this.generateNewUUID(6);const d=ct(Object.assign({},o,{from:s,to:r,text:l})),p={seeks_id:"LK-"+this.generateNewUUID(6),fromNode:c,toNode:h,forDisplayOnly:d.forDisplayOnly||!1,currentLineIndex:0,totalLinesBetweenNodes:1,rgShouldRender:!0,rgCalcedVisible:!0,line:d};n.push(d),e.push(p)}),this.graphData.normalLines.push(...n),this.runtimeDATA4Links.push(...e),this.updateLinks(e)}updateLinks(t){for(const e of t){const n=this.getLinesBetweenNodes([e.fromNode,e.toNode]);for(const o of n){const s=this.getLinkByLine(o);s.totalLinesBetweenNodes=n.length,s.currentLineIndex=n.findIndex(r=>r.id===s.line.id)}}}flatNodeData(t,e,n,o){A.flatNodeData(t,e,n,o)}loadGraphJsonData(t){t.lines||(t.lines=t.relations,console.warn("[relation-graph] For compatibility with older versionsm, Use jsonData.relations as jsonData.lines, It is recommended that you define your data using")),t.lines||(t.lines=t.links||t.edges,console.warn("[relation-graph] For compatibility with older versionsm, Use jsonData.links/jsonData.edges as jsonData.lines, It is recommended that you define your data using"));const e=t.nodes||[],n=t.lines||[],o=[],s=[];this.flatNodeData(e,null,o,s),n.forEach(r=>{s.push(r)}),this.loadNodes(o),v("Nodes is initialized"),this.loadLines(s),this._dataUpdated(),setTimeout(()=>{t.elementLines&&this.addElementLines(t.elementLines),t.fakeLines&&this.addFakeLines(t.fakeLines),this._dataUpdated()},500)}getLineArrow(t,e=!1,n=!1){const o=e?"start-":"";return`${this.options.instanceId}-${o}arrow-default`}getNodes(){return[...this.graphData.nodes]}getShouldRenderNodes(){return this.options.performanceMode?this.runtimeDATA4ShouldRenderGraphData.nodes:this.calcShouldRenderNodes()}calcShouldRenderNodes(){const t=[];return this.getNodes().forEach(e=>{e.rgShouldRender===!1||!A.isVisibleNode(e)||t.push(e)}),t}getShouldRenderLines(){return this.options.performanceMode?this.runtimeDATA4ShouldRenderGraphData.lines:this.calcShouldRenderLines()}calcShouldRenderLines(){const t=[];return this.runtimeDATA4Links.forEach(e=>{e.rgShouldRender===!1||e.line.hidden===!0||!(A.isVisibleNode(e.fromNode)&&A.isVisibleNode(e.toNode))||t.push(e.line)}),t}reinitMutationObservers(){this.destroyMutationObserver();const t=this.$dom.querySelector(".rg-nodes-container");if(t)this.mutationObserver4Nodes=new MutationObserver(o=>{for(const s of o){const r=this.getNodeElByChildrenTarget(s.target),l=this.domToNodeIdMap.get(r);l&&this.updateConnectTargetsOnNode("Mutation",l,r)}}),this.mutationObserver4Nodes.observe(t,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-nodes-container");const e=this.$dom.querySelector(".rg-canvas-slot-behind");if(e)this.mutationObserver4CanvasSlotBehind=new MutationObserver(o=>{console.warn("MutationObserver:updateConnectTargetsOnCanvas:mutations:",o),this.updateConnectTargetsOnCanvas("CanvasBehind-Mutation",e)}),this.mutationObserver4CanvasSlotBehind.observe(e,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-canvas-slot-behind");const n=this.$dom.querySelector(".rg-canvas-slot-above");n&&(this.mutationObserver4CanvasSlotAbove=new MutationObserver(o=>{this.updateConnectTargetsOnCanvas("CanvasAbove-Mutation",n)}),this.mutationObserver4CanvasSlotAbove.observe(n,{childList:!0,subtree:!0,characterData:!0}))}destroyMutationObserver(){this.mutationObserver4Nodes&&(this.mutationObserver4Nodes.disconnect(),this.mutationObserver4Nodes=void 0),this.mutationObserver4CanvasSlotBehind&&(this.mutationObserver4CanvasSlotBehind.disconnect(),this.mutationObserver4CanvasSlotBehind=void 0),this.mutationObserver4CanvasSlotAbove&&(this.mutationObserver4CanvasSlotAbove.disconnect(),this.mutationObserver4CanvasSlotAbove=void 0)}updateConnectTargetsOnCanvas(t,e){if(!e)return;console.warn(`updateConnectTargetsOnCanvas:[${t}]:`);const n=e.classList.contains("rg-canvas-slot-above")?"above":"behind",o=this.canvasConnectTargetsMap.get(n);o&&o.length>0&&this.updateConnectTargetList(t,e,o)}updateConnectTargetsByNodeId(t){const e=this.getNodeElByNodeId(t);this.updateConnectTargetsOnNode("API",t,e)}updateConnectTargetsOnNode(t,e,n){const o=this.nodeConnectTargetsMap.get(e)||[];o.length!==0&&requestIdleCallback(()=>{this.updateConnectTargetList(t,n,o)})}updateConnectTargetList(t,e,n){const o=this.options.canvasZoom/100,s=e.getBoundingClientRect();for(const r of n){const l=e.querySelector(`div[data-target-id="${r.targetId}"]`);if(!l){console.error("Can not find el for connectTarget:",r.targetId,r);continue}this.updateConnectTargetOffset(t,r,l,s,o)}this._dataUpdated()}updateConnectTargetOffset(t,e,n,o,s){const r=n.getBoundingClientRect(),l=Math.round(r.x-o.x),c=Math.round(r.y-o.y);e.offsetX=l/s,e.offsetY=c/s,e.width=r.width/s,e.height=r.height/s}_onConnectTargetMounted(t,e,n,o){const s=this.options.canvasZoom/100,r=o.getBoundingClientRect();this.updateConnectTargetOffset(t,e,n,r,s)}getNodeElByNodeId(t){return this.$dom.querySelector(`[data-id="${t}"]`)}getNodeElByChildrenTarget(t){return _t(t,"rg-node-peel","rg-map")}getConnectTargetById(t){if(!t)throw new Error("[getConnectTargetById]targetId is empty");for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++){const n=this.runtimeDATA4ConnectTargets[e];if(n.targetId===t)return n}}registerConnectTarget(t,e,n,o,s={}){if(n!==B.NodePoint&&n!==B.CanvasPoint)return;if(!t){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${e}`);return}const r=this.getNodeElByChildrenTarget(t),l=r==null?void 0:r.dataset.id;if(l==="rg-newNodeTemplate")return;let c=this.getConnectTargetById(e);if(!c){const d={targetId:e,targetType:B.NodePoint,junctionPoint:U.border,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:{}};this.runtimeDATA4ConnectTargets.push(d),c=this.getConnectTargetById(e)}if(l?this.getNodeById(l):null){c.junctionPoint=o,c.targetType=B.NodePoint,c.nodeId=l,c.targetData=Object.assign({},s||{},{nodeId:l});let d=this.nodeConnectTargetsMap.get(l);d?d.some(f=>f.targetId===c.targetId)||d.push(c):this.nodeConnectTargetsMap.set(l,[c]),this._onConnectTargetMounted("NT-Mounted",c,t,r)}else{const d=t.closest(".rg-canvas-slot");if(!d){console.error(`Can not find CanvasPoint target DOM's parent(.rg-canvas-slot) : ${e}`,t);return}const f=d.classList.contains("rg-canvas-slot-above")?"above":"behind";c.junctionPoint=o,c.targetType=B.CanvasPoint,c.targetData=Object.assign({},s||{});const p=this.canvasConnectTargetsMap.get(f);p?p.some(u=>u.targetId===c.targetId)||p.push(c):this.canvasConnectTargetsMap.set(f,[c]),this._onConnectTargetMounted("CT-Mounted",c,t,d)}return c}unregisterConnectTarget(t){if(this.options.performanceMode)return;const e=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===t);if(e!==-1){const n=this.runtimeDATA4ConnectTargets[e];if(n.targetType===B.NodePoint||n.targetType===B.CanvasPoint){this.runtimeDATA4ConnectTargets.splice(e,1);const o=n.nodeId&&this.nodeConnectTargetsMap.get(n.nodeId);if(o){const s=o.findIndex(r=>r.targetId===t);o.splice(s,1)}}}}setFakeLineTargetRender(t){this.fakeLineTargetRender=t}generateCreatingLineConfig(){const t=this.options,{newLinkTemplate:e,newLineTemplate:n}=t,o=e.fromNode;if(!o)return{line:n,from:null,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const s=e.toNode,r=s.targetType===B.Node?e.toNode:this.getFakeLineTarget(s.targetType,s.id,n);return{line:Object.assign({},n,{isFakeLine:!1}),from:this.getFakeLineTarget(o.targetType,o.id,n),to:r,totalLinesBetweenNodes:1,currentLineIndex:0}}getFakeLineTargetNode(t){return this.getNodeById(t)}getFakeLineTarget(t,e,n){if(t===B.HTMLElementId){let o=this.runtimeDATA4ElLineTargets.find(s=>s.id===e);return o||(o={x:300,y:300,targetType:B.HTMLElementId,nodeShape:1,id:e,el:{offsetWidth:40,offsetHeight:40},hidden:!0},this.runtimeDATA4ElLineTargets.push(o),this.updateCanvasBoxInfo(),this.updateElementTarget(o)),o.hidden?null:o}else{if(t===B.Node)return this.getFakeLineTargetNode(e);if(t===B.NodePoint||t===B.CanvasPoint){const o=this.getConnectTargetById(e);if(!o)return;if(o.nodeId){const s=this.getFakeLineTargetNode(o.nodeId);if(!s){console.error("[getFakeLineTarget]Can not find NodePoint-s Node:",`${o.targetId}@${o.nodeId}`);return}return{x:s.x+o.offsetPercentX*s.el.offsetWidth+o.offsetX,y:s.y+o.offsetPercentY*s.el.offsetHeight+o.offsetY,targetType:B.NodePoint,targetData:o.targetData,nodeShape:0,id:e,el:{offsetWidth:o.width,offsetHeight:o.height},hidden:!1}}else return{x:o.offsetX,y:o.offsetY,targetType:B.CanvasPoint,targetData:o.targetData,nodeShape:0,id:e,el:{offsetWidth:o.width,offsetHeight:o.height},hidden:!1}}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(t,e,n)}generateLineConfig(t){const e=this.getLinkByLine(t);return!e||!e.fromNode.rgCalcedVisible||!e.toNode.rgCalcedVisible?!1:{line:e.line,from:e.fromNode,to:e.toNode,totalLinesBetweenNodes:e.totalLinesBetweenNodes,currentLineIndex:e.currentLineIndex}}generateFakeLineConfig(t){let e=1,n=0;if(t.fromType===B.HTMLElementId&&t.toType===B.HTMLElementId){const r=this.graphData.fakeLines.filter(l=>l.from===t.from&&l.to===t.to);r.length>1&&(console.warn("sameTargetLines element-line:",t),e=r.length,n=r.indexOf(t))}let o=this.getFakeLineTarget(t.fromType,t.from,t),s=this.getFakeLineTarget(t.toType,t.to,t);return!o&&t.fromType===B.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",t.fromType,t.from,t),!1):!s&&t.fromType===B.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",t.toType,t.to,t),!1):{line:t,from:o,to:s,totalLinesBetweenNodes:e,currentLineIndex:n}}getShouldRenderFakeLines(){return this.graphData.fakeLines}getLinks(){return[...this.runtimeDATA4Links]}getRelatedLinesByNode(t){const e=[];for(const n of this.runtimeDATA4Links)(t===n.fromNode||t===n.toNode)&&e.push(n.line);return e}getLinesBetweenNodes(t){const e=[],n=this.runtimeDATA4Links;for(const o of n)t.includes(o.fromNode)&&t.includes(o.toNode)&&e.push(o.line);return e}transRGNodeToJsonObject(t){return Lt(t)}transRGLinkToJsonObject(t){const e=[];return wt(t,e),e}transRGLineToJsonObject(t){return Xt(t)}getGraphJsonData(){const t=[],e=[];return this.graphData.nodes.forEach(n=>{const o=Lt(n);o&&t.push(o)}),this.runtimeDATA4Links.forEach(n=>{wt(n,e)}),{rootId:this.graphData.rootNode?this.graphData.rootNode.id:"",nodes:t,lines:e}}getGraphJsonOptions(){const t={},e=["layouter","autoLayouting","canvasNVInfo","canvasOffset","canvasZoom","fullscreen","instanceId","layoutClassName","layoutDirection","layoutLabel","layoutName","resetViewSize","viewELSize","viewNVInfo","viewSize","canvasSize","newLinkTemplate","newLineTemplate","newNodeTemplate"];return Object.keys(this.options).forEach(n=>{e.includes(n)||(t[n]=this.options[n])}),t}printGraphJsonData(){console.log("graph options:",JSON.stringify(this.getGraphJsonOptions())),console.log("graph json data:",JSON.stringify(this.getGraphJsonData()))}getNodeById(t){for(let e=0;e<this.graphData.nodes.length;e++)if(this.graphData.nodes[e].id===t)return this.graphData.nodes[e]}addNode(t){if(v("addNode:",t),t&&Array.isArray(t)){console.error("addNode: node is array:",t);return}this.loadNodes([t]),this._dataUpdated()}addNodes(t){if(v("addNodes:",t),t&&!Array.isArray(t)){console.error("addNodes: nodes is not array:",t);return}this.loadNodes(t),this._dataUpdated()}getLinkById(t){for(let e=0;e<this.runtimeDATA4Links.length;e++)if(this.runtimeDATA4Links[e].seeks_id===t)return this.runtimeDATA4Links[e]}getLinkByLineId(t){for(let e=0;e<this.runtimeDATA4Links.length;e++)if(this.runtimeDATA4Links[e].line.id===t)return this.runtimeDATA4Links[e]}getLinkByLine(t){return this.getLinkByLineId(t.id)}getLineById(t){for(let e=0;e<this.runtimeDATA4Links.length;e++)if(this.runtimeDATA4Links[e].line.id===t)return this.runtimeDATA4Links[e].line}getLines(){const t=[];for(const e of this.runtimeDATA4Links)t.push(e.line);return t}addLine(t){if(v("addLine:",t),t&&Array.isArray(t)){console.error("addLine: line is array:",t);return}this.addLines([t])}addLines(t){if(v("addLines:",t),t&&!Array.isArray(t)){console.error("addLines: lines is not array:",t);return}if(t.length===0)return;const e=t.filter(o=>!o.isFakeLine);this.loadLines(e);const n=t.filter(o=>o.isFakeLine);this.addFakeLines(n),this._dataUpdated()}removeLine(t){if(!t)throw new Error("removeLine: line is null");if(t.isFakeLine){this.removeFakeLine(t);return}let e=this.getLinkByLine(t);if(!e){v("Can not find link by line:",t);return}v("removeLine:",e,t);const n=this.graphData.normalLines.findIndex(o=>o.id===t.id);n!==-1&&this.graphData.normalLines.splice(n,1),this.removeLink(e),this.updateLinks([e]),this._dataUpdated()}removeLineById(t){let e=this.getFakeLineById(t);if(e){this.removeFakeLine(e);return}v("removeLineById:",t),this.removeLine(this.getLineById(t))}removeLink(t){v("removeLink:",t),this.removeLinkById(t.seeks_id),this._dataUpdated()}removeLinkById(t){v("removeLinkById:",t);for(let e=0;e<this.runtimeDATA4Links.length;e++)if(this.runtimeDATA4Links[e].seeks_id===t){this.runtimeDATA4Links.splice(e,1);break}this._dataUpdated()}getFakeLines(){return[...this.graphData.fakeLines]}addFakeLines(t){v("addFakeLines:",t);for(const e of t)if(e.id||console.warn("Must have id for fake line:",e),this.graphData.fakeLines.some(n=>n.id===e.id))console.error("Ignore duplicate fake line id:",e.id);else{e.isFakeLine=!0;const n=ct(e);n.forDisplayOnly=!0,n.id||(n.id=this.generateNewUUID(6)),this.graphData.fakeLines.push(n)}setTimeout(()=>{this._dataUpdated(),setTimeout(()=>{this._dataUpdated()},300)},100)}removeFakeLine(t){v("removeLine:",t),this.removeFakeLineById(t.id)}getFakeLineById(t){return this.graphData.fakeLines.find(e=>e.id===t)}removeFakeLineById(t){v("removeLineById:",t);for(let e=0;e<this.graphData.fakeLines.length;e++)if(this.graphData.fakeLines[e].id===t){this.graphData.fakeLines.splice(e,1);break}this._dataUpdated()}addElementLines(t){v("addElementLines:",t),t.forEach(e=>{e.fromType=B.HTMLElementId,e.toType=B.HTMLElementId,e.isFakeLine=!0,e.id||(e.id=this.generateNewUUID(6)),e.forDisplayOnly=!0}),this.addFakeLines(t),console.log("addElementLines:",t.length,t),this.updateElementLines()}getElementLineById(t){return this.getFakeLineById(t)}getElementLines(){return this.getFakeLines()}removeELementLineById(t){v("removeELementLineById:",t),this.removeFakeLineById(t)}updateElementLines(){v("updateElementLines:runtimeDATA4ElLineTargets:",this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4ElLineTargets.length!==0&&(this.elLineUpdating||(this.elLineUpdating=!0,setTimeout(()=>{this.elLineUpdating=!1,this._updateElementLines()},50)))}_updateElementLines(){this.updateCanvasBoxInfo();for(const t of this.runtimeDATA4ElLineTargets)this.updateElementTarget(t);this._dataUpdated()}updateCanvasBoxInfo(){const t=this.$canvasDom.getBoundingClientRect();this._canvasBoxXY.x=t.x,this._canvasBoxXY.y=t.y}updateElementTarget(t){const e=document.getElementById(t.id);e&&(t.hidden=!e),this._updateElementLinePosition(e,t)}_updateElementLinePosition(t,e){if(!t)return;const n=t.getBoundingClientRect();e.x=(n.x-this._canvasBoxXY.x)/(this.options.canvasZoom/100),e.y=(n.y-this._canvasBoxXY.y)/(this.options.canvasZoom/100);const o=n.width/(this.options.canvasZoom/100),s=n.height/(this.options.canvasZoom/100);o>2&&Math.abs(o-e.el.offsetWidth)>2&&(e.el.offsetWidth=o),s>2&&Math.abs(s-e.el.offsetHeight)>2&&(e.el.offsetHeight=s)}getElementPosition(t){const n=document.getElementById(t).getBoundingClientRect(),o=this.$canvasDom.getBoundingClientRect(),s=(n.x-o.x)/(this.options.canvasZoom/100),r=(n.y-o.y)/(this.options.canvasZoom/100);return{x:s,y:r}}removeNodeById(t){let e=0;for(let o=0;o<this.runtimeDATA4Links.length;o++){const s=this.runtimeDATA4Links[o];(s.fromNode.id===t||s.toNode.id===t)&&(this.removeLink(s),o--,e++)}v("Removed Node link\uFF1A",t,e),this.beforeNodeBeRemove(t),v("Removed Node line/connect-arget\uFF1A",t);let n=0;for(let o=0;o<this.graphData.nodes.length;o++)if(this.graphData.nodes[o].id===t){this.graphData.nodes.splice(o,1),this.runtimeDATA4NodeMap[t]=void 0,delete this.runtimeDATA4NodeMap[t],n++;break}v("Removed node\uFF1A",t,n),this._dataUpdated()}removeNode(t){this.removeNodeById(t.id),this._dataUpdated()}getNodeRelatedNodes(t){const e=[];for(const n of this.runtimeDATA4Links)n.forDisplayOnly||(n.fromNode===t?e.push(n.toNode):n.toNode===t&&e.push(n.fromNode));return e}getNodeRelatedNodes4From(t){const e=[];for(const n of this.runtimeDATA4Links)n.forDisplayOnly||n.toNode===t&&e.push(n.fromNode);return e}getNodeRelatedNodes4To(t){const e=[];for(const n of this.runtimeDATA4Links)n.forDisplayOnly||n.fromNode===t&&e.push(n.toNode);return e}beforeNodeBeRemove(t){for(let e=0;e<this.graphData.fakeLines.length;e++){const n=this.graphData.fakeLines[e];let o=!1;if(n.fromType===B.Node&&n.from===t)o=!0;else if(n.fromType===B.CanvasPoint||n.fromType===B.NodePoint){const s=this.getConnectTargetById(n.from);s&&s.nodeId===t&&(o=!0)}else if(n.toType===B.CanvasPoint||n.toType===B.NodePoint){const s=this.getConnectTargetById(n.to);s&&s.nodeId===t&&(o=!0)}o&&(this.graphData.fakeLines.splice(e,1),e--)}for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++)this.runtimeDATA4ConnectTargets[e].nodeId===t&&(this.runtimeDATA4ConnectTargets.splice(e,1),e--)}setNodePosition(t,e,n){t.x=e,t.y=n}getGraphOffet(){const t=this.options.graphOffset_x||0,e=this.options.graphOffset_y||0;return{offset_x:t,offset_y:e}}setCanvasCenter(t,e){const n=this.options.viewSize.width/2,o=this.options.viewSize.height/2,s=this.getGraphOffet();this.setZoom(100),this.setCanvasOffset(n-t+s.offset_x,o-e+s.offset_y)}setCanvasOffset(t,e){this.options.canvasOffset.x=t,this.options.canvasOffset.y=e,!this.canvasDragging&&this._dataUpdated()}findGroupNodes(t,e=[]){return this.getNetworkNodesByNode(t,e)}getGroupNodesByNode(t,e=[]){return this.getNetworkNodesByNode(t,e)}getNetworkNodesByNode(t,e=[]){if(!t)throw new Error("Call graphInstance.getNetworkNodesByNode:error: node is undefined");e.includes(t)||e.push(t);for(const n of this.getNodeRelatedNodes(t))e.includes(n)||this.getNetworkNodesByNode(n,e);return e}getDescendantNodes(t){return A.getDescendantNodes(t)}resetViewSize(t=!1){if(!this.options)return;const e=this.$dom.getBoundingClientRect();this.options.viewSize.width=e.width,this.options.viewSize.height=e.height,this._rgAsConnectArea?(this.options.canvasZoom=100,this.options.canvasOffset.x=0,this.options.canvasOffset.y=0):t&&(this.options.canvasZoom=100,this.setCanvasCenter(0,0)),v("resetViewSize:1:",this.options.viewSize.width,this.options.viewSize.height,this.options.canvasOffset.x,this.options.canvasOffset.y),this.updateViewBoxInfo(),this._dataUpdated()}updateViewBoxInfo(){if(!this.$dom){console.error("cannot get view size !");return}const t=this.$dom.getBoundingClientRect();v("resetViewSize:",t.width,t.height,t.left,t.top),this.options.viewELSize.width=t.width,this.options.viewELSize.height=t.height,this.options.viewELSize.left=t.left,this.options.viewELSize.top=t.top}getStuffSize(t){const n=(t||this.graphData.nodes).filter(d=>d.rgCalcedVisible!==!1);if(n.length===0)return{width:10,height:10,minX:0,minY:0,maxX:0,maxY:0};let o=9999999,s=9999999,r=-9999999,l=-9999999;n.forEach(d=>{d.x<o&&(o=d.x),d.x+d.el.offsetWidth>r&&(r=d.x+d.el.offsetWidth),d.y<s&&(s=d.y);const p=d.y+d.el.offsetHeight;p>l&&(l=p)});const c=r-o,h=l-s;return{width:c<0?0:c,height:h<0?0:h,minX:o===9999999?0:o,minY:s===9999999?0:s,maxX:r===-9999999?0:r,maxY:l===-9999999?0:l}}getNodesViewInfo(t){return this.getStuffSize(t)}getNodesCenter(t){const e=this.getStuffSize(t);v("getStuffSize:",e);const n=e.minX+(e.maxX-e.minX)/2,o=e.minY+(e.maxY-e.minY)/2;return{x:n,y:o}}printOptions(){const t=this.getGraphJsonOptions();console.log("options:",t),console.log("options-json-string:"),console.log(JSON.stringify(t))}printData(){const t=this.getGraphJsonData();console.log("data:",t),console.log("data-json-string:"),console.log(JSON.stringify(t))}loading(t=""){this.options.graphLoading=!0,this.options.graphLoadingText=t}clearLoading(){this.options.graphLoading=!1,this.options.graphLoadingText=""}updateShouldRenderGraphData(t=!1){!t&&!this.options.performanceMode||this._updateShouldRenderGraphData()}_updateShouldRenderGraphData(){const t=this.getBoundingClientRect(),e=this.getCanvasXyByClientXy({x:t.x,y:t.y}),n=this.getCanvasXyByClientXy({x:t.x+this.options.viewELSize.width,y:t.y+this.options.viewELSize.height}),o=this.options.snapshotting;let s=0;for(const r of this.graphData.nodes){let l=!0;o||r.alwaysRender?l=!0:((r.x>n.x||r.y>n.y)&&(l=!1),(r.x+r.el.offsetWidth<e.x||r.y+r.el.offsetHeight<e.y)&&(l=!1)),r.rgShouldRender=l,l&&s++}for(const r of this.runtimeDATA4Links){if(o){r.rgShouldRender=!0;continue}r.rgShouldRender=r.fromNode.rgShouldRender||r.toNode.rgShouldRender}this.options.showEasyView&&s>1e3?(this.runtimeDATA4ShouldRenderGraphData.nodes=[],this.runtimeDATA4ShouldRenderGraphData.lines=[]):(this.runtimeDATA4ShouldRenderGraphData.nodes=this.calcShouldRenderNodes(),this.runtimeDATA4ShouldRenderGraphData.lines=this.calcShouldRenderLines()),v("updateShouldRenderGraphData:",this.options.showEasyView,n.x,s)}updateNodesVisibleProperty(){for(const t of this.graphData.nodes)t.rgCalcedVisible=A.isVisibleNode(t);for(const t of this.runtimeDATA4Links)t.rgCalcedVisible=t.fromNode.rgCalcedVisible&&t.toNode.rgCalcedVisible&&!t.line.hidden}setCanvasMoveMode(t){this.options.canvasMoveMode=t,this._dataUpdated()}defaultLineConnectEndHandler(t,e,n){v("defaultLineConnectEndHandler:",t,e,n)}defaultLineVertexBeChangedHandler(t,e,n){v("defaultLineVertexBeChangedHandler:",n&&n.isReverse)}}class en extends tn{constructor(t,e){super(t,e);S(this,"$watermarkDom",null);S(this,"$watermarkPosition","br");S(this,"$backgroundDom",null)}setWatermarkDom(t,e=!0,n=!1,o="br"){e&&(this.$watermarkDom=t),this.$watermarkPosition=o}setBackgroundDom(t,e=!0,n=!0){e&&(this.$backgroundDom=t)}dataURLToBlob(t){try{const e=t.split(","),n=e[0],o=n&&n.match(/:(.*?);/)[1],s=atob(e[1]);let r=s.length;const l=new Uint8Array(r);for(;r--;)l[r]=s.charCodeAt(r);return new Blob([l],{type:o})}catch(e){console.error("[relation-graph]Create and download image error:dataURLToBlob:dataurl",t),console.error("[relation-graph]error object",e)}}async createGraphCanvas(t="png"){const e=this.options.canvasZoom,n=this.$canvasDom.clientWidth,o=this.$canvasDom.clientHeight,s=this.options.layout.autoLayouting;s&&this.stopAutoLayout(),this.loading("Generating..."),this.options.snapshotting=!0;const r=await this.createGraphMainCanvas(t),l=this.$backgroundDom?await this.createGraphBackgroundCanvas(t):null,c=this.$watermarkDom?await this.createGraphWatermarkCanvas(t):null,h=this.mergeCanvas(l,r,c);return this.options.canvasSize.width=n,this.options.canvasSize.height=o,this.options.snapshotting=!1,this._zoomEnd(100,e),this.updateShouldRenderGraphData(),this.updateElementLines(),s&&this.startAutoLayout(),this.clearLoading(),this.dataUpdated(),h}mergeCanvas(t,e,n){const o=window.devicePixelRatio,s=document.createElement("canvas"),r=this.options.canvasSize.width,l=this.options.canvasSize.height;s.width=r*o,s.height=l*o,s.style.width=`${r}px`,s.style.height=`${l}px`;const c=s.getContext("2d");if(s.getContext("2d").scale(1,1),t?c.drawImage(t,0,0):(c.fillStyle=!this.options.backgroundColor||this.options.backgroundColor==="transparent"?"#ffffff":this.options.backgroundColor,c.fillRect(0,0,s.width,s.height)),c.drawImage(e,0,0),n){const h=this.$watermarkDom.getBoundingClientRect(),d=h.width,f=h.height;let p=r-d-20,u=l-f-20;this.$watermarkPosition==="bl"?(p=20,u=l-f-20):this.$watermarkPosition==="tl"?(p=20,u=20):this.$watermarkPosition==="tr"&&(p=r-d-20,u=20),c.drawImage(n,p*o,u*o)}return s}async createGraphBackgroundCanvas(t="png"){const e=window.devicePixelRatio,n=document.createElement("canvas"),o=this.options.canvasSize.width,s=this.options.canvasSize.height;n.width=o*e,n.height=s*e,n.style.width=`${o}px`,n.style.height=`${s}px`,n.getContext("2d").scale(e,e);const r=this.$backgroundDom;r.style.width=this.options.canvasSize.width+"px",r.style.height=this.options.canvasSize.height+"px";const l={backgroundColor:"#ffffff",scale:1,canvas:n,logging:!0,width:this.options.canvasSize.width,height:this.options.canvasSize.height,useCORS:!0},c=await this.createImage(r,l,t,"");return r.style.width="",r.style.height="",c}async createGraphWatermarkCanvas(t="png"){const e=this.$canvasDom.clientWidth,n=this.$canvasDom.clientHeight,o=window.devicePixelRatio,s=document.createElement("canvas");s.width=e*o,s.height=n*o,s.style.width=`${e}px`,s.style.height=`${n}px`,s.getContext("2d").scale(o,o);const r=this.$watermarkDom,l={backgroundColor:"transparent",scale:1,canvas:s,logging:!0,width:e,height:n,useCORS:!0};return await this.createImage(r,l,t,"")}async createGraphMainCanvas(t="png"){const e=this.options.canvasZoom,n=this.options.canvasOffset.x,o=this.options.canvasOffset.y;this.options.checkedNodeId="",this.options.canvasZoom=100,this._zoomEnd(e,this.options.canvasZoom),this.updateShouldRenderGraphData(!0),await ft(500);const s=this.$canvasDom;let r=999999,l=999999,c=-999999,h=-999999;this.graphData.nodes.forEach(E=>{E.x<r&&(r=E.x);const T=E.x+E.el.offsetWidth;T>c&&(c=T);const D=E.y+E.el.offsetHeight;E.y<l&&(l=E.y),D>h&&(h=D)});const d=new WeakMap,f=this.$dom.querySelectorAll("> .rg-map-canvas > .rg-canvas-slot");for(const E of f){let T=999999,D=999999,R=-999999,_=-999999;for(const z of E.children){const F=z,V=F.offsetLeft,P=F.offsetTop;V<T&&(T=V),V>R&&(R=V+F.offsetWidth),P<D&&(D=P),P>_&&(_=P+F.offsetHeight)}T<r&&(r=T),D<l&&(l=D),R>c&&(c=R),_>h&&(h=_),T!==999999&&d.set(E,{offsetX:T,offsetY:D})}const p=200;r=r-p,l=l-p,c=c+p,h=h+p;const u=r,g=l;this.graphData.nodes.forEach(E=>{E.x=E.x-u,E.y=E.y-g});for(const E of f){const T=E;T.style.marginLeft=-u+"px",T.style.marginTop=-g+"px"}this.updateElementLines();const x=this.$canvasDom.querySelectorAll(".rg-lines-svg-el-lines");x.forEach(E=>{const T=E;T.style.width="4000px",T.style.height="4000px"}),this.options.canvasOffset.x=0,this.options.canvasOffset.y=0;const y=c-r,L=h-l,m=window.devicePixelRatio;this.options.canvasSize.width=y,this.options.canvasSize.height=L,v("export image:",{_image_width:y,_image_height:L,_min_x:r,_min_y:l,_max_x:c,_max_y:h,devicePixelRatio:window.devicePixelRatio}),window.scrollTo(0,0);const w=document.createElement("canvas"),b=y,M=L;w.width=b*m,w.height=M*m,w.style.width=`${b}px`,w.style.height=`${M}px`,w.getContext("2d").scale(m,m);const N={backgroundColor:"transparent",scale:1,canvas:w,logging:!0,width:this.options.canvasSize.width,height:this.options.canvasSize.height,useCORS:!0};this.dataUpdated(),await ft(1e3);const O=await this.createImage(s,N,t,"");return f.forEach(E=>{const T=E;T.style.marginLeft="0px",T.style.marginTop="0px"}),this.graphData.nodes.forEach(E=>{E.x=E.x+u,E.y=E.y+g}),x.forEach(E=>{const T=E;T.style.width="1px",T.style.height="1px"}),this.options.canvasOffset.x=n,this.options.canvasOffset.y=o,this.options.canvasZoom=e,O}async createImage(t,e,n,o){v("createImage:",e);const s=window.getHtml2canvas();if(!s){console.error('Please define function window.getHtml2canvas, Make sure you can get "html2canvas" through the following code: const html2canvas = window.getHtml2canvas();');return}return await s(t,e)}async getImageBase64(t="png"){throw new Error("getImageBase64 is deprecated, Please get dom and trans to image by yourself!")}async downloadAsImage(t="png",e){if(this.emitEvent(I.onImageDownload,this.$canvasDom,t)===!1)return;if(this.graphData.nodes.length===0)throw new Error("No nodes, no content to export!");e||(e=this.options.downloadImageFileName),e||(e=`relation-graph-${(Math.random()*1e5).toFixed(0)}`);const o=await this.createGraphCanvas(t);v("downloadImageAsFile:",t,e),this.emitEvent(I.onImageDownload,this.$canvasDom,t)!==!1&&await this.downloadImageAsFile(o,t,e)}async downloadImageAsFile(t,e,n){const o=document.body.appendChild(t);o.style.display="none";const s=this.dataURLToBlob(o.toDataURL(`image/${e}`));document.body.removeChild(o);const r=document.createElement("a");r.style.display="none";try{window.navigator.msSaveOrOpenBlob?window.navigator.msSaveOrOpenBlob(s,`${n}.${e}`):(r.setAttribute("href",URL.createObjectURL(s)),r.setAttribute("download",`${n}.${e}`),document.body.appendChild(r),r.click(),v("click ok!"),URL.revokeObjectURL(await s.text()),v("revokeObjectURL ok!"),document.body.removeChild(r),v("removeChild ok!"))}catch(l){v("[relation-graph]Create and download image error:",l)}}}const ht=i=>!i||i.length===0?"":i.map(a=>{switch(a.type){case"M":return`${a.type} ${a.x} ${a.y}`;case"l":return`${a.type} ${a.dx} ${a.dy}`;case"L":return`${a.type} ${a.x} ${a.y}`;case"h":return`${a.type} ${a.dx}`;case"v":return`${a.type} ${a.dy}`;case"c":return`${a.type} ${a.dx1} ${a.dy1} ${a.dx2} ${a.dy2} ${a.dx} ${a.dy}`;case"s":return`${a.type} ${a.dx2} ${a.dy2} ${a.dx} ${a.dy}`;case"q":return`${a.type} ${a.dx1} ${a.dy1} ${a.dx} ${a.dy}`;case"Q":return`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`;case"t":return`${a.type} ${a.dx} ${a.dy}`;case"a":return`${a.type} ${a.rx} ${a.ry} ${a.xAxisRotation} ${a.largeArcFlag} ${a.sweepFlag} ${a.dx} ${a.dy}`;case"Z":return a.type;default:return console.warn("\u672A\u77E5\u7684\u8DEF\u5F84\u547D\u4EE4\u7C7B\u578B:",a),""}}).join(" ").trim(),Zt=i=>{const a=i.match(/[a-zA-Z][^a-zA-Z]*/g);let t=0,e=0,n=0,o=0,s=0,r=0,l=0,c=0;const h={x:0,y:0},d={x:0,y:0},f=[];for(const p of a){const u=p.trim().split(/[ ,]+/),g=u[0].toUpperCase(),x=u[0]===u[0].toLowerCase();switch(g){case"M":t=J(n,u[1],x),e=J(o,u[2],x),n=t,o=e;break;case"L":t=J(n,u[1],x),e=J(o,u[2],x),f.push({x:t,y:e});break;case"C":s=J(n,u[1],x),r=J(o,u[2],x),l=J(n,u[3],x),c=J(o,u[4],x),t=J(n,u[5],x),e=J(o,u[6],x),n=t,o=e;break;case"Q":s=J(n,u[1],x),r=J(o,u[2],x),t=J(n,u[3],x),e=J(o,u[4],x),n=t,o=e;break;case"V":e=J(o,u[1],x),o=e;break;case"H":t=J(n,u[1],x),n=t;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}p===a[0]&&(h.x=t,h.y=e),p===a[a.length-1]&&(d.x=t,d.y=e)}return{startPoint:h,ctrl1:{x:s,y:r},ctrl2:{x:l,y:c},endPoint:d,lines:f}},J=(i,a,t)=>t?i+parseFloat(a):parseFloat(a),nn=(i,a={x:0,y:0,rotate:0})=>{const{fx:t,fy:e,tx:n,ty:o}=i;a.rotate=Z.getTextAngle(t,e,n,o),a.x=Math.round(t+(n-t)/2),a.y=Math.round(e+(o-e)/2),Number.isNaN(a.rotate)&&(a.rotate=0);const s=Math.round(n-t),r=Math.round(o-e),l=[{type:"M",x:Math.round(t),y:Math.round(e)},{type:"l",dx:s,dy:r}],c=ht(l);return{pathCommands:l,pathData:c,textPosition:a,points:[]}},on=(i,a={x:0,y:0,rotate:0},t={})=>{const{line:e,fx:n,fy:o,fcx:s,fcy:r,f_W:l,f_H:c,tx:h,ty:d,tcx:f,tcy:p,t_W:u,t_H:g}=i,x=h-n,y=d-o,L=n-s,m=o-r,w=h-f,b=d-p,M=e.lineRadius!==void 0?e.lineRadius:t.lineRadius||0,N=Math.min(M,Math.abs(x))*(n<h?1:-1),O=Math.min(M,Math.abs(y))*(o<d?1:-1),E=e.lineDirection||Math.abs(L)>=l/2?"h":"v",T=e.lineDirection||Math.abs(w)>=u/2?"h":"v",D=[];let R=0,_=0;if(E==="v"){const F=e.polyLineStartDistance||Math.max(Math.min(30,Math.abs(d-o)/2),15),V=m>0?F:-F;if(e.onPathStartOffset==="start"?(R=n,_=o+V-(m>0?20:-5)):e.onPathStartOffset==="middle"?(R=n+(h-n)/2,_=o+V):(R=h,_=o+V+(m>0?20:-5)),D.push({type:"M",x:Math.round(n),y:Math.round(o)},{type:"v",dy:Math.round(V-O)},{type:"c",dx1:0,dy1:Math.round(O),dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)}),T==="v")D.push({type:"h",dx:Math.round(h-n-N*2)},{type:"c",dx1:Math.round(N),dy1:0,dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)},{type:"v",dy:Math.round(d-o-V-O)});else{const P=Math.min(30,Math.abs(h-n)/2),$=w>0?-P:P;D.push({type:"h",dx:Math.round(h-n+$-N)},{type:"c",dx1:Math.round(N),dy1:0,dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)},{type:"v",dy:Math.round(d-o-V-O)},{type:"h",dx:Math.round($-N)})}}else{const F=e.polyLineStartDistance||Math.max(Math.min(30,Math.abs(h-n)/2),15),V=L>0?F:-F;if(e.onPathStartOffset==="start"?(R=n+(L>0?10:-50),_=o-5):e.onPathStartOffset==="center"||e.onPathStartOffset==="middle"?(R=n+V,_=o+(d-o)/2):(R=n+V+(L>0?20:-50),_=d-5),D.push({type:"M",x:Math.round(n),y:Math.round(o)},{type:"h",dx:Math.round(V-N)},{type:"c",dx1:Math.round(N),dy1:0,dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)}),T==="v"){const P=Math.min(30,Math.abs(d-o)/2),$=b>0?-P:P;D.push({type:"v",dy:Math.round(d-o+$-O)},{type:"h",dx:Math.round(h-n-V-N)},{type:"c",dx1:0,dy1:Math.round(O),dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)},{type:"v",dy:Math.round($-O)})}else D.push({type:"v",dy:Math.round(d-o-O*2)},{type:"c",dx1:0,dy1:Math.round(O),dx2:Math.round(N),dy2:Math.round(O),dx:Math.round(N),dy:Math.round(O)},{type:"h",dx:Math.round(h-n-V-N)})}a.x=R,a.y=_;const z=ht(D);return{pathCommands:D,pathData:z,textPosition:a,points:[]}},bt={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},sn=({source:i,sourcePosition:a="bottom",target:t})=>a==="left"||a==="right"?i.x<t.x?{x:1,y:0}:{x:-1,y:0}:i.y<t.y?{x:0,y:1}:{x:0,y:-1},Jt=(i,a)=>Math.sqrt(Math.pow(a.x-i.x,2)+Math.pow(a.y-i.y,2));function Pt({source:i,sourcePosition:a="bottom",target:t,targetPosition:e="top",center:n,sourceOffset:o,targetOffset:s}){const r=bt[a],l=bt[e],c={x:i.x+r.x*o,y:i.y+r.y*o},h={x:t.x+l.x*s,y:t.y+l.y*s},d=sn({source:c,sourcePosition:a,target:h}),f=d.x!==0?"x":"y",p=d[f];let u=[],g,x;const y={x:0,y:0},L={x:0,y:0};let m=0;if(r[f]*l[f]===-1){g=n.x,x=n.y;const b=[{x:g,y:c.y},{x:g,y:h.y}],M=[{x:c.x,y:x},{x:h.x,y:x}];r[f]===p?(m=1.1,u=f==="x"?b:M):(m=1.2,u=f==="x"?M:b)}else{const b=[{x:c.x,y:h.y}],M=[{x:h.x,y:c.y}];if(f==="x"?u=r.x===p?M:b:u=r.y===p?b:M,a===e){m=2.1;const D=Math.abs(i[f]-t[f]),R=r[f]===p?o:s;if(D<=R){const _=Math.min(R-1,R-D);r[f]===p?y[f]=(c[f]>i[f]?-1:1)*_:L[f]=(h[f]>t[f]?-1:1)*_}}if(a!==e){m=2.2;const D=f==="x"?"y":"x",R=r[f]===l[D],_=c[D]>h[D],z=c[D]<h[D];(r[f]===1&&(!R&&_||R&&z)||r[f]!==1&&(!R&&z||R&&_))&&(u=f==="x"?b:M)}const N={x:c.x+y.x,y:c.y+y.y},O={x:h.x+L.x,y:h.y+L.y},E=Math.max(Math.abs(N.x-u[0].x),Math.abs(O.x-u[0].x)),T=Math.max(Math.abs(N.y-u[0].y),Math.abs(O.y-u[0].y));E>=T?(g=(N.x+O.x)/2,x=u[0].y):(g=u[0].x,x=(N.y+O.y)/2)}const w=[i,{x:c.x+y.x,y:c.y+y.y},...u,{x:h.x+L.x,y:h.y+L.y},t];return an(w),[w,g,x,0,0,m]}const an=i=>{for(let a=0;a<i.length;a++){const t=i[a];t.x=Math.round(t.x),t.y=Math.round(t.y)}},Ot=i=>{const a=[];for(let t=0;t<i.length;t++){const e=i[t];if(e.x=Math.round(e.x),e.y=Math.round(e.y),t===0||t===i.length-1)a.push(e);else{const n=a[a.length-1];e.x===n.x&&e.y===n.y||a.push(e)}}for(let t=2;t<a.length;t++){const e=a[t-2],n=a[t-1],o=a[t],s=e.x===n.x?"v":"h",r=n.x===o.x?"v":"h";s===r&&(n.merged=!0)}return a.filter(t=>t.merged!==!0)};function rn(i,a,t,e){const n=Math.min(Jt(i,a)/2,Jt(a,t)/2,e),{x:o,y:s}=a;if(i.x===o&&o===t.x||i.y===s&&s===t.y)return[{type:"L",x:o,y:s}];if(i.y===s){const c=i.x<t.x?-1:1,h=i.y<t.y?1:-1;return[{type:"L",x:o+n*c,y:s},{type:"Q",x1:o,y1:s,x:o,y:s+n*h}]}const r=i.x<t.x?1:-1,l=i.y<t.y?-1:1;return[{type:"L",x:o,y:s+n*l},{type:"Q",x1:o,y1:s,x:o+n*r,y:s}]}const me=(i,a)=>{const t=[];return i.forEach((e,n)=>{if(n===0)t.push({type:"M",x:Math.round(e.x),y:Math.round(e.y)});else if(n===i.length-1){const o=i[n-1],s=o.x===e.x?0:o.x<e.x?-1:1,r=o.y===e.y?0:o.y<e.y?-1:1;t.push({type:"l",dx:Math.round(e.x-o.x+s*5),dy:Math.round(e.y-o.y+r*5)})}else{const o=rn(i[n-1],e,i[n+1],a);t.push(...o)}}),t};var ot=(i=>(i.border="border",i.ltrb="ltrb",i.tb="tb",i.lr="lr",i.left="left",i.right="right",i.top="top",i.bottom="bottom",i))(ot||{});const St=(i,a,t,e,n,o,s,r)=>i==="left"?"left":i==="right"?"right":i==="top"?"top":i==="bottom"?"bottom":i==="horizontalLine"?e?o>r?"bottom":"top":o<r?"bottom":"top":i==="verticalLine"?e?n>s?"right":"left":n<s?"right":"left":a===1?"right":a===-1?"left":t===1?"bottom":t===-1?"top":"left",qt=i=>i==="left"?"right":i==="right"?"left":i==="top"?"bottom":i==="bottom"?"top":"left",xe=i=>{if(i.length<2)throw new Error("At least two points are required to form a polyline.");let a=0;const t=[];for(let o=1;o<i.length;o++){const s=i[o].x-i[o-1].x,r=i[o].y-i[o-1].y,l=Math.sqrt(s*s+r*r);t.push(l),a+=l}const e=a/2;let n=0;for(let o=0;o<t.length;o++)if(n+=t[o],n>=e){const s=i[o],r=i[o+1],l=t[o],h=(e-(n-l))/l,d=s.x+(r.x-s.x)*h,f=s.y+(r.y-s.y)*h;return{x:d,y:f}}return{x:0,y:0}},ln=(i,a={x:0,y:0,rotate:0},t={})=>{const{line:e,fromJunctionPoint:n,toJunctionPoint:o,lineDirection:s,lineShape:r,fx:l,fy:c,fcx:h,fcy:d,f_W:f,f_H:p,tx:u,ty:g,tcx:x,tcy:y,t_W:L,t_H:m}=i,w=l-h,b=c-d;let M=w>3?1:w<-3?-1:0,N=b>3?1:b<-3?-1:0;Math.abs(M)===1&&Math.abs(N)===1&&(Math.abs(w)>Math.abs(b)?N=0:M=0),M===0&&N===0&&(M=1);const O=u-x,E=g-y;let T=O>3?1:O<-3?-1:0,D=E>3?1:E<-3?-1:0;Math.abs(T)===1&&Math.abs(D)===1&&(Math.abs(O)>Math.abs(E)?D=0:T=0),T===0&&D===0&&(M=-1);const R=St(n,M,N,!1,l,c,u,g),_=St(o,T,D,!0,l,c,u,g),z=e.isReverse?_:R,F=e.isReverse?R:_,V=l+(u-l)/2,P=c+(g-c)/2;let $={x:0,y:0},Y=30,j=30;e.ctrlOptionsFor44&&($={x:e.ctrlOptionsFor44.cx,y:e.ctrlOptionsFor44.cy},Y+=e.ctrlOptionsFor44.fd,j+=e.ctrlOptionsFor44.td);const X=e.lineRadius!==void 0?e.lineRadius:t.lineRadius||0,[st]=Pt({source:{x:l,y:c},sourcePosition:z,target:{x:u,y:g},targetPosition:F,center:{x:V+$.x,y:P+$.y},sourceOffset:Y,targetOffset:j}),et=Ot(st),K=me(et,X),tt=ht(K),at=xe(st);return a.x=at.x,a.y=at.y,{pathCommands:K,pathData:tt,textPosition:a,points:et,startDirection:z,endDirection:F}},cn=(i,a={x:0,y:0,rotate:0},t={})=>{const{line:e,fromJunctionPoint:n,toJunctionPoint:o,lineDirection:s,lineShape:r,fx:l,fy:c,fcx:h,fcy:d,f_W:f,f_H:p,tx:u,ty:g,tcx:x,tcy:y,t_W:L,t_H:m}=i,w=l-h,b=c-d;let M=w>3?1:w<-3?-1:0,N=b>3?1:b<-3?-1:0;Math.abs(M)===1&&Math.abs(N)===1&&(Math.abs(w)>Math.abs(b)?N=0:M=0),M===0&&N===0&&(M=1);const O=u-x,E=g-y;let T=O>3?1:O<-3?-1:0,D=E>3?1:E<-3?-1:0;Math.abs(T)===1&&Math.abs(D)===1&&(Math.abs(O)>Math.abs(E)?D=0:T=0),T===0&&D===0&&(M=-1);let R=St(n,M,N,!1,l,c,u,g),_=St(o,T,D,!0,l,c,u,g);const z=e.lineRadius!==void 0?e.lineRadius:t.lineRadius||0,F=e.ctrlPointsFor49;let V={x:Math.round(l),y:Math.round(c)},P={x:Math.round(u),y:Math.round(g)},$={x:Math.round(F[0].x),y:Math.round(F[0].y)},Y={x:Math.round(F[F.length-1].x),y:Math.round(F[F.length-1].y)},j=[...F];if(e.isReverse&&([R,_]=[_,R]),Math.abs(V.x-$.x)>3||Math.abs(V.y-$.y)>3){const tt=V.x+($.x-V.x)/2,at=V.y+($.y-V.y)/2,Tt=qt(R),[Et]=Pt({source:V,sourcePosition:R,target:$,targetPosition:Tt,center:{x:tt,y:at},sourceOffset:20,targetOffset:5});j=Ot([...Et,...j])}if(Math.abs(P.x-Y.x)>3||Math.abs(P.y-Y.y)>3){const tt=Y.x+(P.x-Y.x)/2,at=Y.y+(P.y-Y.y)/2,Tt=qt(_),[Et]=Pt({source:Y,sourcePosition:Tt,target:P,targetPosition:_,center:{x:tt,y:at},sourceOffset:5,targetOffset:20});j=Ot([...j,...Et])}const X=j,st=me(X,z),et=ht(st),K=xe(F);return a.x=K.x,a.y=K.y,{pathCommands:[],pathData:et,textPosition:a,points:X,startDirection:R,endDirection:_}},hn=(i,a={x:0,y:0,rotate:0})=>{const{line:t,lineShape:e,fx:n,fy:o,fcx:s,fcy:r,tx:l,ty:c,tcx:h,tcy:d}=i,f=l-n,p=c-o,u=n-s,g=o-r,x=l-h,y=c-d,L=Math.min(200,Math.max(100,Math.abs(f/2))),m=Math.min(200,Math.max(100,Math.abs(p/2))),w=u/(Math.abs(u)+Math.abs(g))*L,b=g/(Math.abs(u)+Math.abs(g))*m;let M={x:w,y:b};const N=x/(Math.abs(x)+Math.abs(y))*L+f,O=y/(Math.abs(x)+Math.abs(y))*m+p;let E={x:N,y:O};t.ctrlPoints&&t.ctrlPoints.length>0&&(t.isReverse?(M.x+=t.ctrlPoints[1].x,M.y+=t.ctrlPoints[1].y,E.x+=t.ctrlPoints[0].x,E.y+=t.ctrlPoints[0].y):(M.x+=t.ctrlPoints[0].x,M.y+=t.ctrlPoints[0].y,E.x+=t.ctrlPoints[1].x,E.y+=t.ctrlPoints[1].y));const T={x:n+M.x,y:o+M.y},D={x:n+E.x,y:o+E.y},R={x:n+f,y:o+p},_=[{type:"M",x:n,y:o},{type:"c",dx1:M.x,dy1:M.y,dx2:E.x,dy2:E.y,dx:f,dy:p}];e===8&&_.push({type:"Z"});const z=ve({x:n,y:o},T,D,R,e<6?.8:.5);a.x=z.x,a.y=z.y;const F=ht(_);return{pathCommands:_,pathData:F,textPosition:a,points:[]}},ve=(i,a,t,e,n=.5)=>{const o={x:(1-n)*i.x+n*a.x,y:(1-n)*i.y+n*a.y},s={x:(1-n)*a.x+n*t.x,y:(1-n)*a.y+n*t.y},r={x:(1-n)*t.x+n*e.x,y:(1-n)*t.y+n*e.y},l={x:(1-n)*o.x+n*s.x,y:(1-n)*o.y+n*s.y},c={x:(1-n)*s.x+n*r.x,y:(1-n)*s.y+n*r.y};return{x:(1-n)*l.x+n*c.x,y:(1-n)*l.y+n*c.y}},dn=(i,a={x:0,y:0,rotate:0})=>{const{line:t,totalLinesBetweenNodes:e,currentLineIndex:n,lineDirection:o,lineShape:s,fx:r,fy:l,fcx:c,fcy:h,f_W:d,f_H:f,tx:p,ty:u,tcx:g,tcy:x,t_W:y,t_H:L}=i,m=p-r,w=u-l,b=p>r?1:-1,M=u>l?1:-1,N=o==="v"?M:b,O=r-c,E=l-h,T=p-g,D=u-x,R=1/(e+1)*(n+1);let _={x:0,y:0},z={x:0,y:0};if(s===G.Curve2)_=o==="v"?{x:0,y:N*30}:{x:N*30,y:0},z=o==="v"?{x:m*R,y:N*-10}:{x:N*-10,y:w*R};else if(s===G.Curve3)_=o==="v"?{x:0,y:w*R}:{x:N*30,y:0},z=o==="v"?{x:0,y:0}:{x:N*-10,y:w*R};else if(s===G.Curve5)_={x:0,y:0},z=o==="v"?{x:0,y:w*R}:{x:m*R,y:0};else if(s===G.Curve7||s===G.Curve8){const et=O/(Math.abs(O)+Math.abs(E))*30,K=E/(Math.abs(O)+Math.abs(E))*30;_={x:et,y:K};const tt=T/(Math.abs(T)+Math.abs(D))*30+m,at=D/(Math.abs(T)+Math.abs(D))*30+w;z={x:tt,y:at}}const F={x:r+_.x,y:l+_.y},V={x:r+z.x,y:l+z.y},P={x:r+m,y:l+w},$=[{type:"M",x:r,y:l},{type:"c",dx1:_.x,dy1:_.y,dx2:z.x,dy2:z.y,dx:m,dy:w}];s===8&&$.push({type:"Z"});const Y=ve({x:r,y:l},F,V,P,s<6?.8:.5);a.x=Y.x,a.y=Y.y;const j=ht($);return{pathCommands:$,pathData:j,textPosition:a,points:[]}};class fn extends en{constructor(a,t){super(a,t)}_getJunctionPoint(a,t){return a===U.border?Z.getBorderPoint4MultiLine(t):a===U.ltrb?Z.getRectJoinPoint(t):a===U.tb?Z.getRectVJoinPoint(t):a===U.lr?Z.getRectHJoinPoint(t):a===U.left?Z.getRectLeftJoinPoint(t):a===U.right?Z.getRectRightJoinPoint(t):a===U.top?Z.getRectTopJoinPoint(t):a===U.bottom?Z.getRectBottomJoinPoint(t):a==="horizontalLine"?Z.getRectVJoinPoint(t):a==="verticalLine"?Z.getRectHJoinPoint(t):Z.getBorderPoint4MultiLine(t)}createLinePath(a,t,e){console.error("createLinePath() is deprecated, please use createLineDrawInfo() instead.")}createLineDrawInfo(a,t){let e,n,o=1,s=0;if(a&&(s=a.currentLineIndex,o=a.totalLinesBetweenNodes),a)e=a.fromNode,n=a.toNode;else{const r=t;if(e=this.getFakeLineTarget(r.fromType,r.from,r),n=this.getFakeLineTarget(r.toType,r.to,r),!e){console.error("Invalid line configuration:error from:",t);return}if(!n){console.error("Invalid line configuration:error to:",t);return}}return this.generateLinePath({line:t,from:e,to:n,totalLinesBetweenNodes:o,currentLineIndex:s})}generateLinePath(a){a.totalLinesBetweenNodes===void 0&&(a.totalLinesBetweenNodes=1),a.currentLineIndex===void 0&&(a.currentLineIndex=0),a.defaultOptions===void 0&&(a.defaultOptions={defaultLineShape:this.options.defaultLineShape,layoutDirection:this.options.layout.layoutDirection,multiLineDistance:this.options.multiLineDistance,defaultJunctionPoint:this.options.defaultJunctionPoint,lineRadius:this.options.defaultPolyLineRadius});try{const t=this.withLineJunctionPoints(a);return this.createLinePathData(t)}catch(t){if(t.rgError)return this.createErrorLineValue(t.errorCode,t.x,t.y);throw t}}throwLineError(a,t,e){return{rgError:!0,errorCode:a,x:t,y:e}}createErrorLineValue(a,t,e){const n={x:0,y:0,rotate:0},o=[{type:"M",x:0,y:0},{type:"l",dx:t,dy:e}];return{pathCommands:o,pathData:ht(o),textPosition:n,points:[]}}withLineJunctionPoints({line:a,from:t,to:e,totalLinesBetweenNodes:n,currentLineIndex:o,defaultOptions:s}){if(!t||!e)throw v("error from-to:",t,e),this.throwLineError("F",-10,0);let r=a.lineShape||s.defaultLineShape||1;const l=a.lineDirection||s.layoutDirection||"h";let c=t.x||0,h=t.y||0,d=e.x||0,f=e.y||0;if(Number.isNaN(c)||Number.isNaN(h))throw v("error start node:",t.text,t.x,t.y),this.throwLineError("A",-10,-10);if(Number.isNaN(d)||Number.isNaN(f))throw v("error end point:",e.text,e.x,e.y),this.throwLineError("B",10,-10);let p=t.el.offsetWidth||60,u=t.el.offsetHeight||60;if(Number.isNaN(p)||Number.isNaN(u))throw this.throwLineError("C",-10,10);let g=e.el.offsetWidth||60,x=e.el.offsetHeight||60;if(Number.isNaN(g)||Number.isNaN(x))throw this.throwLineError("D",10,10);if(c===0&&d===0&&h===0&&f===0)throw this.throwLineError("D",10,10);const y=d-c+(f-h)>0,L=a.isReverse?e:t,m=a.isReverse?t:e,w=L.nodeShape!==void 0&&L.nodeShape!==null?L.nodeShape:1,b=a.junctionOffset||0;c-=b,h-=b,d-=b,f-=b,p+=b*2,u+=b*2,g+=b*2,x+=b*2;const M={from_x:c,from_y:h,to_x:d,to_y:f,f_W:p,f_H:u,t_W:g,t_H:x,nodeShape:w,isReverse:y,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:o,lineDistance:s.multiLineDistance||50},N=m.nodeShape!==void 0&&m.nodeShape!==null?m.nodeShape:1,O={from_x:d,from_y:f,to_x:c,to_y:h,f_W:g,f_H:x,t_W:p,t_H:u,nodeShape:N,isReverse:y,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:o,lineDistance:s.multiLineDistance||50},E=s.defaultJunctionPoint||U.border;let T=a.fromJunctionPoint||E,D=a.toJunctionPoint||E,R=a.fromJuctionPointOffsetX||0,_=a.fromJuctionPointOffsetY||0,z=a.toJuctionPointOffsetX||0,F=a.toJuctionPointOffsetY||0;a.isReverse&&([T,D]=[D,T],[R,_,z,F]=[z,F,R,_]),(t===e||c===0&&d===0&&h===0&&f===0)&&R===0&&_===0&&z===0&&F===0&&((r===G.StandardStraight||r===G.Curve2||r===G.Curve3||r===G.SimpleOrthogonal||r===G.Curve5)&&(r=G.StandardCurve),F=20);const V=this._getJunctionPoint(T,M);V.x+=R,V.y+=_;const P=this._getJunctionPoint(D,O);if(P.x+=z,P.y+=F,!V||!P)throw this.throwLineError("E",-20,-20);const $=c+p/2,Y=h+u/2,j=d+g/2,X=f+x/2;T==="horizontalLine"?(V.x=P.x,V.y=M.from_y+M.f_H/2,r===44&&(V.x+=(P.x>j?1:-1)*30)):T==="verticalLine"&&(V.x=M.from_x+M.f_W/2,V.y=P.y,r===44&&(V.y+=(P.y>X?1:-1)*30)),D==="horizontalLine"?(P.x=V.x,P.y=O.from_y+O.f_H/2,r===44&&(P.x+=(V.x>$?1:-1)*30)):D==="verticalLine"&&(P.x=O.from_x+O.f_W/2,P.y=V.y,r===44&&(P.y+=(V.y>Y?1:-1)*30));const st=V.x,et=V.y,K=P.x,tt=P.y;if(Number.isNaN(st)||Number.isNaN(et))throw v("error start point:",t.text),this.throwLineError("F",-10,0);if(Number.isNaN(K)||Number.isNaN(tt))throw v("error end point:",e.text),this.throwLineError("G",10,0);return{line:a,totalLinesBetweenNodes:n,currentLineIndex:o,lineDirection:l==="v"?"v":"h",lineShape:r,lineRadius:s.lineRadius||0,fromJunctionPoint:T,toJunctionPoint:D,fx:st,fy:et,fcx:$,fcy:Y,f_W:p,f_H:u,tx:K,ty:tt,tcx:j,tcy:X,t_W:g,t_H:x}}createLinePathData(a){const{lineShape:t}=a;let e;return t===G.SimpleOrthogonal?e=on(a,void 0,{lineRadius:a.lineRadius}):t===G.StandardOrthogonal?e=ln(a,void 0,{lineRadius:a.lineRadius}):t===G.HardOrthogonal?e=cn(a,void 0,{lineRadius:a.lineRadius}):t===G.StandardCurve?e=hn(a):t===G.Curve2||t===G.Curve3||t===G.Curve5||t===G.Curve7||t===G.Curve8?e=dn(a):e=nn(a),e}getArrowMarkerId(a,t=!1){let e=a.showStartArrow===!0,n=a.showEndArrow!==!1;if(a.isReverse&&([e,n]=[n,e]),t){if(!e)return;if(a.startMarkerId)return`url('#${a.startMarkerId}')`}else{if(!n)return;if(a.endMarkerId)return`url('#${a.endMarkerId}')`}return`url('#${this.getLineArrow(a.color,t,!1)}')`}getTextTransform(a,t){if(!a||!t)return"translate(0,0)";const{x:e,y:n,rotate:o}=t;if(Number.isNaN(e)||Number.isNaN(n))return"translate(0,0)";const s=a.textOffset_x||this.options.defaultLineTextOffset_x||0,r=a.textOffset_y||this.options.defaultLineTextOffset_y||0,l=a.lineShape||this.options.defaultLineShape;return l===G.StandardStraight||l===G.SimpleOrthogonal?`translate(-50%, -50%) translate(${e+s}px,${n+r}px) rotate(${o||0}deg)`:`translate(-50%, -50%) translate(${e+s}px,${n+r}px)`}generateLineTextStyle(a,t){const e={transform:"",transformOrigin:""};if(!a||!t)return{cssStyles:e};const{line:n}=a,{textPosition:o}=t;if(!n||!o)return{cssStyles:e};let s=n.text||"";s.length>this.options.lineTextMaxLength&&(s=s.substring(0,this.options.lineTextMaxLength||15)+"...");const{x:r,y:l,rotate:c}=o;if(Number.isNaN(r)||Number.isNaN(l))return{text:s,cssStyles:e};const h=[],d=n.textAnchor||"center";d==="start"?h.push("translate(0%, -50%)"):d==="end"?h.push("translate(100%, -50%)"):h.push("translate(-50%, -50%)"),h.push(`translate(${r}px,${l}px)`);const f=n.textOffset_x||this.options.defaultLineTextOffset_x||0,p=n.textOffset_y||this.options.defaultLineTextOffset_y||0;return(n.lineShape||this.options.defaultLineShape||1)===G.StandardStraight?(e.transformOrigin="50% 50%",h.push(`translate(${f}px,${p}px)`)):h.push(`translate(${f}px,${p}px)`),e.transform=h.join(" "),{text:s,cssStyles:e}}generateLineTextStyle4TextPath(a){const{line:t,from:e,to:n}=a;let o=t.text;if(!o||!n||!e)return null;let s=0;const r=e.x,l=e.y,c=n.x,h=n.y;o.length>this.options.lineTextMaxLength&&(o=o.substring(0,this.options.lineTextMaxLength||15)+"..."),r>c&&(s=180,o=o.split("").reverse().join(""));const p=`translate(${0},${0})`;let u="middle";const g=t.lineShape||this.options.defaultLineShape||1;let x="50%";return g===G.SimpleOrthogonal?t.onPathStartOffset==="start"?(x="10%",u="start"):t.onPathStartOffset==="end"?(x="90%",u="end"):t.onPathStartOffset?(x=t.onPathStartOffset,u="start"):this.options.layout.layoutDirection==="v"?x=String(Math.abs(c-r)+43):x=String(Math.abs(h-l)+43):t.onPathStartOffset==="start"?(x="10%",u="start"):t.onPathStartOffset==="end"?(x="90%",u="end"):t.onPathStartOffset?(x=t.onPathStartOffset,u="start"):(x="50%",u="middle"),t.textAnchor&&(u=t.textAnchor),{text:o,textOffset:p,textAnchor:u,onPathStartOffset:x,textRotate:s}}onLineVertexBeDroppedOnConnectController(a,t,e,n){if(v("onLineVertexBeDroppedOnConnectController",a,t,e),t.stopPropagation(),!e){this.onLineVertexBeDropped(a,t,void 0,n);return}const o=xt(t),s=e.getBoundingClientRect(),r={x:s.left,y:s.top+s.height/2},l={x:s.left+s.width/2,y:s.top},c={x:s.left+s.width,y:s.top+s.height/2},h={x:s.left+s.width/2,y:s.top+s.height};let d=ot.left;const f={x:0,y:0};if(a)d=a,d===ot.top||d===ot.bottom?f.x=o.clientX-h.x:d===ot.right?f.y=o.clientY-c.y:f.y=o.clientY-r.y;else{const g=dt(o.clientX,o.clientY,r.x,r.y),x=dt(o.clientX,o.clientY,l.x,l.y),y=dt(o.clientX,o.clientY,c.x,c.y),L=dt(o.clientX,o.clientY,h.x,h.y),m=Math.min(g,x,y,L);m===g?(d=ot.left,f.x=o.clientX-r.x,f.y=o.clientY-r.y):m===x?(d=ot.top,f.x=o.clientX-l.x,f.y=o.clientY-l.y):m===y?(d=ot.right,f.x=o.clientX-c.x,f.y=o.clientY-c.y):m===L&&(d=ot.bottom,f.x=o.clientX-h.x,f.y=o.clientY-h.y)}const u=this.options.canvasZoom/100;f.x=f.x/u,f.y=f.y/u,v("onMouseUpWithOffset:",a,f),this.onLineVertexBeDropped(d,t,f,n)}}class un extends fn{constructor(t,e){super(t,e);S(this,"_zooming",!1)}async zoom(t,e,n){if(!this._rgAsConnectArea){if(this._zooming){console.error("reject zoom:_zooming");return}this._zooming=!0;try{const o=this.emitEvent(I.beforeZoomStart,this.options.canvasZoom,t,n);if(v("[zoom]","abortZoom:",o),o===!0)return;if(this.options.canvasZoom+t<this.options.minCanvasZoom){if(v("zoom:minCanvasZoom"),t=this.options.minCanvasZoom-this.options.canvasZoom,t===0)return}else if(this.options.canvasZoom+t>this.options.maxCanvasZoom&&(v("zoom:maxCanvasZoom"),t=this.options.maxCanvasZoom-this.options.canvasZoom,t===0))return;const s=t/100,r=this.$dom.getBoundingClientRect(),l=this.options.canvasZoom/100,c=Math.max(.01,Math.min(10,l+s));e||(e={x:r.x+r.width/2,y:r.y+r.height/2});const h=e.x-r.left,d=e.y-r.top,f=h-(h-this.options.canvasOffset.x)*(c/l),p=d-(d-this.options.canvasOffset.y)*(c/l);this.options.canvasOffset.x=f,this.options.canvasOffset.y=p;const u=this.options.canvasZoom,g=c*100;this.options.canvasZoom=g,this._zoomEnd(u,g)&&await ft(200)}finally{this._zooming=!1}}}_zoomEnd(t,e){this.updateViewBoxInfo();let n=!1;return t<=40?e>40&&(this.options.performanceMode&&(this.updateShouldRenderGraphData(!0),n=!0),this.options.showEasyView=!1,v("zoom:hide:showEasyView",t,e),this.updateElementLines()):t>40&&e<=40&&(v("zoom:show:showEasyView",t,e),this.options.performanceMode&&(this.options.showEasyView=!0)),this.updateEditingControllerView(),this.emitEvent(I.onZoomEnd,this.options.canvasZoom),this._dataUpdated(),n}setZoom(t,e){const n=Math.floor(t-this.options.canvasZoom);this.zoom(n,e)}getCanvasXyByClientXy(t){const e=this.$dom.getBoundingClientRect(),n={x:t.x-e.left,y:t.y-e.top};return this.getCanvasXyByViewXy(n)}getCanvasXyByViewXy(t){if(this._rgAsConnectArea)return t;const e=this.options.canvasZoom/100,n={x:t.x-this.options.canvasOffset.x,y:t.y-this.options.canvasOffset.y};return{x:n.x/e,y:n.y/e}}getViewXyByCanvasXy(t){const e=this.options.canvasZoom/100;return{x:t.x*e+this.options.canvasOffset.x,y:t.y*e+this.options.canvasOffset.y}}}class gn extends un{constructor(a,t){super(a,t)}moveToCenter(a){const t=this.getNodesCenter(a);v("center:",t.x,t.y);const e=this.options.canvasZoom;this.options.canvasZoom=100,this.setCanvasCenter(t.x,t.y),this.setZoom(e),this._dataUpdated()}zoomToFit(a){const t=this.getStuffSize(a),e=50,n=this.options.viewSize.width/(t.width+e*2),o=this.options.viewSize.height/(t.height+e*2),s=Math.min(n,o,1);v("zoomToFit:",{stuffSize:t,zoomPercent:s,zoomPercentX:n,zoomPercentY:o,viewSize:this.options.viewSize}),this.moveToCenter(a),this.setZoom(s*100),this._dataUpdated()}enableNodeXYAnimation(){this.options.enableNodeXYAnimation=!0,this._dataUpdated()}disableNodeXYAnimation(){this.options.enableNodeXYAnimation=!1,this._dataUpdated()}enableCanvasAnimation(){this.options.enableCanvasTransformAnimation=!0,this._dataUpdated()}disableCanvasAnimation(){this.options.enableCanvasTransformAnimation=!1,this._dataUpdated()}}class pn extends gn{constructor(t,e){super(t,e);S(this,"_mainGroupNodes",[]);S(this,"layouter")}async doLayout(t){const e=Date.now()-this.prevAddNodeTimestamp;e<300&&(this.options.canvasOpacity=.01,this._dataUpdated(),await ft(300-e)),await this._doLayout(t),this.options.canvasOpacity=1,this._dataUpdated()}async _doLayout(t){this.updateNodesVisibleProperty(),v("node size\uFF1A",this.graphData.nodes.length);let e=this.graphData.rootNode;if(t&&(e=typeof t=="string"?this.getNodeById(t):t,!e))throw new Error("custom rootNode not found, id:"+t);e||(e=this.graphData.nodes[0],this._rgAsConnectArea||(console.error("No root node, use first node as root:",e),console.error("You can set rootNode call doLayout(rootNode | nodeId) with a node id"))),this.graphData.rootNode=e;const n=this.createLayout(this.options.layout,!0);this._mainGroupNodes=[],n.layoutOptions.layoutName==="force"?(n.onFinish(()=>{this.emitEvent(I.onForceLayoutFinish)}),await ft(100),v("doLayout:start force:",this.graphData.nodes.length),n.placeNodes(this.graphData.nodes,e)):(e&&this.findGroupNodes(e,this._mainGroupNodes),n.placeNodes(this._mainGroupNodes,e),v("doLayout:placeOtherNodes"),this.placeOtherNodes(),v("doLayout:placeOtherNodes ok!")),this.updateElementLines()}refresh(t=!0){this.resetViewSize(!0),this._dataUpdated(),t&&this.doLayout(),this.updateElementLines(),this._dataUpdated()}placeOtherNodes(){const t=this.options.placeSingleNode&&this.options.layout.layoutName!=="fixed",e=[...this._mainGroupNodes],n=[],o=[];this.graphData.nodes.forEach(s=>{e.includes(s)||(this.options.placeSingleNode&&s.fixed!==!0?this.getNodeRelatedNodes(s).length===0&&(t&&(s.x=Math.floor(Math.random()*200)-100,s.y=Math.floor(Math.random()*200)-100,s.lot||(s.lot={childs:[]})),s.lot.placed=!0,o.push(s)):n.push(s))}),t&&this.placeSingleNodes(o),t&&(this.options.placeOtherGroup&&this.placeOtherGroup(n,e),this._dataUpdated(),this.options.layout.layoutName==="force"&&(this.stopAutoLayout(),setTimeout(()=>{this.startAutoLayout()},500)))}placeSingleNodes(t){if(t.length>0){v("sigle nodes:",t.length);const e=new ut({layoutName:"force"},this.options,this);e.allNodes=this.graphData.nodes,e.fastStart=!0,e.maxLayoutTimes=100,e.byLine=!1,e.placeNodes(t)}}placeOtherGroup(t,e){if(t.length>0){v("[placeOtherGroup]notPlacedNodes nodes:",t.length);const n=JSON.parse(JSON.stringify(this.options.layout)),o=t[0],s=this.createLayout(n);s.isMainLayouer=!1;const r=this.getStuffSize(e);v("[placeOtherGroup]placeOtherGroup:",s.layoutOptions.layoutName,"root:",o.text);let l=this.options.layout.layoutName.includes("tree")?300:600;if(s.layoutOptions.layoutName==="force"){const d=s;d.maxLayoutTimes=0,l=100}o.fixed?v("[placeOtherGroup]fixed root x,y:",o.x,o.y,o.text):(o.x=r.maxX+l,o.y=0,v("[placeOtherGroup]set root x,y:",o.x,o.y,o.text)),s.layoutOptions.fixedRootNode=!0;const c=[];this.findGroupNodes(o,c),v("[placeOtherGroup]thisGroupNodes:",t.length),s.requireLinks&&s.setLinks(this.getLinks()),s.placeNodes(c,o),e.push(...c);const h=[];t.forEach(d=>{e.includes(d)||h.push(d)}),this.options.placeOtherGroup&&this.placeOtherGroup(h,e),this._dataUpdated()}else v("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){v("toggleAutoLayout:to:",this.options.layout.autoLayouting),this.options.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){this.options.layout.autoLayouting=!0,this.options.layout.supportAutoLayout&&(v("startAutoLayout:"),this.layouter.autoLayout(!0))}stopAutoLayout(){this.options.layout.autoLayouting=!1,this.options.layout.supportAutoLayout&&(v("stopAutoLayout:"),this.layouter.stop())}createLayout(t,e=!1){const n=this.options;$t(t);let o=null;if(t.layoutName==="tree"?o=new fe(t,n,this):t.layoutName==="center"?o=new ue(t,n,this):t.layoutName==="circle"?o=new ge(t,n,this):t.layoutName==="force"?o=new ut(t,n,this):t.layoutName==="fixed"?o=new pe(t,n,this):t.layoutName==="smart-tree"?o=new Ue(t,n,this):t.layoutName==="folder"&&(o=new ye(t,n,this)),!o)throw new Error("unknown layout: "+t.layoutName);return o.requireLinks&&o.setLinks(this.getLinks()),o.isMainLayouer=e,o.layoutOptions.fixedRootNode=!0,e&&(n.layout.supportAutoLayout=o.autoLayout!==void 0,this.layouter=o),o}}const yn=async(i,a)=>{const t=i||document.documentElement;a?await mn(t):await xn()},mn=async i=>{i.requestFullscreen?await i.requestFullscreen():i.mozRequestFullScreen?await i.mozRequestFullScreen():i.webkitRequestFullscreen?await i.webkitRequestFullscreen():i.msRequestFullscreen&&await i.msRequestFullscreen()},xn=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class vn extends pn{constructor(t,e){super(t,e);S(this,"prevClickTime",0);S(this,"nodeXYBeforeDrag",{});S(this,"movingListener");S(this,"_currentMovingLineTarget",null);S(this,"step1EventTime",0);S(this,"onCreateLineCallback");S(this,"_wheelAction",0);S(this,"_wheelBuff",0);S(this,"_fullscreenchangeHandler")}setCheckedNode(t){this.options.checkedNodeId=t}setCheckedLinkAndLine(t,e){this.options.checkedLinkId=t?t.seeks_id:"",this.options.checkedLineId=e?e.id:""}setCheckedLine(t){const e=this.getLinkByLine(t);this.options.checkedLinkId=e?e.seeks_id:"",this.options.checkedLineId=t?t.id:""}clearChecked(){this.options.checkedNodeId="",this.options.checkedLineId="",this.options.checkedLinkId=""}clearSelected(){this.graphData.nodes.forEach(t=>{t.selected=!1}),this.getLines().forEach(t=>{t.selected=!1}),this.graphData.fakeLines.forEach(t=>{t.selected=!1})}updateNodeOffsetSize(t,e,n){const o=this.getNodeById(t);if(!o){console.warn("Node not found for resize handling:",t);return}const s=o.el.offsetWidth,r=o.el.offsetHeight;(s!==e||r!==n)&&(v("Node resized:",o.id,s,",",r," > ",e,",",n),o.el.offsetWidth=e,o.el.offsetHeight=n,this._dataUpdated())}onNodeClick(t,e){if(Date.now()-this.prevClickTime<200){v("[node]click abort : time < 200");return}if(this.prevClickTime=Date.now(),this.options.creatingLinePlot){this.onNodeClickWhenCreatingLinePlot(t);return}v("[node]node click",t.text,this.options.creatingLinePlot);const n=t.disablePointEvent===void 0?this.options.disableNodePointEvent:t.disablePointEvent;!e.shiftKey&&!n&&(this.options.checkedLinkId="",this.options.checkedLineId="",this.setCheckedNode(t.id)),this.emitEvent(I.onNodeClick,t,e),this.prevClickTime=Date.now()}onNodeDragStart(t,e){if(vt(e)||!t||(this.options.disableDragNode||t.disableDrag)&&e.target&&!e.target.closest(".rg-node-drag-handler"))return;isNaN(t.x)&&(t.x=0),isNaN(t.y)&&(t.y=0),t.dragging=!0,this.setEditingLine(null,null),this.options.checkedLinkId="",this.options.checkedLineId="";const n=(r,l,c)=>{t.dragging=!1,this.options.editingReferenceLine.show=!1,this.onNodeDraged(t,r,l,c),s&&this.emitEvent(I.onNodeDragEnd,t,c,r,l),this._dataUpdated()};this.nodeXYBeforeDrag={},this.nodeXYBeforeDrag[t.id]={x:t.x,y:t.y};for(const r of this.options.editingController.nodes)this.nodeXYBeforeDrag[r.id]={x:r.x,y:r.y};const o={x:t.x,y:t.y};let s=!1;W.startDrag(e,o,n,(r,l,c)=>{if(!s)Math.abs(r)+Math.abs(l)>4&&(v("[node]onNodeDragStart...",it(e),e),this.emitEvent(I.onNodeDragStart,t,e),s=!0);else{let h=r/(this.options.canvasZoom/100)+c.x,d=l/(this.options.canvasZoom/100)+c.y,f=h-o.x,p=d-o.y;const u=this.emitEvent(I.onNodeDragging,t,h,d,f,p,e);u&&(typeof u.x=="number"&&(h=u.x,f=h-o.x),typeof u.y=="number"&&(d=u.y,p=d-o.y)),this.options.useHorizontalView&&(h=l/(this.options.canvasZoom/100)+c.x,d=-r/(this.options.canvasZoom/100)+c.y),this.draggingSelectedNodes(t,h,d,f,p)}this.updateElementLines(),this._dataUpdated()})}onNodeDraged(t,e,n,o){if(e===0&&n===0){v("[node]node click by drag"),this.onNodeClick(t,o),this.onNodeDragEnd(t,o,e,n);return}Math.abs(e)+Math.abs(n)>6?(this.prevClickTime=Date.now(),setTimeout(()=>{v("[node]onDragEnd2"),this.onNodeDragEnd(t,o,e,n)},100)):(v("[node]onDragEnd1"),this.onNodeDragEnd(t,o,e,n))}onNodeDragEnd(t,e,n,o){this.updateElementLines()}onLineClick(t,e,n){e||(e=this.getLinkByLineId(t.id)),v("onLineClick:","line:",t,"link:",e),(t.disablePointEvent===void 0?this.options.disableLinePointEvent:t.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLinkAndLine(e,t)),this.emitEvent(I.onLineClick,t,e,n),this._dataUpdated()}expandOrCollapseNode(t,e){e.stopPropagation(),t.expanded===!1?this.expandNode(t,e):this.collapseNode(t,e)}expandNode(t,e){v("onNodeExpand:",t),t.expanded=!0,v("relayout check:",this.options.reLayoutWhenExpandedOrCollapsed),this.updateNodesVisibleProperty(),this.doLayoutWhenExpandedOrCollapsed(),this.updateElementLines(),this._dataUpdated(),this.emitEvent(I.onNodeExpand,t,e)}collapseNode(t,e){v("onNodeCollapse:",t),t.expanded=!1,v("relayout check:",this.options.reLayoutWhenExpandedOrCollapsed),this.updateNodesVisibleProperty(),this.doLayoutWhenExpandedOrCollapsed(),this.updateElementLines(),this._dataUpdated(),this.emitEvent(I.onNodeCollapse,t,e)}doLayoutWhenExpandedOrCollapsed(){this.options.reLayoutWhenExpandedOrCollapsed&&this.options.layout.layoutName!=="force"&&(v("relayout..."),this.doLayout())}onCanvasDragEnd(t){this.updateEditingControllerView(),this.updateShouldRenderGraphData(),this.emitEvent(I.onCanvasDragEnd,t)}onCanvasClick(t){this.options.creatingLinePlot&&this.onCanvasClickWhenCreatingLinePlot(t),this.emitEvent(I.onCanvasClick,t)}onCanvasSelectionEnd(t,e){this.emitEvent(I.onCanvasSelectionEnd,t,e),v("[canvas]onCanvasSelectionEnd:",t),this._dataUpdated()}startCreatingNodePlot(t,e){this.options.newNodeTemplate=Ct(JSON.parse(JSON.stringify(Bt)),this.options),this.options.creatingNodePlot=!0;const n=it(t);this.options.showTemplateNode=!n;let o=(u,g)=>{const x=this.options.newNodeTemplate,y={width:x.width||96,height:x.height||96};this.options.newNodeTemplate.x=u-y.width/2,this.options.newNodeTemplate.y=g-y.height/2,this._dataUpdated()},s=(u,g,x)=>{const y="s-"+Date.now();this.addNodes([{id:y,text:this.options.newNodeTemplate.text,x:u,y:g}])};e&&e.templateText&&(this.options.newNodeTemplate.text=e.templateText),e&&e.templateClassName&&(this.options.newNodeTemplate.className=e.templateClassName),e&&e.templateNode&&Object.keys(e.templateNode).forEach(u=>{this.options.newNodeTemplate[u]=e.templateNode[u]}),e&&e.templateMove&&(o=e.templateMove),e&&e.onCreateNode&&(s=e.onCreateNode);const r=this.$dom.getBoundingClientRect();v("[CreatingNodePlot]startCreatingNodePlot:");const l=xt(t),c=l.clientX-r.x+10,h=l.clientY-r.y+10;n||o(c,h);const d=u=>{const g=this.$dom.getBoundingClientRect();v("[CreatingNodePlot]objectTemplateMove");const x=u.clientX-g.x,y=u.clientY-g.y;o(x,y)},f=u=>{v("[CreatingNodePlot]user abort!"),this.$dom.removeEventListener("mousemove",d),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.options.creatingNodePlot=!1},p=u=>{let g=!1;if(this.options.creatingNodePlot||(g=!0),this.$dom.removeEventListener("mousemove",d),this.$dom.removeEventListener("click",p),this.$dom.removeEventListener("contextmenu",f),this.options.creatingNodePlot=!1,g){v("[CreatingNodePlot]action be abort!");return}const x=xt(u),y=x.clientX-r.x+10,L=x.clientY-r.y+10;if(Math.abs(c-y)<30&&Math.abs(h-L)<30){v("[CreatingNodePlot]create node be abort!");return}const m=this.getCanvasXyByClientXy({x:x.clientX,y:x.clientY});v("[CreatingNodePlot]objectBePlaced:",m),s(m.x,m.y,this.options.newNodeTemplate),this._dataUpdated()};setTimeout(()=>{this.$dom.addEventListener("click",p),this.$dom.addEventListener("contextmenu",f)},300),n||this.$dom.addEventListener("mousemove",d)}startCreatingLinePlot(t,e){const n=it(t);e&&e.onCreateLine&&(this.onCreateLineCallback=e.onCreateLine);const o=ct({from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"});e&&e.template&&Object.assign(o,e.template),this.options.newLineTemplate=o,this.options.newLinkTemplate.fromNode=null,this.options.newLinkTemplate.toNode.id="",this.options.newLinkTemplate.toNode.targetType=B.Node,e&&e.fromNode&&(this.options.newLinkTemplate.toNode.x=e.fromNode.x+50,this.options.newLinkTemplate.toNode.y=e.fromNode.y+50,this.options.newLinkTemplate.fromNode=e.fromNode,this.step1EventTime=Date.now()),this.options.creatingLinePlot=!0,this.options.newLinkTemplate.toNodeObject=null,this.options.newLineTemplate.disablePointEvent=!0,this.options.newLinkTemplate.toNode.el.offsetWidth=2,this.options.newLinkTemplate.toNode.el.offsetHeight=2,v("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),this._currentMovingLineTarget=this.options.newLinkTemplate.toNode,n||(v("[CreatingLinePlot]Listener move"),this.movingListener&&this.$dom.removeEventListener("mousemove",this.movingListener),this.movingListener=this.onMovingWhenCreatingLinePlot.bind(this),this.$dom.addEventListener("mousemove",this.movingListener)),this.dataUpdated()}stopCreatingLinePlot(){v("[CreatingLinePlot]stop CreatingLinePlot!"),this.options.creatingLinePlot=!1,this.options.newLinkTemplate.fromNode=null,this.options.newLinkTemplate.toNodeObject=null,this.onCreateLineCallback=void 0,this.$dom.removeEventListener("mousemove",this.movingListener),this.movingListener=void 0,this._currentMovingLineTarget=null,this._currentCreatingLineIsReverse=!1,this.options.nodeConnectController.show=!1,this._dataUpdated()}onMovingWhenCreatingLinePlot(t){v("[CreatingLinePlot]mousemove");const e=this.getCanvasXyByClientXy({x:t.clientX,y:t.clientY});this._currentMovingLineTarget&&(this._currentMovingLineTarget.x=e.x,this._currentMovingLineTarget.y=e.y,this.options.editingLineController.line&&this.updateEditingLineView());const n=t.target;this.options.newLinkTemplate.fromNode&&(this.options.newLinkTemplate.toNode.x=e.x,this.options.newLinkTemplate.toNode.y=e.y,this._dataUpdated());let o="",s=B.Node;const r=this.isNode(n);r&&(o=r.id,r===this.options.newLinkTemplate.fromNode?this.options.nodeConnectController.show=!1:(this.options.nodeConnectController.node=r,this.updateEditingConnectControllerView(),this.options.nodeConnectController.show=!0));const l=this.options.newLinkTemplate,c=n.closest(".rg-connect-ctl-handler");if(c){let h=this.options.nodeConnectController.node;v("[CreatingLinePlot]content point:",c.dataset.point);let d=c.dataset.point||"border";if(c.classList.contains("rg-connect-target")){const{width:f,height:p,x:u,y:g}=c.getBoundingClientRect(),x=this.getCanvasXyByClientXy({x:u,y:g}),y=this.options.canvasZoom/100,L={x:x.x,y:x.y,el:{offsetWidth:f/y,offsetHeight:p/y},nodeShape:1,id:c.dataset.targetId,targetData:JSON.parse(c.dataset.targetData||"{}"),targetType:c.dataset.targetType};console.log("[CreatingLinePlot]fakeNode:",JSON.stringify(L)),this.options.nodeConnectController.node=L,h=this.options.nodeConnectController.node,this.options.nodeConnectController.show=!1,d=c.dataset.point,this._currentMovingLineTarget&&(o=L.id,s=L.targetType,this._currentMovingLineTarget.nodeShape=L.nodeShape),this.updateEditingConnectControllerView()}else this._currentMovingLineTarget&&(s=B.Node);l.fromNode===this._currentMovingLineTarget?this.options.newLineTemplate.isReverse?this.options.newLineTemplate.fromJunctionPoint=d:this.options.newLineTemplate.toJunctionPoint=d:this.options.newLineTemplate.isReverse?this.options.newLineTemplate.fromJunctionPoint=d:this.options.newLineTemplate.toJunctionPoint=d,this._currentMovingLineTarget&&(n.dataset.innode==="true"?(this._currentMovingLineTarget.targetType=B.Node,this._currentMovingLineTarget.el.offsetWidth=5,this._currentMovingLineTarget.el.offsetHeight=5,this._currentMovingLineTarget.x=e.x,this._currentMovingLineTarget.y=e.y,this._currentMovingLineTarget.nodeShape=1,this._currentMovingLineTarget.rotate=0):(v("[CreatingLinePlot]content point:",h.el.offsetWidth,h.el.offsetHeight),this._currentMovingLineTarget.el.offsetWidth=h.el.offsetWidth,this._currentMovingLineTarget.el.offsetHeight=h.el.offsetHeight,this._currentMovingLineTarget.x=h.x,this._currentMovingLineTarget.y=h.y,this._currentMovingLineTarget.nodeShape=h.nodeShape||1,this._currentMovingLineTarget.rotate=0))}else v("[CreatingLinePlot]point:",n.dataset.point),this.options.newLineTemplate.isReverse?this.options.newLineTemplate.fromJunctionPoint=U.border:this.options.newLineTemplate.toJunctionPoint=U.border,this._currentMovingLineTarget&&(this._currentMovingLineTarget.el.offsetWidth=3,this._currentMovingLineTarget.el.offsetHeight=3,this._currentMovingLineTarget.rotate=0,s=B.Node);this._currentMovingLineTarget&&(o&&(this._currentMovingLineTarget.id=o),this._currentMovingLineTarget.targetType=s)}onCanvasClickWhenCreatingLinePlot(t){if(Date.now()-this.step1EventTime<500){v("[CreatingLinePlot]step1EventTime:",this.step1EventTime);return}if(!this.options.newLinkTemplate.fromNode){v("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let e=!1;if(!this.options.newLinkTemplate.toNodeObject){v("[CreatingLinePlot]CreatingLinePlot:toNodeObject not set!");const n=xt(t),o=this.getCanvasXyByClientXy({x:n.clientX,y:n.clientY});e=this.onCreateLine(this.options.newLinkTemplate.fromNode,o)}e!==!0&&this.stopCreatingLinePlot()}onNodeClickWhenCreatingLinePlot(t){this.options.newLinkTemplate.fromNode?(v("[CreatingLinePlot]step 2: set toNodeObjecct:",this.options.newLinkTemplate.fromNode,t),this.options.newLinkTemplate.toNodeObject=t,this.options.newLinkTemplate.toJunctionPoint=U.border,this.onCreateLine(this.options.newLinkTemplate.fromNode,t)!==!0&&this.stopCreatingLinePlot()):(v("[CreatingLinePlot]step 1: set fromNode:",t),this.options.newLinkTemplate.fromNode=t,this.options.newLinkTemplate.toNode.x=t.x+50,this.options.newLinkTemplate.toNode.y=t.y+50,this.step1EventTime=Date.now())}onCreateLine(t,e){v("[CreatingLinePlot][fire-event]onCreateLine:",t,e);const n=ct(this.options.newLineTemplate);this.options.newLineTemplate.isReverse?(n.from=e?e.id:"",n.to=t?t.id:"",n.isReverse=void 0,[t,e]=[e,t]):(n.from=t?t.id:"",n.to=e?e.id:""),n.disablePointEvent=!1;const o=this.emitEvent(I.beforeCreateLine,{lineJson:n,fromNode:t,toNode:e});if(v("[CreatingLinePlot]onCreateLine:abort-flag:",o),o===!0){v("[CreatingLinePlot]onCreateLine:abort!");return}if(this.onCreateLineCallback){v("[CreatingLinePlot]onCreateLine:callback"),this.options.newLineTemplate.disablePointEvent=!1;try{this.onCreateLineCallback(t,e,this.options.newLineTemplate)}catch(r){return console.warn("[Custom Reject Connect By Throw Error:",r),!1}}return v("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(I.onLineBeCreated,{lineJson:n,fromNode:t,toNode:e})}isNode(t){const e=_t(t,"rg-node-peel","rg-map");return e?this.getNodeById(e.dataset.id):void 0}isLine(t){const e=_t(t,"rg-line-peel","rg-map");return e?this.getLineById(e.dataset.id):void 0}isLink(t){throw new Error("Please use isLine")}onContextmenu(t){this.stopCreatingLinePlot();let e="canvas",n=this.isNode(t.target);n?e="node":(n=this.isLine(t.target),n&&(e="line")),v("contextmenu:objectType",e,n);const o=xt(t),s=this.getCanvasXyByClientXy({x:o.clientX,y:o.clientY}),r=this.getViewXyByCanvasXy(s);this.emitEvent(I.onContextmenu,t,e,n,s,r)}async fullscreen(t){t!==this.options.fullscreen&&(v("fullscreen:newValue:",t),t===void 0&&(t=!this.options.fullscreen),await yn(this.$dom,t),this.emitEvent(I.onFullscreen,t))}focusNodeById(t){let e;this.graphData.nodes.forEach(n=>{n.id===t&&(e=n)}),e&&this.handleSelect(e)}focusRootNode(){v("relation-graph:focusRootNode"),this.graphData.rootNode&&this.handleSelect(this.graphData.rootNode)}handleSelect(t){v("checked:",t),this.setZoom(100);const e=t.width||50,n=t.height||50,o=t.x*-1+this.options.viewSize.width/2-e/2,s=t.y*-1+this.options.viewSize.height/2-n/2;this.setCanvasOffset(o,s),this.options.checkedNodeId=t.id,this.updateViewBoxInfo()}onMouseWheel(t){if(!t.ctrlKey&&!t.metaKey&&(this.options.disableWheelEvent||this.options.wheelEventAction==="none"))return!0;try{t.preventDefault(),t.stopPropagation()}catch{}let e=t.deltaY,n=t.deltaX;e===void 0&&(e=t.wheelDelta),n===void 0&&(n=t.wheelDelta),this._onMouseWheel(t,n,e)}_onMouseWheel(t,e,n){const o=t.ctrlKey||t.metaKey;if(!o&&this.options.wheelEventAction==="scroll"){let s=0,r=0;const l=e===0?0:e>0?-1:1,c=n===0?0:n>0?-1:1;Math.abs(e)>Math.abs(n)?(s=1,r=Math.abs(n)/Math.abs(e)):(r=1,s=Math.abs(e)/Math.abs(n));const h=l*this.options.mouseWheelSpeed*5*s,d=c*this.options.mouseWheelSpeed*5*r,f=this.emitEvent(I.beforeScrollStart,h,d,t);if(v("[scroll]","abortScroll:",f),f===!0)return;this.scrollView(h,d)}else if(!(!o&&this.options.wheelEventAction==="none")){const s={x:t.clientX,y:t.clientY},r=n===0?0:n>0?-1:1,l=this.options.mouseWheelSpeed*r;this.zoom(l,s,t)}}scrollView(t,e){this.setCanvasOffset(this.options.canvasOffset.x+t,this.options.canvasOffset.y+e),this.updateEditingControllerView(),this.updateShouldRenderGraphData()}onLineDragStart(t,e){v("onLineDragStart...");const n=this.getLinkByLine(t),o={x:n.fromNode.x,y:n.fromNode.y},s={x:n.toNode.x,y:n.toNode.y},r=(l,c,h,d,f)=>{n.fromNode.x=o.x+l/(this.options.canvasZoom/100),n.fromNode.y=o.y+c/(this.options.canvasZoom/100),n.toNode.x=s.x+l/(this.options.canvasZoom/100),n.toNode.y=s.y+c/(this.options.canvasZoom/100),this.updateEditingControllerView(),this._dataUpdated()};W.startDrag(e,{x:0,y:0},(...l)=>{this.onLineDragEnd(...l)},r)}onLineDragEnd(t,e,n){v("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(t){if(!vt(t)){if(this.options.disableDragCanvas){this.onCanvasClick(t);return}if(this.options.selectionMode||t.shiftKey){this.startCreateSelection(t);return}if(!this.options.disableDragLine){const e=this.isLine(t.target);if(e){this.onLineDragStart(e,t);return}}this.startMoveCanvas(t)}}startMoveCanvas(t,e=!1){let n;if(it(t)){let r,l=1;n=(c,h,d,f,p)=>{const u=p.touches||p.targetTouches,g=u[0];if(u&&u.length>1){p.preventDefault();const x=u[1];r||(r={x:x.clientX,y:x.clientY},l=this.options.canvasZoom);const y={x:g.clientX,y:g.clientY},L={x:x.clientX,y:x.clientY},m=Math.hypot(r.x-f.x,r.y-f.y),b=Math.hypot(L.x-y.x,L.y-y.y)/m,M=this.options.mouseWheelSpeed*b,N=l*M;this.setZoom(N,f),this._dataUpdated()}else{const x=g.clientX,y=g.clientY,L=x-f.x,m=y-f.y;if(this.options.useHorizontalView){const w=d.x+m,b=d.y-L;this.onCanvasDragging(w,b,L,m)}else{const w=d.x+L,b=d.y+m;this.onCanvasDragging(w,b,m,L)}this.updateEditingControllerView(),this._dataUpdated()}}}else n=(r,l,c,h,d)=>{const f=c.x+r,p=c.y+l;this.onCanvasDragging(f,p,r,l),this.updateEditingControllerView(),this._dataUpdated()};const o={x:this.options.canvasOffset.x,y:this.options.canvasOffset.y};this.canvasDragging=!0;let s=e;W.startDrag(t,o,(r,l,c)=>{this.canvasDragging=!1,this.onCanvasDragStop(r,l,c)},(r,l,c,h,d)=>{s?n(r,l,c,h,d):Math.abs(r)+Math.abs(l)>4&&(this.emitEvent(I.onCanvasDragStart,c,h,d),s=!0)})}onCanvasDragging(t,e,n,o){const s=this.emitEvent(I.onCanvasDragging,t,e,n,o);s!==!1&&(s&&(typeof s.x=="number"&&(t=s.x),typeof s.y=="number"&&(e=s.y)),this.setCanvasOffset(t,e))}onCanvasDragStop(t,e,n){if(this.options.creatingSelection){this.options.creatingSelection=!1,this.onCanvasSelectionEnd(this.options.selectionView,n);return}if(Math.abs(t)+Math.abs(e)<4){v("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else v("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(t){let e=!1;const n=(o,s,r,l,c)=>{if(!e&&Math.abs(o)+Math.abs(s)>6&&(e=!0,this.options.creatingSelection=!0,this.options.selectionView.x=l.x,this.options.selectionView.y=l.y),e){const h=this.getBoundingClientRect();o<0?(this.options.selectionView.x=l.x+o-h.x,this.options.selectionView.width=Math.abs(o)):(this.options.selectionView.x=l.x-h.x,this.options.selectionView.width=o),s<0?(this.options.selectionView.y=l.y+s-h.y,this.options.selectionView.height=Math.abs(s)):(this.options.selectionView.y=l.y-h.y,this.options.selectionView.height=s)}this._dataUpdated()};W.startDrag(t,{x:0,y:0},(...o)=>{this.onCanvasDragStop(...o)},n)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let t=!1;document.fullscreenElement?(v("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(v("relation-graph is fullscreen!"),t=!0)):v("div exited fullscreen mode"),t!==this.options.fullscreen&&(this.options.fullscreen=t,this._dataUpdated(),setTimeout(async()=>{this.updateViewBoxInfo(),this.moveToCenter(),this.zoomToFit(),v("relation-graph reset complete!"),this._dataUpdated()},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}async sleep(t){await ft(1e3)}}class Cn extends vn{constructor(a,t){super(a,t)}dataUpdated(){(this.isReact||this.options.showEasyView)&&this._dataUpdated()}setOptions(a){this._setOptions(a)}setRootNodeId(a){if(this.graphData.rootNode=this.graphData.nodes.find(t=>t.id===a),!this.graphData.rootNode)throw new Error("The root node [rootId] is not set! Or cannot get the root node:"+a+", If you don't have any nodes to display, you can simply set an invisible node: {id:'root', opacity:0}")}getRootNode(){return this.graphData.rootNode}setCheckedNode(a){this.options.checkedNodeId=a}getCheckedNode(){return this.getNodeById(this.options.checkedNodeId)}getCheckedLine(){if(!this.getLineById(this.options.checkedLineId))return this.getFakeLineById(this.options.checkedLineId)}getSelectedNodes(){return this.getNodes().filter(a=>a.selected)}getEditingNodes(){return[...this.options.editingController.nodes]}async setJsonData(a){this._setJsonData(a);const t=a.rootId;t&&(this.graphData.rootNode=this.graphData.nodes.find(e=>e.id===t)),!this.graphData.rootNode&&this.graphData.nodes.length>0&&(this.graphData.rootNode=this.graphData.nodes[0]),await this.doLayout()}async appendJsonData(a,t=!0){v("appendData:",a),this.loadGraphJsonData(a),t&&await this.doLayout()}async applyInitialData(a){await this.setJsonData(a),this.moveToCenter(),this.zoomToFit()}fitContentHeight(a=20){this.options.canvasOpacity=.01,this._dataUpdated();const t=this.getNodesViewInfo(),e=t.height,n=t.width,o=this.options.viewSize.width-a*2,s=t.minX+t.width/2,r=t.minY+t.height/2;console.warn("[fitContentHeight]nodesCenter:",s,r),this.setCanvasCenter(s,r);const l=Math.min(1,o/n),c=e*l+a*2;this.options.viewSize.height=c,this.options.viewHeight=c+"px",setTimeout(()=>{this.setZoom(l*100),this.moveToCenter(),this.options.canvasOpacity=1,this._dataUpdated()},200)}}class _n{constructor(a){S(this,"$evCanvasCtx");S(this,"mediaDPR");S(this,"viewScale",1);S(this,"offset",{x:0,y:0});const t=a.getContext("2d");if(!t)throw new Error("\u65E0\u6CD5\u83B7\u53D6 Canvas 2D \u4E0A\u4E0B\u6587");this.$evCanvasCtx=t,this.mediaDPR=window.devicePixelRatio||1}setSize(a,t){const e=this.$evCanvasCtx.canvas;e.width=a*this.mediaDPR,e.height=t*this.mediaDPR,e.style.width=`${a}px`,e.style.height=`${t}px`,this.$evCanvasCtx.setTransform(this.mediaDPR,0,0,this.mediaDPR,0,0),this.applyCurrentViewTransform()}setScale(a){this.viewScale=a,this.applyCurrentViewTransform()}applyCurrentViewTransform(){this.$evCanvasCtx.setTransform(this.mediaDPR,0,0,this.mediaDPR,0,0),this.$evCanvasCtx.scale(this.viewScale,this.viewScale)}setViewOffset(a,t){this.offset.x=a/this.viewScale,this.offset.y=t/this.viewScale}beforeDraw(){}evDrawNode4Rect(a,t,e,n,o,s,r=5){const l=this.$evCanvasCtx,c=this.offset.x+a,h=this.offset.y+t;let d=Math.max(0,r);e<2*d&&(d=e/2),n<2*d&&(d=n/2),l.beginPath(),l.globalAlpha=s,d===0?l.rect(c,h,e,n):(l.moveTo(c+d,h),l.arcTo(c+e,h,c+e,h+d,d),l.arcTo(c+e,h+n,c+e-d,h+n,d),l.arcTo(c,h+n,c,h+n-d,d),l.arcTo(c,h,c+d,h,d),l.closePath()),l.fillStyle=o,l.fill(),l.globalAlpha=1}evDrawNode4Circle(a,t,e,n,o,s){const r=this.$evCanvasCtx,l=this.offset.x+a+e/2,c=this.offset.y+t+n/2;r.beginPath(),r.globalAlpha=s,r.ellipse(l,c,e/2,n/2,0,0,2*Math.PI),r.fillStyle=o,r.fill(),r.globalAlpha=1}evDrawLine(a,t,e,n){const o=this.$evCanvasCtx;o.beginPath(),o.globalAlpha=n,this.evDrawSvgPathOnCanvas(o,a),o.strokeStyle=e,o.lineWidth=t*this.viewScale<.5?.5/this.viewScale:t,o.stroke(),o.globalAlpha=1}getPointValue(a,t,e){return e?a+parseFloat(t):parseFloat(t)}evDrawSvgPathOnCanvas(a,t){const e=t.match(/[a-zA-Z][^a-zA-Z]*/g);if(!e)return;let n=0,o=0,s=0,r=0,l=0,c=0,h=0,d=0,f="";a.beginPath(),e.forEach(p=>{const u=p.trim(),g=u.charAt(0),y=u.substring(1).trim().split(/[ ,]+/).filter(_=>_!=="").map(parseFloat);let L=0,m=0,w=0,b=0,M=0,N=0,O=0,E=0,T=0,D=0,R=0;switch(g){case"M":n=y[0],o=y[1],s=n,r=o,a.moveTo(n+this.offset.x,o+this.offset.y);for(let _=2;_<y.length;_+=2)n=y[_],o=y[_+1],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"L":for(let _=0;_<y.length;_+=2)n=y[_],o=y[_+1],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"l":for(let _=0;_<y.length;_+=2)n+=y[_],o+=y[_+1],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"H":for(let _=0;_<y.length;_++)n=y[_],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"h":for(let _=0;_<y.length;_++)n+=y[_],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"V":for(let _=0;_<y.length;_++)o=y[_],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"v":for(let _=0;_<y.length;_++)o+=y[_],a.lineTo(n+this.offset.x,o+this.offset.y);break;case"C":for(let _=0;_<y.length;_+=6)w=y[_],b=y[_+1],M=y[_+2],N=y[_+3],L=y[_+4],m=y[_+5],a.bezierCurveTo(w+this.offset.x,b+this.offset.y,M+this.offset.x,N+this.offset.y,L+this.offset.x,m+this.offset.y),n=L,o=m,l=M,c=N;break;case"c":for(let _=0;_<y.length;_+=6)w=n+y[_],b=o+y[_+1],M=n+y[_+2],N=o+y[_+3],L=n+y[_+4],m=o+y[_+5],a.bezierCurveTo(w+this.offset.x,b+this.offset.y,M+this.offset.x,N+this.offset.y,L+this.offset.x,m+this.offset.y),l=M,c=N,n=L,o=m;break;case"S":for(let _=0;_<y.length;_+=4)f.match(/[CS]/i)?(w=2*n-l,b=2*o-c):(w=n,b=o),M=y[_],N=y[_+1],L=y[_+2],m=y[_+3],a.bezierCurveTo(w+this.offset.x,b+this.offset.y,M+this.offset.x,N+this.offset.y,L+this.offset.x,m+this.offset.y),n=L,o=m,l=M,c=N;break;case"s":for(let _=0;_<y.length;_+=4)f.match(/[CS]/i)?(w=2*n-l,b=2*o-c):(w=n,b=o),M=n+y[_],N=o+y[_+1],L=n+y[_+2],m=o+y[_+3],a.bezierCurveTo(w+this.offset.x,b+this.offset.y,M+this.offset.x,N+this.offset.y,L+this.offset.x,m+this.offset.y),l=M,c=N,n=L,o=m;break;case"Q":for(let _=0;_<y.length;_+=4)w=y[_],b=y[_+1],L=y[_+2],m=y[_+3],a.quadraticCurveTo(w+this.offset.x,b+this.offset.y,L+this.offset.x,m+this.offset.y),n=L,o=m,h=w,d=b;break;case"q":for(let _=0;_<y.length;_+=4)w=n+y[_],b=o+y[_+1],L=n+y[_+2],m=o+y[_+3],a.quadraticCurveTo(w+this.offset.x,b+this.offset.y,L+this.offset.x,m+this.offset.y),h=w,d=b,n=L,o=m;break;case"T":for(let _=0;_<y.length;_+=2)f.match(/[QT]/i)?(w=2*n-h,b=2*o-d):(w=n,b=o),L=y[_],m=y[_+1],a.quadraticCurveTo(w+this.offset.x,b+this.offset.y,L+this.offset.x,m+this.offset.y),n=L,o=m,h=w,d=b;break;case"t":for(let _=0;_<y.length;_+=2)f.match(/[QT]/i)?(w=2*n-h,b=2*o-d):(w=n,b=o),L=n+y[_],m=o+y[_+1],a.quadraticCurveTo(w+this.offset.x,b+this.offset.y,L+this.offset.x,m+this.offset.y),h=w,d=b,n=L,o=m;break;case"A":for(let _=0;_<y.length;_+=7)O=y[_],E=y[_+1],T=y[_+2],D=y[_+3],R=y[_+4],L=y[_+5],m=y[_+6],this.drawArc(a,n,o,O,E,T,D,R,L,m),n=L,o=m;break;case"a":for(let _=0;_<y.length;_+=7)O=y[_],E=y[_+1],T=y[_+2],D=y[_+3],R=y[_+4],L=n+y[_+5],m=o+y[_+6],this.drawArc(a,n,o,O,E,T,D,R,L,m),n=L,o=m;break;case"Z":case"z":a.closePath(),n=s,o=r;break;default:console.warn(`\u672A\u652F\u6301\u7684SVG\u547D\u4EE4\u5B57\u7B26: ${g}`)}g.match(/[CSQT]/i)?f=g:f=""})}drawArc(a,t,e,n,o,s,r,l,c,h){if(n=Math.abs(n),o=Math.abs(o),n===0||o===0){a.lineTo(c+this.offset.x,h+this.offset.y);return}const d=s%360*Math.PI/180,f=Math.sin(d),p=Math.cos(d),u=p*(t-c)/2+f*(e-h)/2,g=-f*(t-c)/2+p*(e-h)/2,x=u*u/(n*n)+g*g/(o*o);x>1&&(n*=Math.sqrt(x),o*=Math.sqrt(x));let y=(r===l?-1:1)*Math.sqrt(Math.max(0,(n*n*o*o-n*n*g*g-o*o*u*u)/(n*n*g*g+o*o*u*u)));isNaN(y)&&(y=0);const L=y*n*g/o,m=y*-o*u/n,w=p*L-f*m+(t+c)/2,b=f*L+p*m+(e+h)/2,M=(u-L)/n,N=(g-m)/o,O=(-u-L)/n,E=(-g-m)/o;let T=Math.atan2(N,M),D=Math.atan2(N*O-M*E,M*O+N*E);l===0&&D>0?D-=2*Math.PI:l===1&&D<0&&(D+=2*Math.PI);const R=T+D;a.ellipse?a.ellipse(w+this.offset.x,b+this.offset.y,n,o,d,T,R,l===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),a.lineTo(c+this.offset.x,h+this.offset.y))}}class Ln extends Cn{constructor(t,e){super(t,e);S(this,"$easyViewCanvas");S(this,"rgWebglCanvas");S(this,"easyViewUpdating",!1);S(this,"easyViewUpdateTimer");S(this,"easyViewOffset",{x:0,y:0})}setEasyViewCanvas(t){this.$easyViewCanvas=t,this.rgWebglCanvas=new _n(t)}startUpdateTask(){this.updateEasyView(),requestAnimationFrame(this.startUpdateTask.bind(this))}updateEasyView(){this.updateMiniView(),this.options.performanceMode&&(!this.options.showEasyView||requestAnimationFrame(this._updateEasyView.bind(this)))}_updateEasyView(t){try{this._updateShouldRenderGraphData(),this.evDosomethingBeforeDraw(),this.evDrawAllLines(),this.evDrawAllNodes()}catch(e){console.error(e)}}evDosomethingBeforeDraw(){const t=this.$easyViewCanvas.getBoundingClientRect(),e=t.width,n=t.height;this.$easyViewCanvas.width=e,this.$easyViewCanvas.height=n,this.rgWebglCanvas.setSize(e,n),v("updateEasyView",e,n);const o=this.options.canvasZoom/100;this.rgWebglCanvas.setScale(o),this.easyViewOffset.x=this.options.canvasOffset.x,this.easyViewOffset.y=this.options.canvasOffset.y,this.rgWebglCanvas.setViewOffset(this.easyViewOffset.x,this.easyViewOffset.y),this.rgWebglCanvas.beforeDraw()}evDrawAllNodes(){for(const t of this.graphData.nodes)!(t.rgShouldRender!==!1&&t.rgCalcedVisible&&t.opacity!==0)||this.evDrawNode(t)}evDrawNode(t){t.nodeShape===zt.circle?this.evDrawNode4Circle(t):this.evDrawNode4Rect(t)}getNodeColor(t){const e=t.color||this.options.defaultNodeColor||"#dddddd";return e==="transparent"?"rgba(204,204,204,0.55)":e.toLowerCase()==="#ffffff"||e.toLowerCase()==="white"||e.replace(/ /g,"").includes("255,255,255")?"#cccccc":e}evDrawNode4Rect(t){const e=t.el.offsetWidth,n=t.el.offsetHeight,o=t.opacity||1,s=this.getNodeColor(t),r=t.borderRadius===void 0?3:t.borderRadius;this.rgWebglCanvas.evDrawNode4Rect(t.x,t.y,e,n,s,o,r)}evDrawNode4Circle(t){const e=t.el.offsetWidth,n=t.el.offsetHeight,o=t.opacity||1,s=this.getNodeColor(t);this.rgWebglCanvas.evDrawNode4Circle(t.x,t.y,e,n,s,o)}evDrawAllLines(){for(const t of this.runtimeDATA4Links){const e=t.fromNode.rgShouldRender!==!1&&t.fromNode.opacity!==0&&t.fromNode.rgCalcedVisible,n=t.toNode.rgShouldRender!==!1&&t.toNode.opacity!==0&&t.toNode.rgCalcedVisible;!e&&!n||this.evDrawLine(t,t.line)}}evDrawLine(t,e){const n=this.createLineDrawInfo(t,e),o=e.opacity||1,s=e.lineWidth||1,r=e.color||this.options.defaultLineColor||"#888888";this.rgWebglCanvas.evDrawLine(n.pathData,s,r,o)}getPointValue(t,e,n){return n?t+parseFloat(e):parseFloat(e)}}class wn extends Ln{constructor(){super(...arguments);S(this,"_onResizing");S(this,"_onResizeEnd");S(this,"_startPoint",{x:0,y:0});S(this,"_startSize",{x:0,y:0,width:0,height:0});S(this,"_resizeType","l");S(this,"nodeStartSizeMap",new WeakMap);S(this,"resizeMiniLimit",{width:10,height:10});S(this,"_currentCreatingLineIsReverse",!1);S(this,"_startCreateLineFromNodeTime",0)}setEditingNodes(t){this.options.editingController.nodes.forEach(e=>{e.selected=!1}),this.options.editingController.nodes.splice(0,this.options.editingController.nodes.length),this.options.editingController.nodes.push(...t),this.options.editingController.show=this.options.editingController.nodes.length>0,this.updateEditingControllerView()}addEditingNode(t){this.options.editingController.nodes.forEach(e=>{e.selected=!1}),this.options.editingController.show=!0,this.options.editingController.nodes.push(t),this.updateEditingControllerView()}removeEditingNode(t){this.options.editingController.nodes.forEach(e=>{e.selected=!1}),this.options.editingController.nodes.splice(this.options.editingController.nodes.indexOf(t),1),this.options.editingController.show=this.options.editingController.nodes.length>0,this.updateEditingControllerView()}toggleEditingNode(t){this.options.editingController.nodes.forEach(e=>{e.selected=!1}),this.options.editingController.nodes.includes(t)?this.removeEditingNode(t):this.addEditingNode(t)}updateEditingControllerView(){if(this.updateEditingLineView(),this.updateEditingConnectControllerView(),!this.options.editingController.show)return;this.options.editingController.nodes.length>1&&this.options.editingController.nodes.forEach(h=>{h.selected=!0});const{minX:t,minY:e,maxX:n,maxY:o}=this.getStuffSize(this.options.editingController.nodes),s=this.options.editingController.nodes.length>1?5:0,r=this.options.canvasZoom/100;let l=n-t,c=o-e;if(l<0&&(l=0),c<0&&(c=0),l>0&&c>0){const h=this.getViewXyByCanvasXy({x:t,y:e});this.options.editingController.x=h.x-s*r,this.options.editingController.y=h.y-s*r,this.options.editingController.width=l*r+s*2*r,this.options.editingController.height=c*r+s*2*r}else this.options.editingController.show=!1;this.dataUpdated()}_getEventPoint(t){const e={x:t.clientX,y:t.clientY};if(it(t)){const o=t.touches||t.targetTouches;if(!o)throw new Error("error targetTouches");e.x=o[0].clientX,e.x=o[0].clientY}const n=this.getBoundingClientRect();return{x:e.x-n.x,y:e.y-n.y}}onResizeStart(t,e){this._resizeType=t,this._startPoint=this._getEventPoint(e),this._startSize.x=this.options.editingController.x,this._startSize.y=this.options.editingController.y,this._startSize.width=this.options.editingController.width,this._startSize.height=this.options.editingController.height;for(const n of this.options.editingController.nodes)this.nodeStartSizeMap.set(n,{x:n.x,y:n.y,width:n.el.offsetWidth,height:n.el.offsetHeight});this._onResizing&&this.$dom.removeEventListener("mousemove",this._onResizing),this._onResizeEnd&&this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._onResizing=this.onResizing.bind(this),this._onResizeEnd=this.onResizeEnd.bind(this),this.$dom.addEventListener("mousemove",this._onResizing),this.$dom.addEventListener("mouseup",this._onResizeEnd),this.emitEvent(I.onResizeStart,this.options.editingController.nodes)}onResizing(t){const e=this._getEventPoint(t),n=e.x-this._startPoint.x,o=e.y-this._startPoint.y;let s=this.options.editingController.width,r=this.options.editingController.height;const l=1;this._resizeType==="tl"?(this.options.editingController.x=this._startSize.x+n/l,this.options.editingController.y=this._startSize.y+o/l,s=this._startSize.width-n/l,r=this._startSize.height-o/l):this._resizeType==="tr"?(this.options.editingController.y=this._startSize.y+o/l,s=this._startSize.width+n/l,r=this._startSize.height-o/l):this._resizeType==="bl"?(this.options.editingController.x=this._startSize.x+n/l,s=this._startSize.width-n/l,r=this._startSize.height+o/l):this._resizeType==="br"?(s=this._startSize.width+n/l,r=this._startSize.height+o/l):this._resizeType==="t"?(this.options.editingController.y=this._startSize.y+o/l,r=this._startSize.height-o/l):this._resizeType==="r"?s=this._startSize.width+n/l:this._resizeType==="b"?r=this._startSize.height+o/l:this._resizeType==="l"&&(this.options.editingController.x=this._startSize.x+n/l,s=this._startSize.width-n/l),s<this.resizeMiniLimit.width&&(s=this.resizeMiniLimit.width),r<this.resizeMiniLimit.width&&(r=this.resizeMiniLimit.width),this.options.editingController.width=s,this.options.editingController.height=r,this._applyResizeScale(t),this.dataUpdated()}_applyResizeScale(t){const e=this.options.editingController.width/this._startSize.width,n=this.options.editingController.height/this._startSize.height,o=this.getCanvasXyByViewXy({x:this._startSize.x,y:this._startSize.y}),s=this.getCanvasXyByViewXy({x:this.options.editingController.x,y:this.options.editingController.y});let r=!0,l=!0;this._resizeType==="t"||this._resizeType==="b"?r=!1:(this._resizeType==="r"||this._resizeType==="l")&&(l=!1);for(const c of this.options.editingController.nodes){const h=this.nodeStartSizeMap.get(c),d=h.width*e,f=h.height*n,p=s.x+e*(h.x-o.x),u=s.y+n*(h.y-o.y),g=d,x=f;this.emitEvent(I.beforeNodeResize,c,p,u,g,x)===!1||(r&&(c.x=p,c.width=g,c.el.offsetWidth=g),l&&(c.y=u,c.height=x,c.el.offsetHeight=x),v("ResizeNode:",c.id,g,x,e,n))}this.updateEditingControllerView()}onResizeEnd(t){const e=this._getEventPoint(t),n=e.x-this._startPoint.x,o=e.y-this._startPoint.y;this._applyResizeScale(t),this.$dom.removeEventListener("mousemove",this._onResizing),this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._onResizing=null,this._onResizeEnd=null,this.emitEvent(I.onResizeEnd,this.options.editingController.nodes,n,o,t)}draggingSelectedNodes(t,e,n,o,s){const r=this.updateReferenceLineView(t,e,n,o,s);if(r){const{showV:l,fixedX:c,showH:h,fixedY:d}=r;l&&(o+=c-e,e=c),h&&(s+=d-n,n=d)}if(!this.options.editingController.nodes.includes(t))this.setNodePosition(t,e,n),this.updateEditingLineView();else{for(const l of this.options.editingController.nodes){const c=this.nodeXYBeforeDrag[l.id];c&&(l.x=c.x+o,l.y=c.y+s)}this.updateEditingControllerView()}}getNodesInSelectionView(t){const e=this.getCanvasXyByViewXy({x:t.x,y:t.y}),n=this.getCanvasXyByViewXy({x:t.x+t.width,y:t.y+t.height}),o=[];return this.getNodes().forEach(s=>{const r=s.x+s.el.offsetWidth/2,l=s.y+s.el.offsetHeight/2;r>e.x&&l>e.y&&r<n.x&&l<n.y&&o.push(s)}),o}updateEditingConnectControllerView(){if(!this.options.nodeConnectController.show)return;const t=this.options.nodeConnectController.node,e=t.x,n=t.y,o=t.x+t.el.offsetWidth,s=t.y+t.el.offsetHeight,r=0,l=this.options.canvasZoom/100,c=e,h=n,d=o-e,f=s-n,p=this.getViewXyByCanvasXy({x:c,y:h});this.options.nodeConnectController.x=p.x-r*l,this.options.nodeConnectController.y=p.y-r*l,this.options.nodeConnectController.width=d*l+r*2*l,this.options.nodeConnectController.height=f*l+r*2*l,this.dataUpdated()}setEditingLine(t,e){this.options.editingLineController.link=e,this.options.editingLineController.line=t,this.options.editingLineController.show=!!t,this.updateEditingLineView(!0)}updateReferenceLineView(t,e,n,o,s){if(!this.options.showReferenceLine)return;if(!this.options.editingReferenceLine.show){const b=Math.abs(o),M=Math.abs(s);b+M>2&&(this.options.editingReferenceLine.show=!0)}if(!this.options.editingReferenceLine.show)return;const r=e,l=t.el.offsetWidth,c=t.el.offsetHeight,h=e+l/2,d=e+l,f=n,p=n+c/2,u=n+c,g=this.getViewXyByCanvasXy({x:h,y:p});let x=!1,y=!1,L=0,m=0;const w=this.graphData.nodes.filter(b=>this.nodeXYBeforeDrag[b.id]?!1:Math.abs(b.x-h)<600&&Math.abs(b.y-p)<600);w.sort((b,M)=>{const N=dt(h,p,b.x+b.el.offsetWidth/2,b.y+b.el.offsetHeight/2),O=dt(h,p,M.x+M.el.offsetWidth/2,M.y+M.el.offsetHeight/2);return N<O?-1:1});for(const b of w){const M=b.x,N=b.el.offsetWidth,O=b.el.offsetHeight,E=b.x+N/2,T=b.x+N,D=b.y,R=b.y+O/2,_=b.y+O,z=Math.abs(r-M),F=Math.abs(h-E),V=Math.abs(d-T),P=Math.abs(f-D),$=Math.abs(p-R),Y=Math.abs(u-_),j=5;if(F<800&&$<800){if(!y&&F<j){const X=this.getViewXyByCanvasXy({x:E,y:R});this.options.editingReferenceLine.v_x=X.x,this.options.editingReferenceLine.v_y=g.y>X.y?X.y:g.y,this.options.editingReferenceLine.v_height=Math.round(Math.abs(g.y-X.y)),y=!0,L=E-l/2}if(!y&&z<j){const X=this.getViewXyByCanvasXy({x:M,y:R});this.options.editingReferenceLine.v_x=X.x,this.options.editingReferenceLine.v_y=g.y>X.y?X.y:g.y,this.options.editingReferenceLine.v_height=Math.round(Math.abs(g.y-X.y)),y=!0,L=M}if(!y&&V<j){const X=this.getViewXyByCanvasXy({x:T,y:R});this.options.editingReferenceLine.v_x=X.x,this.options.editingReferenceLine.v_y=g.y>X.y?X.y:g.y,this.options.editingReferenceLine.v_height=Math.round(Math.abs(g.y-X.y)),y=!0,L=T-l}if(!x&&$<j){const X=this.getViewXyByCanvasXy({x:E,y:R});this.options.editingReferenceLine.h_y=X.y,this.options.editingReferenceLine.h_x=g.x>X.x?X.x:g.x,this.options.editingReferenceLine.h_width=Math.round(Math.abs(g.x-X.x)),x=!0,m=R-c/2}if(!x&&P<j){const X=this.getViewXyByCanvasXy({x:E,y:D});this.options.editingReferenceLine.h_y=X.y,this.options.editingReferenceLine.h_x=g.x>X.x?X.x:g.x,this.options.editingReferenceLine.h_width=Math.round(Math.abs(g.x-X.x)),x=!0,m=D}if(!x&&Y<j){const X=this.getViewXyByCanvasXy({x:E,y:_});this.options.editingReferenceLine.h_y=X.y,this.options.editingReferenceLine.h_x=g.x>X.x?X.x:g.x,this.options.editingReferenceLine.h_width=Math.abs(g.x-X.x),x=!0,m=_-c}if(x&&y)break}}if(this.options.editingReferenceLine.directionH=x,this.options.editingReferenceLine.directionV=y,this.options.referenceLineAdsorption)return{showV:y,fixedX:L,showH:x,fixedY:m}}hideEditingLineView(){this.options.editingLineController.show=!1}updateEditingLineView(t=!1){this.updateElementLines();const e=this.options;if(!e.editingLineController.show)return;const n=e.editingLineController.link,o=e.editingLineController.line;if(!o||o.to==="newRelationTemplate-to"){e.editingLineController.show=!1;return}let s,r,l;const c=this.createLineDrawInfo(n,o);if(!c){e.editingLineController.show=!1;return}if(o.lineShape===G.StandardOrthogonal){let{textPosition:m,pathData:w,points:b,startDirection:M,endDirection:N}=c;l=m,s=b[0],r=b[b.length-1];const O=[];for(let E=0;E<b.length-1;E++){const T=b[E],D=b[E+1],R={pIndex:E,optionName:"cp-"+E,x:0,y:0,direction:"v",startDirection:M,endDirection:N};T.x!==D.x&&(R.direction="h");const _=this.getViewXyByCanvasXy({x:(T.x+D.x)/2,y:(T.y+D.y)/2});R.x=_.x,R.y=_.y,O.push(R)}if(O.length!==1){if(O.length!==2)if(O.length===3){const E=b[0],T=b[1],D=b[3];if(O[1].direction==="v"){const R=E.x,_=T.x,z=D.x;if(Math.max(R,_,z)!==_&&Math.min(R,_,z)!==_)O[1].optionName="cx";else{const V=Math.abs(_-R),P=Math.abs(_-z);V>=P?O[1].optionName="td":V<P&&(O[1].optionName="fd")}}else{const R=E.y,_=T.y,z=D.y;if(Math.max(R,_,z)!==_&&Math.min(R,_,z)!==_)O[1].optionName="cy";else{const V=Math.abs(_-R),P=Math.abs(_-z);V>=P?O[1].optionName="td":V<P&&(O[1].optionName="fd")}}}else O.length===4?(O[1].optionName="fd",O[2].optionName="td"):O.length===5&&(O[1].optionName="fd",O[2].direction==="v"?O[2].optionName="cx":O[2].optionName="cy",O[3].optionName="td")}e.editingLineController.line44Splits=O,e.editingLineController.line49Points=b,o.ctrlPointsFor49||(o.ctrlPointsFor49=b)}else if(o.lineShape===G.HardOrthogonal){let{textPosition:m,pathData:w,points:b,startDirection:M,endDirection:N}=c;l=m;const O=[];o.ctrlPointsFor49=b,s=b[0],r=b[b.length-1];const E=b;for(let T=0;T<E.length-1;T++){const D=E[T],R=E[T+1],_={pIndex:T,optionName:"cp-"+T,x:0,y:0,direction:"v",startDirection:M,endDirection:N};D.x!==R.x?(_.direction="h",Math.abs(D.x-R.x)<15&&(_.hide=!0)):Math.abs(D.y-R.y)<15&&(_.hide=!0);const z=this.getViewXyByCanvasXy({x:(D.x+R.x)/2,y:(D.y+R.y)/2});_.x=z.x,_.y=z.y,O.push(_)}for(let T=0;T<O.length;T++){const D=O[T-1],R=O[T],_=O[T+1];T===0&&R.direction===_.direction&&(R.hide=!0),T===O.length-1&&R.direction===D.direction&&(R.hide=!0)}e.editingLineController.line44Splits=O,e.editingLineController.line49Points=E}else if(o.lineShape!==1){l=c.textPosition;const m=Zt(c.pathData);o.isReverse?(s=m.endPoint,r=m.startPoint,e.editingLineController.ctrlPoint1=this.getViewXyByCanvasXy(m.ctrl1),e.editingLineController.ctrlPoint2=this.getViewXyByCanvasXy(m.ctrl2)):(s=m.startPoint,r=m.endPoint,e.editingLineController.ctrlPoint1=this.getViewXyByCanvasXy(m.ctrl1),e.editingLineController.ctrlPoint2=this.getViewXyByCanvasXy(m.ctrl2))}else{l=c.textPosition;const m=c.pathData,w=Zt(m);s=w.startPoint,r=w.endPoint}const h=this.getViewXyByCanvasXy(o.isReverse?r:s),d=this.getViewXyByCanvasXy(o.isReverse?s:r);e.editingLineController.startPoint.x=h.x,e.editingLineController.startPoint.y=h.y,e.editingLineController.endPoint.x=d.x,e.editingLineController.endPoint.y=d.y;const f=this.getViewXyByCanvasXy(l),p=this.$canvasDom.querySelector(`g[data-id='${o.id}']`);let u=0,g=0,x=o.textOffset_x||0,y=o.textOffset_y||0;const L=e.canvasZoom/100;if(p){const m=p.querySelector("text.rg-line-text");if(m){x=Math.floor(parseFloat(m.getAttribute("x")||"0")),y=Math.floor(parseFloat(m.getAttribute("y")||"0"));const w=m.clientWidth,b=m.clientHeight;e.editingLineController.text.width=w,e.editingLineController.text.height=b}else e.editingLineController.text.width=20,e.editingLineController.text.height=10,u=-e.editingLineController.text.width/2}e.editingLineController.text.width+=40,e.editingLineController.text.height+=10,e.editingLineController.text.width>120&&(e.editingLineController.text.width=120),e.editingLineController.text.height>20&&(e.editingLineController.text.height=20),e.editingLineController.text.x=f.x+u+x*L,e.editingLineController.text.y=f.y+g+y*L}getStartAndEndPoint(t){const e=t.match(/[a-zA-Z][^a-zA-Z]*/g);let n=0,o=0,s=0,r=0;const l={x:0,y:0},c={x:0,y:0};for(const h of e){const d=h.trim().split(/[ ,]+/),f=d[0].toUpperCase(),p=d[0]===d[0].toLowerCase();switch(f){case"M":n=this.getPointValue(s,d[1],p)+this.easyViewOffset.x,o=this.getPointValue(r,d[2],p)+this.easyViewOffset.y,s=n,r=o;break;case"L":n=this.getPointValue(s,d[1],p)+this.easyViewOffset.x,o=this.getPointValue(r,d[2],p)+this.easyViewOffset.y;break;case"C":this.getPointValue(s,d[1],p),this.getPointValue(r,d[2],p),this.getPointValue(s,d[3],p),this.getPointValue(r,d[4],p),n=this.getPointValue(s,d[5],p),o=this.getPointValue(r,d[6],p),s=n,r=o;break;case"Q":this.getPointValue(s,d[1],p),this.getPointValue(r,d[2],p),n=this.getPointValue(s,d[3],p),o=this.getPointValue(r,d[4],p),s=n,r=o;break;case"V":o=this.getPointValue(r,d[1],p),r=o;break;case"H":n=this.getPointValue(s,d[1],p),s=n;break;case"Z":break;default:v(`Unsupported command: ${f}`)}h===e[0]&&(l.x=n,l.y=o),h===e[e.length-1]&&(c.x=n,c.y=o)}return{startPoint:l,endPoint:c}}startMoveLineVertex(t,e,n){e.stopPropagation();const o=this.options.editingLineController.link,s=this.options.editingLineController.line;let r,l;if(o)r=o.fromNode,l=o.toNode;else{const{from:L,to:m}=this.generateFakeLineConfig(s);r=L,l=m}let c=r;this.setEditingLine(null,null),o?this.removeLine(s):this.removeFakeLine(s),console.log("DragLine start:",t,s.isReverse),this._currentCreatingLineIsReverse=!1;const{startMarkerId:h,endMarkerId:d,fromJunctionPoint:f,fromJuctionPointOffsetX:p,fromJuctionPointOffsetY:u,toJunctionPoint:g,toJuctionPointOffsetX:x,toJuctionPointOffsetY:y}=this.options.newLineTemplate;s.lineShape===G.HardOrthogonal&&(s.lineShape=G.StandardOrthogonal),t==="start"?(s.fromJuctionPointOffsetX=0,s.fromJuctionPointOffsetY=0,s.isReverse?this._currentCreatingLineIsReverse=!0:(c=l,s.isReverse=!0)):(s.toJuctionPointOffsetX=0,s.toJuctionPointOffsetY=0,s.isReverse&&(c=l,s.isReverse=void 0,this._currentCreatingLineIsReverse=!0)),this._currentCreatingLineIsReverse&&(this.options.newLinkTemplate.fromJunctionPoint=g,this.options.newLinkTemplate.toJunctionPoint=f,this.options.newLineTemplate.startMarkerId=d,this.options.newLineTemplate.endMarkerId=h,this.options.newLineTemplate.fromJuctionPointOffsetX=p,this.options.newLineTemplate.fromJuctionPointOffsetY=u,this.options.newLineTemplate.toJuctionPointOffsetX=x,this.options.newLineTemplate.toJuctionPointOffsetY=y),this.startCreatingLinePlot(e,{template:s,fromNode:c,onCreateLine:n})}startCreateLineFromNode(t,e,n,o){if(n.stopPropagation(),this._startCreateLineFromNodeTime=Date.now(),!e.from){if(!t){const r=this.options.editingController.nodes;r.length===1&&(t=r[0])}t&&(e.from=t.id,e.fromType=t.targetType)}if(!e.from)throw console.error("Error:lineTemplate:",e),Error("Error:startCreateLineByTemplate: lineTemplate must has [fromType, from]");const s=this.getFakeLineTarget(e.fromType,e.from,e);if(!s)throw console.error("Error:fakeTarget[fromType, from]:",e.fromType,e.from,e),Error(`Error:startCreateLineByTemplate: error from fakeTarget[fromType, from]:${e.fromType}, ${e.from}`);e.lineShape||(e.lineShape=6),this.startCreatingLinePlot(n,{template:e,fromNode:s,onCreateLine:o})}onLineVertexBeDropped(t,e,n={x:0,y:0},o){if(e.stopPropagation(),!this.options.creatingLinePlot||Date.now()-this._startCreateLineFromNodeTime<500)return;console.log("Connect end:",this.options.newLineTemplate.isReverse);const s=this.options.nodeConnectController.node;if(!this.options.newLinkTemplate.fromNode)this.options.newLineTemplate.isReverse?(this.options.newLineTemplate.toJunctionPoint=t,this.options.newLineTemplate.toJuctionPointOffsetX=n.x,this.options.newLineTemplate.toJuctionPointOffsetY=n.y):(this.options.newLineTemplate.fromJunctionPoint=t,this.options.newLineTemplate.fromJuctionPointOffsetX=n.x,this.options.newLineTemplate.fromJuctionPointOffsetY=n.y),this.options.newLinkTemplate.fromNode=s;else{this.options.newLineTemplate.isReverse?(this.options.newLineTemplate.fromJunctionPoint=t,this.options.newLineTemplate.fromJuctionPointOffsetX=n.x,this.options.newLineTemplate.fromJuctionPointOffsetY=n.y):(this.options.newLineTemplate.toJunctionPoint=t,this.options.newLineTemplate.toJuctionPointOffsetX=n.x,this.options.newLineTemplate.toJuctionPointOffsetY=n.y),this.options.newLinkTemplate.toNodeObject=s;const r=this.options.newLinkTemplate.fromNode,l=s;try{this.emitEvent(I.onLineVertexDropped,{newLineTemplate:this.options.newLineTemplate,fromNode:r,toNode:l}),o&&o(r,l,this.options.newLineTemplate),this.onCreateLine(this.options.newLinkTemplate.fromNode,this.options.nodeConnectController.node)!==!0&&this.stopCreatingLinePlot()}catch(c){this.stopCreatingLinePlot(),console.warn("[Custom Reject onCreateLine By Throw Error:",c)}}}startMoveLineText(t,e){if(vt(t))return;const n=this._getEventPoint(t),o=this.options.editingLineController.line,s=o.textOffset_x||0,r=o.textOffset_y||0,l=h=>{const d=this.options.canvasZoom/100,f=this._getEventPoint(h),p=f.x-n.x,u=f.y-n.y;o.textOffset_x=Math.round(s+p/d),o.textOffset_y=Math.round(r+u/d),this.updateEditingLineView(),this._dataUpdated()},c=h=>{this.$dom.removeEventListener("mousemove",l),this.$dom.removeEventListener("mouseup",c),e&&e(),this._dataUpdated()};this.$dom.addEventListener("mousemove",l),this.$dom.addEventListener("mouseup",c)}startMoveLine6CtrlPoint(t,e){return e.stopPropagation(),e.preventDefault(),new Promise((n,o)=>{const r=this.options.editingLineController.line;r.ctrlPoints||(r.ctrlPoints=[]),r.ctrlPoints.length===0&&(r.ctrlPoints.push({x:0,y:0}),r.ctrlPoints.push({x:0,y:0})),r.isReverse&&(t=r.ctrlPoints.length-1-t);const c=this.options.canvasZoom/100,h=r.ctrlPoints[t],{x:d,y:f}=h,p=()=>{this.dataUpdated(),n()};W.startDrag(e,{x:0,y:0},p,(u,g)=>{h.x=d+u/c,h.y=f+g/c,this.updateEditingLineView(),this.dataUpdated()})})}startMoveLine44CtrlPoint(t,e){return e.stopPropagation(),e.preventDefault(),console.log("startMoveLine44CtrlPoint:",t.optionName),new Promise((n,o)=>{const s=this.options.editingLineController,r=s.line;r.ctrlOptionsFor44||(r.ctrlOptionsFor44={cx:0,cy:0,fd:0,td:0});const c=this.options.canvasZoom/100,h=r.ctrlOptionsFor44[t.optionName],d={indexOffset:0};let f=JSON.parse(JSON.stringify(r.ctrlPointsFor49));const p=()=>{if(r.lineShape===G.HardOrthogonal){const u=Ot(r.ctrlPointsFor49);r.ctrlPointsFor49=u}this.updateEditingLineView(),this.dataUpdated(),n()};W.startDrag(e,{x:0,y:0},p,(u,g)=>{if(r.lineShape===G.StandardOrthogonal)if(t.optionName==="cx"){const y=h+u/c*1;r.ctrlOptionsFor44.cx=y}else if(t.optionName==="cy"){const y=h+g/c*1;r.ctrlOptionsFor44.cy=y}else if(t.optionName==="fd"){const x=bt[t.startDirection],y=t.direction==="v"?u*x.x:g*x.y;r.ctrlOptionsFor44.fd=h+y/c}else if(t.optionName==="td"){const x=bt[t.endDirection],y=t.direction==="v"?u*x.x:g*x.y;r.ctrlOptionsFor44.td=h+y/c}else(t.direction==="v"&&Math.abs(u)>5||t.direction==="h"&&Math.abs(g)>5)&&(r.ctrlPointsFor49=s.line49Points,r.lineShape=49,f=JSON.parse(JSON.stringify(r.ctrlPointsFor49)));else if(r.lineShape===G.HardOrthogonal){const{newPoints:x,pointsChanged:y}=bn(r.ctrlPointsFor49,f,t.pIndex+d.indexOffset,t,d,u/c,g/c);y&&(f=JSON.parse(JSON.stringify(x))),r.ctrlPointsFor49=x}this.updateEditingLineView(),this.dataUpdated()})})}}const bn=(i,a,t,e,n,o,s)=>{const r=JSON.parse(JSON.stringify(i));let l=!1;if(t<0||t>=i.length-1)return{newPoints:r,pointsChanged:l};r[t-1];const c=r[t],h=r[t+1];a[t-1];const d=a[t];a[t+1];let f=o,p=s;if(e.direction==="v"){const u=a[t-2],g=a[t+2],x=d.x+f;let y=3e3;if(u){const L=Math.abs(u.x-x);L<10&&L<y&&(y=L,f=u.x-d.x)}if(g){const L=Math.abs(g.x-x);L<10&&L<y&&(y=L,f=g.x-d.x)}}else{const u=a[t-2],g=a[t+2],x=d.y+p;let y=3e3;if(u){const L=Math.abs(u.y-x);L<10&&L<y&&(y=L,p=u.y-d.y)}if(g){const L=Math.abs(g.y-x);L<10&&L<y&&(y=L,p=g.y-d.y)}}if(e.direction==="v")if(t===0){const u=c.y<h.y?1:-1,g={x:c.x,y:c.y},x={x:c.x,y:c.y+20*u};c.x=x.x+f,c.y=x.y,r.splice(t,0,g,x),n.indexOffset+=2,l=!0}else if(t===i.length-2){const u=c.y<h.y?1:-1,g={x:d.x+f,y:h.y-20*u},x={x:h.x,y:h.y-20*u};r.splice(t+1,0,g,x),l=!0}else c.x=d.x+f,h.x=d.x+f;else if(t===0){const u=c.x<h.x?1:-1,g={x:c.x,y:c.y},x={x:c.x+20*u,y:c.y};c.x=x.x,c.y=d.y+p,r.splice(t,0,g,x),n.indexOffset+=2,l=!0}else if(t===i.length-2){const u=c.x<h.x?1:-1,g={x:h.x-20*u,y:d.y+p},x={x:h.x-20*u,y:h.y};r.splice(t+1,0,g,x),l=!0}else c.y=d.y+p,h.y=d.y+p;return{newPoints:r,pointsChanged:l}};class On extends wn{constructor(t,e){super(t,e);S(this,"$miniViewCanvas");S(this,"$mvCanvasCtx");S(this,"mediaDPR");S(this,"miniViewUpdating",!1);S(this,"miniViewUpdateHasNext",!1);S(this,"canvasDomScale",1);S(this,"miniViewBox",{visibleAreaStart:{x:0,y:0},visibleAreaEnd:{x:0,y:0},canvas_start_x:0,canvas_start_y:0,canvas_end_x:0,canvas_end_y:0,canvas_width:0,canvas_height:0,miniview_width:0,miniview_height:0});S(this,"visibleArea",{x:0,y:0});S(this,"_canvasItemMiniSizeLimit",1);S(this,"miniviewVisiableHandleMoveing",!1)}initImageTool(){this.mediaDPR=window.devicePixelRatio||1}setMiniViewCanvas(t){this.$miniViewCanvas=t,this.$mvCanvasCtx=this.$miniViewCanvas.getContext("2d")}updateMiniView(){!this.options.showMiniView||requestAnimationFrame(this._updateMiniView.bind(this))}_updateMiniView(){try{this.miniViewUpdating=!0,this.mvDosomethingBeforeDraw(),this.mvDrawAllNodes(),this.mvDrawMask()}catch(t){console.error(t)}this.miniViewUpdating=!1,this.miniViewUpdateHasNext&&(this.miniViewUpdateHasNext=!1,this._updateMiniView())}mvDosomethingBeforeDraw(){let t=9999999,e=9999999,n=-9999999,o=-9999999,s=0;for(const L of this.getNodes())if(L.rgCalcedVisible&&L.opacity!==0){L.x<t&&(t=L.x),L.y<e&&(e=L.y);const m=L.x+L.el.offsetWidth,w=L.y+L.el.offsetHeight;m>n&&(n=m),w>o&&(o=w),s++}if(s===0)return;const r=1,l=50,c=50;this.miniViewBox.canvas_start_x=t-l,this.miniViewBox.canvas_start_y=e-c,this.miniViewBox.canvas_end_x=n+l,this.miniViewBox.canvas_end_y=o+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y;const h=this.$miniViewCanvas.parentElement.getBoundingClientRect(),d=h.width,f=h.height;let p=0,u=0,g=r;d/this.miniViewBox.canvas_width<f/this.miniViewBox.canvas_height?(g=d/this.miniViewBox.canvas_width*r,p=d,u=d/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=f/this.miniViewBox.canvas_height*r,p=f/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,u=f),this.miniViewBox.miniview_width=d,this.miniViewBox.miniview_height=f,this.$miniViewCanvas.width=d,this.$miniViewCanvas.height=f,this.$mvCanvasCtx.canvas.width=d*this.mediaDPR,this.$mvCanvasCtx.canvas.height=f*this.mediaDPR,this.$mvCanvasCtx.canvas.style.width=`${d}px`,this.$mvCanvasCtx.canvas.style.height=`${f}px`;const x=(f-u)/2,y=(d-p)/2;if(this.miniViewBox.canvas_start_x-=y/g,this.miniViewBox.canvas_start_y-=x/g,v("updateMiniView",y,x),this.$mvCanvasCtx.setTransform(this.mediaDPR,0,0,this.mediaDPR,0,0),this.$mvCanvasCtx.scale(g,g),!this.miniviewVisiableHandleMoveing){const L=this.getBoundingClientRect(),m=this.getCanvasXyByViewXy({x:0,y:0}),w=this.getCanvasXyByViewXy({x:L.width,y:L.height}),b=w.x-m.x,M=w.y-m.y;this.miniViewBox.visibleAreaStart=m,this.miniViewBox.visibleAreaEnd=w,this.options.miniViewVisibleHandle.width=g*b,this.options.miniViewVisibleHandle.height=g*M;const N=m.x-this.miniViewBox.canvas_start_x,O=m.y-this.miniViewBox.canvas_start_y;this.options.miniViewVisibleHandle.x=g*N,this.options.miniViewVisibleHandle.y=g*O,this.canvasDomScale=g,this.options.miniViewVisibleHandle.x+this.options.miniViewVisibleHandle.width<0||this.options.miniViewVisibleHandle.y+this.options.miniViewVisibleHandle.height<0||this.options.miniViewVisibleHandle.y>this.miniViewBox.miniview_height||this.options.miniViewVisibleHandle.x>this.miniViewBox.miniview_width?this.options.miniViewVisibleHandle.emptyContent=!0:this.options.miniViewVisibleHandle.emptyContent=!1}}mvDrawMask(){}mvDrawAllNodes(){const t=this.canvasDomScale;for(const e of this.getNodes())if(e.rgCalcedVisible&&e.opacity!==0){let n=e.el.offsetWidth,o=e.el.offsetHeight;t*n<this._canvasItemMiniSizeLimit&&(n=this._canvasItemMiniSizeLimit/this.canvasDomScale),t*o<this._canvasItemMiniSizeLimit&&(o=this._canvasItemMiniSizeLimit/this.canvasDomScale),this.mvDrawNode(e,n,o)}}mvDrawNode(t,e,n){t.nodeShape===0?this.mvDrawNode4Circle(t,e,n):this.mvDrawNode4Rect(t,e,n)}mvDrawNode4Rect(t,e,n){const o=this.$mvCanvasCtx,s=t.x-this.miniViewBox.canvas_start_x,r=t.y-this.miniViewBox.canvas_start_y;o.beginPath(),o.globalAlpha=t.opacity||1,o.rect(s,r,e,n),o.fillStyle=this.getNodeColor(t),o.fill(),o.globalAlpha=1}mvDrawNode4Circle(t,e,n){const o=this.$mvCanvasCtx,s=t.x+e/2-this.miniViewBox.canvas_start_x,r=t.y+n/2-this.miniViewBox.canvas_start_y;o.beginPath(),o.globalAlpha=t.opacity||1,o.ellipse(s,r,e/2,n/2,0,0,2*Math.PI),o.fillStyle=this.getNodeColor(t),o.fill(),o.globalAlpha=1}mvDrawAllLines(){for(const t of this.getLinks())t.fromNode.rgCalcedVisible&&t.toNode.rgCalcedVisible&&this.mvDrawLine(t,t.line)}mvDrawLine(t,e){const n=this.$mvCanvasCtx,o=this.createLineDrawInfo(t,e);n.beginPath(),n.globalAlpha=e.opacity||1,this.mvDrawSvgPathOnCanvas(n,o.pathData),n.strokeStyle=e.color||this.options.defaultLineColor||"#888888",n.lineWidth=e.lineWidth||1,n.stroke(),n.globalAlpha=1}mvDrawSvgPathOnCanvas(t,e){const n=e.match(/[a-zA-Z][^a-zA-Z]*/g);let o=0,s=0,r=0,l=0,c=0,h=0,d=0,f=0,p=!1;n.forEach(u=>{const g=u.trim().split(/[ ,]+/),x=g[0].toUpperCase(),y=g[0]===g[0].toLowerCase();switch(x){case"M":o=this.getPointValue(r,g[1],y)-this.miniViewBox.canvas_start_x,s=this.getPointValue(l,g[2],y)-this.miniViewBox.canvas_start_y,r=o,l=s,p&&(t.closePath(),p=!1),t.moveTo(o,s);break;case"L":o=this.getPointValue(r,g[1],y)-this.miniViewBox.canvas_start_x,s=this.getPointValue(l,g[2],y)-this.miniViewBox.canvas_start_y,t.lineTo(o,s);break;case"C":c=this.getPointValue(r,g[1],y),h=this.getPointValue(l,g[2],y),d=this.getPointValue(r,g[3],y),f=this.getPointValue(l,g[4],y),o=this.getPointValue(r,g[5],y),s=this.getPointValue(l,g[6],y),r=o,l=s,t.bezierCurveTo(c,h,d,f,o,s);break;case"Q":c=this.getPointValue(r,g[1],y),h=this.getPointValue(l,g[2],y),o=this.getPointValue(r,g[3],y),s=this.getPointValue(l,g[4],y),r=o,l=s;break;case"V":s=this.getPointValue(l,g[1],y),l=s,t.lineTo(o,s);break;case"H":o=this.getPointValue(r,g[1],y),r=o,t.lineTo(o,s);break;case"Z":t.closePath(),p=!1;break;default:v(`Unsupported command: ${x}`)}})}onVisiableViewHandleDragStart(t){t.preventDefault(),t.stopPropagation();const e=this.options.canvasOffset.x,n=this.options.canvasOffset.y,o=this.miniViewBox.canvas_width,s=this.miniViewBox.canvas_height,r=(c,h,d,f,p)=>{const u=c/this.miniViewBox.miniview_width,g=h/this.miniViewBox.miniview_height,x=this.options.canvasZoom/100,y=o*u*x,L=s*g*x;this.setCanvasOffset(e-y,n-L),this.updateEditingControllerView(),this.dataUpdated()},l=(c,h,d)=>{this.miniviewVisiableHandleMoveing=!1,this.onCanvasDragEnd(d)};W.startDrag(t,this.options.miniViewVisibleHandle,l,r)}resetByVisiableView(t){!this.options.miniViewVisibleHandle.emptyContent||(this.setZoom(100),this.moveToCenter(),this.zoomToFit())}}class Ce extends On{constructor(a,t){super(a,t)}setListeners(a){this.listeners=a}ready(){this.initDom(),this.resetViewSize(!0),this.initImageTool(),this.updateViewBoxInfo(),this.addFullscreenListener(),this.emitEvent(I.onReady,this)}beforeUnmount(){this.options.instanceDestroyed=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.destroyMutationObserver(),this.destroyResizeObserver()}}const Gt=i=>{const[a,t]=k.useState(0),e=k.useRef(0),n=k.useRef(i.relationGraphCore?new i.relationGraphCore:new Ce),o=s=>{e.current++,t(e.current)};return k.useEffect(()=>{n.current.setUpdateViewHook(o),i.onProviderReady&&i.onProviderReady(n.current)},[]),C.jsx(C.Fragment,{children:C.jsx(Ve,{value:n.current,children:C.jsx(ze,{value:o,children:C.jsx(Be,{value:a,children:i.children})})})})},Sn=(i,a)=>{const t=k.useContext(H),e=k.useRef(i.relationGraphInstance);k.useImperativeHandle(a,()=>({getInstance(){return t||e.current},async setJsonData(o,s,r){throw new Error(`Please Initialize the graph using the new method:
49
- Method 1:
42
+ `}},ne=({iconName:s,className:o})=>{const e=un[s];return x.jsx("svg",{className:`rg-icon ${o||""}`,viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",dangerouslySetInnerHTML:{__html:e.data}})},fn=()=>{const s=W(),{options:o}=q(),e=t=>{s.clearLoading()};return x.jsx(x.Fragment,{children:o&&x.jsx("div",{className:`rg-graph-loading ${o.graphLoading?"":"rg-graph-loading-hide"}`,onClick:t=>{e()},children:x.jsxs("div",{className:"rg-graph-loading-message",children:[x.jsx(ne,{iconName:"icon-lianjiezhong",className:"rg-graph-loading-icon"}),"Loading..."]})})})},gn=({nodeSlot:s})=>{W();const{options:o}=q();return o&&x.jsxs("div",{className:"rg-operate",children:[x.jsxs("div",{className:"rg-creating-container",children:[o.creatingNodePlot&&o.showTemplateNode&&x.jsx(ut,{nodeProps:o.newNodeTemplate,nodeSlot:s}),o.creatingSelection&&x.jsx("div",{className:"rg-selection",style:{transform:`translate(${o.selectionView.x}px, ${o.selectionView.y}px)`,width:o.selectionView.width+"px",height:o.selectionView.height+"px"}})]}),x.jsx(hn,{}),x.jsx(fn,{})]})},gt=({direction:s="h",positionH:o="left",positionV:e="bottom",children:t})=>{const n=W();oe();const{options:i}=q(),a=()=>{n==null||n.toggleAutoLayout()},r=async()=>{n&&(n.enableCanvasAnimation(),n.setZoom(100),n.moveToCenter(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300))},l=async d=>{await(n==null?void 0:n.zoom(d))},c=async()=>{await(n==null?void 0:n.fullscreen())};return I.useEffect(()=>{},[]),x.jsxs("div",{className:`rg-toolbar rg-xs-toolbar rg-toolbar-h-${o||i.toolBarPositionH} rg-toolbar-v-${e||i.toolBarPositionV} rg-toolbar-${s||i.toolBarDirection}`,children:[x.jsx("div",{title:"Full Screen",className:"rg-mb-button",style:{marginTop:0},onClick:c,children:x.jsx(ne,{iconName:"icon-quanping"})}),x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>l(20),children:x.jsx(ne,{iconName:"icon-fangda"})}),x.jsx("div",{className:"rg-current-zoom",onClick:r,children:`${Math.round(i.canvasZoom)}%`}),x.jsx("div",{className:"rg-mb-button",style:{marginTop:0},onClick:()=>l(-20),children:x.jsx(ne,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",className:`rg-mb-button ${i.layout.autoLayouting?"rg-mb-button-on":""}`,onClick:a,children:i.layout.autoLayouting?x.jsx(ne,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ne,{iconName:"icon-zidong"})}),t]})},pt=({children:s})=>x.jsx(x.Fragment,{}),je=({children:s})=>x.jsx(x.Fragment,{}),yt=({children:s})=>x.jsx(x.Fragment,{}),mt=({children:s})=>x.jsx(x.Fragment,{}),vt=s=>{const o=W();oe();const e=I.useRef(),[t,n]=I.useState(!1);I.useEffect(()=>{C("<RelationGraph> Dom Mounted!"),o.setDom(e.current),n(!0);const v=L=>{o.onMouseWheel(L)};return e.current.addEventListener("wheel",v,{passive:!1}),()=>{var L;C("<RelationGraph> Dom UnMounted!"),(L=e.current)==null||L.removeEventListener("wheel",v),o.beforeUnmount()}},[]);const{options:i}=q();let a,r;const l=[],c=[],d=[],h=pe.default.Children.toArray(s.children).filter(v=>{if(v&&pe.default.isValidElement(v))if(v.type===Et){const L=v.props.children;if(typeof L=="function")a=L;else throw new Error("RGSlotOnNode children must be a function, e.g. <RGSlotOnNode>{ (node: RGNode) => <div>{node.text}</div> }</RGSlotOnNode>")}else if(v.type===pt){const L=v.props.children;if(typeof L=="function")r=L;else throw new Error("RGSlotOnLine children must be a function, e.g. <RGSlotOnLine>{ (lineConfig: RGGenerateLineConfig) => <RGLineContent lineConfig={lineConfig} /> }</RGSlotOnLine>")}else{if(v.type===je)return l.push(v.props.children),!1;if(v.type===yt)return c.push(v.props.children),!1;if(v.type===mt)return d.push(v.props.children),!1}return!0}),f=l,y=d,u=c.concat(...h);if(a&&s.nodeSlot)throw new Error("You can only provide nodeSlot or RGSlotOnNode, but not both.");if(r&&s.lineSlot)throw new Error("You can only provide lineSlot or RGSlotOnLine, but not both.");const g=a||s.nodeSlot,m=r||s.lineSlot,p=s.nodeExpandButtonSlot;return x.jsx("div",{ref:e,id:`relation-graph-ins-${i==null?void 0:i.instanceId}`,className:["relation-graph",(i==null?void 0:i.creatingLinePlot)&&"rg-creating-line",(i==null?void 0:i.dragEventAction)==="move"?"rg-move-mode":"",i!=null&&i.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",(i==null?void 0:i.enableCanvasTransformAnimation)&&"rg-enable-canvas-animation"].filter(Boolean).join(" "),tabIndex:1,style:{width:"100%",height:i!=null&&i.viewHeight?i==null?void 0:i.viewHeight:"100%",opacity:t?1:0,"--rg-checked-item-bg-color":i==null?void 0:i.checkedItemBackgroundColor,"--rg-background-color":i==null?void 0:i.backgroundColor,"--rg-node-color":i==null?void 0:i.defaultNodeColor,"--rg-node-border-color":i==null?void 0:i.defaultNodeBorderColor,"--rg-node-border-width":(i==null?void 0:i.defaultNodeBorderWidth)+"px","--rg-node-border-radius":(i==null?void 0:i.defaultNodeBorderRadius)+"px","--rg-line-color":i==null?void 0:i.defaultLineColor,"--rg-line-width":(i==null?void 0:i.defaultLineWidth)+"px"},children:i&&x.jsxs(x.Fragment,{children:[i.showToolBar&&x.jsx(gt,{}),x.jsx(cn,{nodeSlot:g,lineSlot:m,canvasPlugSlot:u,canvasPlugAboveSlot:y,nodeExpandButtonSlot:p}),x.jsx(gn,{nodeSlot:g}),x.jsx("div",{className:"rg-graph-plugs",children:x.jsx("div",{className:"rg-view-slot",children:f})})]})})},xt=s=>{const o=W();return I.useEffect(()=>{tt("React"),o.setOptions(s.options);const e=nt(s);C("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated(),s.initialData&&(C("[RelationGraph] apply data"),o.applyInitialData(s.initialData))},[]),I.useEffect(()=>{C("[RelationGraph] update options:",s.options),console.warn("[RelationGraph] update options:",s.options),o.setOptions(s.options),o.dataUpdated()},[s.options]),x.jsx(vt,{...s})};class pn{constructor(o){N(this,"$evCanvasCtx");N(this,"viewScale",1);N(this,"offset",{x:0,y:0});const e=o.getContext("2d");if(!e)throw new Error("\u65E0\u6CD5\u83B7\u53D6 Canvas 2D \u4E0A\u4E0B\u6587");this.$evCanvasCtx=e}setSize(o,e){const t=this.$evCanvasCtx.canvas;t.width=o*window.devicePixelRatio,t.height=e*window.devicePixelRatio,t.style.width=`${o}px`,t.style.height=`${e}px`,this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.applyCurrentViewTransform()}setScale(o){this.viewScale=o,this.applyCurrentViewTransform()}applyCurrentViewTransform(){this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$evCanvasCtx.scale(this.viewScale,this.viewScale)}setViewOffset(o,e){this.offset.x=o/this.viewScale,this.offset.y=e/this.viewScale}beforeDraw(){}evDrawNode4Rect(o,e,t,n,i,a,r=5,l){const c=this.$evCanvasCtx,d=this.offset.x+o,h=this.offset.y+e;let f=Math.max(0,r);t<2*f&&(f=t/2),n<2*f&&(f=n/2),c.beginPath(),c.globalAlpha=a,f===0?c.rect(d,h,t,n):(c.moveTo(d+f,h),c.arcTo(d+t,h,d+t,h+f,f),c.arcTo(d+t,h+n,d+t-f,h+n,f),c.arcTo(d,h+n,d,h+n-f,f),c.arcTo(d,h,d+f,h,f),c.closePath()),c.fillStyle=i,c.fill(),c.globalAlpha=1,c.strokeStyle=l,c.lineWidth=1,c.stroke()}evDrawNode4Circle(o,e,t,n,i,a,r){const l=this.$evCanvasCtx,c=this.offset.x+o+t/2,d=this.offset.y+e+n/2;l.beginPath(),l.globalAlpha=a,l.ellipse(c,d,t/2,n/2,0,0,2*Math.PI),l.fillStyle=i,l.fill(),l.strokeStyle=r,l.lineWidth=1,l.stroke(),l.globalAlpha=1}evDrawLine(o,e,t,n){const i=this.$evCanvasCtx;i.beginPath(),i.globalAlpha=n,this.evDrawSvgPathOnCanvas(i,o),i.strokeStyle=t,i.lineWidth=e*this.viewScale<.5?.5:e,i.stroke(),i.globalAlpha=1}getPointValue(o,e,t){return t?o+parseFloat(e):parseFloat(e)}evDrawSvgPathOnCanvas(o,e){const t=e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!t)return;let n=0,i=0,a=0,r=0,l=0,c=0,d=0,h=0,f="";o.beginPath(),t.forEach(y=>{const u=y.trim(),g=u.charAt(0),p=u.substring(1).trim().split(/[ ,]+/).filter(w=>w!=="").map(parseFloat);let v=0,L=0,_=0,S=0,b=0,O=0,R=0,M=0,k=0,P=0,T=0;switch(g){case"M":n=p[0],i=p[1],a=n,r=i,o.moveTo(n+this.offset.x,i+this.offset.y);for(let w=2;w<p.length;w+=2)n=p[w],i=p[w+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"L":for(let w=0;w<p.length;w+=2)n=p[w],i=p[w+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"l":for(let w=0;w<p.length;w+=2)n+=p[w],i+=p[w+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"H":for(let w=0;w<p.length;w++)n=p[w],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"h":for(let w=0;w<p.length;w++)n+=p[w],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"V":for(let w=0;w<p.length;w++)i=p[w],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"v":for(let w=0;w<p.length;w++)i+=p[w],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"C":for(let w=0;w<p.length;w+=6)_=p[w],S=p[w+1],b=p[w+2],O=p[w+3],v=p[w+4],L=p[w+5],o.bezierCurveTo(_+this.offset.x,S+this.offset.y,b+this.offset.x,O+this.offset.y,v+this.offset.x,L+this.offset.y),n=v,i=L,l=b,c=O;break;case"c":for(let w=0;w<p.length;w+=6)_=n+p[w],S=i+p[w+1],b=n+p[w+2],O=i+p[w+3],v=n+p[w+4],L=i+p[w+5],o.bezierCurveTo(_+this.offset.x,S+this.offset.y,b+this.offset.x,O+this.offset.y,v+this.offset.x,L+this.offset.y),l=b,c=O,n=v,i=L;break;case"S":for(let w=0;w<p.length;w+=4)f.match(/[CS]/i)?(_=2*n-l,S=2*i-c):(_=n,S=i),b=p[w],O=p[w+1],v=p[w+2],L=p[w+3],o.bezierCurveTo(_+this.offset.x,S+this.offset.y,b+this.offset.x,O+this.offset.y,v+this.offset.x,L+this.offset.y),n=v,i=L,l=b,c=O;break;case"s":for(let w=0;w<p.length;w+=4)f.match(/[CS]/i)?(_=2*n-l,S=2*i-c):(_=n,S=i),b=n+p[w],O=i+p[w+1],v=n+p[w+2],L=i+p[w+3],o.bezierCurveTo(_+this.offset.x,S+this.offset.y,b+this.offset.x,O+this.offset.y,v+this.offset.x,L+this.offset.y),l=b,c=O,n=v,i=L;break;case"Q":for(let w=0;w<p.length;w+=4)_=p[w],S=p[w+1],v=p[w+2],L=p[w+3],o.quadraticCurveTo(_+this.offset.x,S+this.offset.y,v+this.offset.x,L+this.offset.y),n=v,i=L,d=_,h=S;break;case"q":for(let w=0;w<p.length;w+=4)_=n+p[w],S=i+p[w+1],v=n+p[w+2],L=i+p[w+3],o.quadraticCurveTo(_+this.offset.x,S+this.offset.y,v+this.offset.x,L+this.offset.y),d=_,h=S,n=v,i=L;break;case"T":for(let w=0;w<p.length;w+=2)f.match(/[QT]/i)?(_=2*n-d,S=2*i-h):(_=n,S=i),v=p[w],L=p[w+1],o.quadraticCurveTo(_+this.offset.x,S+this.offset.y,v+this.offset.x,L+this.offset.y),n=v,i=L,d=_,h=S;break;case"t":for(let w=0;w<p.length;w+=2)f.match(/[QT]/i)?(_=2*n-d,S=2*i-h):(_=n,S=i),v=n+p[w],L=i+p[w+1],o.quadraticCurveTo(_+this.offset.x,S+this.offset.y,v+this.offset.x,L+this.offset.y),d=_,h=S,n=v,i=L;break;case"A":for(let w=0;w<p.length;w+=7)R=p[w],M=p[w+1],k=p[w+2],P=p[w+3],T=p[w+4],v=p[w+5],L=p[w+6],this.drawArc(o,n,i,R,M,k,P,T,v,L),n=v,i=L;break;case"a":for(let w=0;w<p.length;w+=7)R=p[w],M=p[w+1],k=p[w+2],P=p[w+3],T=p[w+4],v=n+p[w+5],L=i+p[w+6],this.drawArc(o,n,i,R,M,k,P,T,v,L),n=v,i=L;break;case"Z":case"z":o.closePath(),n=a,i=r;break;default:console.warn(`\u672A\u652F\u6301\u7684SVG\u547D\u4EE4\u5B57\u7B26: ${g}`)}g.match(/[CSQT]/i)?f=g:f=""})}drawArc(o,e,t,n,i,a,r,l,c,d){if(n=Math.abs(n),i=Math.abs(i),n===0||i===0){o.lineTo(c+this.offset.x,d+this.offset.y);return}const h=a%360*Math.PI/180,f=Math.sin(h),y=Math.cos(h),u=y*(e-c)/2+f*(t-d)/2,g=-f*(e-c)/2+y*(t-d)/2,m=u*u/(n*n)+g*g/(i*i);m>1&&(n*=Math.sqrt(m),i*=Math.sqrt(m));let p=(r===l?-1:1)*Math.sqrt(Math.max(0,(n*n*i*i-n*n*g*g-i*i*u*u)/(n*n*g*g+i*i*u*u)));isNaN(p)&&(p=0);const v=p*n*g/i,L=p*-i*u/n,_=y*v-f*L+(e+c)/2,S=f*v+y*L+(t+d)/2,b=(u-v)/n,O=(g-L)/i,R=(-u-v)/n,M=(-g-L)/i;let k=Math.atan2(O,b),P=Math.atan2(O*R-b*M,b*R+O*M);l===0&&P>0?P-=2*Math.PI:l===1&&P<0&&(P+=2*Math.PI);const T=k+P;o.ellipse?o.ellipse(_+this.offset.x,S+this.offset.y,n,i,h,k,T,l===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),o.lineTo(c+this.offset.x,d+this.offset.y))}}let me={x:0,y:0};const ve={x:0,y:0},le={x:0,y:0};let De,Ae;const Ve=s=>{const o={clientX:0,clientY:0};if(ce(s)){const e=s.touches||s.targetTouches;if(!e)throw new Error("error targetTouches");o.clientX=e[0].clientX,o.clientY=e[0].clientY}else o.clientX=s.clientX,o.clientY=s.clientY;return o},J={startDrag(s,o,e,t){t?De=(n,i,a)=>{const r=n-le.x,l=i-le.y;t(r,l,ve,le,a)}:De=(n,i)=>{me.x=ve.x+(n-le.x),me.y=ve.y+(i-le.y)},Ae=e,me=o,ve.x=me.x,ve.y=me.y;try{const n=Ve(s);le.x=n.clientX,le.y=n.clientY,ce(s)?(document.body.addEventListener("touchmove",J.onNodeMove),document.body.addEventListener("touchend",J.onNodeDragend),document.body.addEventListener("mousemove",J.onNodeMove),document.body.addEventListener("mouseup",J.onNodeDragend),s.preventDefault()):(document.body.addEventListener("mousemove",J.onNodeMove),document.body.addEventListener("mouseup",J.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(s){const o=Ve(s);De(o.clientX,o.clientY,s)},onNodeDragend(s){if(ce(s)?(document.body.removeEventListener("touchmove",J.onNodeMove),document.body.removeEventListener("touchend",J.onNodeDragend),document.body.removeEventListener("mousemove",J.onNodeMove),document.body.removeEventListener("mouseup",J.onNodeDragend)):(document.body.removeEventListener("mousemove",J.onNodeMove),document.body.removeEventListener("mouseup",J.onNodeDragend)),Ae){const o=Ve(s),e=o.clientX,t=o.clientY,n=e-le.x,i=t-le.y;Ae(n,i,s)}}};function yn(s,o,e,t,n,i,a,r,l){const c=n-s,d=i-o,h=Math.sqrt(c*c+d*d);if(h===0)return{x:s,y:o};const f=l*d/h,y=-(l*c)/h,u=s+f,g=o+y,m=s-e/2,p=s+e/2,v=o-t/2,L=o+t/2;let _=[];if(c!==0){let O=(m-u)/c,R=g+O*d;R>=v&&R<=L&&_.push({x:m,y:R});let M=(p-u)/c,k=g+M*d;k>=v&&k<=L&&_.push({x:p,y:k})}if(d!==0){let O=(v-g)/d,R=u+O*c;R>=m&&R<=p&&_.push({x:R,y:v});let M=(L-g)/d,k=u+M*c;k>=m&&k<=p&&_.push({x:k,y:L})}if(_.length===0&&c===0&&d===0)return{x:u,y:g};let S=null,b=1/0;return _.forEach(O=>{const R=Math.sqrt((O.x-n)**2+(O.y-i)**2);R<b&&(b=R,S=O)}),S}const Z={getRectPoint(s,o,e,t,n,i,a,r,l=!1,c=1,d=0,h=14,f=!1){const y=s+n/2,u=o+i/2,g=e+a/2,m=t+r/2;if(c>1){const M=Math.min(h,n,i),k=-M/2,P=M/(c-1),T=l&&f||!l&&!f?k*-1-d*P:k+d*P,w=yn(y,u,n,i,g,m,a,r,T);if(w)return w}const p=y<g?1:-1,v=u<m?1:-1;if(m===u)return{x:y+p*n/2,y:u};const L=Math.abs((g-y)/(m-u)),_=n/i;let S=0,b=0;L<_?(S=p*i/2*L,b=v*i/2):(S=p*n/2,b=v*n/2/L);const O=y+S,R=u+b;return{x:O,y:R}},getRectPointBasic(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2;let f=h===c?0:(d-l)/(h-c);f===0&&h===c&&d===l?f=1:f===0&&(f=(d-l)/(h-c+(h>c?-1:1)*1e-4));const y=n/i;let u=0,g=0,m="1";return Math.abs(f)<y?(m="2",c<=h?(g=i/2,u=g*f):(g=-i/2,u=g*f)):(m="3",l<=d?(u=n/2,g=f===0&&d===l?0:u/f):(u=-n/2,g=f===0&&d===l?0:u/f)),{x:l+u,y:c+g,_case:m}},getRectJoinPoint(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l}=s,c=o+i/2,d=e+a/2,h=t+r/2,f=n+l/2,y=Math.atan2(f-d,h-c)*180/Math.PI,u=y<0?y+360:y;return u>45&&u<=135?{x:o+i,y:e+a/2}:u>135&&u<=225?{x:o+i/2,y:e+a}:u>225&&u<=315?{x:o,y:e+a/2}:{x:o+i/2,y:e}},getRectHJoinPoint(s){const{from_x:o,from_y:e,to_x:t,f_W:n,f_H:i,t_W:a}=s,r=i/2;return o+n<t?{x:o+n,y:e+r}:{x:o,y:e+r}},getRectLeftJoinPoint(s){const{from_x:o,from_y:e,f_H:t}=s;return{x:o,y:e+t/2}},getRectRightJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t,y:e+n/2}},getRectTopJoinPoint(s){const{from_x:o,from_y:e,f_W:t}=s;return{x:o+t/2,y:e}},getRectBottomJoinPoint(s){const{from_x:o,from_y:e,f_W:t,f_H:n}=s;return{x:o+t/2,y:e+n}},getRectHorizontalLineJoinPoint(s){return this.getRectVJoinPoint(s)},getRectVerticalLineLineJoinPoint(s){return this.getRectHJoinPoint(s)},getRectVJoinPoint(s){const{from_x:o,from_y:e,to_y:t,f_W:n,f_H:i,t_H:a}=s,r=n/2;return e+i<t?{y:e+i,x:o+r}:{y:e,x:o+r}},getBorderPoint(s,o,e,t,n,i,a,r,l){return l===0?this.getCirclePoint(s,o,e,t,n,i,a,r):this.getRectPoint(s,o,e,t,n,i,a,r)},getBorderPoint4MultiLine(s){const{from_x:o,from_y:e,to_x:t,to_y:n,f_W:i,f_H:a,t_W:r,t_H:l,nodeShape:c,isReverse:d=!1,isEndPoint:h,totalLinesBetweenNodes:f=1,currentLineIndex:y=0,lineDistance:u=50}=s;return c===0?this.getCirclePoint4MultiLine(o,e,t,n,i,a,r,l,d,f,y,u,h):this.getRectPoint(o,e,t,n,i,a,r,l,d,f,y,u,h)},getCirclePoint(s,o,e,t,n,i,a,r){const l=e+a/2,c=t+r/2,d=s+n/2,h=o+i/2,f=l-d;if(f===0)return{x:d,y:h-i/2*(c<h?1:-1)};const u=(c-h)/f,g=Math.sqrt(1/(1/(n/2)**2+u**2/(i/2)**2))*(l<d?1:-1),m=u*g;return{x:d-g,y:h-m}},getCirclePoint4MultiLine(s,o,e,t,n,i,a,r,l,c,d,h,f){let y=e+a/2;const u=t+r/2;let g=s+n/2;const m=o+i/2;let p=y-g;p>-1&&p<1&&(y=y-.5,g=g+.5,p=-1);let L=0;if(c>1){const T=Math.min(h,n,i),w=-T/2,D=T/(c-1);L=l&&f||!l&&!f?w*-1-d*D:w+d*D}const _=u-m,S=Math.sqrt(p**2+_**2)*L/p,b=_/p,O=n/2,R=i/2,M=g<y?-1:1,k=(-1*O**2*b*S+O*R*Math.sqrt(Math.abs(R**2+b**2*O**2-S**2))/M)/(R**2+O**2*b**2),P=b*k+S;return{x:g-k,y:m-P}},getCirclePointBasic(s,o,e,t,n,i,a,r,l){const c=s+n/2,d=o+i/2,h=e+a/2,f=t+r/2,y=h-c,u=f-d,g=Math.sqrt(y*y+u*u),m=g-l,p=m*y/g*-1,v=m*u/g*-1;return{x:h+p,y:f+v}},getCirclePointPlus(s,o,e,t,n,i,a,r){const l=s+n/2,c=o+i/2,d=e+a/2,h=t+r/2,f=d-l,y=h-c,u=Math.sqrt(f*f+y*y),g=(u-n/2)*f/u*-1,m=(u-i/2)*y/u*-1;return{x:d+g,y:h+m}},getOvalPoint(s,o,e,t,n,i=180){const a=t*(360/n),r=(180-i+a)*Math.PI/180;return{x:s+e*Math.sin(r),y:o+e*Math.cos(r)*-1}},getRotatedPoint(s,o,e,t,n){const i=n*Math.PI/180,a=Math.cos(i),r=Math.sin(i),l=(s-e)*a-(o-t)*r+e,c=(s-e)*r+(o-t)*a+t;return{x:l,y:c}},getFlippedX(s,o){return o-(s-o)},getFlippedY(s,o){return o-(s-o)},getAngleType(s,o){if(s>=0&&o>=0)return 1;if(s<0&&o>=0)return 2;if(s<0&&o<0)return 3;if(s>=0&&o<0)return 4},getTextAngle(s,o,e,t){let n=Math.atan2(t-o,e-s)*180/Math.PI;return n<0&&(n+=360),n>90&&n<=270&&(n+=180),n>=360&&(n-=360),Math.round(n)}},ge=(s,o,e,t)=>{const n=s-e,i=o-t;return Math.sqrt(n**2+i**2)};function qe(s,o,e,t,n=0,i=0){let a=1,r=n,l=i,c=0;for(let d of e){const h=d.width,f=d.height;f>c&&(c=f),t(d,r,l),r+=h+o,a>s?(l+=c+o,a=1,r=0,c=0):a++}}class mn{constructor(o){N(this,"graphInstance");N(this,"initialized",!1);this.graphInstance=o}analyzeNetwork(o,e,t=!1,n=!1){this.initialized||(this.initialized=!0),o.forEach(u=>{u.lot||(u.lot={}),u.lot.eached=!1,u.lot.index_of_level=0,u.lot.index_of_p_childs=0,u.lot.index_of_parent=0,u.lot.strength=0,u.lot.strengthWithChilds_from=0,u.lot.strengthWithChilds=0,u.lot.childrenSizeVisible=0,u.lot.childrenSize=0,u.lot.childs=[],u.lot.subling=void 0,u.lot.parent=void 0}),e.lot.parent=void 0;const i=this.markNodeParent(e);C("groupNodes:marked-tree-node:",i.networkNodes.length);const a=[],r={direct:1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},l={direct:-1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},c=[e];this.expandLevelNodesWithDirection(a,c,0,t,n,r,l),this.calcStrengthWithChildsValue(a),this.calcStrengthFromValue(e,1),t&&this.calcStrengthFromValue(e,-1);const d=a.filter(u=>u.lot.level===1),h=d.length===0?1:d.map(u=>u.lot.strengthWithChilds).reduce((u,g)=>u+g,0);r.max_strength=h;const f=a.filter(u=>u.lot.level>=0);C("groupNodes:tree-nodes:",f.length,r);const y={tree:{networkNodes:f,analyticResult:r},reverseTree:{networkNodes:[],analyticResult:l}};if(t){const u=a.filter(p=>p.lot.level===-1),g=u.length===0?1:u.map(p=>p.lot.strengthWithChilds).reduce((p,v)=>p+v,0);l.max_strength=g;const m=a.filter(p=>p.lot.level<=0);C("groupNodes:reverse-tree-nodes:",m.length,l),y.reverseTree.networkNodes=m}for(const u of o)this.graphInstance.updateNode(u,{rgChildrenSize:u.lot.childrenSize});return y}markNodeParent(o){let e=[];return this._markNodeParent(e,[o],0),{networkNodes:e}}_markNodeParent(o,e,t){t===0&&e.forEach(i=>{i.lot.parent=void 0});const n=[];for(const i of e){o.includes(i)||o.push(i);for(const a of this.graphInstance.getNodeRelatedNodes(i))o.includes(a)||(o.push(a),a.lot.parent=i,n.push(a))}n.length>0&&this._markNodeParent(o,n,t+1)}expandLevelNodesWithDirection(o,e,t,n,i,a,r){const l=n&&t<0?r:a;C(`bothWay:${n}(deep:${i}) level ${t} size: ${e.length}`,l.direct),e.length>l.max_length&&(l.max_length=e.length),t>l.max_deep&&(l.max_deep=t),t<l.min_deep&&(l.min_deep=t),l.levels.has(t)||l.levels.set(t,{level:t,all_size:e.length,all_strength:0});const c=l.levels.get(t);e.forEach(u=>{u.lot.eached=!0,u.lot.subling=c,u.lot.level=t,o.push(u)});const d=[],h=[];let f=1,y=0;e.forEach(u=>{let g=[],m=[];n?i||t===0?(g=this.graphInstance.getNodeIncomingNodes(u),m=this.graphInstance.getNodeOutgoingNodes(u)):(t<0&&(f=-1),m=this.graphInstance.getNodeRelatedNodes(u)):m=this.graphInstance.getNodeRelatedNodes(u),this._appendNodeChildrenToNextLevelNodes(u,m,h,c,n,1),this._appendNodeChildrenToNextLevelNodes(u,g,d,c,n,-1),u.lot.index_of_level=y,y++}),c.all_strength>l.max_strength&&(l.max_strength=c.all_strength),h.length>0&&this.expandLevelNodesWithDirection(o,h,t+f,n,i,a,r),d.length>0&&this.expandLevelNodesWithDirection(o,d,t-1,n,i,a,r)}_appendNodeChildrenToNextLevelNodes(o,e,t,n,i,a){let r=0,l=0,c=0;if(e.forEach(d=>{d.lot||(d.lot={eached:!1,childs:[]}),d.lot.eached||(l++,d.lot.parent=o,z.isVisibleNode(d)&&(d.lot.eached=!0,d.lot.index_of_parent=c++,t.push(d),r++),o.lot.childs.push(d))}),a===1){const d=r>0?r:1;o.lot.strength=d,n.all_strength+=d,o.lot.strength_of_level=n.all_strength,o.lot.childrenSizeVisible=r,o.lot.childrenSize=l}}calcStrengthWithChildsValue(o){o.forEach(e=>{e.lot.childrenSizeVisible>0&&(e.lot.strengthWithChilds=0)}),o.forEach(e=>{e.lot.childrenSizeVisible===0&&(e.lot.strengthWithChilds=1,this.conductStrengthToParents(e))})}calcStrengthFromValue(o,e=1){this._calcStrengthFromValue([o],0,e===-1?-1:1)}_calcStrengthFromValue(o,e,t=1){const n=[];let i=0;o.forEach(a=>{(a.lot.level===0||t===(a.lot.level<0?-1:1))&&(a.lot.childs.forEach(r=>{n.push(r)}),a.lot.parent&&i<a.lot.parent.lot.strengthWithChilds_from&&(i=a.lot.parent.lot.strengthWithChilds_from),a.lot.strengthWithChilds_from=i,i+=a.lot.strengthWithChilds)}),n.length>0&&this._calcStrengthFromValue(n,e+(t<0?-1:1),t)}conductStrengthToParents(o){o.lot.parent&&Math.abs(o.lot.level)-1===Math.abs(o.lot.parent.lot.level)&&(o.lot.parent.lot.strengthWithChilds+=1,this.conductStrengthToParents(o.lot.parent))}}class ue{constructor(o,e,t){N(this,"graphOptions");N(this,"layoutOptions");N(this,"graphInstance");N(this,"networkAnalyzer");N(this,"allNodes",[]);N(this,"isMainLayouer",!0);N(this,"requireLinks",!1);N(this,"allLinks",[]);N(this,"rootNode");this.layoutOptions=o,this.graphOptions=e,this.graphInstance=t,this.networkAnalyzer=new mn(t)}setLinks(o){C("setLinks:",o.length),this.allLinks=o}generateCalcNodes(o){const e=[],t=new Map;for(const n of o){const i={rgNode:n,x:n.x,y:n.y,width:n.el_W,height:n.el_H};e.push(i),t.set(n.id,i)}return{calcNodes:e,calcNodeMap:t}}generateLevels(o){const e=[],t=new Map;for(const n of o){if(!n.lot||typeof n.lot.level!="number")continue;const i=n.lot.level;e.includes(i)||(e.push(i),t.set(i,[])),t.get(i).push(n)}return e.sort((n,i)=>n-i),{levels:e,levelNodesMap:t}}adjustNodePositions(o,e,t){if(!o||o.length===0)return[];for(let n=1;n<o.length;n++){const i=o[n],a=o[n-1];switch(e){case"right":i.x<a.x+a.width+t&&(i.x=a.x+a.width+t);break;case"left":i.x+i.width>a.x-t&&(i.x=a.x-i.width-t);break;case"bottom":i.y<a.y+a.height+t&&(i.y=a.y+a.height+t);break;case"top":i.y+i.height>a.y-t&&(i.y=a.y-i.height-t);break}}return o}getReverseAlignItems(o){return vn[o]}updateNodePosition(o,e,t){this.graphInstance.updateNode(typeof o=="string"?o:o.id,{x:e,y:t})}layoutEnd(){this.graphInstance&&(this.graphInstance.dataProvider.updateShouldRenderGraphData(),this.graphInstance._dataUpdated())}}const vn={start:"end",end:"start",center:"center"};class Se extends ue{constructor(e,t,n){super(e,t,n);N(this,"layoutOptions");N(this,"fastStart",!1);N(this,"skipInitLayout",!1);N(this,"maxLayoutTimes",300);N(this,"byNode",!0);N(this,"byLine",!0);N(this,"lockX",!1);N(this,"lockY",!1);N(this,"force_node_repulsion",1);N(this,"force_line_elastic",1);N(this,"stopWhenBalanced",!1);N(this,"instanceId","");N(this,"calcNodes",[]);N(this,"_graphEventHandler");N(this,"layoutTimes",0);N(this,"prev10",[]);N(this,"visibleNodes",[]);N(this,"_onFinishCallback");N(this,"_onTickCallback");N(this,"calcNodeMap",new WeakMap);N(this,"forCalcNodes",[]);N(this,"recentGraphVelocity",[]);N(this,"graphVelocityBalancedValue",.1);N(this,"prevLogTime",0);N(this,"animationFrameTimer",0);N(this,"prevNodeLevel1Index",0);N(this,"prevNodeLevel2Index",0);N(this,"stoped",!1);N(this,"maxTractionLength",300);N(this,"zeroForceLength",30);N(this,"maxRepulsionDistance",400);N(this,"nodeCollisionRadius",30);N(this,"maxMoveSpeed",100);N(this,"n2nMaxForce",50);this.layoutOptions=e,this.layoutOptions.fastStart!==void 0&&(this.fastStart=this.layoutOptions.fastStart),this.layoutOptions.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=this.layoutOptions.maxLayoutTimes),this.layoutOptions.byNode!==void 0&&(this.byNode=this.layoutOptions.byNode),this.layoutOptions.byLine!==void 0&&(this.byLine=this.layoutOptions.byLine),this.layoutOptions.force_node_repulsion!==void 0&&(this.force_node_repulsion=this.layoutOptions.force_node_repulsion),this.layoutOptions.force_line_elastic!==void 0&&(this.force_line_elastic=this.layoutOptions.force_line_elastic),this.layoutOptions.force_x_coefficient===void 0&&(this.layoutOptions.force_x_coefficient=1),this.layoutOptions.force_y_coefficient===void 0&&(this.layoutOptions.force_y_coefficient=1),this.layoutOptions.disableLiveChanges===void 0&&(this.layoutOptions.disableLiveChanges=!1),this.layoutOptions.stopWhenBalanced&&(this.stopWhenBalanced=!0),this.layoutOptions.skipInitLayout!==void 0&&(this.skipInitLayout=this.layoutOptions.skipInitLayout),this.layoutOptions.maxTractionLength!==void 0&&(this.maxTractionLength=this.layoutOptions.maxTractionLength),this.layoutOptions.zeroForceLength!==void 0&&(this.zeroForceLength=this.layoutOptions.zeroForceLength),this.layoutOptions.maxRepulsionDistance!==void 0&&(this.maxRepulsionDistance=this.layoutOptions.maxRepulsionDistance),this.layoutOptions.nodeCollisionRadius!==void 0&&(this.nodeCollisionRadius=this.layoutOptions.nodeCollisionRadius),this.requireLinks=!0,this.instanceId=n?n.generateNewUUID(5):"error-id"}placeNodes(e,t){if(C("RGForceLayout["+this.instanceId+"].placeNodes"),this.calcNodes=e,this.allNodes.length===0&&(this.allNodes=e),this.rootNode=t,this.fastStart)C("RGForceLayout["+this.instanceId+"] fastStart"),this.calcNodes.forEach(n=>{if(n.fixed===!0)return;let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=Math.floor(Math.random()*200)-100,r=!0),(Number.isNaN(a)||a===void 0)&&(a=Math.floor(Math.random()*200)-100,r=!0),i===0&&a===0&&(i=Math.floor(Math.random()*200)-100,a=Math.floor(Math.random()*200)-100,r=!0),r&&this.updateNodePosition(n,i,a)});else if(!this.skipInitLayout){if(C("!!!initNodesPosition....."),t){C("layout by root:",t),(Number.isNaN(t.x)||t.x===void 0)&&this.updateNodePosition(t,0,0);const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,t),{networkNodes:i,analyticResult:a}=n;t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r=z.getNodeLotXY({alignItemsX:"center",alignItemsY:"center"},t);t.lot.x=r.x,t.lot.y=r.y,this.placeRelativePosition(t,i,a,1,[]),C("!!!initNodesPosition fixedRootNode:2:",t.x,t.y),i.forEach(l=>{if(l.fixed===!0||!l.rgCalcedVisibility||l===t)return;const c=l.lot.x-z.getNodeWidth(l)/2,d=l.lot.y-z.getNodeHeight(l)/2;this.updateNodePosition(l,c,d)})}}this.allNodes.forEach(n=>{let i=n.x,a=n.y,r=!1;(Number.isNaN(i)||i===void 0)&&(i=0,r=!0),(Number.isNaN(a)||a===void 0)&&(a=0,r=!0),r&&this.updateNodePosition(n,i,a)}),C("["+this.instanceId+"]Start Auto Layout....."),this.start()}getLevelR(e,t){if(e.length===0)return;let n=0;for(let i=0;i<t;i++)n+=e[i]||e[e.length-1];return n}placeRelativePosition(e,t,n,i,a){const r=Math.min(this.graphOptions.viewSize.height,this.graphOptions.viewSize.width)*.4;let l=Math.min(Math.max(r,150),400)*i;C("analyticResult:",this.layoutOptions,n,r,l,i,a);const c={x:e.lot.x,y:e.lot.y},d=t.filter(h=>h.lot.level===1);this.placeNodesInFanRegion(d,0,360,c,1,n.max_strength,a,1,i)}placeNodesInFanRegion(e,t,n,i,a,r,l,c,d=1){var g,m;console.warn("[center]levelNodes:",a,e.length,r);let h=t;const f=n-t,y=200,u=this.getLevelR(l,a)||a*y*d;for(const p of e){const v=((g=p.lot)==null?void 0:g.strengthWithChilds)/r,L=i.x+u,_=i.y,S=v*f,b=h+S/2,O=Z.getRotatedPoint(L,_,i.x,i.y,b);p.lot.x=O.x,p.lot.y=O.y,p.lot.childs&&p.lot.childs.length>0&&this.placeNodesInFanRegion(p.lot.childs,h,h+S,i,a+1,(m=p.lot)==null?void 0:m.strengthWithChilds,l,c+1),h+=S}}graphEventHandle(e,...t){if(e===A.onNodeDragStart){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!0)}else if(e===A.onNodeDragging){const n=t[0],i=t[1],a=t[2],r=this.calcNodeMap.get(n);console.log("[force]onNodeDragging:",n.id,r),r&&(r.x=i,r.y=a)}else if(e===A.onNodeDragEnd){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!1)}}connectToGraphInstance(){this._graphEventHandler=this.graphEventHandle.bind(this),this.graphInstance&&this.graphInstance.addEventHandler(this._graphEventHandler)}disConnectToGraphInstance(){this.graphInstance&&this.graphInstance.removeEventHandler(this._graphEventHandler)}updateVisibleNodes(e){this.visibleNodes=[],e&&(this.allNodes=e),this.allNodes.forEach(t=>{t.lot||(C("node miss lot:",t.text),t.lot={x:t.x,y:t.y,childs:[]}),this.visibleNodes.push(t)}),this.resetCalcNodes(),C("visibleNodes:",this.visibleNodes.length)}viewUpdate(){this._onTickCallback&&this._onTickCallback(),this.graphInstance&&this.graphInstance.forceLayoutTickCallback()}autoLayout(e=!1){if(this.updateVisibleNodes(),this.isMainLayouer){const t=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...t.layout,autoLayouting:!0}})}this.doForceLayout(0)}onFinish(e){this._onFinishCallback=e}onTick(e){this._onTickCallback=e}applyFBuffToNodes(){for(const e of this.forCalcNodes)this.applyToNodePosition(e)}applyPositionToNodes(){this.visibleNodes.forEach(e=>{if(e.fixed)return;const t=this.calcNodeMap.get(e);t&&(e.x=t.x,e.y=t.y)}),this.viewUpdate()}layoutFinished(){if(cancelAnimationFrame(this.animationFrameTimer),this.isMainLayouer){const e=this.graphInstance.dataProvider.getOptions();this.graphInstance.dataProvider.updateOptions({layout:{...e.layout,autoLayouting:!1}})}C("Force Layout["+this.instanceId+"] finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(e){console.error(e)}}resetCalcNodes(){C("resetCalcNodes:",this.visibleNodes.length),this.forCalcNodes=[],this.calcNodeMap=new WeakMap,this.visibleNodes.forEach(e=>{const t={rgNode:e,Fx:0,Fy:0,x:e.x,y:e.y,dragging:!1,force_weight:e.force_weight||1,forceCenterOffset_X:(e.width||e.el_W||60)/2,forceCenterOffset_Y:(e.height||e.el_H||60)/2,fixed:e.fixed||!1};this.forCalcNodes.push(t),this.calcNodeMap.set(e,t)})}start(){this.stoped&&this.layoutTimes===0||(this.stoped=!1,this.layoutTimes=0,this.updateVisibleNodes(),this.connectToGraphInstance(),this.autoLayout(!0))}doForceLayout(e){if(this.graphInstance.viewComponentUnmounted){C("["+this.instanceId+"]stop layout:viewComponentUnmounted"),this.layoutFinished();return}let t="0";e>0?(this.prev10.length>=10&&(this.prev10.splice(0,1),t=(1e3/((this.prev10[this.prev10.length-1]-this.prev10[0])/10)).toFixed(1)),this.prev10.push(e)):this.visibleNodes.length===0&&this.updateVisibleNodes(),this.layoutTimes++,this.calcNodesPosition(),this.applyFBuffToNodes(),this.layoutOptions.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),this.layoutTimes<=this.maxLayoutTimes?(Date.now()-this.prevLogTime>3e3&&(C("Force Layout["+this.instanceId+"] Is Working...layoutTimes:",this.layoutTimes,"of",this.maxLayoutTimes,t,"Hz",this.visibleNodes.length),this.prevLogTime=Date.now()),this.animationFrameTimer=requestAnimationFrame(this.doForceLayout.bind(this))):this.layoutFinished()}calcNodesPosition(){if(this.byNode)for(let e=this.prevNodeLevel1Index;e<this.forCalcNodes.length;e++){const t=this.forCalcNodes[e];if(!t.dragging&&!t.fixed){for(let n=this.prevNodeLevel2Index;n<this.forCalcNodes.length;n++)if(e!==n){const i=this.forCalcNodes[n];if(i.dragging)continue;this.addGravityByNode(t,i)}}}if(this.byLine){if(this.allLinks&&this.allLinks.length>0){for(const e of this.allLinks)if(!e.line.forDisplayOnly){let t=e.line.force_elastic===void 0?1:e.line.force_elastic;if(this.visibleNodes.includes(e.fromNode)&&this.visibleNodes.includes(e.toNode)){const n=this.calcNodeMap.get(e.fromNode),i=this.calcNodeMap.get(e.toNode);this.addElasticByLine(n,i,t)}}}else for(const e of this.visibleNodes)if(e.lot&&e.lot.parent){const t=this.calcNodeMap.get(e.lot.parent),n=this.calcNodeMap.get(e);this.addElasticByLine(t,n,1)}}return!0}stop(){if(this.stoped=!0,this.layoutTimes===0)return;const e=this.graphInstance.dataProvider.getOptions();cancelAnimationFrame(this.animationFrameTimer),C("[RGForceLayout]["+this.instanceId+"]stop:",e.layout.autoLayouting,this.layoutTimes),this.layoutTimes=Number.MAX_VALUE,this.layoutFinished()}addElasticByLine(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;let c=Math.sqrt((a-l)**2+(i-r)**2);if(c<this.zeroForceLength)return;c>this.maxTractionLength&&(c=this.maxTractionLength);const d=(c-this.zeroForceLength)*.05*this.force_line_elastic*n,h=d,f=d,y=(i-r)/c,u=(a-l)/c;this.addFtoNode(e,y*h*-1,u*h*-1),this.addFtoNode(t,y*f,u*f)}addGravityByNode(e,t,n=1){const i=e.x,a=e.y,r=t.x,l=t.y;if(n===1&&(Math.abs(i-r)>this.maxRepulsionDistance||Math.abs(a-l)>this.maxRepulsionDistance))return;const c=Math.sqrt((a-l)**2+(i-r)**2);if(n===1&&c>this.maxRepulsionDistance)return;let d=(this.maxRepulsionDistance-c)*.05*this.force_node_repulsion*n;c<this.nodeCollisionRadius&&(d=d*2);const h=(i-r)/c,f=(a-l)/c;this.addFtoNode(e,h*d,f*d)}addFtoNode(e,t,n){if(e.fixed||e.dragging||Number.isNaN(t)||Number.isNaN(n))return;t>this.n2nMaxForce&&(t=this.n2nMaxForce),n>this.n2nMaxForce&&(n=this.n2nMaxForce),t<-this.n2nMaxForce&&(t=-this.n2nMaxForce),n<-this.n2nMaxForce&&(n=-this.n2nMaxForce);const i=e.force_weight||1;this.lockX||(e.Fx+=t*(1/i)),this.lockY||(e.Fy+=n*(1/i))}applyToNodePosition(e){if(e.fixed)return 0;if(e.dragging){const i=e.rgNode;return this.updateNodePosition(i,e.x,e.y),0}if(this.calcNodes!==this.allNodes&&!this.calcNodes.includes(e.rgNode))return 0;let t=e.Fx,n=e.Fy;if(t>this.maxMoveSpeed&&(t=this.maxMoveSpeed),n>this.maxMoveSpeed&&(n=this.maxMoveSpeed),t<-this.maxMoveSpeed&&(t=-this.maxMoveSpeed),n<-this.maxMoveSpeed&&(n=-this.maxMoveSpeed),e.x=e.x+t*this.layoutOptions.force_x_coefficient,e.y=e.y+n*this.layoutOptions.force_y_coefficient,!this.layoutOptions.disableLiveChanges){const i=e.rgNode;this.updateNodePosition(i,e.x,e.y)}e.Fx=0,e.Fy=0}}class Ct extends ue{constructor(e,t,n){super(e,t,n);N(this,"enableGatherNodes",!1);N(this,"layoutOptions");this.layoutOptions=e,C("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;console.log("this.layoutOptions.alignItemsX:1:",this.layoutOptions.alignItemsX),i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps or treeNodeGapH,treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes,this.layoutOptions.rotate||(this.layoutOptions.rotate=0)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),C("RGTreeLayout:placeNodes"),t)C("layout by root:",t);else{console.error("root is null");return}C("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=z.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y;const r=e;if(C("groupNodes:2:",r.length,r.map(d=>d.text).join(",")),this.layoutOptions.simpleTree===!0){const{tree:d}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!1);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult)}else{const{tree:d,reverseTree:h}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!0);this.placeNodesPosition(this.rootNode,d.networkNodes,d.analyticResult),this.placeNodesPosition(this.rootNode,h.networkNodes,h.analyticResult)}const l=this.layoutOptions.rotate||0;console.log("rotate:",l);const c={x:t.x,y:t.y};this.allNodes.forEach(d=>{if(d.fixed!==!0&&!!z.isVisibleNode(d)&&(Number.isNaN(d.lot.x)&&(C("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(C("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==t)){if(l){const u=Z.getRotatedPoint(d.lot.x,d.lot.y,c.x,c.y,l);d.lot.x=u.x,d.lot.y=u.y}const h=d.lot.level<0?i:n,f=z.getNodeXByLotX(h,d),y=z.getNodeYByLotY(h,d);this.updateNodePosition(d,f,y)}}),C("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t,n){this.placeRelativePosition(e,t,n)}placeRelativePosition(e,t,n){const i=this.layoutOptions.layoutExpansionDirection,{levels:a,levelNodesMap:r}=this.generateLevels(t),l=n.max_strength;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20,h=new Map;for(const m of a){const p=r.get(m);h.set(m,Math.max(...p.map(v=>v.el_H)))}let f=0,y=0;for(const m of t){const p=m.el_W;f+=p,y++}const g=f/y+c;t.forEach(m=>{m.fixed!==!0&&m!==e&&(this.layoutOptions.from==="bottom"?m.lot.y=e.lot.y-this.getLevelDistance(m.lot.level,h,d+10):m.lot.y=e.lot.y+this.getLevelDistance(m.lot.level,h,d+10))}),t.forEach(m=>{m.fixed!==!0&&m.lot.level!==0&&(i==="start"?m.lot.x=e.lot.x-g*m.lot.strengthWithChilds_from:i==="end"?m.lot.x=e.lot.x+g*m.lot.strengthWithChilds_from:m.lot.x=e.lot.x+g*(l/-2+m.lot.strengthWithChilds_from+m.lot.strengthWithChilds/2))}),this.applyNodesGap(t,"v"),this.gatherNodes(t,"v",g)}else{const c=this.layoutOptions.treeNodeGapH||20,d=this.layoutOptions.treeNodeGapV||20;console.log("levelNodesMap:",r);const h=new Map;for(const m of a){const p=r.get(m);h.set(m,Math.max(...p.map(v=>v.el_W||v.width)))}let f=0,y=0;for(const m of t){const p=m.el_H;f+=p,y++}if(y===0)return;const g=f/y+d;t.forEach(m=>{m.fixed!==!0&&m!==e&&(this.layoutOptions.from==="right"?m.lot.x=e.lot.x-this.getLevelDistance(m.lot.level,h,c+50):m.lot.x=e.lot.x+this.getLevelDistance(m.lot.level,h,c+50))}),t.forEach(m=>{m.fixed!==!0&&m.lot.level!==0&&(i==="start"?m.lot.y=e.lot.y-g*m.lot.strengthWithChilds_from:i==="end"?m.lot.y=e.lot.y+g*m.lot.strengthWithChilds_from:m.lot.y=e.lot.y+g*(l/-2+m.lot.strengthWithChilds_from+m.lot.strengthWithChilds/2))}),console.log("levelMaxWidthMap:",e.id,h),this.applyNodesGap(t,"h"),this.gatherNodes(t,"h",g)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}applyNodesGap(e,t){if(this.layoutOptions.ignoreNodeSize)return;const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},a=this.layoutOptions.layoutExpansionDirection,{levels:r,levelNodesMap:l}=this.generateLevels(e),c=new Map;for(const f of r){const y=l.get(f);c.set(f,Math.max(...y.map(u=>u.el_W)))}const{calcNodes:d,calcNodeMap:h}=this.generateCalcNodes(e);d.forEach(f=>{const y=f.rgNode.lot.level<0?i:n;f.x=z.getNodeXByLotX(y,f.rgNode),f.y=z.getNodeYByLotY(y,f.rgNode),f.width=f.rgNode.el_W,f.height=f.rgNode.el_H,f.buffY=0});for(const f of r){const y=l.get(f)||[];if(t==="h")if(a==="end"){y.sort((g,m)=>g.lot.y-m.lot.y);const u=y.map(g=>h.get(g.id));this.adjustNodePositions(u,"bottom",this.layoutOptions.treeNodeGapV);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=z.getNodeLotXY(m,g).y}}else{y.sort((g,m)=>m.lot.y-g.lot.y);const u=y.map(g=>h.get(g.id));this.adjustNodePositions(u,"top",this.layoutOptions.treeNodeGapV);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.y=z.getNodeLotXY(m,g).y}}else if(a==="end"){y.sort((g,m)=>g.lot.x-m.lot.x);const u=y.map(g=>h.get(g.id));this.adjustNodePositions(u,"right",this.layoutOptions.treeNodeGapH);for(const g of u){const m=g.rgNode.lot.level<0?i:n,p=z.getNodeLotXY(m,g);g.rgNode.lot.x=p.x}}else{y.sort((g,m)=>m.lot.x-g.lot.x);const u=y.map(g=>h.get(g.id));this.adjustNodePositions(u,"left",this.layoutOptions.treeNodeGapH);for(const g of u){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.x=z.getNodeLotXY(m,g).x}}console.log("levelNodes:",f,y)}if(t==="h"){const f=new Map,y=new Map;for(const L of r){const S=l.get(L).map(b=>h.get(b.id));f.set(L,Math.max(...S.map(b=>b.width))),y.set(L,Math.min(...S.map(b=>b.x)))}const u=this.layoutOptions.treeNodeGapH;let g=r.filter(L=>L>0).sort((L,_)=>L-_),m=r.filter(L=>L<0).sort((L,_)=>_-L),p=1;this.layoutOptions.from==="right"&&([m,g]=[g,m],p=-1);let v=0;for(const L of g){const _=L-p,S=y.get(_),b=f.get(_),O=y.get(L)+v;f.get(L);const R=S+b+u;if(R>O){const M=R-O;console.log("[xxxxx]move",_,L,R,O,M),v=M;const k=l.get(L);for(const P of k)P.lot.x+=v;y.set(L,O+M)}else console.log("[xxxxx]goon",_,L,R,O),y.set(L,O)}v=0;for(const L of m){const _=L+p,S=y.get(_);f.get(_);const b=y.get(L)+v,O=f.get(L),R=S-u;if(b+O>R){const M=R-(b+O);v=M;const k=l.get(L);for(const P of k)P.lot.x+=v;y.set(L,b+M)}else y.set(L,b)}}else{const f=new Map,y=new Map;for(const L of r){const S=l.get(L).map(b=>h.get(b.id));f.set(L,Math.max(...S.map(b=>b.height))),y.set(L,Math.min(...S.map(b=>b.y)))}const u=this.layoutOptions.treeNodeGapV;let g=r.filter(L=>L>0).sort((L,_)=>L-_),m=r.filter(L=>L<0).sort((L,_)=>_-L),p=1;this.layoutOptions.from==="bottom"&&([m,g]=[g,m],p=-1);let v=0;for(const L of g){const _=L-p,S=y.get(_),b=f.get(_),O=y.get(L)+v;f.get(L);const R=S+b+u;if(R>O){const M=R-O;console.log("[xxxxx]move",_,L,R,O,M),v=M;const k=l.get(L);for(const P of k)P.lot.y+=v;y.set(L,O+M)}else console.log("[xxxxx]goon",_,L,R,O),y.set(L,O)}v=0;for(const L of m){const _=L+p,S=y.get(_);f.get(_);const b=y.get(L)+v,O=f.get(L),R=S-u;if(b+O>R){const M=R-(b+O);v=M;const k=l.get(L);for(const P of k)P.lot.y+=v;y.set(L,b+M)}else y.set(L,b)}}}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const{calcNodes:i,calcNodeMap:a}=this.generateCalcNodes(e);i.forEach(l=>{l.movedNodeSizeBefore=1,l.movedNodeSizeAfter=1});const{levelNodesMap:r}=this.generateLevels(e);e.forEach(l=>{if(l.fixed!==!0&&l.lot.level!==0){const c=r.get(l.lot.level)||[];if(l.lot.strengthWithChilds===1&&l.lot.childrenSizeVisible<=1){const d=this.getBloomingNearByParent(l,l.lot.parent,c,t);if(d){const h=a.get(l.id);t==="h"?l.lot.y-d.lot.y>0?(l.lot.y=d.lot.y+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.y=d.lot.y-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++):l.lot.x-d.lot.x>0?(l.lot.x=d.lot.x+n*h.movedNodeSizeAfter,h.movedNodeSizeAfter++):(l.lot.x=d.lot.x-n*h.movedNodeSizeBefore,h.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}}class Lt extends Se{constructor(e,t,n){super(e,t,n);N(this,"layoutOptions");this.layoutOptions=e,this.layoutOptions.distance_coefficient||(this.layoutOptions.distance_coefficient=1),this.layoutOptions.levelGaps&&!this.layoutOptions.levelGaps&&(this.layoutOptions.levelDistance=[...this.layoutOptions.levelGaps])}placeNodes(e,t){if(C("RGCenterLayout:placeNodes"),!t){C("root is null:",t);return}C("layout by root:",t),this.allNodes=e,this.calcNodes=e,this.rootNode=t;const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode),{networkNodes:i,analyticResult:a}=n;if(this.layoutOptions.genLotInfoOnly){C("only gen lot info, return");return}t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const r={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},l=z.getNodeLotXY(r,t);t.lot.x=l.x,t.lot.y=l.y,C("root position:",t.lot.x,t.lot.y);const c=this.layoutOptions.distance_coefficient||1,d=this.getLevelDistanceArr();this.placeRelativePosition(this.rootNode,i,a,c,d),i.forEach(h=>{if(h.fixed!==!0&&!!h.rgCalcedVisibility&&h!==t){const f=r,y=z.getNodeXByLotX(f,h),u=z.getNodeYByLotY(f,h);this.updateNodePosition(h,y,u)}}),this.layoutEnd()}getLevelDistanceArr(){let e=[];if(this.layoutOptions.levelDistance){if(Array.isArray(this.layoutOptions.levelDistance))e=this.layoutOptions.levelDistance;else return console.error("Error levelDistance, levelDistance must is Array"),new Array(10).fill(200);if(e.length>0&&e.length<10)for(let t=e.length;t<10;t++)e.push(e[e.length-1])}return e}}class wt extends Se{constructor(o,e,t){super(o,e,t)}placeNodes(o,e){if(e)C("layout by root:",e);else{C("root is null:",e);return}this.allNodes=o,this.rootNode=e,e.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(e,0,0);const t={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},n=z.getNodeLotXY(t,e);e.lot.x=n.x,e.lot.y=n.y;const i=this.allNodes.filter(l=>l.rgCalcedVisibility),a=i.length;let r=a*90/Math.PI/2;r<200&&(r=200),r>800&&(r=800),i.forEach((l,c)=>{const d=Z.getOvalPoint(e.lot.x,e.lot.y,r,c,a);l.lot.x=d.x,l.lot.y=d.y,console.log("xxxxxxxxxxxxxx:",l.id,l.lot.x,l.lot.y)}),i.forEach(l=>{if(l===e||l.fixed===!0||!l.rgCalcedVisibility)return;const c=t,d=z.getNodeXByLotX(c,l),h=z.getNodeYByLotY(c,l);this.updateNodePosition(l,d,h)}),this.layoutEnd()}}class Nt extends ue{constructor(e,t,n){super(e,t,n);N(this,"graphOptions");N(this,"layoutOptions");N(this,"allNodes",[]);this.layoutOptions=e,this.graphOptions=t}placeNodes(e,t){if(t)C("layout by root:",t);else{C("root is null:",t);return}C("allNodes:",e.length),this.networkAnalyzer.analyzeNetwork(e,t,!1,!1),C("[Fixed layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize),this.layoutEnd()}}class xn extends ue{constructor(e,t,n){super(e,t,n);N(this,"graphInstance");N(this,"layoutOptions");N(this,"levelGaps",[]);this.layoutOptions=e,C("new RGSmartTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps&&(Array.isArray(this.layoutOptions.levelGaps)?this.levelGaps=this.layoutOptions.levelGaps:console.error("Error levelDistance, levelDistance must is Array"));const i=this.layoutOptions.from;i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=30),this.layoutOptions.treeNodeGapV<30&&(this.layoutOptions.treeNodeGapV=30)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=30),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.treeNodeGapH<30&&(this.layoutOptions.treeNodeGapH=30)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY),this.requireLinks=!0,this.graphInstance=n}placeNodes(e,t){if(C("RGSmartTreeLayout:placeNodes"),t)C("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,C("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},{tree:a,reverseTree:r}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode,!0,!0);t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const l=z.getNodeLotXY(n,t);t.lot.x=l.x,t.lot.y=l.y,this.placeRelativePosition(t,[...a.networkNodes].concat(r.networkNodes),Math.max(a.analyticResult.max_strength,r.analyticResult.max_strength)),C("allNodes:",e.length);const c={left:0,top:90,right:180,bottom:270}[this.layoutOptions.from],d={x:t.x,y:t.y};this.allNodes.forEach(y=>{if(y.fixed===!0||!y.rgCalcedVisibility)return;if(Number.isNaN(y.lot.x)&&(C("bad lot x:",y.text,y.lot.x),y.lot.x=0),Number.isNaN(y.lot.y)&&(C("bad lot y:",y.text,y.lot.y),y.lot.y=0),c){const p=Z.getRotatedPoint(y.lot.x,y.lot.y,d.x,d.y,c);y.lot.x=p.x,y.lot.y=p.y}const u=y.lot.level<0?i:n,g=z.getNodeXByLotX(u,y),m=z.getNodeYByLotY(u,y);this.updateNodePosition(y,g,m)}),C("create rootNode coordinates:1",t.x,t.y);const h=new Se({layoutName:"force",maxLayoutTimes:30,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0,disableLiveChanges:!0},this.graphOptions,this.graphInstance);h.isMainLayouer=!1,h.requireLinks=!0,this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?h.lockY=!0:h.lockX=!0;const f=t.fixed;t.fixed=!0,h.skipInitLayout=!0,h.setLinks(this.graphInstance.getLinks()),h.resetCalcNodes(),setTimeout(()=>{t.fixed=f},800),h.onFinish(()=>{t.fixed=f,this.graphInstance&&(this.graphInstance.enableNodeXYAnimation(),this.graphInstance._dataUpdated()),this.applyNodesGap(this.allNodes),this.graphInstance&&(this.graphInstance._dataUpdated(),setTimeout(()=>{this.graphInstance.disableNodeXYAnimation(),this.graphInstance._dataUpdated()},300))}),h.placeNodes(this.allNodes,t),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h";let a=this.layoutOptions.treeNodeGapH||300,r=this.layoutOptions.treeNodeGapV||10;i==="v"&&([a,r]=[r,a]);const{levels:l,levelNodesMap:c}=this.generateLevels(t),d=new Map;for(const g of l){const m=c.get(g);d.set(g,Math.max(...m.map(p=>p.el_W)))}let h=0,f=0;for(const g of t){const m=g.el_H;h+=m,f++}if(f===0)return;const u=h/f+r;t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.x=e.lot.x+this.getLevelDistance(g.lot.level,d,a))}),t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.level===0?g.lot.y=e.lot.y+u*g.lot.index_of_level:g.lot.y=e.lot.y+u*(n/-2+g.lot.strengthWithChilds_from+g.lot.strengthWithChilds/2))})}applyNodesGap(e){const t=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h",{levels:n,levelNodesMap:i}=this.generateLevels(e),a=new Map;for(const c of n){const d=i.get(c);a.set(c,Math.max(...d.map(h=>h.el_W)))}const{calcNodes:r,calcNodeMap:l}=this.generateCalcNodes(e);r.forEach(c=>{c.x=c.rgNode.x,c.y=c.rgNode.y,c.width=c.rgNode.el_W,c.height=c.rgNode.el_H,c.buffY=0});for(const c of n){const d=i.get(c)||[];if(t==="h"){const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.y<this.rootNode.y).sort((u,g)=>g.y-u.y),y=h.filter(u=>u.y>=this.rootNode.y).sort((u,g)=>u.y-g.y);this.adjustNodePositions(f,"top",5),this.adjustNodePositions(y,"bottom",5);for(const u of h)u.rgNode.y=u.y}else{const h=d.map(u=>l.get(u.id)),f=h.filter(u=>u.x<this.rootNode.x).sort((u,g)=>g.x-u.x),y=h.filter(u=>u.x>=this.rootNode.x).sort((u,g)=>u.x-g.x);this.adjustNodePositions(f,"left",5),this.adjustNodePositions(y,"right",5);for(const u of h)u.rgNode.x=u.x}console.log("levelNodes:",c,d)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=1;a<=e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return i}else{let i=0;for(let a=-1;a>=e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r)}return-i}}getLevelGap(e,t,n){var a;let i=t+(e===-1?n/2:0);if(((a=this.layoutOptions.levelGaps)==null?void 0:a.length)>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(i=r)}return i}}class _t extends ue{constructor(e,t,n){super(e,t,n);N(this,"enableGatherNodes",!1);N(this,"layoutOptions");this.layoutOptions=e,C("new RGFolderLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.bottomJuctionPointOffsetX===void 0&&(this.layoutOptions.bottomJuctionPointOffsetX=-50);const i=this.layoutOptions.from;i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="bottom"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="end"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):i==="right"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="end"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="center"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps, treeNodeGapH, treeNodeGapV option in layoutOptions"),this.enableGatherNodes=this.layoutOptions.enableGatherNodes}placeNodes(e,t){if(C("RGFolderLayout:placeNodes"),t)C("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,console.log("fixedRootNode:",this.layoutOptions.fixedRootNode);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},i={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=z.getNodeLotXY(n,t);t.lot.x=a.x,t.lot.y=a.y,C("allNodes:",e.length);const{tree:r}=this.networkAnalyzer.analyzeNetwork(e,t,!1);this.placeRelativePosition(t,r.networkNodes,r.analyticResult),C("networkNodes:",r.networkNodes.length),this.allNodes.forEach(l=>{if(l.fixed!==!0&&(Number.isNaN(l.lot.x)&&(C("bad lot x:",l.text,l.lot.x),l.lot.x=0),Number.isNaN(l.lot.y)&&(C("bad lot y:",l.text,l.lot.y),l.lot.y=0),l!==t)){const c=l.lot.level<0?i:n,d=z.getNodeXByLotX(c,l),h=z.getNodeYByLotY(c,l);this.updateNodePosition(l,d,h)}}),C("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeRelativePosition(e,t,n){const i=this.layoutOptions.treeNodeGapH||20,a=this.layoutOptions.treeNodeGapV||20,r=new Map;let l=0,c=0;for(const f of t){const y=f.lot.level,u=f.el_W,g=f.el_H;l+=g,c++;const m=r.get(y);m===void 0?r.set(y,u):u>m&&r.set(y,m)}if(c===0)return;console.log("levelMaxWidthMap:",r);const h=l/c+a;t.forEach(f=>{f.fixed!==!0&&f!==e&&(this.layoutOptions.from==="right"?f.lot.x=e.lot.x-this.getLevelDistance(f.lot.level,r,i+50):f.lot.x=e.lot.x+this.getLevelDistance(f.lot.level,r,i+50))}),t.forEach(f=>{f.fixed!==!0&&f!==e&&f.lot.level!==0&&(f.lot.y=e.lot.y+h*f.lot.strengthWithChilds_from)}),this.gatherNodes(t,"h",h)}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const i={};e.forEach(a=>{if(a.lot.level!==0)return;const r=a.lot.level+"";i[r]||(i[r]=[]),i[r].push(a),a.lot.movedNodeSizeBefore=1,a.lot.movedNodeSizeAfter=1}),e.forEach(a=>{if(a.fixed!==!0&&a.lot.level!==0){const r=a.lot.level+"",l=i[r];if(a.lot.strengthWithChilds===1&&a.lot.childrenSizeVisible<=1){const c=this.getBloomingNearByParent(a,a.lot.parent,l,t);c&&(t==="h"?a.lot.y-c.lot.y>0?(a.lot.y=c.lot.y+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.y=c.lot.y-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++):a.lot.x-c.lot.x>0?(a.lot.x=c.lot.x+n*c.lot.movedNodeSizeAfter,c.lot.movedNodeSizeAfter++):(a.lot.x=c.lot.x-n*c.lot.movedNodeSizeBefore,c.lot.movedNodeSizeBefore++))}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const l of n)if(l.lot.childrenSizeVisible>1&&l.lot.parent===t){const c=i==="h"?l.lot.y-t.lot.y:l.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=l)}if(r&&r!==e)return r}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++)i+=t.get(a)+this.getLevelGap(a,n);return i}else{let i=e<-1?0:-t.get(e)/2;for(let a=e;a<0;a++)i+=t.get(a)+this.getLevelGap(a,n)+50;return-i}}getLevelGap(e,t){var i;let n=t;if(((i=this.layoutOptions.levelGaps)==null?void 0:i.length)>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(n=a)}return n}}const fe=s=>!s||s.length===0?"":s.map(o=>{switch(o.type){case"M":return`${o.type} ${o.x} ${o.y}`;case"l":return`${o.type} ${o.dx} ${o.dy}`;case"L":return`${o.type} ${o.x} ${o.y}`;case"h":return`${o.type} ${o.dx}`;case"v":return`${o.type} ${o.dy}`;case"c":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"s":return`${o.type} ${o.dx2} ${o.dy2} ${o.dx} ${o.dy}`;case"q":return`${o.type} ${o.dx1} ${o.dy1} ${o.dx} ${o.dy}`;case"Q":return`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`;case"t":return`${o.type} ${o.dx} ${o.dy}`;case"a":return`${o.type} ${o.rx} ${o.ry} ${o.xAxisRotation} ${o.largeArcFlag} ${o.sweepFlag} ${o.dx} ${o.dy}`;case"Z":return o.type;default:return console.warn("\u672A\u77E5\u7684\u8DEF\u5F84\u547D\u4EE4\u7C7B\u578B:",o),""}}).join(" ").trim(),Je=s=>{const o=s.match(/[a-zA-Z][^a-zA-Z]*/g);let e=0,t=0,n=0,i=0,a=0,r=0,l=0,c=0;const d={x:0,y:0},h={x:0,y:0},f=[];for(const y of o){const u=y.trim().split(/[ ,]+/),g=u[0].toUpperCase(),m=u[0]===u[0].toLowerCase();switch(g){case"M":e=H(n,u[1],m),t=H(i,u[2],m),n=e,i=t;break;case"L":e=H(n,u[1],m),t=H(i,u[2],m),f.push({x:e,y:t});break;case"C":a=H(n,u[1],m),r=H(i,u[2],m),l=H(n,u[3],m),c=H(i,u[4],m),e=H(n,u[5],m),t=H(i,u[6],m),n=e,i=t;break;case"Q":a=H(n,u[1],m),r=H(i,u[2],m),e=H(n,u[3],m),t=H(i,u[4],m),n=e,i=t;break;case"V":t=H(i,u[1],m),i=t;break;case"H":e=H(n,u[1],m),n=e;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}y===o[0]&&(d.x=e,d.y=t),y===o[o.length-1]&&(h.x=e,h.y=t)}return{startPoint:d,ctrl1:{x:a,y:r},ctrl2:{x:l,y:c},endPoint:h,lines:f}},H=(s,o,e)=>e?s+parseFloat(o):parseFloat(o),Cn=(s,o,e,t,n,i,a)=>{const r=JSON.parse(JSON.stringify(s));let l=!1;if(e<0||e>=s.length-1)return{newPoints:r,pointsChanged:l};r[e-1];const c=r[e],d=r[e+1];o[e-1];const h=o[e];o[e+1];let f=i,y=a;if(t.direction==="v"){const u=o[e-2],g=o[e+2],m=h.x+f;let p=3e3;if(u){const v=Math.abs(u.x-m);v<10&&v<p&&(p=v,f=u.x-h.x)}if(g){const v=Math.abs(g.x-m);v<10&&v<p&&(p=v,f=g.x-h.x)}}else{const u=o[e-2],g=o[e+2],m=h.y+y;let p=3e3;if(u){const v=Math.abs(u.y-m);v<10&&v<p&&(p=v,y=u.y-h.y)}if(g){const v=Math.abs(g.y-m);v<10&&v<p&&(p=v,y=g.y-h.y)}}if(t.direction==="v")if(e===0){const u=c.y<d.y?1:-1,g={x:c.x,y:c.y},m={x:c.x,y:c.y+20*u};c.x=m.x+f,c.y=m.y,r.splice(e,0,g,m),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.y<d.y?1:-1,g={x:h.x+f,y:d.y-20*u},m={x:d.x,y:d.y-20*u};r.splice(e+1,0,g,m),l=!0}else c.x=h.x+f,d.x=h.x+f;else if(e===0){const u=c.x<d.x?1:-1,g={x:c.x,y:c.y},m={x:c.x+20*u,y:c.y};c.x=m.x,c.y=h.y+y,r.splice(e,0,g,m),n.indexOffset+=2,l=!0}else if(e===s.length-2){const u=c.x<d.x?1:-1,g={x:d.x-20*u,y:h.y+y},m={x:d.x-20*u,y:d.y};r.splice(e+1,0,g,m),l=!0}else c.y=h.y+y,d.y=h.y+y;return{newPoints:r,pointsChanged:l}},Ln=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=Z.getTextAngle(e,t,n,i),o.x=e+(n-e)/2,o.y=t+(i-t)/2,Number.isNaN(o.rotate)&&(o.rotate=0);const a=n-e,r=i-t,l=[{type:"M",x:e,y:t},{type:"l",dx:a,dy:r}],c=fe(l);return{pathCommands:l,pathData:c,textPosition:o,points:[]}},wn=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fx:n,fy:i,fcx:a,fcy:r,f_W:l,f_H:c,tx:d,ty:h,tcx:f,tcy:y,t_W:u,t_H:g}=s,m=d-n,p=h-i,v=n-a,L=i-r,_=d-f,S=h-y,b=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,O=Math.min(b,Math.abs(m))*(n<d?1:-1),R=Math.min(b,Math.abs(p))*(i<h?1:-1),M=t.lineDirection||Math.abs(v)>=l/2?"h":"v",k=t.lineDirection||Math.abs(_)>=u/2?"h":"v",P=[];let T=0,w=0;if(M==="v"){const V=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(h-i)/2),15),X=L>0?V:-V;if(t.onPathStartOffset==="start"?(T=n,w=i+X-(L>0?20:-5)):t.onPathStartOffset==="middle"?(T=n+(d-n)/2,w=i+X):(T=d,w=i+X+(L>0?20:-5)),P.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"v",dy:Math.round(X-R)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)}),k==="v")P.push({type:"h",dx:Math.round(d-n-O*2)},{type:"c",dx1:Math.round(O),dy1:0,dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)},{type:"v",dy:Math.round(h-i-X-R)});else{const G=Math.min(30,Math.abs(d-n)/2),E=_>0?-G:G;P.push({type:"h",dx:Math.round(d-n+E-O)},{type:"c",dx1:Math.round(O),dy1:0,dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)},{type:"v",dy:Math.round(h-i-X-R)},{type:"h",dx:Math.round(E-O)})}}else{const V=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(d-n)/2),15),X=v>0?V:-V;if(t.onPathStartOffset==="start"?(T=n+(v>0?10:-50),w=i-5):t.onPathStartOffset==="center"||t.onPathStartOffset==="middle"?(T=n+X,w=i+(h-i)/2):(T=n+X+(v>0?20:-50),w=h-5),P.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"h",dx:Math.round(X-O)},{type:"c",dx1:Math.round(O),dy1:0,dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)}),k==="v"){const G=Math.min(30,Math.abs(h-i)/2),E=S>0?-G:G;P.push({type:"v",dy:Math.round(h-i+E-R)},{type:"h",dx:Math.round(d-n-X-O)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)},{type:"v",dy:Math.round(E-R)})}else P.push({type:"v",dy:Math.round(h-i-R*2)},{type:"c",dx1:0,dy1:Math.round(R),dx2:Math.round(O),dy2:Math.round(R),dx:Math.round(O),dy:Math.round(R)},{type:"h",dx:Math.round(d-n-X-O)})}o.x=T,o.y=w;const D=fe(P);return{pathCommands:P,pathData:D,textPosition:o,points:[]}},Me={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},Nn=({source:s,sourcePosition:o="bottom",target:e})=>o==="left"||o==="right"?s.x<e.x?{x:1,y:0}:{x:-1,y:0}:s.y<e.y?{x:0,y:1}:{x:0,y:-1},Ze=(s,o)=>Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));function ze({source:s,sourcePosition:o="bottom",target:e,targetPosition:t="top",center:n,sourceOffset:i,targetOffset:a}){const r=Me[o],l=Me[t],c={x:s.x+r.x*i,y:s.y+r.y*i},d={x:e.x+l.x*a,y:e.y+l.y*a},h=Nn({source:c,sourcePosition:o,target:d}),f=h.x!==0?"x":"y",y=h[f];let u=[],g,m;const p={x:0,y:0},v={x:0,y:0};let L=0;if(r[f]*l[f]===-1){g=n.x,m=n.y;const S=[{x:g,y:c.y},{x:g,y:d.y}],b=[{x:c.x,y:m},{x:d.x,y:m}];r[f]===y?(L=1.1,u=f==="x"?S:b):(L=1.2,u=f==="x"?b:S)}else{const S=[{x:c.x,y:d.y}],b=[{x:d.x,y:c.y}];if(f==="x"?u=r.x===y?b:S:u=r.y===y?S:b,o===t){L=2.1;const P=Math.abs(s[f]-e[f]),T=r[f]===y?i:a;if(P<=T){const w=Math.min(T-1,T-P);r[f]===y?p[f]=(c[f]>s[f]?-1:1)*w:v[f]=(d[f]>e[f]?-1:1)*w}}if(o!==t){L=2.2;const P=f==="x"?"y":"x",T=r[f]===l[P],w=c[P]>d[P],D=c[P]<d[P];(r[f]===1&&(!T&&w||T&&D)||r[f]!==1&&(!T&&D||T&&w))&&(u=f==="x"?S:b)}const O={x:c.x+p.x,y:c.y+p.y},R={x:d.x+v.x,y:d.y+v.y},M=Math.max(Math.abs(O.x-u[0].x),Math.abs(R.x-u[0].x)),k=Math.max(Math.abs(O.y-u[0].y),Math.abs(R.y-u[0].y));M>=k?(g=(O.x+R.x)/2,m=u[0].y):(g=u[0].x,m=(O.y+R.y)/2)}return[[s,{x:c.x+p.x,y:c.y+p.y},...u,{x:d.x+v.x,y:d.y+v.y},e],g,m,0,0,L]}const ke=s=>{const o=[];for(let e=0;e<s.length;e++){const t=s[e];if(t.x=Math.round(t.x),t.y=Math.round(t.y),e===0||e===s.length-1)o.push(t);else{const n=o[o.length-1];t.x===n.x&&t.y===n.y||o.push(t)}}for(let e=2;e<o.length;e++){const t=o[e-2],n=o[e-1],i=o[e],a=t.x===n.x?"v":"h",r=n.x===i.x?"v":"h";a===r&&(n.merged=!0)}return o.filter(e=>e.merged!==!0)};function _n(s,o,e,t){const n=Math.min(Ze(s,o)/2,Ze(o,e)/2,t),{x:i,y:a}=o;if(s.x===i&&i===e.x||s.y===a&&a===e.y)return[{type:"L",x:i,y:a}];if(s.y===a){const c=s.x<e.x?-1:1,d=s.y<e.y?1:-1;return[{type:"L",x:i+n*c,y:a},{type:"Q",x1:i,y1:a,x:i,y:a+n*d}]}const r=s.x<e.x?1:-1,l=s.y<e.y?-1:1;return[{type:"L",x:i,y:a+n*l},{type:"Q",x1:i,y1:a,x:i+n*r,y:a}]}const bt=(s,o)=>{const e=[];return s.forEach((t,n)=>{if(n===0)e.push({type:"M",x:Math.round(t.x),y:Math.round(t.y)});else if(n===s.length-1){const i=s[n-1];let a=i.x===t.x?0:i.x<t.x?-1:1,r=i.y===t.y?0:i.y<t.y?-1:1;s.length===2&&(a=0,r=0),e.push({type:"l",dx:Math.round(t.x-i.x+o*a),dy:Math.round(t.y-i.y+o*r)})}else{const i=_n(s[n-1],t,s[n+1],o);e.push(...i)}}),e};var de=(s=>(s.border="border",s.ltrb="ltrb",s.tb="tb",s.lr="lr",s.left="left",s.right="right",s.top="top",s.bottom="bottom",s))(de||{});const Ie=(s,o,e,t,n,i,a,r)=>s==="left"?"left":s==="right"?"right":s==="top"?"top":s==="bottom"?"bottom":s==="horizontalLine"?t?i>r?"bottom":"top":i<r?"bottom":"top":s==="verticalLine"?t?n>a?"right":"left":n<a?"right":"left":o===1?"right":o===-1?"left":e===1?"bottom":e===-1?"top":"left",Qe=s=>s==="left"?"right":s==="right"?"left":s==="top"?"bottom":s==="bottom"?"top":"left",Ot=s=>{if(s.length<2)throw new Error("At least two points are required to form a polyline.");let o=0;const e=[];for(let i=1;i<s.length;i++){const a=s[i].x-s[i-1].x,r=s[i].y-s[i-1].y,l=Math.sqrt(a*a+r*r);e.push(l),o+=l}const t=o/2;let n=0;for(let i=0;i<e.length;i++)if(n+=e[i],n>=t){const a=s[i],r=s[i+1],l=e[i],d=(t-(n-l))/l,h=a.x+(r.x-a.x)*d,f=a.y+(r.y-a.y)*d;return{x:h,y:f}}return{x:0,y:0}},bn=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:y,tx:u,ty:g,tcx:m,tcy:p,t_W:v,t_H:L}=s,_=l-d,S=c-h;let b=_>1?1:_<-1?-1:0,O=S>1?1:S<-1?-1:0;Math.abs(b)===1&&Math.abs(O)===1&&(Math.abs(_)>Math.abs(S)?O=0:b=0),b===0&&O===0&&(b=1);const R=u-m,M=g-p;let k=R>1?1:R<-1?-1:0,P=M>1?1:M<-1?-1:0;Math.abs(k)===1&&Math.abs(P)===1&&(Math.abs(R)>Math.abs(M)?P=0:k=0),k===0&&P===0&&(b=-1);const T=Ie(n,b,O,!1,l,c,u,g),w=Ie(i,k,P,!0,l,c,u,g),D=T,V=w,X=l+(u-l)/2,G=c+(g-c)/2;let E={x:0,y:0},j=30,$=30;t.ctrlOptionsFor44&&(E={x:t.ctrlOptionsFor44.cx,y:t.ctrlOptionsFor44.cy},j+=t.ctrlOptionsFor44.fd,$+=t.ctrlOptionsFor44.td);const K=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,[Q]=ze({source:{x:l,y:c},sourcePosition:D,target:{x:u,y:g},targetPosition:V,center:{x:X+E.x,y:G+E.y},sourceOffset:j,targetOffset:$}),ie=ke(Q),te=bt(ie,K),ee=fe(te),se=Ot(Q);return o.x=se.x,o.y=se.y,{pathCommands:te,pathData:ee,textPosition:o,points:ie,startDirection:D,endDirection:V}},On=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:l,fy:c,fcx:d,fcy:h,f_W:f,f_H:y,tx:u,ty:g,tcx:m,tcy:p,t_W:v,t_H:L}=s,_=l-d,S=c-h;let b=_>3?1:_<-3?-1:0,O=S>3?1:S<-3?-1:0;Math.abs(b)===1&&Math.abs(O)===1&&(Math.abs(_)>Math.abs(S)?O=0:b=0),b===0&&O===0&&(b=1);const R=u-m,M=g-p;let k=R>3?1:R<-3?-1:0,P=M>3?1:M<-3?-1:0;Math.abs(k)===1&&Math.abs(P)===1&&(Math.abs(R)>Math.abs(M)?P=0:k=0),k===0&&P===0&&(b=-1);let T=Ie(n,b,O,!1,l,c,u,g),w=Ie(i,k,P,!0,l,c,u,g);const D=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,V=t.ctrlPointsFor49;let X={x:Math.round(l),y:Math.round(c)},G={x:Math.round(u),y:Math.round(g)},E={x:Math.round(V[0].x),y:Math.round(V[0].y)},j={x:Math.round(V[V.length-1].x),y:Math.round(V[V.length-1].y)},$=[...V];if(t.isReverse&&([T,w]=[w,T]),Math.abs(X.x-E.x)>3||Math.abs(X.y-E.y)>3){const ee=X.x+(E.x-X.x)/2,se=X.y+(E.y-X.y)/2,ae=Qe(T),[Y]=ze({source:X,sourcePosition:T,target:E,targetPosition:ae,center:{x:ee,y:se},sourceOffset:20,targetOffset:5});$=ke([...Y,...$])}if(Math.abs(G.x-j.x)>3||Math.abs(G.y-j.y)>3){const ee=j.x+(G.x-j.x)/2,se=j.y+(G.y-j.y)/2,ae=Qe(w),[Y]=ze({source:j,sourcePosition:ae,target:G,targetPosition:w,center:{x:ee,y:se},sourceOffset:5,targetOffset:20});$=ke([...$,...Y])}const K=$,Q=bt(K,D),ie=fe(Q),te=Ot(V);return o.x=te.x,o.y=te.y,{pathCommands:[],pathData:ie,textPosition:o,points:K,startDirection:T,endDirection:w}},Sn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,lineShape:t,fx:n,fy:i,fcx:a,fcy:r,tx:l,ty:c,tcx:d,tcy:h}=s,f=l-n,y=c-i;let u=n-a,g=i-r,m=l-d,p=c-h,{fromJunctionPoint:v,toJunctionPoint:L}=e;e.isReverse&&([v,L]=[L,v]),(v===U.left||v===U.right)&&(g=0),(v===U.top||v===U.bottom)&&(u=0),(L===U.left||L===U.right)&&(p=0),(L===U.top||L===U.bottom)&&(m=0);const _=Math.min(200,Math.max(100,Math.abs(f/2))),S=Math.min(200,Math.max(100,Math.abs(y/2))),b=u/(Math.abs(u)+Math.abs(g))*_,O=g/(Math.abs(u)+Math.abs(g))*S;let R={x:b,y:O};const M=m/(Math.abs(m)+Math.abs(p))*_+f,k=p/(Math.abs(m)+Math.abs(p))*S+y;let P={x:M,y:k};e.ctrlPoints&&e.ctrlPoints.length>0&&(e.isReverse?(R.x+=e.ctrlPoints[1].x,R.y+=e.ctrlPoints[1].y,P.x+=e.ctrlPoints[0].x,P.y+=e.ctrlPoints[0].y):(R.x+=e.ctrlPoints[0].x,R.y+=e.ctrlPoints[0].y,P.x+=e.ctrlPoints[1].x,P.y+=e.ctrlPoints[1].y));const T={x:n+R.x,y:i+R.y},w={x:n+P.x,y:i+P.y},D={x:n+f,y:i+y},V=[{type:"M",x:n,y:i},{type:"c",dx1:R.x,dy1:R.y,dx2:P.x,dy2:P.y,dx:f,dy:y}];t===8&&V.push({type:"Z"});const X=St({x:n,y:i},T,w,D,t<6?.8:.5);o.x=X.x,o.y=X.y;const G=fe(V);return{pathCommands:V,pathData:G,textPosition:o,points:[]}},St=(s,o,e,t,n=.5)=>{const i={x:(1-n)*s.x+n*o.x,y:(1-n)*s.y+n*o.y},a={x:(1-n)*o.x+n*e.x,y:(1-n)*o.y+n*e.y},r={x:(1-n)*e.x+n*t.x,y:(1-n)*e.y+n*t.y},l={x:(1-n)*i.x+n*a.x,y:(1-n)*i.y+n*a.y},c={x:(1-n)*a.x+n*r.x,y:(1-n)*a.y+n*r.y};return{x:(1-n)*l.x+n*c.x,y:(1-n)*l.y+n*c.y}},Pn=(s,o={x:0,y:0,rotate:0})=>{const{line:e,totalLinesBetweenNodes:t,currentLineIndex:n,lineDirection:i,lineShape:a,fx:r,fy:l,fcx:c,fcy:d,f_W:h,f_H:f,tx:y,ty:u,tcx:g,tcy:m,t_W:p,t_H:v}=s,L=y-r,_=u-l,S=y>r?1:-1,b=u>l?1:-1,O=i==="v"?b:S,R=r-c,M=l-d,k=y-g,P=u-m,T=1/(t+1)*(n+1);let w={x:0,y:0},D={x:0,y:0};if(a===F.Curve2)w=i==="v"?{x:0,y:O*30}:{x:O*30,y:0},D=i==="v"?{x:L*T,y:O*-10}:{x:O*-10,y:_*T};else if(a===F.Curve3)w=i==="v"?{x:0,y:_*T}:{x:O*30,y:0},D=i==="v"?{x:0,y:0}:{x:O*-10,y:_*T};else if(a===F.Curve5)w={x:0,y:0},D=i==="v"?{x:0,y:_*T}:{x:L*T,y:0};else if(a===F.Curve7||a===F.Curve8){const ie=R/(Math.abs(R)+Math.abs(M))*30,te=M/(Math.abs(R)+Math.abs(M))*30;w={x:ie,y:te};const ee=k/(Math.abs(k)+Math.abs(P))*30+L,se=P/(Math.abs(k)+Math.abs(P))*30+_;D={x:ee,y:se}}const V={x:r+w.x,y:l+w.y},X={x:r+D.x,y:l+D.y},G={x:r+L,y:l+_},E=[{type:"M",x:r,y:l},{type:"c",dx1:w.x,dy1:w.y,dx2:D.x,dy2:D.y,dx:L,dy:_}];a===8&&E.push({type:"Z"});const j=St({x:r,y:l},V,X,G,a<6?.8:.5);o.x=j.x,o.y=j.y;const $=fe(E);return{pathCommands:E,pathData:$,textPosition:o,points:[]}};class Rn{constructor(){N(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]});N(this,"options",{});N(this,"runtimeDATA4NodeMap",new Map);N(this,"runtimeDATA4Links",[]);N(this,"runtimeDATA4LinkMap",new Map);N(this,"runtimeDATA4ConnectTargets",[]);N(this,"runtimeDATA4ElLineTargets",[]);N(this,"runtimeDATA4ShouldRenderItems",{nodes:[],lines:[],fakeLines:[]})}}class Tn extends Rn{constructor(){super()}getOptions(){return this.options}getNodeById(o){return this.runtimeDATA4NodeMap.get(o)}getLineById(o){var e;return(e=this.runtimeDATA4LinkMap.get(o))==null?void 0:e.line}getLinkByLineId(o){return this.runtimeDATA4LinkMap.get(o)}getFakeLineById(o){return this.graphData.fakeLines.find(e=>e.id===o)}getNodes(){return this.graphData.nodes}getLinks(){return this.runtimeDATA4Links}getFakeLines(){return this.graphData.fakeLines}getLines(){return this.runtimeDATA4Links.map(o=>o.line)}getRootNode(){return this.graphData.rootNode}getShouldRenderNodes(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.nodes:this.graphData.nodes}getShouldRenderLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.lines:this.graphData.normalLines}getShouldRenderFakeLines(){return this.isPerformanceMode()?this.runtimeDATA4ShouldRenderItems.fakeLines:this.graphData.fakeLines}isPerformanceMode(){return this.options.performanceMode}getCanvasScale(){return this.options.canvasZoom/100}getConnectTargets(){return this.runtimeDATA4ConnectTargets}getConnectTargetById(o){if(!o)throw new Error("[getConnectTargetById]targetId is empty");for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++){const t=this.runtimeDATA4ConnectTargets[e];if(t.targetId===o)return t}}getElLineTargets(){return this.runtimeDATA4ElLineTargets}getElLineTargetById(o){return this.runtimeDATA4ElLineTargets.find(e=>e.id===o)}calcShouldRenderNodes(){const o=[];return this.graphData.nodes.forEach(e=>{e.rgShouldRender!==!1&&e.rgCalcedVisibility!==!1&&o.push(e)}),o}calcShouldRenderLines(){const o=[];return this.runtimeDATA4Links.forEach(e=>{e.rgShouldRender!==!1&&e.line.hidden!==!0&&e.rgCalcedVisibility!==!1&&o.push(e.line)}),o}calcShouldRenderFakeLines(){return this.graphData.fakeLines}findNodeByXy(o){const e=this.graphData.nodes;for(let t=e.length-1;t>=0;t--){const n=e[t],i=n.x,a=n.y,r=n.el_W||n.width||50,l=n.el_H||n.height||50;if(o.x>i&&o.x<i+r&&o.y>a&&o.y<a+l)return n}return null}}class Mn{constructor(){N(this,"map");this.map=new Map}_key(o,e){return o<=e?`${o}${e}`:`${e}${o}`}addEdge(o,e){const t=this._key(o,e),n=this.map.get(t)||0;return this.map.set(t,n+1),n}getCount(o,e){const t=this._key(o,e);return this.map.get(t)||0}clear(){this.map.clear()}}class Pe extends Tn{constructor(){super();N(this,"commits");N(this,"updateViewHook",e=>{});this.options=Oe({}),this.commits=this.resetCommints()}clearReactiveData(){this.graphData.nodes=[],this.graphData.normalLines=[],this.graphData.fakeLines=[],this.runtimeDATA4Links.splice(0,this.runtimeDATA4Links.length),this.runtimeDATA4ElLineTargets.splice(0,this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4ConnectTargets.splice(0,this.runtimeDATA4ElLineTargets.length),this.runtimeDATA4NodeMap.clear(),this.runtimeDATA4LinkMap.clear(),this.graphData.rootNode=void 0,this.updateShouldRenderGraphData(),this.commits.optionsChanged=!0,this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}resetCommints(){return{optionsChanged:!1,changedNodes:[],nodesListChanged:!1,changedLines:[],linesListChanged:!1,changedFakeLines:[],fakeLinesListChanged:!1,changedConnectTargets:[],connectTargetsListChanged:!1}}commitLine(e){this.commits.linesListChanged=!0}commitNode(e){this.commits.changedNodes.includes(e)||this.commits.changedNodes.push(e),this.commits.linesListChanged=!0,this.commits.fakeLinesListChanged=!0}commitFakeLine(e){this.commits.fakeLinesListChanged=!0}commitConnectTarget(e){this.commits.changedConnectTargets.includes(e)||this.commits.changedConnectTargets.push(e),this.commits.fakeLinesListChanged=!0}dataUpdated(){const e=this.commits;this.commits=this.resetCommints(),this.updateViewHook(e)}updateOptions(e){if(e.layout&&console.warn("RGDataProvider:updateOptions:layout:",e.layout),Object.assign(this.options,e),this.isPerformanceMode()&&!this.options.showEasyView){const t=Object.keys(e);console.log("changedKeys:",t.join(",")),t.includes("canvasZoom")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),t.includes("viewSize")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0),t.includes("canvasOffset")&&(this.commits.nodesListChanged=!0,this.commits.linesListChanged=!0)}this.commits.optionsChanged=!0}clearChecked(){this.updateOptions({checkedNodeId:"",checkedLineId:""})}setCanvasOffset(e,t){this.updateOptions({canvasOffset:{x:e,y:t}}),this.commits.optionsChanged=!0}setCanvasZoom(e){this.updateOptions({canvasZoom:e})}setEditingLine(e){if(e){const t=this.getLineById(e.id)||this.getFakeLineById(e.id);t&&this.updateOptions({editingLineController:{...this.options.editingLineController,line:t,show:!0},checkedLineId:e.id})}else this.updateOptions({editingLineController:{...this.options.editingLineController,line:null,show:!1},checkedLineId:""})}setEditingNodes(e){for(const n of e)if(!n||!this.getNodeById(n.id)){console.error("setEditingNodes Error: node not found:",n);return}this.getNodes().filter(n=>n.selected).forEach(n=>this.updateNode(n.id,{selected:!1})),this.updateOptions({editingController:{...this.options.editingController,nodes:e,show:e.length>0}}),e.length>1&&this.options.editingController.nodes.forEach(n=>this.updateNode(n.id,{selected:!0}))}setCanvasCenter(e,t){const n=this.options.viewSize.width/2,i=this.options.viewSize.height/2,a=this.options.canvasZoom/100;this.setCanvasOffset(n-e*a,i-t*a)}removeNodeById(e){this.beforeNodeBeRemove(e),C("Removed Node line/connect-arget\uFF1A",e);let t=0;for(let n=0;n<this.graphData.nodes.length;n++)e.includes(this.graphData.nodes[n].id)&&(this.graphData.nodes.splice(n,1),t++);for(const n of e)this.runtimeDATA4NodeMap.delete(n);C("Removed node\uFF1A",e,t),this.commits.nodesListChanged=!0}removeLineByIds(e){C("_removeLineByIds:",e.length,e),this.removeFakeLineByIds(e);let t=0;for(let n=0;n<this.graphData.normalLines.length;n++){const i=this.graphData.normalLines[n];e.includes(i.id)&&(this.graphData.normalLines.splice(n,1),n--,t++)}C("_removeLineByIds:",t),this.removeLinkByLineIds(e),this.updateLinks(),this.commits.linesListChanged=!0}removeFakeLineByIds(e){C("_removeFakeLineByIds:",e.length,e);let t=0;for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];e.includes(i.id)&&(this.graphData.fakeLines.splice(n,1),n--,t++)}this.commits.fakeLinesListChanged=!0,C("_removeFakeLineByIds:",t)}removeLinkByLineIds(e){C("_removeLinkByLineIds:",e.length,e);let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];e.includes(i.lineId)&&(this.runtimeDATA4Links.splice(n,1),this.runtimeDATA4LinkMap.delete(i.lineId),n--,t++)}this.commits.fakeLinesListChanged=!0,C("_removeLinkByLineIds:",t)}removeConnectTarget(e){const t=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===e);if(t!==-1){const n=this.runtimeDATA4ConnectTargets[t];(n.targetType===B.NodePoint||n.targetType===B.CanvasPoint)&&this.runtimeDATA4ConnectTargets.splice(t,1)}this.commits.connectTargetsListChanged=!0}updateLinks(e=[]){const t=new Mn;for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.addEdge(i,a);r!==n.currentLineIndex&&(n.currentLineIndex=r,this.commitLine(n.lineId))}for(const n of this.runtimeDATA4Links){const{from:i,to:a}=n.line,r=t.getCount(i,a);r!==n.totalLinesBetweenNodes&&(n.totalLinesBetweenNodes=r,this.commitLine(n.lineId))}t.clear()}beforeNodeBeRemove(e){let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const i=this.runtimeDATA4Links[n];(e.includes(i.fromNode.id)||e.includes(i.toNode.id))&&(this.removeLinkByLineIds([i.lineId]),n--,t++)}C("Removed Node link\uFF1A",e,t);for(let n=0;n<this.graphData.fakeLines.length;n++){const i=this.graphData.fakeLines[n];let a=!1;if(i.fromType===B.Node&&e.includes(i.from))a=!0;else if(i.fromType===B.CanvasPoint||i.fromType===B.NodePoint){const r=this.getConnectTargetById(i.from);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}else if(i.toType===B.CanvasPoint||i.toType===B.NodePoint){const r=this.getConnectTargetById(i.to);r&&r.nodeId&&e.includes(r.nodeId)&&(a=!0)}a&&(this.graphData.fakeLines.splice(n,1),n--,this.commits.fakeLinesListChanged=!0)}for(let n=0;n<this.runtimeDATA4ConnectTargets.length;n++){const i=this.runtimeDATA4ConnectTargets[n];i.nodeId&&e.includes(i.nodeId)&&(this.runtimeDATA4ConnectTargets.splice(n,1),this.commitConnectTarget(i.targetId),n--)}}addFakeLines(e){for(const t of e)if(t.id||console.warn("Must have id for fake line:",t),this.graphData.fakeLines.some(n=>n.id===t.id))console.error("Ignore duplicate fake line id:",t.id);else{t.isFakeLine=!0;const n=he(t,this.options);n.forDisplayOnly=!0,n.id||(n.id=Be(6)),this.graphData.fakeLines.push(n)}this.commits.fakeLinesListChanged=!0}clearFakeLines(){this.graphData.fakeLines.splice(0,this.graphData.fakeLines.length),this.commits.fakeLinesListChanged=!0}addNodes(e){for(const t of e)this.runtimeDATA4NodeMap.set(t.id,t);this.graphData.nodes.push(...e.map(t=>this.runtimeDATA4NodeMap.get(t.id))),this.commits.nodesListChanged=!0}addLines(e){this.graphData.normalLines.push(...e);const t=[];for(const n of e){const i=this.getNodeById(n.from),a=this.getNodeById(n.to),r={lineId:n.id,line:n,fromNode:i,toNode:a,currentLineIndex:0,totalLinesBetweenNodes:1,rgShouldRender:!0,rgCalcedVisibility:!0};this.runtimeDATA4LinkMap.set(r.lineId,r),t.push(r)}this.runtimeDATA4Links.push(...t.map(n=>this.runtimeDATA4LinkMap.get(n.lineId))),this.updateLinks(),this.commits.linesListChanged=!0}updateNode(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e,t);return}const i=t.hidden!==void 0&&n.hidden!==t.hidden;if(Object.assign(n,t,{id:e}),i){const a=z.getDescendantNodes(n);this.updateNodesVisibleProperty([n].concat(a))}this.commitNode(e)}updateNodeData(e,t){const n=this.getNodeById(e);if(!n){console.error("Cannot find node to update:",e);return}this.updateNode(e,{data:Object.assign(n.data||{},t)})}updateLine(e,t){const n=this.getLineById(e);if(!n){this.updateFakeLine(e,t);return}const i=t.hidden!==void 0&&n.hidden!==t.hidden;if(Object.assign(n,t,{id:e}),i){const a=this.getLinkByLineId(e);a&&(a.rgCalcedVisibility=this.calcLinkVisibility(a))}this.commitLine(e)}updateLineData(e,t){const n=this.getLineById(e);if(!n){console.error("Cannot find line to update:",e);return}this.updateLine(e,{data:Object.assign(n.data||{},t)})}updateFakeLine(e,t){const n=this.getFakeLineById(e);if(!n){console.error("Cannot find fakeLine to update:",e,t);return}Object.assign(n,t,{id:e}),this.commitFakeLine(e)}updateConnectTarget(e,t){const n=this.getConnectTargetById(e);!n||(Object.assign(n,t,{targetId:e}),this.commitConnectTarget(e))}updateElLineTarget(e,t){const n=this.getElLineTargetById(e);!n||Object.assign(n,t,{id:e})}updateNodesVisibleProperty(e){let t=!1;e||(e=this.getNodes(),t=!0);for(const n of e){const i=z.isVisibleNode(n);n.rgCalcedVisibility!==i&&(n.rgCalcedVisibility=i,this.commitNode(n.id))}for(const n of this.runtimeDATA4Links)if(t||e.includes(n.fromNode)||e.includes(n.toNode)){const a=this.calcLinkVisibility(n);n.rgCalcedVisibility=a,n.line.hidden=!a,this.commitLine(n.lineId)}}calcLinkVisibility(e){return e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility}updateShouldRenderGraphData(){const e=this.options,t=e.canvasZoom/100,n={x:-e.canvasOffset.x/t,y:-e.canvasOffset.y/t},i={x:n.x+e.viewSize.width/t,y:n.y+e.viewSize.height/t},a=e.snapshotting;for(const r of this.getNodes()){let l=!0;a||r.alwaysRender?l=!0:((r.x>i.x||r.y>i.y)&&(l=!1),(r.x+r.el_W<n.x||r.y+r.el_H<n.y)&&(l=!1)),r.rgShouldRender=l}for(const r of this.runtimeDATA4Links){if(a){r.rgShouldRender=!0;continue}r.rgShouldRender=r.fromNode.rgShouldRender||r.toNode.rgShouldRender}this.options.showEasyView?(this.runtimeDATA4ShouldRenderItems.nodes=[],this.runtimeDATA4ShouldRenderItems.lines=[],this.runtimeDATA4ShouldRenderItems.fakeLines=[]):(this.runtimeDATA4ShouldRenderItems.nodes=this.calcShouldRenderNodes(),this.runtimeDATA4ShouldRenderItems.lines=this.calcShouldRenderLines(),this.runtimeDATA4ShouldRenderItems.fakeLines=this.calcShouldRenderFakeLines())}addConnectTarget(e){return this.runtimeDATA4ConnectTargets.push(e),this.commits.connectTargetsListChanged=!0,this.commits.fakeLinesListChanged=!0,this.getConnectTargetById(e.targetId)}addElLineTarget(e){this.runtimeDATA4ElLineTargets.push(e),this.commits.fakeLinesListChanged=!0}setRootNodeId(e){if(this.graphData.rootNode=this.graphData.nodes.find(t=>t.id===e),!this.graphData.rootNode)throw new Error("The root node [rootId] is not set! Or cannot get the root node:"+e+", If you don't have any nodes to display, you can simply set an invisible node: {id:'root', opacity:0}")}}class kn{constructor(){N(this,"listeners");N(this,"useReactiveDataToAutoUpdateView",!1);N(this,"instanceId");N(this,"dataProvider");N(this,"options");N(this,"_dataUpdatedRequested",!1);N(this,"eventHandlers",[]);N(this,"_emitHook");this.dataProvider=new Pe,this.options=this.dataProvider.getOptions(),this.listeners={},this.instanceId="RG-"+this.generateNewUUID(5)}generateNewUUID(o=5){return Be(o)}enableDebugLog(o){this.dataProvider.updateOptions({debug:o}),window&&(window.relationGraphDebug=o)}_dataUpdated(){this._requestDataUpdate()}_requestDataUpdate(){!window||!window.requestAnimationFrame||this._dataUpdatedRequested||(this._dataUpdatedRequested=!0,requestAnimationFrame(this._doSomethingAfterDataUpdated.bind(this)))}_doSomethingAfterDataUpdated(){try{!this.useReactiveDataToAutoUpdateView||this.dataProvider.isPerformanceMode()?(this._previousUpdateTime=Date.now(),this.updateShouldRenderGraphData(),this.updateEasyView(),this.dataProvider&&this.dataProvider.dataUpdated()):this.updateMiniView()}catch(o){console.error("[relation-graph]Error:",o)}finally{this._dataUpdatedRequested=!1}}addEventHandler(o){this.eventHandlers.includes(o)||this.eventHandlers.push(o)}removeEventHandler(o){const e=this.eventHandlers.indexOf(o);e!==-1&&this.eventHandlers.splice(e,1)}setEventEmitHook(o){this._emitHook=o,console.warn("[setEventEmitHook]",this._emitHook)}emitEvent(o,...e){let{result:t,handled:n}=this.defaultEventHandler(o,...e);for(const i of this.eventHandlers){const a=i(o,...e);a!==void 0&&(t=a,n=!0)}if(n||this._emitHook&&this._emitHook(o,...e,i=>{i!==void 0&&(t=i)}),t!==void 0)return C("[custom event hook]Event:",o," => returnValue:",t),t}defaultEventHandler(o,...e){let t,n=!1;if(o===A.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(o===A.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(e[0],e[1]));else if(o===A.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3],c=e[4],d=e[5];t=this.listeners.onNodeDragging(i,a,r,l,c,d)}}else if(o===A.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const i=e[0],a=e[1],r=e[2],l=e[3];t=this.listeners.onCanvasDragging(i,a,r,l)}}else if(o===A.onNodeDragEnd){const i=e[0],a=e[1],r=e[2],l=e[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(i,a,r,l))}else if(o===A.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(o===A.onNodeClick){if(this.listeners.onNodeClick){n=!0;const i=e[0],a=e[1];this.listeners.onNodeClick(i,a)}}else if(o===A.onLineClick){if(this.listeners.onLineClick){n=!0;const i=e[0],a=e[1],r=e[2];this.listeners.onLineClick(i,a,r)}}else if(o===A.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const i=e[0],a=e[1];this.listeners.onNodeExpand(i,a)}}else if(o===A.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const i=e[0],a=e[1];this.listeners.onNodeCollapse(i,a)}}else if(o===A.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const i=e[0];this.listeners.onCanvasDragEnd(i)}}else if(o===A.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const i=e[0];this.listeners.onCanvasClick(i)}}else if(o===A.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const i=e[0],a=e[1];this.listeners.onCanvasSelectionEnd(i,a)}}else if(o===A.onContextmenu){if(this.listeners.onContextmenu){n=!0;const i=e[0],a=e[1],r=e[2];this.listeners.onContextmenu(i,a,r)}}else if(o===A.onFullscreen){if(this.listeners.onFullscreen){n=!0;const i=e[0],a=e[1];t=this.listeners.onFullscreen(i,a)}}else if(o===A.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const i=e[0];t=this.listeners.beforeAddNodes(i)}}else if(o===A.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const i=e[0];t=this.listeners.beforeAddLines(i)}}else if(o===A.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const i=e[0];t=this.listeners.onKeyboardDown(i)}}else if(o===A.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const i=e[0];t=this.listeners.onKeyboardUp(i)}}else if(o===A.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const i=e[0];t=this.listeners.onLineBeCreated(i)}}else if(o===A.onCanvasDragStart&&this.listeners.onCanvasDragStart){n=!0;const i=e[0],a=e[1],r=e[2];t=this.listeners.onCanvasDragStart(i,a,r)}return{result:t,handled:n}}setEventListener(o){Object.assign(this.listeners,o)}}class In extends kn{constructor(){super(...arguments);N(this,"$dom");N(this,"$canvasDom");N(this,"_rgAsConnectArea",!1);N(this,"$lineTextContainer4NormalLine");N(this,"$lineTextContainer4FakeLine")}getLineTextContainer(e){if(!(!e||!this.$canvasDom))return e.isFakeLine?(this.$lineTextContainer4NormalLine||(this.$lineTextContainer4NormalLine=this.$canvasDom.querySelector(".rg-lines-container-el-lines .rg-linetext-container")),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container")),this.$lineTextContainer4FakeLine)}getViewBoundingClientRect(){var e;return this.$dom?(e=this.$dom)==null?void 0:e.getBoundingClientRect():(console.error("[getViewBoundingClientRect] RelationGraph DOM is not set yet!"),null)}getBoundingClientRect(){return console.warn("Please use getViewBoundingClientRect instead of getBoundingClientRect, this method is compatible with older api versions."),this.getViewBoundingClientRect()}_getEventPoint(e){return this.getViewXyByEvent(e)}getViewXyByEvent(e){const t={x:e.clientX,y:e.clientY};if(ce(e)){const i=e.touches||e.targetTouches;if(!i)throw new Error("error targetTouches");t.x=i[0].clientX,t.x=i[0].clientY}const n=this.getViewBoundingClientRect();return{x:t.x-n.x,y:t.y-n.y}}getCanvasXyByClientXy(e){const t=this.getViewBoundingClientRect(),n={x:e.x-t.left,y:e.y-t.top};return this.getCanvasXyByViewXy(n)}getCanvasXyByViewXy(e){if(this._rgAsConnectArea)return e;const t=this.dataProvider.getOptions(),n=t.canvasZoom/100,i={x:e.x-t.canvasOffset.x,y:e.y-t.canvasOffset.y};return{x:i.x/n,y:i.y/n}}getViewXyByCanvasXy(e){const t=this.dataProvider.getOptions(),n=t.canvasZoom/100;return{x:e.x*n+t.canvasOffset.x,y:e.y*n+t.canvasOffset.y}}getCanvasCoordinateByClientCoordinate(e){return console.warn("Please use getCanvasXyByClientXy instead of getCanvasCoordinateByClientCoordinate, this method is compatible with older api versions."),this.getCanvasXyByClientXy(e)}isNode(e){const t=Le(e,"rg-node-peel","rg-map");if(!!t)return this.dataProvider.getNodeById(t.dataset.id)}isLine(e){const t=Le(e,"rg-line-peel","relation-graph");if(!!t)return this.dataProvider.getLineById(t.dataset.id)}isLink(e){throw new Error("Please use isLine")}}class En extends Pe{constructor(e,t,n,i){super();N(this,"dataStores");this.dataStores=e;const a=Object.assign({},this.options,n);this.options=n,Object.assign(this.options,a),this.graphData=t,this.runtimeDATA4Links=i.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=i.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=i.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=i.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=i.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=i.runtimeDATA4ElLineTargets,this.updateViewHook=r=>{if(console.log("###########updateViewHook"),r.optionsChanged&&(this.dataStores.store4Options.set(this.getOptions()),console.log("[updateViewHook]optionsChanged")),r.nodesListChanged&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),r.linesListChanged){const l=this.getShouldRenderLines();this.dataStores.store4ShouldRenderLines.set(l),console.log("[updateViewHook]linesListChanged")}if(r.fakeLinesListChanged){const l=this.getShouldRenderFakeLines();this.dataStores.store4ShouldRenderFakeLines.set(l),console.log("[updateViewHook]fakeLinesListChanged")}}}}class Dn extends Pe{constructor(o,e,t){super(),this.graphData=o,this.runtimeDATA4Links=t.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=t.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=t.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=t.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=t.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=t.runtimeDATA4ElLineTargets;const n=Object.assign({},this.options,e);this.options=e,Object.assign(this.options,n)}}class An extends Pe{constructor(e,t){super();N(this,"dataStores");this.dataStores=e,this.updateViewHook=n=>{n.optionsChanged&&this.dataStores.store4Options.set(this.getOptions()),(n.nodesListChanged||n.changedNodes.length>0)&&(this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),console.log("[updateViewHook]nodesListChanged")),(n.linesListChanged||n.changedLines.length>0)&&(this.dataStores.store4ShouldRenderLines.set(this.getShouldRenderLines()),console.log("[updateViewHook]linesListChanged")),(n.fakeLinesListChanged||n.changedFakeLines.length>0)&&this.dataStores.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()])}}}class Vn extends Pe{constructor(o,e){super(),e(),this.updateViewHook=t=>{if(t.optionsChanged&&o.store4Options.set(this.getOptions()),t.nodesListChanged||t.changedNodes.length>0){const n=this.getShouldRenderNodes();o.store4ShouldRenderNodes.set([...n])}if(t.linesListChanged||t.changedLines.length>0){const n=this.getShouldRenderLines();o.store4ShouldRenderLines.set(n)}t.fakeLinesListChanged?o.store4ShouldRenderFakeLines.set(this.getShouldRenderFakeLines()):t.changedFakeLines.length>0&&o.store4ShouldRenderFakeLines.set(this.getShouldRenderFakeLines())}}}class Xn extends In{constructor(){super();N(this,"_initRawPropertyFn",(e,t,n)=>{});N(this,"dataStores")}setReactiveData4Vue2(e,t,n,i){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new Dn(e,t,n),this._initRawPropertyFn=i,this.options=this.dataProvider.options,this.dataStores={shouldRenderNodesStore:n.runtimeDATA4ShouldRenderItems.nodes,shouldRenderLinesStore:n.runtimeDATA4ShouldRenderItems.lines,shouldRenderFakeLinesStore:n.runtimeDATA4ShouldRenderItems.fakeLines}}setReactiveData4Vue3(e,t,n,i,a){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new En(e,t,n,i),this._initRawPropertyFn=a,this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines,optionsRef:e.optionsRef,shouldRenderNodesRef:e.shouldRenderNodesRef,shouldRenderLinesRef:e.shouldRenderLinesRef,shouldRenderFakeLinesRef:e.shouldRenderFakeLinesRef},console.error("[RelationGraphWith2Data] setReactiveData4Vue3:",this.options)}setReactiveData4React(e,t){this.dataProvider=new Vn(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines}}setReactiveData4Svelte(e,t){this.dataProvider=new An(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines},console.log("[RelationGraphWith2Data] setReactiveData4Svelte:",this.options)}generateNewNodeId(e=5){const t=Be(e);return this.dataProvider.getNodeById(t)?this.generateNewNodeId(e+1):t}}class zn extends Xn{constructor(){super()}getOptions(){return this.dataProvider.getOptions()}getNodeById(o){return this.dataProvider.getNodeById(o)}getLineById(o){return this.dataProvider.getLineById(o)}getLinkByLineId(o){return this.dataProvider.getLinkByLineId(o)}getLinkByLine(o){return this.getLinkByLineId(o.id)}getLines(){return this.dataProvider.getLines()}getElementLineById(o){return this.getFakeLineById(o)}getElementLines(){return this.getFakeLines()}getFakeLines(){return this.dataProvider.getFakeLines()}getFakeLineById(o){return this.dataProvider.getFakeLineById(o)}getNodes(){return this.dataProvider.getNodes()}getLinks(){return this.dataProvider.getLinks()}getConnectTargets(){return this.dataProvider.getConnectTargets()}}class Bn extends zn{constructor(){super()}getRelatedLinesByNode(o){const e=[];for(const t of this.getLinks())(o===t.fromNode||o===t.toNode)&&e.push(t.line);return e}getLinksBetweenNodes(o){const e=[],t=this.getLinks();for(const n of t)o.includes(n.fromNode)&&o.includes(n.toNode)&&e.push(n);return e}getLinesBetweenNodes(o){return this.getLinksBetweenNodes(o).map(e=>e.line)}getNodeRelatedNodes(o){const e=[];for(const t of this.getLinks())t.line.forDisplayOnly||(t.fromNode===o?e.includes(t.toNode)||e.push(t.toNode):t.toNode===o&&(e.includes(t.fromNode)||e.push(t.fromNode)));return e}getNodeIncomingNodes(o){const e=[];for(const t of this.getLinks())t.line.forDisplayOnly||t.toNode===o&&(e.includes(t.fromNode)||e.push(t.fromNode));return e}getNodeOutgoingNodes(o){const e=[];for(const t of this.getLinks())t.line.forDisplayOnly||t.fromNode===o&&(e.includes(t.toNode)||e.push(t.toNode));return e}findGroupNodes(o,e=[]){return this._getNetworkNodesByNode(o,e)}getGroupNodesByNode(o,e=[]){return this._getNetworkNodesByNode(o,e)}getNetworkNodesByNode(o){return this._getNetworkNodesByNode(o)}_getNetworkNodesByNode(o,e=[]){if(!o)throw new Error("Call graphInstance.getNetworkNodesByNode:error: node is undefined");e.includes(o)||e.push(o);for(const t of this.getNodeRelatedNodes(o))e.includes(t)||this._getNetworkNodesByNode(t,e);return e}getStuffSize(o){return console.warn("Please use getNodesRectBox instead of getStuffSize, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesViewInfo(o){return console.warn("Please use getNodesRectBox instead of getNodesViewInfo, this method is compatible with older api versions."),this.getNodesRectBox(o)}getNodesRectBox(o){const t=(o||this.getNodes()).filter(d=>d.rgCalcedVisibility!==!1);if(t.length===0)return{width:10,height:10,minX:0,minY:0,maxX:0,maxY:0};let n=9999999,i=9999999,a=-9999999,r=-9999999;t.forEach(d=>{d.x<n&&(n=d.x),d.x+d.el_W>a&&(a=d.x+d.el_W),d.y<i&&(i=d.y);const f=d.y+d.el_H;f>r&&(r=f)});const l=a-n,c=r-i;return{width:l<0?0:l,height:c<0?0:c,minX:n===9999999?0:n,minY:i===9999999?0:i,maxX:a===-9999999?0:a,maxY:r===-9999999?0:r}}getNodesCenter(o){const e=this.getNodesRectBox(o);C("getNodesCenter:",e);const t=e.minX+(e.maxX-e.minX)/2,n=e.minY+(e.maxY-e.minY)/2;return{x:t,y:n}}getDescendantNodes(o){return z.getDescendantNodes(o)}getNodesInSelectionView(o){const e=this.getCanvasXyByViewXy({x:o.x,y:o.y}),t=this.getCanvasXyByViewXy({x:o.x+o.width,y:o.y+o.height}),n=[];return this.getNodes().forEach(i=>{const a=i.x+i.el_W/2,r=i.y+i.el_H/2;a>e.x&&r>e.y&&a<t.x&&r<t.y&&n.push(i)}),n}getShouldRenderNodes(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderNodes()}getShouldRenderLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderLines()}getShouldRenderFakeLines(o){return this.dataProvider.isPerformanceMode()&&o?o:this.dataProvider.getShouldRenderFakeLines()}}class Gn extends Bn{constructor(){super();N(this,"_elLineUpdateTimer");N(this,"_canvasCurrentInfo",{x:0,y:0,scale:1});N(this,"_nodeResizeEffectTimer");N(this,"prevAddNodeTimestamp",0)}removeLine(e){this.removeLines([e])}removeLines(e){this.removeLineByIds(e.map(t=>t.id))}removeLineById(e){this.removeLineByIds([e])}removeLineByIds(e){this.dataProvider.removeLineByIds(e),this._dataUpdated()}removeFakeLine(e){this.removeFakeLineById(e.id)}removeFakeLineById(e){C("removeLineById:",e),this.dataProvider.removeFakeLineByIds([e]),this._dataUpdated()}removeLink(e){C("removeLink:",e),this.removeLinkByLineId(e.lineId)}removeLinkByLineId(e){this.dataProvider.removeLineByIds([e]),this._dataUpdated()}removeNodeById(e){this.dataProvider.removeNodeById([e]),this._dataUpdated()}removeNodesByIds(e){e.forEach(t=>this.dataProvider.removeNodeById(e)),this._dataUpdated()}removeNodes(e){this.dataProvider.removeNodeById(e.map(t=>t.id)),this._dataUpdated()}removeNode(e){this.dataProvider.removeNodeById([e.id]),this._dataUpdated()}removeELementLineById(e){C("removeELementLineById:",e),this.removeFakeLineById(e)}addNode(e){if(C("addNode:",e),e&&Array.isArray(e)){console.error("addNode: node is array:",e);return}this._addNodes([e]),this._dataUpdated()}addNodes(e){if(C("addNodes:",e),e&&!Array.isArray(e)){console.error("addNodes: nodes is not array:",e);return}this._addNodes(e),this._dataUpdated()}addLine(e){if(C("addLine:",e),e&&Array.isArray(e)){console.error("addLine: line is array:",e);return}this.addLines([e])}addLines(e){if(C("addLines:",e),e&&!Array.isArray(e)){console.error("addLines: lines is not array:",e);return}if(e.length===0)return;const t=e.filter(i=>!i.isFakeLine);this._addLines(t);const n=e.filter(i=>i.isFakeLine);this.addFakeLines(n),this._dataUpdated()}_addFakeLines(e){this.dataProvider.addFakeLines(e)}addFakeLines(e){C("addFakeLines:",e),this._addFakeLines(e),this._dataUpdated()}updateElementLines(){this.dataProvider.getElLineTargets().length!==0&&(C("updateElementLines:runtimeDATA4ElLineTargets:",this.dataProvider.getElLineTargets().length),this._elLineUpdateTimer&&clearTimeout(this._elLineUpdateTimer),this._elLineUpdateTimer=setTimeout(()=>{this._updateElementLines(),this._dataUpdated()},100))}_updateElementLines(){this._updateCanvasBoxInfo();for(const e of this.dataProvider.getElLineTargets())this.updateElementTarget(e)}_updateCanvasBoxInfo(){const e=this.$canvasDom.getBoundingClientRect();this._canvasCurrentInfo.x=e.x,this._canvasCurrentInfo.y=e.y,this._canvasCurrentInfo.scale=this.dataProvider.getOptions().canvasZoom/100}updateElementTarget(e){const t=this._getElementTargetPosition(document.getElementById(e.id),e);t?this.dataProvider.updateElLineTarget(e.id,{hidden:!1,...t}):this.dataProvider.updateElLineTarget(e.id,{hidden:!0})}_getElementTargetPosition(e){if(!e)return null;const t=e.getBoundingClientRect(),n=(t.x-this._canvasCurrentInfo.x)/this._canvasCurrentInfo.scale,i=(t.y-this._canvasCurrentInfo.y)/this._canvasCurrentInfo.scale,a=t.width/this._canvasCurrentInfo.scale,r=t.height/this._canvasCurrentInfo.scale;return{x:n,y:i,el_W:a,el_H:r}}addElementLines(e){C("addElementLines:",e),e.forEach(t=>{t.fromType=B.HTMLElementId,t.toType=B.HTMLElementId,t.isFakeLine=!0,t.id||(t.id=this.generateNewUUID(6)),t.forDisplayOnly=!0}),this.addFakeLines(e),console.log("addElementLines:",e.length,e),this.updateElementLines()}updateNodeOffsetSize(e,t,n){const i=this.getNodeById(e);if(!i)return;const a=i.el_W,r=i.el_H;(a!==t||r!==n)&&(this.dataProvider.updateNode(e,{el_W:t,el_H:n}),this._nodeResizeEffectTimer&&clearTimeout(this._nodeResizeEffectTimer),this._nodeResizeEffectTimer=setTimeout(()=>{this._dataUpdated()},100))}clearFakeLines(){this.dataProvider.clearFakeLines(),this._dataUpdated()}clearElementLines(){const e=[];for(const t of this.getFakeLines())(t.fromType===B.HTMLElementId||t.toType===B.HTMLElementId)&&e.push(t.id);this.dataProvider.removeFakeLineByIds(e),this._dataUpdated()}_addNodes(e){this.emitEvent(A.beforeAddNodes,e);const t={};this.getNodes().forEach(a=>{t[a.id]=a});const n=[],i=this.getOptions();e.forEach(a=>{let r=t[a.id];if(!r){let{text:l,id:c}=a;!l&&a.label&&(l=a.label,console.warn('Use "label" as "text":',a.label)),!l&&c&&(l=c,console.warn('Use "id" as "text":',c)),r=be(Object.assign({},a,{text:l}),i),this._initRawPropertyFn&&this._initRawPropertyFn(r,"lot",r.lot),r&&(t[r.id]=r,n.push(r))}}),this.dataProvider.addNodes(n),n.length>0&&(this.prevAddNodeTimestamp=Date.now())}_addLines(e){this.emitEvent(A.beforeAddLines,e);const t=[];e.forEach(n=>{let{from:i,to:a,text:r}=n;if(!i)if(n.source)i=n.source,console.warn('Use "source" as "from":',n.source);else{console.error('JsonLine Must have field:"from"',n);return}if(!a)if(n.target)a=n.target,console.warn('Use "target" as "to":',n.target);else{console.error('JsonLine Must have field:"to"',n);return}if(r||n.label&&(r=n.label,console.warn('Use "label" as "text":',n.label)),!this.getNodeById(i)){console.error("Can not found from node:",n);return}if(!this.getNodeById(a)){console.error("Can not found to node:",n);return}if(n.id){if(this.getLineById(n.id)){console.warn("_addLines:skip duplicate line id:",n.id);return}else if(t.some(f=>f.id===n.id)){console.warn("Duplicate line id in new lines:",n.id);return}}else n.id="L-"+this.generateNewUUID(6);const d=he(Object.assign({},n,{from:i,to:a,text:r}),this.getOptions());t.push(d)}),this.dataProvider.addLines(t)}updateNode(e,t){this.dataProvider.updateNode(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateNodePosition(e,t,n){this.dataProvider.updateNode(typeof e=="string"?e:e.id,{x:t,y:n}),this._dataUpdated()}updateNodeData(e,t){this.dataProvider.updateNodeData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLine(e,t){this.dataProvider.updateLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateLineData(e,t){this.dataProvider.updateLineData(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateFakeLine(e,t){this.dataProvider.updateFakeLine(typeof e=="string"?e:e.id,t),this._dataUpdated()}flatNodeData(e,t,n,i){z.flatNodeData(e,t,n,i)}loadGraphJsonData(e){e.lines||(e.lines=e.relations,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.relations as jsonData.lines, It is recommended that you define your data using")),e.lines||(e.lines=e.links||e.edges,e.lines&&console.warn("[relation-graph] For compatibility with older version, Use jsonData.links/jsonData.edges as jsonData.lines, It is recommended that you define your data using"));const t=e.nodes||[],n=e.lines||[],i=[],a=[];this.flatNodeData(t,null,i,a),n.forEach(r=>{a.push(r)}),this._addNodes(i),C("Nodes is initialized"),this._addLines(a),this._dataUpdated(),setTimeout(()=>{e.elementLines&&(console.warn("elementLines is deprecated, please use fakeLines with isFakeLine and fromType/toType = RGInnerConnectTargetType.HTMLElementId instead:",e.elementLines),this.addElementLines(e.elementLines)),e.fakeLines&&this.addFakeLines(e.fakeLines),this._dataUpdated()},500)}updateShouldRenderGraphData(e=!1){!e&&!this.dataProvider.isPerformanceMode()||this.dataProvider.updateShouldRenderGraphData()}updateNodesVisibleProperty(e){this.dataProvider.updateNodesVisibleProperty(e)}updateVisibleNodesSize(){for(const e of this.getShouldRenderNodes()){const t=this.getNodeElByNodeId(e.id);t&&this._onNodeDomResize(t,t.clientWidth,t.clientHeight)}}_clearGraph(){this.dataProvider.clearReactiveData(),this.dataProvider.clearChecked(),this.dataProvider.setEditingLine(null),this.dataProvider.setEditingNodes([])}_setJsonData(e,t=!1){this._clearGraph(),C("set jsonData:",e),this.loadGraphJsonData(e)}}class Fn extends Gn{constructor(){super();N(this,"canvasConnectTargetsMap",new Map);N(this,"nodeConnectTargetsMap",new Map);N(this,"connectTargetElementMap",new Map);N(this,"_connectTargetUpdateRequestedSet",new Map);N(this,"_updateTimer");N(this,"_removedConnectTargetMap",new Map)}updateConnectTargetsOnCanvas(e,t){if(!t)return;console.warn(`updateConnectTargetsOnCanvas:[${e}]:`);const n=t.classList.contains("rg-canvas-slot-above")?"above":"behind",i=this.canvasConnectTargetsMap.get(n);i&&i.length>0&&this.updateConnectTargetList(e,t,i)}updateConnectTargetsByNodeId(e){const t=this.getNodeElByNodeId(e);this.updateConnectTargetsOnNode("API",e,t)}getNodeElByNodeId(e){return this.$dom.querySelector(`[data-id="${e}"]`)}updateConnectTargetsOnNode(e,t,n){const i=this.nodeConnectTargetsMap.get(t)||[];i.length!==0&&this.updateConnectTargetList(e,n,i)}updateConnectTargetList(e,t,n){const i=this.dataProvider.getCanvasScale();for(const a of n){const r=this.connectTargetElementMap.get(a.targetId);if(!r){console.error("Can not find el for connectTarget:",a.targetId,a);continue}this._requestUpdateConnectTargetOffset(e,a,r,t,i)}}_requestUpdateConnectTargetOffset(e,t,n,i,a){this._connectTargetUpdateRequestedSet.set(t.targetId,{stableTimes:0,connectTarget:t,by:e,connectTargetEl:n,relativeEl:i}),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(this._connectTargetUpdateRequestedSet.size+10,50))}_updateAllRequestedConnectTargetOffsets(){let e=0,t=0;for(const n of this._connectTargetUpdateRequestedSet.values()){const{by:i,connectTargetEl:a,relativeEl:r,connectTarget:l}=n;if(this.dataProvider.isPerformanceMode()&&l.nodeId){const h=this.getNodeById(l.nodeId);if(!h||!h.rgShouldRender||!h.rgCalcedVisibility){t++;continue}}const c=this.dataProvider.getCanvasScale();this._updateConnectTargetOffset(i,l,a,r,c)?e++:n.stableTimes++,n.stableTimes>2&&this._connectTargetUpdateRequestedSet.delete(l.targetId)}e>0?(console.warn(`_updateAllRequestedConnectTargetOffsets: ${e} of ${this._connectTargetUpdateRequestedSet.size} changed, ${t} Skipped!`),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(e/2+10,50)),this._dataUpdated()):(console.warn("_updateAllRequestedConnectTargetOffsets:::::::OK",this._connectTargetUpdateRequestedSet.size),this._connectTargetUpdateRequestedSet.clear(),this._dataUpdated())}_updateConnectTargetOffset(e,t,n,i,a){const r=i.getBoundingClientRect(),l=n.getBoundingClientRect(),c=Math.round(l.x-r.x),d=Math.round(l.y-r.y),h=this.dataProvider.getCanvasScale(),f=c/h,y=d/h,u=l.width/h,g=l.height/h;return t.offsetX!==f||t.offsetY!==y||t.width!==u||t.height!==g?(this.dataProvider.updateConnectTarget(t.targetId,{offsetX:f,offsetY:y,width:l.width/h,height:l.height/h}),console.warn("#######ConnectTargetOffset Changed!",t.targetId,t.offsetX,t.offsetY),!0):(console.warn("#######ConnectTargetOffset Not changed!",t.targetId,t.offsetX,t.offsetY),!1)}_onConnectTargetMounted(e,t,n,i){const a=this.dataProvider.getCanvasScale();this._requestUpdateConnectTargetOffset(e,t,n,i,a)}getNodeElByChildrenTarget(e){return Le(e,"rg-node-peel","rg-map")}registerConnectTarget(e,t,n,i,a={}){if(n!==B.NodePoint&&n!==B.CanvasPoint)return;if(!e){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${t}`);return}const r=this.getNodeElByChildrenTarget(e),l=r==null?void 0:r.dataset.id;if(l==="rg-newNodeTemplate")return;let c=this.dataProvider.getConnectTargetById(t);if(!c){const h={targetId:t,targetType:n,junctionPoint:i,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:a||{}};this.reuseConnectTarget(h),c=this.dataProvider.addConnectTarget(h)}return this.connectTargetElementMap.set(c.targetId,e),(l?this.getNodeById(l):null)?this._addConnectTargetToNodeMap(l,c,e,r):this._addConnectTargetToCanvasMap(c,e),c}_addConnectTargetToNodeMap(e,t,n,i){this.dataProvider.updateConnectTarget(t.targetId,{junctionPoint:t.junctionPoint,targetType:B.NodePoint,nodeId:e,targetData:Object.assign({},t.targetData||{},{nodeId:e})});let a=this.nodeConnectTargetsMap.get(e);a?a.some(r=>r.targetId===t.targetId)||a.push(t):this.nodeConnectTargetsMap.set(e,[t]),this._onConnectTargetMounted("NT-Mounted",t,n,i)}_addConnectTargetToCanvasMap(e,t){let n=Le(t,"rg-canvas-slot","rg-map");if(!n){console.error(`Can not find CanvasPoint target DOM's parent(.rg-canvas-slot) : ${e.targetId}`,t);return}if(n){const i=n.classList.contains("rg-canvas-slot-above")?"above":"behind";this.dataProvider.updateConnectTarget(e.targetId,{junctionPoint:e.junctionPoint,targetType:B.CanvasPoint,targetData:Object.assign({},e.targetData||{})});const a=this.canvasConnectTargetsMap.get(i);a?a.some(r=>r.targetId===e.targetId)||a.push(e):this.canvasConnectTargetsMap.set(i,[e]),this._onConnectTargetMounted("CT-Mounted",e,t,n)}}unregisterConnectTarget(e){const t=this.dataProvider.getConnectTargetById(e);if(!t)return;let n;if(t.nodeId&&this.nodeConnectTargetsMap.has(t.nodeId))n=this.nodeConnectTargetsMap.get(t.nodeId);else{let i=this.canvasConnectTargetsMap.get("behind").findIndex(a=>a.targetId===e);i!==-1?n=this.canvasConnectTargetsMap.get("behind"):(i=this.canvasConnectTargetsMap.get("above").findIndex(a=>a.targetId===e),i!==-1&&(n=this.canvasConnectTargetsMap.get("above")))}if(n){const i=n.findIndex(a=>a.targetId===e);i!==-1&&n.splice(i,1)}this.dataProvider.removeConnectTarget(e),this.connectTargetElementMap.delete(e),this._removedConnectTargetMap.set(t.targetId,t)}reuseConnectTarget(e){if(this._removedConnectTargetMap.has(e.targetId)){const t=this._removedConnectTargetMap.get(e.targetId);e.offsetX=t.offsetX,e.offsetY=t.offsetY,e.width=t.width,e.height=t.height,e.offsetPercentX=t.offsetPercentX,e.offsetPercentY=t.offsetPercentY,this._removedConnectTargetMap.delete(e.targetId)}}}class Yn extends Fn{constructor(){super();N(this,"fakeLineTargetRender")}generateCreatingLineConfig(e){e||(e=this.dataProvider.getOptions());const{newLinkTemplate:t,newLineTemplate:n}=e,i=t.fromNode;if(!i)return{line:n,from:null,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const a=t.toNode,r=a.targetType===B.Node?t.toNode:this.getFakeLineTarget(a.targetType,a.id,n);return{line:Object.assign({},n,{isFakeLine:!1}),from:this.getFakeLineTarget(i.targetType,i.id,n),to:r,totalLinesBetweenNodes:1,currentLineIndex:0}}generateLineConfig(e){const t=this.getLinkByLine(e);return t?{line:t.line,from:t.fromNode,to:t.toNode,totalLinesBetweenNodes:t.totalLinesBetweenNodes,currentLineIndex:t.currentLineIndex}:!1}generateFakeLineConfig(e){let t=1,n=0;if(e.fromType===B.HTMLElementId&&e.toType===B.HTMLElementId){const r=this.dataProvider.getFakeLines().filter(l=>l.from===e.from&&l.to===e.to);r.length>1&&(console.warn("sameTargetLines element-line:",e),t=r.length,n=r.indexOf(e))}let i=this.getFakeLineTarget(e.fromType,e.from,e),a=this.getFakeLineTarget(e.toType,e.to,e);return!i&&e.fromType===B.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",e.fromType,e.from,e),!1):!a&&e.fromType===B.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",e.toType,e.to,e),!1):{line:e,from:i,to:a,totalLinesBetweenNodes:t,currentLineIndex:n}}setFakeLineTargetRender(e){this.fakeLineTargetRender=e}getFakeLineTarget(e,t,n){if(e===B.HTMLElementId){let i=this.dataProvider.getElLineTargets().find(a=>a.id===t);return i||(i={x:300,y:300,targetType:B.HTMLElementId,nodeShape:1,id:t,el_W:40,el_H:40,hidden:!0},this.dataProvider.addElLineTarget(i),this.updateElementLines()),i.hidden?null:i}else{if(e===B.Node)return this.getNodeById(t);if(e===B.NodePoint||e===B.CanvasPoint){const i=this.dataProvider.getConnectTargetById(t);if(!i)return;if(i.nodeId){const a=this.getNodeById(i.nodeId);if(!a){console.error("[getFakeLineTarget]Can not find NodePoint-s Node:",`${i.targetId}@${i.nodeId}`);return}return{x:a.x+i.offsetPercentX*a.el_W+i.offsetX,y:a.y+i.offsetPercentY*a.el_H+i.offsetY,targetType:B.NodePoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}else return{x:i.offsetX,y:i.offsetY,targetType:B.CanvasPoint,targetData:i.targetData,nodeShape:0,id:t,el_W:i.width,el_H:i.height,hidden:!1}}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(e,t,n)}}class Hn extends Yn{constructor(){super()}_updateOptions(o){o.instanceId||(o.instanceId=this.instanceId),console.log("[RelationGraphWith2Data] _updateOptions:",JSON.stringify(o),this.options);const e=Object.assign({},o);if(e.layouts)throw new Error("Graph options do not support setting layouts properties !");if(e.defaultPloyLineRadius&&(e.defaultPolyLineRadius=e.defaultPloyLineRadius),e.debug!==void 0){const t=e.debug===!0;t&&C("RGOptions:user instance options:",e),window&&(window.relationGraphDebug=t)}e.layout&&(He(e.layout),Ye(e.layout,e)),this.dataProvider.updateOptions(e)}resetViewSize(o=!1){const e=this.getViewBoundingClientRect(),t={};t.viewSize={width:e.width,height:e.height},this._rgAsConnectArea?(t.canvasZoom=100,t.canvasOffset={x:0,y:0}):o&&(t.canvasZoom=100,t.canvasOffset={x:t.viewSize.width/2,y:t.viewSize.height/2}),this.dataProvider.updateOptions(t),C("resetViewSize:1:",t),this._dataUpdated()}loading(o=""){this.dataProvider.updateOptions({graphLoading:!0,graphLoadingText:o}),this._dataUpdated()}clearLoading(){this.dataProvider.updateOptions({graphLoading:!1,graphLoadingText:""}),this._dataUpdated()}setCheckedNode(o){console.log("setCheckedNode:",o),this.dataProvider.updateOptions({checkedNodeId:o?typeof o=="string"?o:o.id:""}),this._dataUpdated()}setCheckedLine(o){this.dataProvider.updateOptions({checkedLineId:o?typeof o=="string"?o:o.id:""})}clearChecked(){this.dataProvider.clearChecked(),this._dataUpdated()}clearSelected(){const o=this.getNodes().filter(n=>n.selected),e=this.getLines().filter(n=>n.selected),t=this.getFakeLines().filter(n=>n.selected);o.forEach(n=>this.dataProvider.updateNode(n.id,{selected:!1})),e.forEach(n=>this.dataProvider.updateLine(n.id,{selected:!1})),t.forEach(n=>this.dataProvider.updateFakeLine(n.id,{selected:!1})),this._dataUpdated()}setCanvasOffset(o,e){this.dataProvider.setCanvasOffset(o,e),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}setCanvasMoveMode(o){this.dataProvider.updateOptions({canvasMoveMode:o}),this._dataUpdated()}onMiniViewMounted(){this.dataProvider.updateOptions({showMiniView:!0}),this._dataUpdated()}onMiniViewUnMounted(){this.dataProvider.updateOptions({showMiniView:!1})}onReferenceLineMounted(o){this.dataProvider.updateOptions({referenceLineAdsorption:o||!1,showReferenceLine:!0})}onReferenceLineUnMounted(){this.dataProvider.updateOptions({referenceLineAdsorption:!1,showReferenceLine:!1})}}class jn extends Hn{constructor(){super()}getCreatingLine(o){if(o||(o=this.getOptions()),!o.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=this.generateCreatingLineConfig();return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}}getCreatingNode(o){return o||(o=this.getOptions()),o.creatingNodePlot?{creating:o.creatingNodePlot,nodeJson:o.newNodeTemplate}:{creating:!1}}}class Wn extends jn{constructor(){super()}_getJunctionPoint(o,e){return o===U.border?Z.getBorderPoint4MultiLine(e):o===U.ltrb?Z.getRectJoinPoint(e):o===U.tb?Z.getRectVJoinPoint(e):o===U.lr?Z.getRectHJoinPoint(e):o===U.left?Z.getRectLeftJoinPoint(e):o===U.right?Z.getRectRightJoinPoint(e):o===U.top?Z.getRectTopJoinPoint(e):o===U.bottom?Z.getRectBottomJoinPoint(e):o==="horizontalLine"?Z.getRectHorizontalLineJoinPoint(e):o==="verticalLine"?Z.getRectVerticalLineLineJoinPoint(e):Z.getBorderPoint4MultiLine(e)}createLinePath(o,e,t){throw new Error("createLinePath() is deprecated, please use createLineDrawInfo() instead.")}createLineDrawInfo(o,e){let t,n,i=1,a=0;if(o&&(a=o.currentLineIndex,i=o.totalLinesBetweenNodes),o)t=o.fromNode,n=o.toNode;else{const r=e;if(t=this.getFakeLineTarget(r.fromType,r.from,r),n=this.getFakeLineTarget(r.toType,r.to,r),!t){console.error("Invalid line configuration:error from:",e);return}if(!n){console.error("Invalid line configuration:error to:",e);return}}return this.generateLinePath({line:e,from:t,to:n,totalLinesBetweenNodes:i,currentLineIndex:a})}generateLinePath(o){const e=this.getOptions();o.totalLinesBetweenNodes===void 0&&(o.totalLinesBetweenNodes=1),o.currentLineIndex===void 0&&(o.currentLineIndex=0),o.defaultOptions===void 0&&(o.defaultOptions={layoutDirection:e.layout.layoutDirection,multiLineDistance:e.multiLineDistance,defaultJunctionPoint:e.defaultJunctionPoint,lineRadius:e.defaultPolyLineRadius,defaultLineJunctionOffset:e.defaultLineJunctionOffset,defaultNodeShape:e.defaultNodeShape});try{const t=this.withLineJunctionPoints(o);return this.createLinePathData(t)}catch(t){if(t.rgError)return this.createErrorLineValue(t.errorCode,t.x,t.y);throw t}}throwLineError(o,e,t){return{rgError:!0,errorCode:o,x:e,y:t}}createErrorLineValue(o,e,t){const n={x:0,y:0,rotate:0},i=[{type:"M",x:0,y:0},{type:"l",dx:e,dy:t}];return{pathCommands:i,pathData:fe(i),textPosition:n,points:[]}}withLineJunctionPoints({line:o,from:e,to:t,totalLinesBetweenNodes:n,currentLineIndex:i,defaultOptions:a}){if(!e||!t)throw C("error from-to:",e,t),this.throwLineError("F",-10,0);let r=o.lineShape||1;const l=o.lineDirection||a.layoutDirection||"h";let c=e.x||0,d=e.y||0,h=t.x||0,f=t.y||0;if(Number.isNaN(c)||Number.isNaN(d))throw C("error start node:",e.text,e.x,e.y),this.throwLineError("A",-10,-10);if(Number.isNaN(h)||Number.isNaN(f))throw C("error end point:",t.text,t.x,t.y),this.throwLineError("B",10,-10);let y=e.el_W||60,u=e.el_H||60;if(Number.isNaN(y)||Number.isNaN(u))throw this.throwLineError("C",-10,10);let g=t.el_W||60,m=t.el_H||60;if(Number.isNaN(g)||Number.isNaN(m))throw this.throwLineError("D",10,10);if(c===0&&h===0&&d===0&&f===0)throw this.throwLineError("D",10,10);const p=h-c+(f-d)>0,v=o.isReverse?t:e,L=o.isReverse?e:t,_=Ne(v.nodeShape,a.defaultNodeShape),S=o.junctionOffset||a.defaultLineJunctionOffset||0;c-=S,d-=S,h-=S,f-=S,y+=S*2,u+=S*2,g+=S*2,m+=S*2;const b={from_x:c,from_y:d,to_x:h,to_y:f,f_W:y,f_H:u,t_W:g,t_H:m,nodeShape:_,isReverse:p,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||50},O=Ne(L.nodeShape,a.defaultNodeShape),R={from_x:h,from_y:f,to_x:c,to_y:d,f_W:g,f_H:m,t_W:y,t_H:u,nodeShape:O,isReverse:p,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||50},M=a.defaultJunctionPoint||U.border;let k=o.fromJunctionPoint||M,P=o.toJunctionPoint||M,T=o.fromJuctionPointOffsetX||0,w=o.fromJuctionPointOffsetY||0,D=o.toJuctionPointOffsetX||0,V=o.toJuctionPointOffsetY||0;o.isReverse&&([k,P]=[P,k],[T,w,D,V]=[D,V,T,w]),(e===t||c===0&&h===0&&d===0&&f===0)&&T===0&&w===0&&D===0&&V===0&&((r===F.StandardStraight||r===F.Curve2||r===F.Curve3||r===F.SimpleOrthogonal||r===F.Curve5)&&(r=F.StandardCurve),V=20);const X=this._getJunctionPoint(k,b);X.x+=T,X.y+=w;const G=this._getJunctionPoint(P,R);if(G.x+=D,G.y+=V,!X||!G)throw this.throwLineError("E",-20,-20);const E=c+y/2,j=d+u/2,$=h+g/2,K=f+m/2;k==="horizontalLine"?(X.x=G.x,(r===44||r===49)&&(X.x+=(G.x>$?1:-1)*30)):k==="verticalLine"&&(X.y=G.y,(r===44||r===49)&&(X.y+=(G.y>K?1:-1)*30)),P==="horizontalLine"?(G.x=X.x,(r===44||r===49)&&(G.x+=(X.x>E?1:-1)*30)):P==="verticalLine"&&(G.y=X.y,(r===44||r===49)&&(G.y+=(X.y>j?1:-1)*30));const Q=X.x,ie=X.y,te=G.x,ee=G.y;if(Number.isNaN(Q)||Number.isNaN(ie))throw C("error start point:",e.text),this.throwLineError("F",-10,0);if(Number.isNaN(te)||Number.isNaN(ee))throw C("error end point:",t.text),this.throwLineError("G",10,0);return{line:o,totalLinesBetweenNodes:n,currentLineIndex:i,lineDirection:l==="v"?"v":"h",lineShape:r,lineRadius:a.lineRadius||0,fromJunctionPoint:k,toJunctionPoint:P,fx:Q,fy:ie,fcx:E,fcy:j,f_W:y,f_H:u,tx:te,ty:ee,tcx:$,tcy:K,t_W:g,t_H:m}}createLinePathData(o){const{lineShape:e}=o;let t;return e===F.SimpleOrthogonal?t=wn(o,void 0,{lineRadius:o.lineRadius}):e===F.StandardOrthogonal?t=bn(o,void 0,{lineRadius:o.lineRadius}):e===F.HardOrthogonal?t=On(o,void 0,{lineRadius:o.lineRadius}):e===F.StandardCurve?t=Sn(o):e===F.Curve2||e===F.Curve3||e===F.Curve5||e===F.Curve7||e===F.Curve8?t=Pn(o):t=Ln(o),t}getArrowMarkerId(o,e=!1){let t=o.showStartArrow===!0,n=o.showEndArrow!==!1;if(o.isReverse&&([t,n]=[n,t]),e){if(!t)return;if(o.startMarkerId)return`url('#${o.startMarkerId}')`}else{if(!n)return;if(o.endMarkerId)return`url('#${o.endMarkerId}')`}return`url('#${this.getLineArrow(o.color,e,!1)}')`}getLineArrow(o,e=!1,t=!1){const n=e?"start-":"";return`${this.getOptions().instanceId}-${n}arrow-default`}getTextTransform(o,e){if(!o||!e)return"translate(0,0)";const{x:t,y:n,rotate:i}=e;if(Number.isNaN(t)||Number.isNaN(n))return"translate(0,0)";const a=this.getOptions(),r=o.textOffset_x||a.defaultLineTextOffset_x||0,l=o.textOffset_y||a.defaultLineTextOffset_y||0,c=o.lineShape||1;return c===F.StandardStraight||c===F.SimpleOrthogonal?`translate(-50%, -50%) translate(${t+r}px,${n+l}px) rotate(${i||0}deg)`:`translate(-50%, -50%) translate(${t+r}px,${n+l}px)`}generateLineTextStyle(o,e){const t=this.getOptions(),n={transform:"",transformOrigin:""};if(!o||!e)return{cssStyles:n};const{line:i}=o,{textPosition:a}=e;if(!i||!a)return{cssStyles:n};let r=i.text||"";r.length>t.lineTextMaxLength&&(r=r.substring(0,t.lineTextMaxLength||15)+"...");const{x:l,y:c,rotate:d}=a;if(Number.isNaN(l)||Number.isNaN(c))return{text:r,cssStyles:n};const h=[],f=i.textAnchor||"center";f==="start"?h.push("translate(0%, -50%)"):f==="end"?h.push("translate(100%, -50%)"):h.push("translate(-50%, -50%)"),h.push(`translate(${l}px,${c}px)`);const y=i.textOffset_x||t.defaultLineTextOffset_x||0,u=i.textOffset_y||t.defaultLineTextOffset_y||0;return(i.lineShape||1)===F.StandardStraight?(n.transformOrigin="50% 50%",h.push(`translate(${y}px,${u}px)`)):h.push(`translate(${y}px,${u}px)`),n.transform=h.join(" "),{text:r,cssStyles:n}}generateLineTextStyle4TextPath(o){const{line:e,from:t,to:n}=o;let i=e.text;if(!i||!n||!t)return null;let a=0;const r=t.x,l=t.y,c=n.x,d=n.y,h=this.getOptions();i.length>h.lineTextMaxLength&&(i=i.substring(0,h.lineTextMaxLength||15)+"...");const u=`translate(${0},${0})`;let g="middle";const m=e.lineShape||1;let p="50%";return m===F.SimpleOrthogonal?e.onPathStartOffset==="start"?(p="10%",g="start"):e.onPathStartOffset==="end"?(p="90%",g="end"):e.onPathStartOffset?(p=e.onPathStartOffset,g="start"):h.layout.layoutDirection==="v"?p=String(Math.abs(c-r)+43):p=String(Math.abs(d-l)+43):e.onPathStartOffset==="start"?(p="10%",g="start"):e.onPathStartOffset==="end"?(p="90%",g="end"):e.onPathStartOffset?(p=e.onPathStartOffset,g="start"):(p="50%",g="middle"),e.textAnchor&&(g=e.textAnchor),{text:i,textOffset:u,textAnchor:g,onPathStartOffset:p,textRotate:a}}}class $n extends Wn{constructor(){super()}zoom(o,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions();try{const i=this.emitEvent(A.beforeZoomStart,n.canvasZoom,o,t);if(C("[zoom]","abortZoom:",i),i===!0)return;if(n.canvasZoom+o<n.minCanvasZoom){if(C("zoom:minCanvasZoom"),o=n.minCanvasZoom-n.canvasZoom,o===0)return}else if(n.canvasZoom+o>n.maxCanvasZoom&&(C("zoom:maxCanvasZoom"),o=n.maxCanvasZoom-n.canvasZoom,o===0))return;const a=o/100,r=this.getViewBoundingClientRect(),l=n.canvasZoom/100,c=Math.max(.01,Math.min(10,l+a));e||(e={x:r.x+r.width/2,y:r.y+r.height/2});const d=e.x-r.left,h=e.y-r.top,f=d-(d-n.canvasOffset.x)*(c/l),y=h-(h-n.canvasOffset.y)*(c/l),u=n.canvasZoom,g=c*100;this._performanceModeLogicHook(u,g),this.dataProvider.updateOptions({canvasOffset:{x:f,y},canvasZoom:g}),this.emitEvent(A.onZoomEnd,g,u)}finally{this._updateEditingControllerView(),this._dataUpdated()}}_performanceModeLogicHook(o,e){const t=this.getOptions();o<=40?e>40&&(t.performanceMode&&this.updateShouldRenderGraphData(!0),this.dataProvider.updateOptions({showEasyView:!1}),C("zoom:hide:showEasyView",o,e),this.updateElementLines()):o>40&&e<=40&&(C("zoom:show:showEasyView",o,e),t.performanceMode&&this.dataProvider.updateOptions({showEasyView:!0}))}setZoom(o,e){const t=this.getOptions(),n=Math.round(o-t.canvasZoom);this.zoom(n,e)}}class Un extends $n{constructor(){super()}fitContentHeight(o=20){this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated();const e=this.getOptions(),t=this.getNodesRectBox(),n=t.height,i=t.width,a=e.viewSize.width-o*2,r=t.minX+t.width/2,l=t.minY+t.height/2;console.warn("[fitContentHeight]nodesCenter:",r,l),this.dataProvider.setCanvasCenter(r,l);const c=Math.min(1,a/i),d=n*c+o*2;this.dataProvider.updateOptions({viewSize:{...e.viewSize,height:d},viewHeight:d+"px"}),setTimeout(()=>{this.setZoom(c*100),this._moveToCenter(),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()},200)}_moveToCenter(o){const e=this.getNodesCenter(o);this.dataProvider.setCanvasCenter(e.x,e.y),this._dataUpdated()}setCanvasCenter(o,e){this.dataProvider.setCanvasCenter(o,e),this._dataUpdated()}zoomToFit(o){const e=this.getOptions(),t=this.getNodesRectBox(o),n=50,i=e.viewSize.width/(t.width+n*2),a=e.viewSize.height/(t.height+n*2),r=Math.min(i,a,1);C("zoomToFit:",{stuffSize:t,zoomPercent:r,zoomPercentX:i,zoomPercentY:a,viewSize:e.viewSize}),this._moveToCenter(o),this.setZoom(r*100),this._dataUpdated()}enableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!0}),this._dataUpdated()}disableNodeXYAnimation(){this.dataProvider.updateOptions({enableNodeXYAnimation:!1}),this._dataUpdated()}enableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!0}),this._dataUpdated()}disableCanvasAnimation(){this.dataProvider.updateOptions({enableCanvasTransformAnimation:!1}),this._dataUpdated()}focusNodeById(o){const e=this.getNodeById(o);e&&this.focusNode(e)}focusRootNode(){throw new Error("focusRootNode is deprecated, please use focusNodeById instead.")}focusNode(o){C("checked:",o);const e=this.getOptions();this.setZoom(100);const t=o.width||50,n=o.height||50,i=o.x*-1+e.viewSize.width/2-t/2,a=o.y*-1+e.viewSize.height/2-n/2;this.dataProvider.setCanvasOffset(i,a),this.dataProvider.updateOptions({checkedNodeId:o.id})}}class qn extends ue{constructor(e,t,n){super(e,t,n);N(this,"rotate",0);N(this,"enableGatherNodes",!1);N(this,"layoutOptions");this.layoutOptions=e,C("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;console.log("this.layoutOptions.alignItemsX:1:",this.layoutOptions.alignItemsX),i==="top"||i==="bottom"?(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=10),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=50)):(this.layoutOptions.treeNodeGapH||(this.layoutOptions.treeNodeGapH=50),this.layoutOptions.treeNodeGapV||(this.layoutOptions.treeNodeGapV=10)),i==="top"?(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="center"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.layoutOptions.alignItemsX),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.getReverseAlignItems(this.layoutOptions.alignItemsY))):(this.layoutOptions.alignItemsX||(this.layoutOptions.alignItemsX="start"),this.layoutOptions.alignItemsY||(this.layoutOptions.alignItemsY="start"),this.layoutOptions.alignParentItemsX||(this.layoutOptions.alignParentItemsX=this.getReverseAlignItems(this.layoutOptions.alignItemsX)),this.layoutOptions.alignParentItemsY||(this.layoutOptions.alignParentItemsY=this.layoutOptions.alignItemsY)),console.log("this.layoutOptions.alignItemsX:2:",this.layoutOptions.alignItemsX),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const a=this.layoutOptions.layoutExpansionDirection,r=a==="start"||a==="left"||a==="top"?"start":a==="end"||a==="right"||a==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=r,this.layoutOptions.treeNodeGapH<100&&(this.layoutOptions.treeNodeGapH=100),this.layoutOptions.treeNodeGapV<10&&(this.layoutOptions.treeNodeGapV=10),(this.layoutOptions.from==="bottom"||this.layoutOptions.from==="right")&&(this.rotate=180),this.layoutOptions.changeNodeSizeDuringLayout===void 0&&(this.layoutOptions.changeNodeSizeDuringLayout=!1)}placeNodes(e,t){if(console.log("tree:placeNodes:rootNode",t.id,t),C("RGTreeLayout:placeNodes"),t)C("layout by root:",t);else{console.error("root is null");return}C("allNodes:",e.length),this.layoutOptions.alignItemsX,this.layoutOptions.alignItemsY,this.layoutOptions.alignParentItemsX,this.layoutOptions.alignParentItemsY,this.rootNode=t,this.allNodes=e,t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0),t.lot.x=t.x,t.lot.y=t.y;const n=e;C("groupNodes:2:",n.length,n.map(r=>r.text).join(","));const i=this.rotate;console.log("rotate:",i),this.networkAnalyzer.analyzeNetwork(n,this.rootNode,!1),this.placeNodesPosition(t,n);const a={x:t.x,y:t.y};this.allNodes.forEach(r=>{if(r.fixed!==!0&&!!z.isVisibleNode(r)&&(Number.isNaN(r.lot.x)&&(C("bad lot x:",r.text,r.lot.x),r.lot.x=0),Number.isNaN(r.lot.y)&&(C("bad lot y:",r.text,r.lot.y),r.lot.y=0),r!==t)){this.layoutOptions.from==="right"&&(r.lot.x=Z.getFlippedX(r.lot.x,a.x)),this.layoutOptions.from==="bottom"&&(r.lot.y=Z.getFlippedY(r.lot.y,a.y));const l=this.layoutOptions.from==="right"?z.getNodeXByLotX({alignItemsX:"end"},r):r.lot.x,c=this.layoutOptions.from==="bottom"?z.getNodeYByLotY({alignItemsY:"end"},r):r.lot.y;this.updateNodePosition(r,l,c)}});for(const r of this.allNodes)this.graphInstance.updateNode(r,{rgChildrenSize:r.lot.childs.length});C("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t){this.placeRelativePosition(e,t)}placeRelativePosition(e,t){e.lot.parent=void 0,e.lot.level=0;const n=[];this.buildNetwork([e],n,0);const i=Math.max(...n.map(c=>c.lot.level)),a=this.layoutOptions.from==="left"||this.layoutOptions.from==="right";this.reduceNodeRect(n,i,a),a?this.placeNodeChildrenH(n,0):this.placeNodeChildrenV(n,0);let r=e.lot.x-e.x,l=e.lot.y-e.y;this.layoutOptions.from==="right"&&(r+=e.lot.width),this.layoutOptions.from==="bottom"&&(l+=e.lot.height),n.forEach(c=>{c.fixed!==!0&&(c.lot.x-=r,c.lot.y-=l)}),console.log("levelMaxWidthMap:",e.id)}buildNetwork(e,t,n){n===0&&t.push(...e);const i=[];e.forEach(a=>{if(!z.isVisibleNode(a))return;const r=this.graphInstance.getNodeIncomingNodes(a).filter(z.isVisibleNode),c=this.graphInstance.getNodeOutgoingNodes(a).filter(z.isVisibleNode).filter(h=>!t.includes(h));t.push(...c);const d=r.filter(h=>!t.includes(h));t.push(...d),a.lot.level=n,a.lot.toNodes=c,a.lot.fromNodes=d;for(const h of d.concat(c))h.lot.parent=a,i.includes(h)||i.push(h)}),i.length>0&&this.buildNetwork(i,t,n+1)}reduceNodeRect(e,t,n=!1){let i=this.layoutOptions.treeNodeGapH,a=this.layoutOptions.treeNodeGapV;const r=i,l=a,c=e.filter(d=>d.lot.level===t);console.log("reduceNodeRect:level:",t,c.length);for(const d of c){if(!z.isVisibleNode(d))continue;let h=d.el_W||d.width||50,f=d.el_H||d.height||50;if(d.lot.width=h,d.lot.height=f,d.lot.toNodes.length===0&&d.lot.fromNodes.length===0)d.lot.width_with_childs=h,d.lot.height_with_childs=f;else if(n){let y=0,u=0;for(const p of d.lot.fromNodes)p.lot.height_with_childs>u&&(u=p.lot.height_with_childs),y+=p.lot.width_with_childs+l;let g=0,m=0;for(const p of d.lot.toNodes)p.lot.height_with_childs>m&&(m=p.lot.height_with_childs),g+=p.lot.width_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),f=Math.max(u+r/2,f/2)+Math.max(m+r/2,f/2),d.lot.width_with_childs=h+Math.max(y,g)+l,d.lot.height_with_childs=f}else{let y=0,u=0;for(const p of d.lot.fromNodes)p.lot.width_with_childs>y&&(y=p.lot.width_with_childs),u+=p.lot.height_with_childs+l;let g=0,m=0;for(const p of d.lot.toNodes)p.lot.width_with_childs>g&&(g=p.lot.width_with_childs),m+=p.lot.height_with_childs+l;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),h=Math.max(y+r/2,h/2)+Math.max(g+r/2,h/2),d.lot.width_with_childs=h,d.lot.height_with_childs=f+Math.max(u,m)+l}}t>=0&&this.reduceNodeRect(e,t-1,n)}placeNodeChildrenV(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.width;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartX=d.lot.x+h/2-d.lot.width_with_childs/2);const f=d.lot.groupStartX,y=d.lot.y;let u=0,g=0;for(const p of d.lot.fromNodes)p.lot.width_with_childs>u&&(u=p.lot.width_with_childs);for(const p of d.lot.toNodes)p.lot.width_with_childs>g&&(g=p.lot.width_with_childs);const m=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let p=d.lot.height+r;for(const v of d.lot.fromNodes)v.lot.groupStartX=m-v.lot.width_with_childs-a/2,v.lot.y=y+p+r,p+=v.lot.height_with_childs+r}if(d.lot.toNodes.length>0){let p=d.lot.height+r;for(const v of d.lot.toNodes)v.lot.groupStartX=m+a/2,v.lot.y=y+p+r,p+=v.lot.height_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.x=f,d.width=d.lot.width_with_childs):d.lot.x=m-d.lot.width/2:d.lot.x=f}l>0&&this.placeNodeChildrenV(e,t+1)}placeNodeChildrenH(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let l=0;const c=e.filter(d=>d.lot.level===t);console.log("placeNodeChildren:level:",t,c.length);for(const d of c){l++;let h=d.lot.height;this.layoutOptions.changeNodeSizeDuringLayout&&(h=0),t===0&&(d.lot.groupStartY=d.lot.y+h/2-d.lot.height_with_childs/2);const f=d.lot.groupStartY,y=d.lot.x;let u=0,g=0;for(const p of d.lot.fromNodes)p.lot.height_with_childs>u&&(u=p.lot.height_with_childs);for(const p of d.lot.toNodes)p.lot.height_with_childs>g&&(g=p.lot.height_with_childs);const m=f+Math.max(u+a/2,h/2);if(d.lot.fromNodes.length>0){let p=d.lot.width+r;for(const v of d.lot.fromNodes)v.lot.groupStartY=m-v.lot.height_with_childs-a/2,v.lot.x=y+p+r,p+=v.lot.width_with_childs+r}if(d.lot.toNodes.length>0){let p=d.lot.width+r;for(const v of d.lot.toNodes)v.lot.groupStartY=m+a/2,v.lot.x=y+p+r,p+=v.lot.width_with_childs+r}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(d.lot.y=f,d.height=d.lot.height_with_childs):d.lot.y=m-d.lot.height/2:d.lot.y=f}l>0&&this.placeNodeChildrenH(e,t+1)}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let i=0;for(let a=0;a<e;a++){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return i}else{let i=0;for(let a=0;a>e;a--){const r=t.get(a);i+=r+this.getLevelGap(a,n,r,e)}return-i}}getLevelGap(e,t,n,i){let a=t+(i===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const r=this.layoutOptions.levelGaps[Math.abs(e)];r&&(a=r)}return a}}class Jn extends Un{constructor(){super();N(this,"layoutor")}async doLayout(e){const t=Date.now()-this.prevAddNodeTimestamp;t<300&&(this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated(),await Xe(300-t)),await this._doLayout(e),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()}async _doLayout(e){this.updateNodesVisibleProperty();const t=this.getNodes();C("node size\uFF1A",t.length);let n=this.dataProvider.getRootNode();if(e&&(n=typeof e=="string"?this.getNodeById(e):e,!n))throw new Error("custom rootNode not found, id:"+e);n||(n=t[0],this._rgAsConnectArea||(C("[relation-graph]No root node, use first node as root:",n),C("[relation-graph]You can set rootNode call doLayout(rootNode | nodeId) with a node id")));const i=this.getOptions();this.dataProvider.setRootNodeId(n?n.id:""),this.stopAutoLayout();const a=this.createLayout(i.layout,!0);if(a.layoutOptions.layoutName==="force")a.isMainLayouer=!0,a.onFinish(()=>{this.emitEvent(A.onForceLayoutFinish)}),await Xe(100),C("doLayout:start force:",t.length),a.placeNodes(t,n);else{this.enableNodeXYAnimation();let r=[];n&&(r=this.getNetworkNodesByNode(n),a.placeNodes(r,n)),C("doLayout:placeOtherNodes:all:",t.length,"mainGroupNodes:",r.length),this.placeOtherNodes(r),setTimeout(()=>{this.disableNodeXYAnimation()},300),C("doLayout:placeOtherNodes ok!")}t.forEach(r=>this.dataProvider.updateNode(r.id,{x:r.x||0,y:r.y||0,rgChildrenSize:r.rgChildrenSize||0})),this.updateElementLines()}async refresh(e=!0){this.resetViewSize(!0),this._dataUpdated(),e&&await this.doLayout(),this.updateElementLines(),this._dataUpdated()}placeOtherNodes(e=[]){const t=this.getOptions();if(t.layout.layoutName==="fixed"||!t.placeOtherGroup)return;const i=[],a=[],r=this.getNodes();r.forEach(c=>{if(c.fixed===!0||e.includes(c))return;this.getNodeRelatedNodes(c).length===0?a.push(c):i.push(c)}),C("doLayout:allNodes:",r.length),C("doLayout:mainGroupNodes:",e.length),C("doLayout:notInMainGroupNodes:",i.length),C("doLayout:singleNodes:",a.length);const l=[{nodes:e}];this.placeNextNetwork(i,[...e],l),this.placeSingleNodes(a),l.push({nodes:a}),this.sortGroups(l),this._dataUpdated()}placeSingleNodes(e){if(e.length>0){const t=Math.ceil(Math.sqrt(e.length));qe(t,30,e.map(i=>({width:i.el_W,height:i.el_H,node:i})),(i,a,r)=>{const l=i.node;l.x=a,l.y=r,l.lot||(l.lot={childs:[]})}),C("[placeSingleNodes]Single nodes:",e.length)}}sortGroups(e){C("[placeSingleNodes]sortGroups groupList:",e.length,e.map(a=>a.nodes.length));const t=e.map(a=>{const r=this.getNodesRectBox(a.nodes);return{width:r.width,height:r.height,nodes:a.nodes,orignX:r.minX,orignY:r.minY}});if(t.length===0)return;const n=Math.floor(Math.sqrt(t.length))||1;qe(n,100,t,(a,r,l)=>{const c=r-a.orignX,d=l-a.orignY;C(`[placeNextNetwork]Move ${a.nodes.length} Nodes :`,c,d,a," > ");for(const h of a.nodes)this.updateNodePosition(h,h.x+c,h.y+d)},t[0].orignX,t[0].orignY)}placeNextNetwork(e,t,n){if(e.length>0){const i=this.getOptions();C("[placeNextNetwork]notPlacedNodes nodes:",e.length);const a=JSON.parse(JSON.stringify(i.layout)),r=e[0],l=this.createLayout(a);if(l.isMainLayouer=!1,C("[placeNextNetwork]layoutName:",l.layoutOptions.layoutName,"root:",r.text),l.layoutOptions.layoutName==="force"){const h=l;h.maxLayoutTimes=0}r.fixed?C("[placeNextNetwork]fixed root x,y:",r.x,r.y,r.text):(this.updateNodePosition(r,0,0),C("[placeNextNetwork]set root x,y:",r.x,r.y,r.text)),l.layoutOptions.fixedRootNode=!0;const c=this.getNetworkNodesByNode(r);C("[placeNextNetwork]thisNetworkNodes:",e.length),l.requireLinks&&l.setLinks(this.getLinks()),l.placeNodes(c,r),t.push(...c),n.push({nodes:c});const d=[];e.forEach(h=>{t.includes(h)||d.push(h)}),i.placeOtherGroup&&this.placeNextNetwork(d,t,n),this._dataUpdated()}else C("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){const e=this.getOptions();C("toggleAutoLayout:to:",e.layout.autoLayouting),e.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){var t;this.getOptions().layout.supportAutoLayout&&(t=this.layoutor)!=null&&t.start&&(C("Start force layout:"+this.layoutor.instanceId),this.layoutor.start())}stopAutoLayout(){var t;this.getOptions().layout.supportAutoLayout&&(t=this.layoutor)!=null&&t.stop&&(C("Stop force layout:"+this.layoutor.instanceId),this.layoutor.stop())}createLayout(e,t=!1){console.error("########createLayout:",e);const n=this.getOptions();He(e);let i=null;if(e.layoutName==="tree"?i=new Ct(e,n,this):e.layoutName==="center"?i=new Lt(e,n,this):e.layoutName==="circle"?i=new wt(e,n,this):e.layoutName==="force"?i=new Se(e,n,this):e.layoutName==="fixed"?i=new Nt(e,n,this):e.layoutName==="smart-tree"?i=new xn(e,n,this):e.layoutName==="io-tree"?i=new qn(e,n,this):e.layoutName==="folder"&&(i=new _t(e,n,this)),!i)throw new Error("unknown layout: "+e.layoutName);return i.requireLinks&&i.setLinks(this.getLinks()),i.isMainLayouer=t,i.layoutOptions.fixedRootNode=!0,t&&(this.layoutor=i,this.dataProvider.updateOptions({layout:{...n.layout,supportAutoLayout:i.autoLayout!==void 0}})),i}}const Zn=async(s,o)=>{const e=s||document.documentElement;o?await Qn(e):await Kn()},Qn=async s=>{s.requestFullscreen?await s.requestFullscreen():s.mozRequestFullScreen?await s.mozRequestFullScreen():s.webkitRequestFullscreen?await s.webkitRequestFullscreen():s.msRequestFullscreen&&await s.msRequestFullscreen()},Kn=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class ei extends Jn{constructor(){super();N(this,"_prevClickNodeTime",0);N(this,"_nodeXYMappingBeforeDrag",{});N(this,"canvasAutoMoving",e=>{const t=this.getOptions(),n=t.viewSize,i=40;let a=0,r=0;e.x<i?a=i-e.x:n.width-i<e.x&&(a=n.width-i-e.x),e.y<i?r=i-e.y:n.height-i<e.y&&(r=n.height-i-e.y);const l=a!==0||r!==0;l&&(a=Math.max(Math.min(a/5,30),-30),r=Math.max(Math.min(r/5,30),-30));const c=t.canvasOffset.x+a,d=t.canvasOffset.y+r;return this.onCanvasDragging(c,d,a,r),l});N(this,"_canvasMovingTimer");N(this,"_relayoutTaskTimer");N(this,"_onMovingWhenCreatingLine");N(this,"_step1EventTime",0);N(this,"_onCreateLineCallback");N(this,"_mouseWheelTimer");N(this,"_mouseWheelEventPrevApplyTime",0);N(this,"_mouseWheelForce",{x:0,y:0});N(this,"_fullscreenchangeHandler")}onNodeClick(e,t){if(Date.now()-this._prevClickNodeTime<200){C("[node]click abort : time < 200");return}this._prevClickNodeTime=Date.now();const n=this.getOptions();if(n.creatingLinePlot){this.onNodeClickWhenCreatingLinePlot(e);return}const i=e.disablePointEvent===void 0?n.disableNodePointEvent:e.disablePointEvent;C("[node]node click",e.text,n.creatingLinePlot,i),!t.shiftKey&&!i&&(n.checkedLineId="",this.dataProvider.updateOptions({checkedLineId:"",checkedNodeId:e.id})),this.emitEvent(A.onNodeClick,e,t),this._prevClickNodeTime=Date.now()}onNodeDragStart(e,t){if(!e||we(t))return;const n=this.getOptions();if((e.disableDrag||n.disableDragNode)&&!(t.target&&t.target.closest(".rg-node-drag-handler"))){const g=m=>{this.onNodeClick(e,m),document.body.removeEventListener("mouseup",g)};document.body.addEventListener("mouseup",g);return}isNaN(e.x)&&(e.x=0),isNaN(e.y)&&(e.y=0),this.dataProvider.setEditingLine(null),this.dataProvider.updateOptions({checkedLineId:""});let a=!1;const r=(u,g,m)=>{m.stopPropagation(),a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.dataProvider.updateOptions({draggingNodeId:"",editingReferenceLine:{...n.editingReferenceLine,show:!1}}),this._onNodeDragEnd(e,u,g,m),d?this.emitEvent(A.onNodeDragEnd,e,m,u,g):this.onNodeClick(e,t),this._dataUpdated()};this._nodeXYMappingBeforeDrag={},this._nodeXYMappingBeforeDrag[e.id]={x:e.x,y:e.y};for(const u of n.editingController.nodes)this._nodeXYMappingBeforeDrag[u.id]={x:u.x,y:u.y};const l=this.getCanvasXyByViewXy(this.getViewXyByEvent(t)),c={x:e.x,y:e.y};let d=!1;this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer);let h;const f=()=>{if(!h||a)return;const u=this.getViewXyByEvent(h),g=this.getCanvasXyByViewXy(u),m=g.x-l.x,p=g.y-l.y;let v=m+c.x,L=p+c.y,_=v-c.x,S=L-c.y;const b=this.emitEvent(A.onNodeDragging,e,v,L,_,S,h);b&&(typeof b.x=="number"&&(v=b.x,_=v-c.x),typeof b.y=="number"&&(L=b.y,S=L-c.y)),this.canvasAutoMoving(u),this.draggingSelectedNodes(e,v,L,_,S),this._dataUpdated()},y=()=>{f(),this._canvasMovingTimer=requestAnimationFrame(y)};J.startDrag(t,c,r,(u,g,m,p,v)=>{d?h=v:Math.abs(u)+Math.abs(g)>4&&(C("[node]onNodeDragStart...",ce(h),h),this.emitEvent(A.onNodeDragStart,e,h),d=!0,this.dataProvider.updateOptions({draggingNodeId:e.id}),this._canvasMovingTimer=requestAnimationFrame(y)),this.updateElementLines(),this._dataUpdated()})}_onNodeDragEnd(e,t,n,i){this.updateElementLines()}onLineClick(e,t,n){t||(t=this.getLinkByLineId(e.id)),C("onLineClick:","line:",e,"link:",t);const i=this.getOptions();(e.disablePointEvent===void 0?i.disableLinePointEvent:e.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLine(e)),this.emitEvent(A.onLineClick,e,t,n),this._dataUpdated()}expandOrCollapseNode(e,t){t.stopPropagation(),e.expanded===!1?this.expandNode(e,t):this.collapseNode(e,t)}expandNode(e,t){C("onNodeExpand:",e),this.dataProvider.updateNode(e.id,{expanded:!0}),this.emitEvent(A.onNodeExpand,e,t),this._effectWhenExpandedOrCollapsed(e)}collapseNode(e,t){C("onNodeCollapse:",e),this.dataProvider.updateNode(e.id,{expanded:!1}),this.emitEvent(A.onNodeCollapse,e,t),this._effectWhenExpandedOrCollapsed(e)}_effectWhenExpandedOrCollapsed(e){this._relayoutTaskTimer&&clearTimeout(this._relayoutTaskTimer),this._relayoutTaskTimer=setTimeout(()=>{const t=this.getDescendantNodes(e);this.updateNodesVisibleProperty([e].concat(t)),this.updateElementLines(),this._dataUpdated();const n=this.getOptions();n.reLayoutWhenExpandedOrCollapsed&&(n.layout.layoutName==="force"?this.startAutoLayout():this.doLayout())},100)}onCanvasDragEnd(e){this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated(),this.emitEvent(A.onCanvasDragEnd,e)}onCanvasClick(e){if(this.getOptions().creatingLinePlot)this.onCanvasClickWhenCreatingLinePlot(e);else{if(this.dataProvider.isPerformanceMode()){const n=this.getNodeAtEvent(e);if(n){this.emitEvent(A.onNodeClick,n,e);return}}this.emitEvent(A.onCanvasClick,e)}}getNodeAtEvent(e){const t=this.getCanvasXyByClientXy(e);return this.dataProvider.findNodeByXy(t)}onCanvasSelectionEnd(e,t){this.emitEvent(A.onCanvasSelectionEnd,e,t),C("[canvas]onCanvasSelectionEnd:",e),this._dataUpdated()}startCreatingNodePlot(e,t){if(!t)throw new Error("startCreatingNodePlot need setting param");if(!t.onCreateNode)throw new Error("startCreatingNodePlot need setting.onCreateNode param as callback");const n=be(JSON.parse(JSON.stringify(Fe)),this.getOptions()),i=ce(e);this.dataProvider.updateOptions({newNodeTemplate:Object.assign({},n,t.templateNode),creatingNodePlot:!0,showTemplateNode:!i});let a=(u,g)=>{const m=this.getOptions().newNodeTemplate,p={width:m.width||96,height:m.height||96};this.dataProvider.updateOptions({newNodeTemplate:{...m,x:u-p.width/2,y:g-p.height/2}}),this._dataUpdated()};const r=this.getViewBoundingClientRect();C("[CreatingNodePlot]startCreatingNodePlot:");const l=Ce(e),c=l.clientX-r.x+10,d=l.clientY-r.y+10;i||a(c,d);const h=u=>{C("[CreatingNodePlot]objectTemplateMove");const g=this.getViewXyByEvent(u);t.templateMove&&t.templateMove(g.x,g.y),a(g.x,g.y)},f=u=>{C("[CreatingNodePlot]user abort!"),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",y),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1})},y=u=>{let g=!1;if(this.getOptions().creatingNodePlot||(g=!0),this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("click",y),this.$dom.removeEventListener("contextmenu",f),this.dataProvider.updateOptions({creatingNodePlot:!1}),g){C("[CreatingNodePlot]action be abort!");return}const m=Ce(u),p=m.clientX-r.x+10,v=m.clientY-r.y+10;if(Math.abs(c-p)<30&&Math.abs(d-v)<30){C("[CreatingNodePlot]create node be abort!");return}const L=this.getCanvasXyByClientXy({x:m.clientX,y:m.clientY});C("[CreatingNodePlot]objectBePlaced:",L),t.onCreateNode(L.x,L.y,this.getOptions().newNodeTemplate),this._dataUpdated()};setTimeout(()=>{this.$dom.addEventListener("click",y),this.$dom.addEventListener("contextmenu",f)},300),i||this.$dom.addEventListener("mousemove",h)}startCreatingLinePlot(e,t){const n=ce(e);t&&t.onCreateLine&&(this._onCreateLineCallback=t.onCreateLine);const i=he({from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:"new line"},this.getOptions());t&&t.template&&Object.assign(i,t.template),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1})}),this.dataProvider.updateOptions({newLineTemplate:Object.assign(i,{isReverse:t.isReverse||!1,disablePointEvent:!0}),creatingLinePlot:!0});const a=Object.assign({},this.getOptions().newLinkTemplate,{fromNode:null,toNode:{id:"",targetType:B.Node,x:0,y:0,el_W:2,el_H:2},toNodeObject:null});t&&t.fromNode&&(a.toNode.x=t.fromNode.x+50,a.toNode.y=t.fromNode.y+50,a.fromNode=t.fromNode,this._step1EventTime=Date.now()),this.dataProvider.updateOptions({newLinkTemplate:a}),C("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),n||(C("[CreatingLinePlot]Listener move"),this._onMovingWhenCreatingLine&&this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=this.onMovingWhenCreatingLinePlot.bind(this),this.$dom.addEventListener("mousemove",this._onMovingWhenCreatingLine)),this._dataUpdated()}stopCreatingLinePlot(){C("[CreatingLinePlot]stop CreatingLinePlot!"),this.dataProvider.updateOptions({creatingLinePlot:!1,newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:null,toNodeObject:null},nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}),this._onCreateLineCallback=void 0,this.$dom.removeEventListener("mousemove",this._onMovingWhenCreatingLine),this._onMovingWhenCreatingLine=void 0,this._dataUpdated()}onMovingWhenCreatingLinePlot(e){C("[CreatingLinePlot]mousemove");const t=this.getCanvasXyByClientXy({x:e.clientX,y:e.clientY}),n=this.getOptions(),i=e.target;let a="",r=B.Node;const l=this.isNode(i);let c=!1,d={x:0,y:0,el_W:5,el_H:5,nodeShape:0};l&&(a=l.id,l===this.getOptions().newLinkTemplate.fromNode?this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}):(this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:l,show:!0}}),this._updateEditingConnectControllerView()));const h=i.closest(".rg-connect-ctl-handler");if(h){let f=this.getOptions().nodeConnectController.node;C("[CreatingLinePlot]content point:",h.dataset.point);let y=h.dataset.point||"border";if(h.classList.contains("rg-connect-target")){const{width:u,height:g,x:m,y:p}=h.getBoundingClientRect(),v=this.getCanvasXyByClientXy({x:m,y:p}),L=this.dataProvider.getCanvasScale(),_={x:v.x,y:v.y,el_W:u/L,el_H:g/L,nodeShape:1,id:h.dataset.targetId,targetData:JSON.parse(h.dataset.targetData||"{}"),targetType:h.dataset.targetType};c=!0,d.x=_.x,d.y=_.y,d.el_W=_.el_W,d.el_H=_.el_H,d.nodeShape=_.nodeShape,console.log("[CreatingLinePlot]fakeNode:",JSON.stringify(_)),this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:_,show:!1}}),y=h.dataset.point,n.newLinkTemplate.toNode&&(a=_.id,r=_.targetType,this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,nodeShape:_.nodeShape}}})),this._updateEditingConnectControllerView()}else f&&(r=B.Node,c=!0,d.x=f.x,d.y=f.y,d.el_W=f.el_W,d.el_H=f.el_H,d.nodeShape=f.nodeShape,i.dataset.innode==="true"&&(d.x=t.x,d.y=t.y,d.el_W=2,d.el_H=2,d.nodeShape=1));n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:y}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:y}})}else C("[CreatingLinePlot]point:",i.dataset.point),n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:U.border}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:U.border}}),n.newLinkTemplate.toNode&&(r=B.Node);n.newLinkTemplate.toNode&&(a&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,id:a}}}),this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,targetType:r}}})),n.newLinkTemplate.fromNode&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,x:c?d.x:t.x,y:c?d.y:t.y,el_W:d.el_W,el_H:d.el_H,nodeShape:d.nodeShape}}}),this._dataUpdated()}onCanvasClickWhenCreatingLinePlot(e){if(Date.now()-this._step1EventTime<500){C("[CreatingLinePlot]step1EventTime:",this._step1EventTime);return}const t=this.getOptions();if(!t.newLinkTemplate.fromNode){C("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let n=!1;if(!t.newLinkTemplate.toNodeObject){C("[CreatingLinePlot]CreatingLinePlot:toNodeObject not set!");const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY});n=this.onReadyToCreateLine(t.newLinkTemplate.fromNode,a)}n!==!0&&this.stopCreatingLinePlot()}onNodeClickWhenCreatingLinePlot(e){const t=this.getOptions();t.newLinkTemplate.fromNode?(C("[CreatingLinePlot]step 2: set toNodeObjecct:",t.newLinkTemplate.fromNode,e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,toNodeObject:e}}),this.onReadyToCreateLine(t.newLinkTemplate.fromNode,e)!==!0&&this.stopCreatingLinePlot()):(C("[CreatingLinePlot]step 1: set fromNode:",e),this.dataProvider.updateOptions({newLinkTemplate:{...t.newLinkTemplate,fromNode:e,toNode:{...t.newLinkTemplate.toNode,x:e.x+50,y:e.y+50}}}),this._step1EventTime=Date.now())}onReadyToCreateLine(e,t){C("[CreatingLinePlot][fire-event]onCreateLine:",e,t);const n=this.getOptions(),i=he(n.newLineTemplate,this.getOptions());n.newLineTemplate.isReverse?(i.from=t?t.id:"",i.to=e?e.id:"",i.isReverse=void 0,[e,t]=[t,e]):(i.from=e?e.id:"",i.to=t?t.id:""),i.disablePointEvent=!1;const a=this.emitEvent(A.beforeCreateLine,{lineJson:i,fromNode:e,toNode:t});if(C("[CreatingLinePlot]onCreateLine:abort-flag:",a),a===!0){C("[CreatingLinePlot]onCreateLine:abort!");return}if(this._onCreateLineCallback){C("[CreatingLinePlot]onCreateLine:callback");try{this._onCreateLineCallback(e,t,i)}catch(l){return console.warn("[Custom Reject Connect By Throw Error:",l),!1}}return C("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(A.onLineBeCreated,{lineJson:i,fromNode:e,toNode:t})}onContextmenu(e){e.stopPropagation(),e.preventDefault(),this.stopCreatingLinePlot();let t="canvas",n=this.isNode(e.target);n?t="node":(n=this.isLine(e.target),n&&(t="line")),C("contextmenu:objectType",t,n);const i=Ce(e),a=this.getCanvasXyByClientXy({x:i.clientX,y:i.clientY}),r=this.getViewXyByCanvasXy(a);this.emitEvent(A.onContextmenu,e,t,n,a,r)}async fullscreen(e){const t=this.getOptions();if(e!==void 0&&e===t.fullscreen)return;C("fullscreen:newValue:",e),console.log("fullscreen:newValue:",e),e===void 0&&(e=!t.fullscreen);let n=this.$dom;t.fullscreenElementXPath&&(n=document.querySelector(t.fullscreenElementXPath)||this.$dom),await Zn(n,e),this.dataProvider.updateOptions({fullscreen:e}),this.emitEvent(A.onFullscreen,e),this._dataUpdated()}onMouseWheel(e){const t=this.getOptions();if(!e.ctrlKey&&!e.metaKey&&(t.disableWheelEvent||t.wheelEventAction==="none"))return!0;try{e.preventDefault(),e.stopPropagation()}catch{}let{deltaX:n,deltaY:i,deltaMode:a}=e;a===1?(n*=40,i*=40):a===2&&(n*=800,i*=800),this._mouseWheelForce.x+=n,this._mouseWheelForce.y+=i,this._applyWheelEvent(e)}_applyWheelEvent(e){clearTimeout(this._mouseWheelTimer),this._mouseWheelTimer=setTimeout(()=>{const t=this._mouseWheelForce.x,n=this._mouseWheelForce.y;this._onMouseWheel(e,t,n),this._mouseWheelForce.x-=t,this._mouseWheelForce.y-=n,this._mouseWheelEventPrevApplyTime=Date.now(),(Math.abs(this._mouseWheelForce.x)>1||Math.abs(this._mouseWheelForce.y)>1)&&this._applyWheelEvent(e)},Date.now()-this._mouseWheelEventPrevApplyTime>50?0:50)}_onMouseWheel(e,t,n){const i=e.ctrlKey||e.metaKey,a=this.getOptions();if(!i&&a.wheelEventAction==="scroll"){let r=Math.max(Math.abs(t),Math.abs(n));const l=t/r,c=n/r;r>200&&(r=200);const d=a.mouseWheelSpeed/10*-l*r,h=a.mouseWheelSpeed/10*-c*r,f=this.emitEvent(A.beforeScrollStart,d,h,e);if(C("[scroll]","abortScroll:",f),f===!0)return;this.scrollView(d,h)}else if(!(!i&&a.wheelEventAction==="none")){const r={x:e.clientX,y:e.clientY};let l=a.mouseWheelSpeed/20*-n;l=Math.max(Math.min(l,20),-20),this.zoom(l,r,e)}}scrollView(e,t){const n=this.getOptions();this.dataProvider.setCanvasOffset(n.canvasOffset.x+e,n.canvasOffset.y+t),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}onLineDragStart(e,t){C("onLineDragStart...");const n=this.getLinkByLine(e),i={x:n.fromNode.x,y:n.fromNode.y},a={x:n.toNode.x,y:n.toNode.y},r=(l,c,d,h,f)=>{const y=this.dataProvider.getCanvasScale();n.fromNode.x=i.x+l/y,n.fromNode.y=i.y+c/y,n.toNode.x=a.x+l/y,n.toNode.y=a.y+c/y,this._updateEditingControllerView(),this._dataUpdated()};J.startDrag(t,{x:0,y:0},(...l)=>{this.onLineDragEnd(...l)},r)}onLineDragEnd(e,t,n){C("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(e){if(we(e)||e.target&&e.target.closest(".rg-line-peel"))return;const t=this.getOptions();if(this.dataProvider.isPerformanceMode()&&t.editingController.nodes.length>0){const n=this.getNodeAtEvent(e);if(n){this.onNodeDragStart(n,e);return}}if(t.dragEventAction==="none"){this.onCanvasClick(e);return}if(t.dragEventAction==="selection"||e.shiftKey){this.startCreateSelection(e);return}if(!t.disableDragLine){const n=this.isLine(e.target);if(n){this.onLineDragStart(n,e);return}}this.startMoveCanvas(e)}startMoveCanvas(e,t=!1){let n;if(ce(e)){let l,c=1;n=(d,h,f,y,u)=>{const g=u.touches||u.targetTouches,m=g[0];if(g&&g.length>1){u.preventDefault();const p=g[1],v=this.getOptions();l||(l={x:p.clientX,y:p.clientY},c=v.canvasZoom);const L={x:m.clientX,y:m.clientY},_={x:p.clientX,y:p.clientY},S=Math.hypot(l.x-y.x,l.y-y.y),O=Math.hypot(_.x-L.x,_.y-L.y)/S,R=v.mouseWheelSpeed*O,M=c*R;this.setZoom(M,y),this._dataUpdated()}else{const p=m.clientX,v=m.clientY,L=p-y.x,_=v-y.y,S=f.x+L,b=f.y+_;this.onCanvasDragging(S,b,_,L),this._updateEditingControllerView(),this._dataUpdated()}}}else n=(l,c,d,h,f)=>{const y=d.x+l,u=d.y+c;this.onCanvasDragging(y,u,l,c),this._updateEditingControllerView(),this._dataUpdated()};const i=this.getOptions(),a={x:i.canvasOffset.x,y:i.canvasOffset.y};let r=t;J.startDrag(e,a,(l,c,d)=>{this.onCanvasDragStop(l,c,d)},(l,c,d,h,f)=>{r?n(l,c,d,h,f):Math.abs(l)+Math.abs(c)>4&&(this.emitEvent(A.onCanvasDragStart,d,h,f),r=!0)})}onCanvasDragging(e,t,n,i){const a=this.emitEvent(A.onCanvasDragging,e,t,n,i);a!==!1&&(a&&(typeof a.x=="number"&&(e=a.x),typeof a.y=="number"&&(t=a.y)),this.dataProvider.setCanvasOffset(e,t))}onCanvasDragStop(e,t,n){const i=this.getOptions();if(i.creatingSelection){this.dataProvider.updateOptions({creatingSelection:!1}),this.onCanvasSelectionEnd(i.selectionView,n);return}if(Math.abs(e)+Math.abs(t)<4){C("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else C("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(e){const t=()=>{if(!n||a)return;const d=this.getViewXyByEvent(n);this.canvasAutoMoving(d)&&this._updateEditingControllerView();const f=this.getViewXyByCanvasXy(r),y=d.x-f.x,u=d.y-f.y;y<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x+y,width:Math.abs(y)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:f.x,width:Math.abs(y)}}),u<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y+u,height:Math.abs(u)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:f.y,height:u}}),this._dataUpdated()};let n,i=!1,a=!0;const r=this.getCanvasXyByViewXy(this.getViewXyByEvent(e)),l=()=>{t(),this._canvasMovingTimer=requestAnimationFrame(l)},c=(d,h,f,y,u)=>{n=u,i?n=u:Math.abs(d)+Math.abs(h)>6&&(i=!0,a=!1,this.dataProvider.updateOptions({creatingSelection:!0}),this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this._canvasMovingTimer=requestAnimationFrame(l)),this._dataUpdated()};J.startDrag(e,{x:0,y:0},(...d)=>{a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.onCanvasDragStop(...d)},c)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let e=!1;document.fullscreenElement?(C("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(C("relation-graph is fullscreen!"),e=!0)):C("div exited fullscreen mode"),e!==this.getOptions().fullscreen&&(this.dataProvider.updateOptions({fullscreen:e}),this._dataUpdated(),setTimeout(async()=>{this.resetViewSize(),this._moveToCenter(),this.zoomToFit(),C("relation-graph reset complete!")},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}defaultLineConnectEndHandler(e,t,n){C("defaultLineConnectEndHandler:",e,t,n)}defaultLineVertexBeChangedHandler(e,t,n){C("defaultLineVertexBeChangedHandler:",n&&n.isReverse)}async sleep(e){await Xe(e)}forceLayoutTickCallback(){this._updateEditingControllerView(),this.dataProvider.updateShouldRenderGraphData(),this._dataUpdated()}}class ti extends ei{constructor(){super();N(this,"$easyViewCanvas");N(this,"$rgWebglPainter");N(this,"_updateEasyViewRequested",!1);N(this,"_easyViewOffset",{x:0,y:0})}setEasyViewCanvas(e){this.$easyViewCanvas=e,this.$rgWebglPainter=new pn(e)}updateEasyView(){this.updateMiniView(),this.dataProvider.isPerformanceMode()&&(!this.getOptions().showEasyView||this._updateEasyViewRequested||(this._updateEasyViewRequested=!0,requestAnimationFrame(this._updateEasyView.bind(this))))}_updateEasyView(e){try{const t=Date.now();if(!this.$easyViewCanvas)return;this.updateShouldRenderGraphData(),this.evDosomethingBeforeDraw(),this.evDrawAllLines(),this.evDrawAllNodes()}catch(t){console.error(t)}finally{this._updateEasyViewRequested=!1}}evDosomethingBeforeDraw(){const e=this.getOptions(),t=e.viewSize.width,n=e.viewSize.height;this.$easyViewCanvas.width=t,this.$easyViewCanvas.height=n,this.$rgWebglPainter.setSize(t,n),C("updateEasyView:viewSize:",t,n);const i=this.dataProvider.getCanvasScale();this.$rgWebglPainter.setScale(i),this._easyViewOffset.x=e.canvasOffset.x,this._easyViewOffset.y=e.canvasOffset.y,this.$rgWebglPainter.setViewOffset(this._easyViewOffset.x,this._easyViewOffset.y),this.$rgWebglPainter.beforeDraw()}evDrawAllNodes(){const e=this.getOptions().defaultNodeShape;for(const t of this.getNodes()){if(!(t.rgShouldRender!==!1&&t.rgCalcedVisibility&&t.opacity!==0))continue;const i=Ne(t.nodeShape,e);this.evDrawNode(t,i)}}evDrawNode(e,t){t===_e.circle?this.evDrawNode4Circle(e):this.evDrawNode4Rect(e)}getNodeColor(e){const t=e.color||this.getOptions().defaultNodeColor||"#dddddd";return t==="transparent"?"rgba(204,204,204,0.2)":t}evDrawNode4Rect(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderRadius===void 0?3:e.borderRadius,l=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Rect(e.x,e.y,t,n,a,i,r,l)}evDrawNode4Circle(e){const t=e.el_W,n=e.el_H,i=e.opacity||.8,a=this.getNodeColor(e),r=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Circle(e.x,e.y,t,n,a,i,r)}evDrawAllLines(){for(const e of this.getLinks()){const t=e.fromNode.rgShouldRender!==!1&&e.fromNode.opacity!==0&&e.fromNode.rgCalcedVisibility,n=e.toNode.rgShouldRender!==!1&&e.toNode.opacity!==0&&e.toNode.rgCalcedVisibility;!t&&!n||this.evDrawLine(e,e.line)}}evDrawLine(e,t){const n=this.createLineDrawInfo(e,t),i=t.opacity||1,a=this.getOptions(),r=t.color||a.defaultLineColor||"#888888",l=t.lineWidth||a.defaultLineWidth||1;this.$rgWebglPainter.evDrawLine(n.pathData,l,r,i)}}class ni extends ti{constructor(){super();N(this,"_onResizing");N(this,"_onResizeEnd");N(this,"_startPoint",{x:0,y:0});N(this,"_startEventCanvasXy",{x:0,y:0});N(this,"_startSizeCanvasXy",{x:0,y:0});N(this,"_startSize",{x:0,y:0,width:0,height:0,widthOnCanvas:0,heightOnCanvas:0});N(this,"_resizeType","l");N(this,"_nodeStartSizeMap",new WeakMap);N(this,"resizeMinLimit",{width:10,height:10});N(this,"_resizeDraggingTimer");N(this,"_resizeDraggingEvent");N(this,"_resizeDraggingStoped",!0);N(this,"_startCreateLineFromNodeTime",0)}setEditingNodes(e){if(e===null||e.length===0)this.dataProvider.setEditingNodes([]);else{const t=e.map(i=>i.id),n=this.getNodes().filter(i=>t.includes(i.id));this.dataProvider.setEditingNodes(n)}this._updateEditingControllerView(),this._dataUpdated()}addEditingNode(e){if(!this.getNodeById(e.id))throw new Error("Node not found: "+e.id);this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.concat(e)),this._updateEditingControllerView(),this._dataUpdated()}removeEditingNode(e){this.dataProvider.setEditingNodes(this.getOptions().editingController.nodes.filter(t=>t.id!==e.id)),this._updateEditingControllerView(),this._dataUpdated()}toggleEditingNode(e){this.getOptions().editingController.nodes.findIndex(n=>n.id===e.id)===-1?this.addEditingNode(e):this.removeEditingNode(e)}updateEditingControllerView(){this._updateEditingControllerView(),this._dataUpdated()}_updateEditingControllerView(){this._updateEditingLineView(),this._updateEditingConnectControllerView();const e=this.getOptions();if(!e.editingController.show)return;const{minX:t,minY:n,maxX:i,maxY:a}=this.getNodesRectBox(e.editingController.nodes),r=e.editingController.nodes.length>1?5:0,l=this.dataProvider.getCanvasScale();let c=i-t,d=a-n;if(c<0&&(c=0),d<0&&(d=0),c>0&&d>0){const h=this.getViewXyByCanvasXy({x:t,y:n}),f=h.x-r*l,y=h.y-r*l,u=c*l+r*2*l,g=d*l+r*2*l;this.dataProvider.updateOptions({editingController:{...e.editingController,x:f,y,width:u,height:g}})}else this.dataProvider.updateOptions({editingController:{...e.editingController,show:!1}})}onResizeStart(e,t){this._resizeType=e,this._startPoint=this.getViewXyByEvent(t),this._startEventCanvasXy=this.getCanvasXyByViewXy(this._startPoint);const n=this.getOptions();this._startSize.x=n.editingController.x,this._startSize.y=n.editingController.y,this._startSizeCanvasXy=this.getCanvasXyByViewXy(this._startSize),this._startSize.width=n.editingController.width,this._startSize.height=n.editingController.height;const i=this.dataProvider.getCanvasScale();this._startSize.widthOnCanvas=n.editingController.width/i,this._startSize.heightOnCanvas=n.editingController.height/i;for(const l of n.editingController.nodes)this._nodeStartSizeMap.set(l,{x:l.x,y:l.y,width:l.el_W,height:l.el_H});this._onResizing&&this.$dom.removeEventListener("mousemove",this._onResizing),this._onResizeEnd&&this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._resizeDraggingEvent=null,this._resizeDraggingStoped=!1,this._onResizing=this.onResizing.bind(this),this._onResizeEnd=this.onResizeEnd.bind(this),this.$dom.addEventListener("mousemove",this._onResizing),this.$dom.addEventListener("mouseup",this._onResizeEnd);const a=this.onResizingRequest.bind(this),r=()=>{a(),this._resizeDraggingTimer=requestAnimationFrame(r)};this._resizeDraggingTimer=requestAnimationFrame(r),this.emitEvent(A.onResizeStart,n.editingController.nodes)}onResizing(e){this._resizeDraggingEvent=e}onResizingRequest(){if(!this._resizeDraggingEvent||this._resizeDraggingStoped)return;const e=this.getViewXyByEvent(this._resizeDraggingEvent);this.canvasAutoMoving(e);const t=this.getViewXyByCanvasXy(this._startEventCanvasXy),n=this.getViewXyByCanvasXy(this._startSizeCanvasXy),i=e.x-t.x,a=e.y-t.y,r=this.getOptions();let l=r.editingController.width,c=r.editingController.height,d=r.editingController.x,h=r.editingController.y;const f=this.dataProvider.getCanvasScale();this._resizeType==="tl"?(d=t.x+i,h=t.y+a,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="tr"?(h=t.y+a,d=n.x,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="bl"?(d=t.x+i,h=n.y,l=this._startSize.widthOnCanvas*f-i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="br"?(d=n.x,h=n.y,l=this._startSize.widthOnCanvas*f+i,c=this._startSize.heightOnCanvas*f+a):this._resizeType==="t"?(h=t.y+a,c=this._startSize.heightOnCanvas*f-a):this._resizeType==="r"?(d=n.x,l=this._startSize.widthOnCanvas*f+i):this._resizeType==="b"?(c=this._startSize.heightOnCanvas*f+a,h=n.y):this._resizeType==="l"&&(d=t.x+i,l=this._startSize.widthOnCanvas*f-i),l<this.resizeMinLimit.width&&(l=this.resizeMinLimit.width),c<this.resizeMinLimit.width&&(c=this.resizeMinLimit.height),this.dataProvider.updateOptions({editingController:{...r.editingController,x:d,y:h,width:l,height:c}}),this._applyResizeScale(this._resizeDraggingEvent),this._updateEditingControllerView(),this._dataUpdated()}_applyResizeScale(e){const t=this.getOptions(),n=this.dataProvider.getCanvasScale(),i=t.editingController.width/n/this._startSize.widthOnCanvas,a=t.editingController.height/n/this._startSize.heightOnCanvas,r=this._startSizeCanvasXy,l=this.getCanvasXyByViewXy({x:t.editingController.x,y:t.editingController.y});let c=!0,d=!0;this._resizeType==="t"||this._resizeType==="b"?c=!1:(this._resizeType==="r"||this._resizeType==="l")&&(d=!1);for(const h of t.editingController.nodes){const f=this._nodeStartSizeMap.get(h),y=f.width*i,u=f.height*a,g=l.x+i*(f.x-r.x),m=l.y+a*(f.y-r.y),p=y,v=u;this.emitEvent(A.beforeNodeResize,h,g,m,p,v)===!1||(c&&this.dataProvider.updateNode(h.id,{x:g,width:p,el_W:p}),d&&this.dataProvider.updateNode(h.id,{y:m,height:v,el_H:v}),C("ResizeNode:",h.id,p,v,i,a))}}onResizeEnd(e){cancelAnimationFrame(this._resizeDraggingTimer),this._resizeDraggingStoped=!0;const t=this.getViewXyByEvent(e),n=t.x-this._startPoint.x,i=t.y-this._startPoint.y;this._applyResizeScale(e),this.$dom.removeEventListener("mousemove",this._onResizing),this.$dom.removeEventListener("mouseup",this._onResizeEnd),this._onResizing=null,this._onResizeEnd=null,this.emitEvent(A.onResizeEnd,this.getOptions().editingController.nodes,n,i,e)}draggingSelectedNodes(e,t,n,i,a){const r=this.updateReferenceLineView(e,t,n,i,a);if(r){const{showV:c,fixedX:d,showH:h,fixedY:f}=r;c&&(i+=d-t,t=d),h&&(a+=f-n,n=f)}const l=this.getOptions();if(!l.editingController.nodes.includes(e))this.dataProvider.updateNode(e.id,{x:t,y:n}),this._updateEditingLineView();else{for(const c of l.editingController.nodes){const d=this._nodeXYMappingBeforeDrag[c.id];d&&this.dataProvider.updateNode(c.id,{x:d.x+i,y:d.y+a})}this._updateEditingControllerView()}}_updateEditingConnectControllerView(){const e=this.getOptions();if(!e.nodeConnectController.show)return;const t=e.nodeConnectController.node,n=t.x,i=t.y,a=t.x+t.el_W,r=t.y+t.el_H,l=0,c=this.dataProvider.getCanvasScale(),d=n,h=i,f=a-n,y=r-i,u=this.getViewXyByCanvasXy({x:d,y:h});this.dataProvider.updateOptions({nodeConnectController:{...e.nodeConnectController,x:u.x-l*c,y:u.y-l*c,width:f*c+l*2*c,height:y*c+l*2*c}})}setEditingLine(e){this.dataProvider.setEditingLine(e),this._updateEditingLineView(),this._dataUpdated()}updateReferenceLineView(e,t,n,i,a){const r=this.getOptions();if(!r.showReferenceLine)return;if(!r.editingReferenceLine.show){const T=Math.abs(i),w=Math.abs(a);T+w>2&&this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,show:!0}})}if(!r.editingReferenceLine.show)return;const l=t,c=e.el_W,d=e.el_H,h=t+c/2,f=t+c,y=n,u=n+d/2,g=n+d,m=this.getViewXyByCanvasXy({x:h,y:u});let p=!1,v=!1,L=0,_=0;const S=this.getNodes().filter(T=>this._nodeXYMappingBeforeDrag[T.id]?!1:Math.abs(T.x-h)<600&&Math.abs(T.y-u)<600);S.sort((T,w)=>{const D=ge(h,u,T.x+T.el_W/2,T.y+T.el_H/2),V=ge(h,u,w.x+w.el_W/2,w.y+w.el_H/2);return D<V?-1:1});let{v_x:b,v_y:O,v_height:R,h_x:M,h_y:k,h_width:P}=r.editingReferenceLine;for(const T of S){const w=T.x,D=T.el_W,V=T.el_H,X=T.x+D/2,G=T.x+D,E=T.y,j=T.y+V/2,$=T.y+V,K=Math.abs(l-w),Q=Math.abs(h-X),ie=Math.abs(f-G),te=Math.abs(y-E),ee=Math.abs(u-j),se=Math.abs(g-$),ae=5;if(Q<800&&ee<800){if(!v&&Q<ae){const Y=this.getViewXyByCanvasXy({x:X,y:j});b=Y.x,O=m.y>Y.y?Y.y:m.y,R=Math.round(Math.abs(m.y-Y.y)),v=!0,L=X-c/2}if(!v&&K<ae){const Y=this.getViewXyByCanvasXy({x:w,y:j});b=Y.x,O=m.y>Y.y?Y.y:m.y,R=Math.round(Math.abs(m.y-Y.y)),v=!0,L=w}if(!v&&ie<ae){const Y=this.getViewXyByCanvasXy({x:G,y:j});b=Y.x,O=m.y>Y.y?Y.y:m.y,R=Math.round(Math.abs(m.y-Y.y)),v=!0,L=G-c}if(!p&&ee<ae){const Y=this.getViewXyByCanvasXy({x:X,y:j});k=Y.y,M=m.x>Y.x?Y.x:m.x,P=Math.round(Math.abs(m.x-Y.x)),p=!0,_=j-d/2}if(!p&&te<ae){const Y=this.getViewXyByCanvasXy({x:X,y:E});k=Y.y,M=m.x>Y.x?Y.x:m.x,P=Math.round(Math.abs(m.x-Y.x)),p=!0,_=E}if(!p&&se<ae){const Y=this.getViewXyByCanvasXy({x:X,y:$});k=Y.y,M=m.x>Y.x?Y.x:m.x,P=Math.abs(m.x-Y.x),p=!0,_=$-d}if(p&&v)break}}if(this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,v_x:b,v_y:O,v_height:R,h_x:M,h_y:k,h_width:P,directionH:p,directionV:v}}),r.referenceLineAdsorption)return{showV:v,fixedX:L,showH:p,fixedY:_}}hideEditingLineView(){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}})}updateEditingLineView(){this._updateEditingLineView(),this._dataUpdated()}_updateEditingLineView(){this.updateElementLines();const e=this.getOptions();if(!e.editingLineController.show)return;const t=e.editingLineController.line,n=this.getLinkByLine(t);if(!t||t.to==="newRelationTemplate-to"){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}let i,a,r;const l=this.createLineDrawInfo(n,t);if(!l){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}if(t.lineShape===F.StandardOrthogonal){let{textPosition:_,pathData:S,points:b,startDirection:O,endDirection:R}=l;r=_,i=b[0],a=b[b.length-1];const M=[];for(let k=0;k<b.length-1;k++){const P=b[k],T=b[k+1],w={pIndex:k,optionName:"cp-"+k,x:0,y:0,direction:"v",startDirection:O,endDirection:R};P.x!==T.x&&(w.direction="h");const D=this.getViewXyByCanvasXy({x:(P.x+T.x)/2,y:(P.y+T.y)/2});w.x=D.x,w.y=D.y,M.push(w)}if(M.length!==1){if(M.length!==2)if(M.length===3){const k=b[0],P=b[1],T=b[3];if(M[1].direction==="v"){const w=k.x,D=P.x,V=T.x;if(Math.max(w,D,V)!==D&&Math.min(w,D,V)!==D)M[1].optionName="cx";else{const G=Math.abs(D-w),E=Math.abs(D-V);G>=E?M[1].optionName="td":G<E&&(M[1].optionName="fd")}}else{const w=k.y,D=P.y,V=T.y;if(Math.max(w,D,V)!==D&&Math.min(w,D,V)!==D)M[1].optionName="cy";else{const G=Math.abs(D-w),E=Math.abs(D-V);G>=E?M[1].optionName="td":G<E&&(M[1].optionName="fd")}}}else M.length===4?(M[1].optionName="fd",M[2].optionName="td"):M.length===5&&(M[1].optionName="fd",M[2].direction==="v"?M[2].optionName="cx":M[2].optionName="cy",M[3].optionName="td")}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:M,line49Points:b}})}else if(t.lineShape===F.HardOrthogonal){let{textPosition:_,pathData:S,points:b,startDirection:O,endDirection:R}=l;r=_;const M=[];b=t.ctrlPointsFor49,i=b[0],a=b[b.length-1];const k=b;for(let P=0;P<k.length-1;P++){const T=k[P],w=k[P+1],D={pIndex:P,optionName:"cp-"+P,x:0,y:0,direction:"v",startDirection:O,endDirection:R};T.x!==w.x?(D.direction="h",Math.abs(T.x-w.x)<15&&(D.hide=!0)):Math.abs(T.y-w.y)<15&&(D.hide=!0);const V=this.getViewXyByCanvasXy({x:(T.x+w.x)/2,y:(T.y+w.y)/2});D.x=V.x,D.y=V.y,M.push(D)}for(let P=0;P<M.length;P++){const T=M[P-1],w=M[P],D=M[P+1];P===0&&w.direction===D.direction&&(w.hide=!0),P===M.length-1&&w.direction===T.direction&&(w.hide=!0)}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:M,line49Points:k}})}else if(t.lineShape!==1){r=l.textPosition;const _=Je(l.pathData);let S,b;t.isReverse?(i=_.endPoint,a=_.startPoint,S=this.getViewXyByCanvasXy(_.ctrl1),b=this.getViewXyByCanvasXy(_.ctrl2)):(i=_.startPoint,a=_.endPoint,S=this.getViewXyByCanvasXy(_.ctrl1),b=this.getViewXyByCanvasXy(_.ctrl2)),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,ctrlPoint1:S,ctrlPoint2:b}})}else{r=l.textPosition;const _=l.pathData,S=Je(_);i=S.startPoint,a=S.endPoint}const c=this.getViewXyByCanvasXy(t.isReverse?a:i),d=this.getViewXyByCanvasXy(t.isReverse?i:a);this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,startPoint:c,endPoint:d}});const h=this.getViewXyByCanvasXy(r),f=this.$canvasDom.querySelector(`g[data-id='${t.id}']`);let y=0,u=0,g=t.textOffset_x||0,m=t.textOffset_y||0;const p=this.dataProvider.getCanvasScale();let v=20,L=20;if(f){const _=f.querySelector("text.rg-line-text");if(_){g=Math.floor(parseFloat(_.getAttribute("x")||"0")),m=Math.floor(parseFloat(_.getAttribute("y")||"0"));const S=_.clientWidth,b=_.clientHeight;v=S,L=b}}v+=40,L+=10,v>120&&(v=120),L>20&&(L=20),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,text:{...this.getOptions().editingLineController.text,width:v,height:L,x:h.x+y+g*p,y:h.y+u+m*p}}})}startMoveLineVertex(e,t,n){t.stopPropagation();const i=this.getOptions().editingLineController.line,a=this.getLinkByLine(i);let r,l;if(a)r=a.fromNode,l=a.toNode;else{const{from:h,to:f}=this.generateFakeLineConfig(i);r=h,l=f}let c=r;this.dataProvider.setEditingLine(null),a?this.removeLine(i):this.removeFakeLine(i),console.log("DragLine start:",e,i.isReverse);let d=!1;i.lineShape===F.HardOrthogonal&&(i.lineShape=F.StandardOrthogonal),e==="start"?(i.fromJuctionPointOffsetX=0,i.fromJuctionPointOffsetY=0,c=l,d=!0):(i.toJuctionPointOffsetX=0,i.toJuctionPointOffsetY=0),this.startCreatingLinePlot(t,{template:i,fromNode:c,isReverse:d,onCreateLine:n})}startCreateLineFromNode(e,t,n,i){n.stopPropagation();const a=JSON.parse(JSON.stringify(t));if(this._startCreateLineFromNodeTime=Date.now(),!a.from){if(!e){const l=this.getOptions().editingController.nodes;l.length===1&&(e=l[0])}e&&(a.from=e.id,a.fromType=e.targetType)}if(!a.from)throw console.error("Error:lineTemplate:",a),Error("Error:startCreateLineByTemplate: lineTemplate must has [fromType, from]");const r=this.getFakeLineTarget(a.fromType,a.from,a);if(!r)throw console.error("Error:fakeTarget[fromType, from]:",a.fromType,a.from,a),Error(`Error:startCreateLineByTemplate: error from fakeTarget[fromType, from]:${a.fromType}, ${a.from}`);a.lineShape||(a.lineShape=6),this.startCreatingLinePlot(n,{template:a,fromNode:r,isReverse:!1,onCreateLine:i})}onLineVertexBeDropped(e,t,n={x:0,y:0},i){t.stopPropagation();const a=this.getOptions();if(!a.creatingLinePlot||Date.now()-this._startCreateLineFromNodeTime<500)return;console.log("Connect end:isReverse:",a.newLineTemplate.isReverse);const r=a.nodeConnectController.node;let{toJunctionPoint:l,toJuctionPointOffsetX:c,toJuctionPointOffsetY:d,fromJunctionPoint:h,fromJuctionPointOffsetX:f,fromJuctionPointOffsetY:y}=a.newLineTemplate;if(!a.newLinkTemplate.fromNode)a.newLineTemplate.isReverse?(l=e,c=n.x,d=n.y):(h=e,f=n.x,y=n.y),this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJuctionPointOffsetX:f,fromJuctionPointOffsetY:y,toJunctionPoint:l,toJuctionPointOffsetX:c,toJuctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:r}});else{a.newLineTemplate.isReverse?(h=e,f=n.x,y=n.y):(l=e,c=n.x,d=n.y);const u=this.getOptions().newLinkTemplate.fromNode;this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:h,fromJuctionPointOffsetX:f,fromJuctionPointOffsetY:y,toJunctionPoint:l,toJuctionPointOffsetX:c,toJuctionPointOffsetY:d},newLinkTemplate:{...this.getOptions().newLinkTemplate,toNodeObject:r}});const g=r;try{const m={newLineTemplate:this.getOptions().newLineTemplate,fromNode:u,toNode:g};this.emitEvent(A.onLineVertexDropped,m),i&&i(m.fromNode,m.toNode,m.newLineTemplate),this.onReadyToCreateLine(this.getOptions().newLinkTemplate.fromNode,this.getOptions().nodeConnectController.node)!==!0&&this.stopCreatingLinePlot()}catch(m){this.stopCreatingLinePlot(),console.warn("[Custom Reject onCreateLine By Throw Error:",m)}}}startMoveLineText(e,t){if(we(e))return;const n=this.getViewXyByEvent(e),a=this.getOptions().editingLineController.line;console.log("startMoveLineText:",a.id);const r=a.textOffset_x||0,l=a.textOffset_y||0,c=h=>{const f=this.dataProvider.getCanvasScale(),y=this.getViewXyByEvent(h),u=y.x-n.x,g=y.y-n.y;a.textOffset_x=Math.round(r+u/f),a.textOffset_y=Math.round(l+g/f),this._updateEditingLineView(),this._dataUpdated()},d=h=>{this.$dom.removeEventListener("mousemove",c),this.$dom.removeEventListener("mouseup",d),t&&t(),this._dataUpdated()};this.$dom.addEventListener("mousemove",c),this.$dom.addEventListener("mouseup",d)}startMoveLine6CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const r=this.getOptions().editingLineController.line;let l=r.ctrlPoints||[];l.length===0&&(l.push({x:0,y:0}),l.push({x:0,y:0})),this.dataProvider.updateLine(r.id,{ctrlPoints:l}),console.log("startMoveLine6CtrlPoint:line:",r),l=r.ctrlPoints,r.isReverse&&(e=l.length-1-e);const c=this.dataProvider.getCanvasScale(),d=l[e],{x:h,y:f}=d,y=()=>{n(r),this._dataUpdated()};J.startDrag(t,{x:0,y:0},y,(u,g)=>{d.x=h+u/c,d.y=f+g/c,this.dataProvider.updateLine(r.id,{ctrlPoints:l}),this._updateEditingLineView(),this._dataUpdated()})}startMoveLine44CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const a=this.getOptions().editingLineController,r=a.line;console.log("startMoveLine44CtrlPoint:",r==null?void 0:r.lineShape,e.optionName);let l=r.ctrlOptionsFor44;l||(l={cx:0,cy:0,fd:0,td:0},this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l}),l=r.ctrlOptionsFor44);const c=l[e.optionName],d={indexOffset:0};let h=r.ctrlPointsFor49?JSON.parse(JSON.stringify(r.ctrlPointsFor49)):null;const f=(u,g)=>{console.log("lineSplitCtrlMoving:",r==null?void 0:r.lineShape,e.optionName);const m=this.dataProvider.getCanvasScale();if(r.lineShape===F.StandardOrthogonal){if(e.optionName==="cx"){const v=c+u/m*1;l.cx=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="cy"){const v=c+g/m*1;l.cy=v,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="fd"){const p=Me[e.startDirection],v=e.direction==="v"?u*p.x:g*p.y;l.fd=c+v/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.optionName==="td"){const p=Me[e.endDirection],v=e.direction==="v"?u*p.x:g*p.y;l.td=c+v/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:l})}else if(e.direction==="v"&&Math.abs(u)>5||e.direction==="h"&&Math.abs(g)>5){const p=a.line49Points;h=JSON.parse(JSON.stringify(p)),console.log(":startCtrlPointsFor49:::",h),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:h}),this.dataProvider.updateLine(r.id,{lineShape:F.HardOrthogonal})}}else if(r.lineShape===F.HardOrthogonal){const{newPoints:p,pointsChanged:v}=Cn(r.ctrlPointsFor49,h,e.pIndex+d.indexOffset,e,d,u/m,g/m);v&&(h=JSON.parse(JSON.stringify(p))),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:p})}},y=()=>{if(r.lineShape===F.HardOrthogonal){const u=ke(r.ctrlPointsFor49);this.dataProvider.updateLine(r.id,{ctrlPointsFor49:u})}this._updateEditingLineView(),n&&n(r),this._dataUpdated()};J.startDrag(t,{x:0,y:0},y,(u,g)=>{f(u,g),this._updateEditingLineView(),this._dataUpdated()})}onLineVertexBeDroppedOnConnectController(e,t,n,i){if(C("onLineVertexBeDroppedOnConnectController",e,t,n),t.stopPropagation(),!n){this.onLineVertexBeDropped(e,t,void 0,i);return}const a=Ce(t),r=n.getBoundingClientRect(),l={x:r.left,y:r.top+r.height/2},c={x:r.left+r.width/2,y:r.top},d={x:r.left+r.width,y:r.top+r.height/2},h={x:r.left+r.width/2,y:r.top+r.height};let f=de.left;const y={x:0,y:0};if(e)f=e,f===de.top||f===de.bottom?y.x=a.clientX-h.x:f===de.right?y.y=a.clientY-d.y:y.y=a.clientY-l.y;else{const g=ge(a.clientX,a.clientY,l.x,l.y),m=ge(a.clientX,a.clientY,c.x,c.y),p=ge(a.clientX,a.clientY,d.x,d.y),v=ge(a.clientX,a.clientY,h.x,h.y),L=Math.min(g,m,p,v);L===g?(f=de.left,y.x=a.clientX-l.x,y.y=a.clientY-l.y):L===m?(f=de.top,y.x=a.clientX-c.x,y.y=a.clientY-c.y):L===p?(f=de.right,y.x=a.clientX-d.x,y.y=a.clientY-d.y):L===v&&(f=de.bottom,y.x=a.clientX-h.x,y.y=a.clientY-h.y)}const u=this.dataProvider.getCanvasScale();y.x=y.x/u,y.y=y.y/u,C("onMouseUpWithOffset:",e,y),this.onLineVertexBeDropped(f,t,y,i)}}class ii extends ni{constructor(){super();N(this,"$miniViewCanvas");N(this,"$mvCanvasCtx");N(this,"_canvasDomScale",1);N(this,"miniViewBox",{visibleAreaStart:{x:0,y:0},visibleAreaEnd:{x:0,y:0},canvas_start_x:0,canvas_start_y:0,canvas_end_x:0,canvas_end_y:0,canvas_width:0,canvas_height:0,miniview_width:0,miniview_height:0});N(this,"visibleArea",{x:0,y:0});N(this,"_canvasItemMiniSizeLimit",1)}setMiniViewCanvas(e){this.$miniViewCanvas=e,this.$mvCanvasCtx=this.$miniViewCanvas.getContext("2d")}updateMiniView(){!this.getOptions().showMiniView||(this.updateMiniViewVisibleArea(),this._updateMiniView())}_updateMiniView(){try{const e=Date.now();this.mvDosomethingBeforeDraw(),this.mvDrawAllNodes()}catch(e){console.error(e)}}mvDosomethingBeforeDraw(){let e=9999999,t=9999999,n=-9999999,i=-9999999,a=0;for(const v of this.getNodes())if(v.rgCalcedVisibility&&v.opacity!==0){v.x<e&&(e=v.x),v.y<t&&(t=v.y);const L=v.x+v.el_W,_=v.y+v.el_H;L>n&&(n=L),_>i&&(i=_),a++}const r=1,l=50,c=50;a===0?(this.miniViewBox.canvas_start_x=-100-l,this.miniViewBox.canvas_start_y=-100-c,this.miniViewBox.canvas_end_x=100+l,this.miniViewBox.canvas_end_y=100+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y):(this.miniViewBox.canvas_start_x=e-l,this.miniViewBox.canvas_start_y=t-c,this.miniViewBox.canvas_end_x=n+l,this.miniViewBox.canvas_end_y=i+c,this.miniViewBox.canvas_width=this.miniViewBox.canvas_end_x-this.miniViewBox.canvas_start_x,this.miniViewBox.canvas_height=this.miniViewBox.canvas_end_y-this.miniViewBox.canvas_start_y);const d=this.$miniViewCanvas.parentElement.getBoundingClientRect(),h=d.width,f=d.height;let y=0,u=0,g=1;h/this.miniViewBox.canvas_width<f/this.miniViewBox.canvas_height?(g=h/this.miniViewBox.canvas_width*r,y=h,u=h/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=f/this.miniViewBox.canvas_height*r,y=f/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,u=f),this.miniViewBox.miniview_width=h,this.miniViewBox.miniview_height=f,this.$miniViewCanvas.width=h,this.$miniViewCanvas.height=f,this.$mvCanvasCtx.canvas.width=h*window.devicePixelRatio,this.$mvCanvasCtx.canvas.height=f*window.devicePixelRatio,this.$mvCanvasCtx.canvas.style.width=`${h}px`,this.$mvCanvasCtx.canvas.style.height=`${f}px`;const m=(f-u)/2,p=(h-y)/2;this.miniViewBox.canvas_start_x-=p/g,this.miniViewBox.canvas_start_y-=m/g,this.$mvCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$mvCanvasCtx.scale(g,g),this._canvasDomScale=g,this.$mvCanvasCtx.clearRect(0,0,this.$mvCanvasCtx.canvas.width,this.$mvCanvasCtx.canvas.height)}updateMiniViewVisibleArea(){const e=this.getCanvasXyByViewXy({x:0,y:0}),t=this.getOptions().viewSize,n=this.getCanvasXyByViewXy({x:t.width,y:t.height}),i=this._canvasDomScale,a=n.x-e.x,r=n.y-e.y;this.miniViewBox.visibleAreaStart=e,this.miniViewBox.visibleAreaEnd=n;const l=i*a,c=i*r,d=e.x-this.miniViewBox.canvas_start_x,h=e.y-this.miniViewBox.canvas_start_y,f=i*d,y=i*h;let u=!1;(f+l<0||y+c<0||y>this.miniViewBox.miniview_height||f>this.miniViewBox.miniview_width)&&(u=!0),this.dataProvider.updateOptions({miniViewVisibleHandle:{...this.getOptions().miniViewVisibleHandle,emptyContent:u,width:l,height:c,x:f,y}})}mvDrawAllNodes(){const e=this._canvasDomScale,t=this.getOptions().defaultNodeShape;for(const n of this.getNodes())if(n.rgCalcedVisibility&&n.opacity!==0){let i=n.el_W,a=n.el_H;e*i<this._canvasItemMiniSizeLimit&&(i=this._canvasItemMiniSizeLimit/this._canvasDomScale),e*a<this._canvasItemMiniSizeLimit&&(a=this._canvasItemMiniSizeLimit/this._canvasDomScale);const r=Ne(n.nodeShape,t);this.mvDrawNode(n,r,i,a)}}mvDrawNode(e,t,n,i){t===_e.circle?this.mvDrawNode4Circle(e,n,i):this.mvDrawNode4Rect(e,n,i)}mvDrawNode4Rect(e,t,n){const i=this.$mvCanvasCtx,a=e.x-this.miniViewBox.canvas_start_x,r=e.y-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.rect(a,r,t,n),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawNode4Circle(e,t,n){const i=this.$mvCanvasCtx,a=e.x+t/2-this.miniViewBox.canvas_start_x,r=e.y+n/2-this.miniViewBox.canvas_start_y;i.beginPath(),i.globalAlpha=e.opacity||1,i.ellipse(a,r,t/2,n/2,0,0,2*Math.PI),i.fillStyle=this.getNodeColor(e),i.fill(),i.strokeStyle="#666666",i.lineWidth=2,i.stroke(),i.globalAlpha=1}mvDrawAllLines(){for(const e of this.getLinks())e.fromNode.rgCalcedVisibility&&e.toNode.rgCalcedVisibility&&this.mvDrawLine(e,e.line)}mvDrawLine(e,t){const n=this.$mvCanvasCtx,i=this.createLineDrawInfo(e,t);n.beginPath(),n.globalAlpha=t.opacity||1,this.mvDrawSvgPathOnCanvas(n,i.pathData);const a=this.getOptions();n.strokeStyle=t.color||a.defaultLineColor||"#888888",n.lineWidth=t.lineWidth||a.defaultLineWidth||1,n.stroke(),n.globalAlpha=1}mvDrawSvgPathOnCanvas(e,t){const n=t.match(/[a-zA-Z][^a-zA-Z]*/g);let i=0,a=0,r=0,l=0,c=0,d=0,h=0,f=0,y=!1;n.forEach(u=>{const g=u.trim().split(/[ ,]+/),m=g[0].toUpperCase(),p=g[0]===g[0].toLowerCase();switch(m){case"M":i=H(r,g[1],p)-this.miniViewBox.canvas_start_x,a=H(l,g[2],p)-this.miniViewBox.canvas_start_y,r=i,l=a,y&&(e.closePath(),y=!1),e.moveTo(i,a);break;case"L":i=H(r,g[1],p)-this.miniViewBox.canvas_start_x,a=H(l,g[2],p)-this.miniViewBox.canvas_start_y,e.lineTo(i,a);break;case"C":c=H(r,g[1],p),d=H(l,g[2],p),h=H(r,g[3],p),f=H(l,g[4],p),i=H(r,g[5],p),a=H(l,g[6],p),r=i,l=a,e.bezierCurveTo(c,d,h,f,i,a);break;case"Q":c=H(r,g[1],p),d=H(l,g[2],p),i=H(r,g[3],p),a=H(l,g[4],p),r=i,l=a;break;case"V":a=H(l,g[1],p),l=a,e.lineTo(i,a);break;case"H":i=H(r,g[1],p),r=i,e.lineTo(i,a);break;case"Z":e.closePath(),y=!1;break;default:C(`Unsupported command: ${m}`)}})}onVisibleViewHandleDragStart(e){e.preventDefault(),e.stopPropagation(),console.log("onVisibleViewHandleDragStart:");const t=this.getOptions(),n=t.canvasOffset.x,i=t.canvasOffset.y,a=this.miniViewBox.canvas_width,r=this.miniViewBox.canvas_height,l=()=>{const u=f/this.miniViewBox.miniview_width,g=y/this.miniViewBox.miniview_height,m=this.dataProvider.getCanvasScale(),p=a*u*m,v=r*g*m;console.log("setCanvasOffset:buff:",f,y),this.dataProvider.setCanvasOffset(n-p,i-v),this._updateEditingControllerView(),this.updateMiniViewVisibleArea(),this.updateShouldRenderGraphData(),this.dataProvider.dataUpdated()};let c;const d=(u,g,m)=>{c&&clearInterval(c),this.onCanvasDragEnd(m)};let h=!1,f=0,y=0;J.startDrag(e,{x:0,y:0},d,(u,g)=>{f=u,y=g,console.log("onVisibleViewHandleDragStart:move:",u,g),!h&&Math.abs(u)+Math.abs(g)>3&&(console.log("onVisibleViewHandleDragStart:start"),h=!0,c=setInterval(()=>{l()},50))})}resetByVisiableView(e){!this.getOptions().miniViewVisibleHandle.emptyContent||(this.setZoom(100),this._moveToCenter(),this.zoomToFit())}}class oi extends ii{constructor(){super();N(this,"$watermarkDom",null);N(this,"$watermarkPosition","br");N(this,"$backgroundDom",null);N(this,"_originBackgroundColor","")}setWatermarkDom(e,t=!0,n=!1,i="br"){t&&(this.$watermarkDom=e),this.$watermarkPosition=i}setBackgroundDom(e,t=!0,n=!0){e===null?(this._originBackgroundColor=this.options.backgroundColor,this.dataProvider.updateOptions({backgroundColor:"transparent"}),t?this.$backgroundDom=e:this.$backgroundDom=null):(this.dataProvider.updateOptions({backgroundColor:this._originBackgroundColor}),this.$backgroundDom=null)}async prepareForImageGeneration(){return this.$canvasDom}async restoreAfterImageGeneration(){}}class si extends oi{constructor(){super();N(this,"resizeObserver");N(this,"resizeListenerMap",new WeakMap);N(this,"domToNodeIdMap",new WeakMap);N(this,"mutationObserver4Nodes");N(this,"mutationObserver4CanvasSlotBehind");N(this,"mutationObserver4CanvasSlotAbove");N(this,"_updateCanvasConnectTargetsTask");N(this,"onKeyDownHanlder");N(this,"onKeyUpHanlder")}setDom(e){C("relation-graph mounted on:",this.instanceId,e),this.$dom=e}setCanvasDom(e){C("relation-graph canvas dom mounted!"),this.$canvasDom=e,this.reinitMutationObservers(),this.getLineTextContainer({isFakeLine:!0}),this.getLineTextContainer({isFakeLine:!1})}getResizeObserver(){return this.resizeObserver||(this.resizeObserver=new ResizeObserver((e,t)=>{for(const n of e){const i=this.resizeListenerMap.get(n.target);i?n.borderBoxSize?i(n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):i(n.target.clientWidth,n.target.clientHeight):n.borderBoxSize?this._onNodeDomResize(n.target,n.borderBoxSize[0].inlineSize,n.borderBoxSize[0].blockSize):this._onNodeDomResize(n.target,n.target.clientWidth,n.target.clientHeight)}})),this.resizeObserver}initDom(){this.addResizeListener(this.$dom,(e,t)=>{C("resizeListener:this.$dom"),this.resetViewSize(),this.updateEasyView(),this._rgAsConnectArea&&(this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-above"))),this._updateEditingLineView(),this._updateEditingControllerView(),this._dataUpdated(),setTimeout(()=>{C("resizeListener:updateShouldRenderGraphData"),this.emitEvent(A.onViewResize,{width:e,height:t}),this._dataUpdated()},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener())}reinitMutationObservers(){this.destroyMutationObserver();const e=this.$canvasDom.querySelector(".rg-nodes-container-wrapper");if(e)this.mutationObserver4Nodes=new MutationObserver(i=>{if(this.dataProvider.getConnectTargets().length>0)for(const a of i){const r=this.getNodeElByChildrenTarget(a.target),l=this.domToNodeIdMap.get(r);l&&this.updateConnectTargetsOnNode("Mutation",l,r)}}),this.mutationObserver4Nodes.observe(e,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-nodes-container-wrapper");const t=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-behind");if(t)this.mutationObserver4CanvasSlotBehind=new MutationObserver(i=>{console.warn("MutationObserver:updateConnectTargetsOnCanvas:mutations:",i),this.updateConnectTargetsOnCanvas("CanvasBehind-Mutation",t)}),this.mutationObserver4CanvasSlotBehind.observe(t,{childList:!0,subtree:!0,characterData:!0});else throw new Error("MutationObserver:error:Can not find: .rg-canvas-slot-behind");const n=this.$canvasDom.parentElement.querySelector(".rg-canvas-slot-above");n&&(this.mutationObserver4CanvasSlotAbove=new MutationObserver(i=>{this.updateConnectTargetsOnCanvas("CanvasAbove-Mutation",n)}),this.mutationObserver4CanvasSlotAbove.observe(n,{childList:!0,subtree:!0,characterData:!0}))}destroyMutationObserver(){this.mutationObserver4Nodes&&(this.mutationObserver4Nodes.disconnect(),this.mutationObserver4Nodes=void 0),this.mutationObserver4CanvasSlotBehind&&(this.mutationObserver4CanvasSlotBehind.disconnect(),this.mutationObserver4CanvasSlotBehind=void 0),this.mutationObserver4CanvasSlotAbove&&(this.mutationObserver4CanvasSlotAbove.disconnect(),this.mutationObserver4CanvasSlotAbove=void 0)}addKeyboardListener(){this.onKeyDownHanlder=e=>{we(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!1&&this.setCanvasMoveMode(!0)),this.emitEvent(A.onKeyboardDown,e))},this.onKeyUpHanlder=e=>{we(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!0&&this.setCanvasMoveMode(!1)),this.emitEvent(A.onKeyboardUp,e))},this.$dom.addEventListener("keydown",this.onKeyDownHanlder),this.$dom.addEventListener("keyup",this.onKeyUpHanlder)}removeKeyboardListener(){this.onKeyDownHanlder&&this.$dom.removeEventListener("keydown",this.onKeyDownHanlder),this.onKeyUpHanlder&&this.$dom.removeEventListener("keyup",this.onKeyUpHanlder)}addResizeListener(e,t){this.resizeListenerMap.set(e,t),this.getResizeObserver().observe(e)}_onNodeDomResize(e,t,n){if(t===0||n===0)return;const i=this.domToNodeIdMap.get(e);this._onNodeResize(e,i,t,n)}_onNodeResize(e,t,n,i){n===0||i===0||(this.updateConnectTargetsOnNode("Node-Created",t,e),this.updateNodeOffsetSize(t,n,i))}addNodeResizeListener(e,t){this.domToNodeIdMap.set(e,t.id),this._onNodeResize(e,t.id,e.offsetWidth,e.offsetHeight),this.getResizeObserver().observe(e)}removeNodeResizeListener(e){this.domToNodeIdMap.delete(e),e?this.getResizeObserver().unobserve(e):C("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(e){this.resizeListenerMap.delete(e),this.resizeObserver&&this.resizeObserver.unobserve(e)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}}class ai extends si{constructor(){super()}dataUpdated(){this._requestDataUpdate()}setOptions(o){this._updateOptions(o),this._dataUpdated()}updateOptions(o){this._updateOptions(o),this._dataUpdated()}moveToCenter(o){this._moveToCenter(o),this._dataUpdated()}transToLinker(o=!0){this._rgAsConnectArea=o,this.resetViewSize(),this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas("View Resize",this.$dom.querySelector(".rg-canvas-slot-above")),this.removeKeyboardListener(),this._rgAsConnectArea||this.addKeyboardListener(),this._dataUpdated()}setRootNodeId(o){this.dataProvider.setRootNodeId(o)}getRootNode(){return this.dataProvider.getRootNode()}getCheckedNode(){return this.getNodeById(this.getOptions().checkedNodeId)}getCheckedLine(){if(!this.getLineById(this.getOptions().checkedLineId))return this.getFakeLineById(this.getOptions().checkedLineId)}getSelectedNodes(){return this.getNodes().filter(o=>o.selected)}getEditingNodes(){return[...this.getOptions().editingController.nodes]}async setJsonData(o){this._setJsonData(o),await this.doLayout(o.rootId)}async appendJsonData(o,e=!0){C("appendData:",o),this.loadGraphJsonData(o),e&&await this.doLayout()}async applyInitialData(o){await this.setJsonData(o),this.moveToCenter(),this.zoomToFit()}getGraphJsonData(){var t;const o=[],e=[];return this.getNodes().forEach(n=>{const i=Te(n);i&&o.push(i)}),this.getLines().forEach(n=>{const i=Re(n);i&&e.push(i)}),{rootId:((t=this.dataProvider.getRootNode())==null?void 0:t.id)||"",nodes:o,lines:e}}transRGNodeToJsonObject(o){return Te(o)}transRGLinkToJsonObject(o){return Ge(o)}transRGLineToJsonObject(o){return Re(o)}getGraphJsonOptions(){const o={},e=["layouter","layoutor","autoLayouting","canvasNVInfo","canvasOffset","canvasZoom","fullscreen","instanceId","layoutClassName","layoutDirection","layoutLabel","layoutName","resetViewSize","viewELSize","viewNVInfo","viewSize","canvasSize","newLinkTemplate","newLineTemplate","newNodeTemplate"],t=this.getOptions();return Object.keys(t).forEach(n=>{e.includes(n)||(o[n]=t[n])}),o}clearGraph(){this._clearGraph(),this._dataUpdated()}printOptions(){const o=this.getGraphJsonOptions();console.log("options:",o),console.log("options-json-string:"),console.log(JSON.stringify(o))}printData(){const o=this.getGraphJsonData();console.log("data:",o),console.log("data-json-string:"),console.log(JSON.stringify(o))}printGraphJsonData(){this.printOptions(),this.printData()}}class Pt extends ai{constructor(){super();N(this,"viewComponentUnmounted",!1)}setListeners(e){this.listeners=e}ready(){this.initDom(),this.resetViewSize(!0),this.addFullscreenListener(),this.emitEvent(A.onReady,this),this.viewComponentUnmounted=!1}beforeUnmount(){this.viewComponentUnmounted=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.destroyMutationObserver(),this.destroyResizeObserver()}}const ri=ye.Provider,li=ot.Provider,di=Ee.Provider,ci=re.Provider;function Rt(s,o=!1){const e=s?Reflect.construct(s,[]):new Pt;return e._rgAsConnectArea=o,console.log("[RGProvider]Creating new graphInstance",e.instanceId,o),e}function We(s,o=!1){const e=I.useContext(ye);return e||(console.log("[RGProvider]No parent RGProvider found, creating new graphInstance"),Rt(s,o))}const Tt=({graphInstance:s,children:o})=>{const[e,t]=I.useState(0),{data:n,dataStores:i}=hi(),a=I.useRef(0),r=I.useCallback(l=>{a.current++,t(a.current)},[]);return a.current===0&&s.setReactiveData4React(i,r),x.jsx(ri,{value:s,children:x.jsx(li,{value:r,children:x.jsx(di,{value:e,children:x.jsx(ci,{value:n,children:o})})})})},$e=({graphInstance:s,children:o})=>I.useContext(ye)?x.jsx(x.Fragment,{children:o}):x.jsx(Tt,{graphInstance:s,children:o}),hi=()=>{const[s,o]=I.useState(Oe({})),[e,t]=I.useState([]),[n,i]=I.useState([]),[a,r]=I.useState([]);return{data:{options:s,shouldRenderNodes:e,shouldRenderLines:n,shouldRenderFakeLines:a},dataStores:{store4Options:{set:u=>{o({...u})}},store4ShouldRenderNodes:{set:u=>{t(u)}},store4ShouldRenderLines:{set:u=>{i(u)}},store4ShouldRenderFakeLines:{set:u=>{r(u)}}}}},xe=s=>s,ui=`graphRef.value.getInstance() will be deprecated
43
+
44
+ It is recommended to use the graphInstance:
45
+ ###### Method 1: ######
46
+
47
+ import { RGProvider } from 'relation-graph-vue2';
48
+
49
+ <RGProvider>
50
+ <YourComponent>
51
+ <RelationGraph>
52
+ ...
53
+ </RelationGraph>
54
+ </YourComponent>
55
+ </RGProvider>
56
+
57
+ // YourComponent.vue file:
58
+
59
+ // ensuring the correct context is provided so that you can access the graphInstance:
60
+
61
+ import { RelationGraph, useGraphInstance } from 'relation-graph-vue2';
62
+ const graphInstance = useGraphInstance();
63
+
64
+ const graphOptions = ref<RGOptions>({ ... }); // Your RGOptions here
65
+ // Now you can use graphInstance to manipulate the graph data and call APIs. This will facilitate data manipulation and API calls.
66
+
67
+ <div>
68
+ ...
69
+ <RelationGraph :options="graphOptions">
70
+ ...
71
+ </RelationGraph>
72
+ ...
73
+ </div>
74
+
75
+ However, you can still use the current method, but you can only obtain the <RelationGraph> component instance through:
76
+ graphRef.value.getInstance(). in your <YourComponent>;
77
+ And method graphRef.value.getInstance() will be deprecated in future versions.
78
+
79
+ More details: https://www.relation-graph.com/docs/better-integration#vue3
80
+
81
+ Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
82
+ `,fi=`graphRef.value.getInstance() will be deprecated
83
+
84
+ It is recommended to use the graphInstance:
85
+ ###### Method 1: ######
86
+
87
+ <script setup lang="ts">
88
+ import { useRelationGraph } from 'relation-graph-vue3';
89
+
90
+ const graphOptions = ref<RGOptions>({ ... }); // Your RGOptions here
91
+ const {RelationGraph, graphInstance} = useRelationGraph(); // options is reactive
92
+
93
+ onMounted(() => {
94
+ // Set Data Method 1:
95
+ // Now you can use graphInstance to manipulate the graph data and call APIs.
96
+ graphInstance.setJsonData(...); // Set your initial data\uFF0CThe data will be layout automatically(Use graphOptions.value.layout)
97
+
98
+ // Set Data Method 2:
99
+ // Or set json data by addNodes + addLines directly
100
+ graphInstance.addNodes([{ id:'a' }, { id: 'b'}, { id: 'c'}]);
101
+ graphInstance.addLines([{ from: 'a', to: 'b' }, { from: 'b', to: 'c' }]);
102
+ graphInstance.doLayout('a'); // Use graphOptions.value.layout as default layout algorithm, Use 'a' as the root node id.
103
+ // Tips: How to make different node groups use different layouts: https://www.relation-graph.com/docs/api/layout
104
+
105
+ // After setting data, you can call other APIs as needed
106
+ graphInstance.moveToCenter();
107
+ graphInstance.zoomToFit();
108
+ });
109
+ <\/script>
110
+ <template>
111
+ ...
112
+ <RelationGraph :options="graphOptions">
113
+ ...
114
+ </RelationGraph>
115
+ ...
116
+ </template>
117
+
118
+
119
+ ###### Method 2: ######
120
+
121
+ import { RGProvider } from 'relation-graph-vue3';
122
+
123
+ <RGProvider>
124
+ <YourComponent>
125
+ <RelationGraph>
126
+ ...
127
+ </RelationGraph>
128
+ </YourComponent>
129
+ </RGProvider>
130
+
131
+ // YourComponent.vue file:
132
+
133
+ // ensuring the correct context is provided so that you can access the graphInstance:
134
+
135
+ import { RelationGraph, useGraphInstance } from 'relation-graph-vue3';
136
+ const graphInstance = useGraphInstance();
137
+
138
+ // Now you can use graphInstance to manipulate the graph data and call APIs. This will facilitate data manipulation and API calls.
139
+
140
+ <div>
141
+ ...
142
+ <RelationGraph>
143
+ ...
144
+ </RelationGraph>
145
+ ...
146
+ </div>
147
+
148
+ However, you can still use the current method, but you can only obtain the <RelationGraph> component instance through:
149
+ graphRef.value.getInstance(). in your <YourComponent>;
150
+ And method graphRef.value.getInstance() will be deprecated in future versions.
151
+
152
+ More details: https://www.relation-graph.com/docs/better-integration#vue3
153
+
154
+ Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
155
+ `,gi=`graphRef.current.getInstance() will be deprecated
156
+
157
+ It is recommended to use the graphInstance:
158
+ ###### Method 1: ######
159
+
160
+ import { useRelationGraph, RGOptions } from 'relation-graph-react';
161
+
162
+ const [graphOptions, setGraphOptions] = useRef<RGOptions>({ ... }); // Your RGOptions here
163
+ const {RelationGraph, graphInstance} = useRelationGraph(); // options is reactive
164
+
165
+ useEffect(() => {
166
+ // Set Data Method 1:
167
+ // Now you can use graphInstance to manipulate the graph data and call APIs.
168
+ graphInstance.setJsonData(...); // Set your initial data\uFF0CThe data will be layout automatically(Use graphOptions.value.layout)
169
+
170
+ // Set Data Method 2:
171
+ // Or set json data by addNodes + addLines directly
172
+ graphInstance.addNodes([{ id:'a' }, { id: 'b'}, { id: 'c'}]);
173
+ graphInstance.addLines([{ from: 'a', to: 'b' }, { from: 'b', to: 'c' }]);
174
+ graphInstance.doLayout('a'); // Use graphOptions.value.layout as default layout algorithm, Use 'a' as the root node id.
175
+ // Tips: How to make different node groups use different layouts: https://www.relation-graph.com/docs/api/layout
176
+
177
+ // After setting data, you can call other APIs as needed
178
+ graphInstance.moveToCenter();
179
+ graphInstance.zoomToFit();
180
+ }, []);
181
+ return (
182
+ <div>
183
+ ...
184
+ <RelationGraph options={graphOptions}>
185
+ ...
186
+ </RelationGraph>
187
+ ...
188
+ </div>
189
+ )
190
+
191
+
192
+
193
+ ###### Method 2: ######
194
+
195
+ import { RGProvider } from 'relation-graph-react';
196
+
197
+ <RGProvider>
198
+ <YourComponent>
199
+ <RelationGraph>
200
+ ...
201
+ </RelationGraph>
202
+ </YourComponent>
203
+ </RGProvider>
204
+
205
+ // YourComponent.vue file:
206
+
207
+ // ensuring the correct context is provided so that you can access the graphInstance:
208
+
209
+ import { RelationGraph, useGraphInstance } from 'relation-graph-react';
210
+ const graphInstance = useGraphInstance();
211
+
212
+ // Now you can use graphInstance to manipulate the graph data and call APIs. This will facilitate data manipulation and API calls.
213
+
214
+ <div>
215
+ ...
216
+ <RelationGraph>
217
+ ...
218
+ </RelationGraph>
219
+ ...
220
+ </div>
221
+
222
+ However, you can still use the current method, but you can only obtain the <RelationGraph> component instance through:
223
+ graphRef.current.getInstance(). in your <YourComponent>;
224
+ And method graphRef.value.getInstance() will be deprecated in future versions.
225
+
226
+ More details: https://www.relation-graph.com/docs/better-integration#vue3
227
+
228
+ Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
229
+ `,pi=`Please Initialize the graph using the new method:
230
+
231
+ ###### Method 1: ######
50
232
  // Use graphInstance to set the data.
51
- const graphInstance = graphRef.current.getInstance();
52
- await graphInstance.setJsonData(jsonData);
53
- Method 2:
233
+ // Set Data Method 1:
234
+ // Now you can use graphInstance to manipulate the graph data and call APIs.
235
+ graphInstance.setJsonData(...); // Set your initial data\uFF0CThe data will be layout automatically(Use graphOptions.value.layout)
236
+
237
+ // Set Data Method 2:
238
+ // Or set json data by addNodes + addLines directly
239
+ graphInstance.addNodes([{ id:'a' }, { id: 'b'}, { id: 'c'}]);
240
+ graphInstance.addLines([{ from: 'a', to: 'b' }, { from: 'b', to: 'c' }]);
241
+ graphInstance.doLayout('a'); // Use graphOptions.value.layout as default layout algorithm, Use 'a' as the root node id.
242
+ // Tips: How to make different node groups use different layouts: https://www.relation-graph.com/docs/api/layout
243
+
244
+ // After setting data, you can call other APIs as needed
245
+ graphInstance.moveToCenter();
246
+ graphInstance.zoomToFit();
247
+
248
+ ###### Method 2: ######
54
249
  Set the initial data using the "initialData" property of the RelationGraph component.
55
- Method 3:
56
- Initialize using the onReady event of the RelationGraph component. then use graphInstance to set the data.`)}}),[]),k.useEffect(()=>{},[]);const n=o=>{console.error("onProviderReady::Index",o),e.current=o};return t?C.jsx(Ut,{...i,children:i.children}):C.jsx(Gt,{relationGraphCore:i.relationGraphCore,onProviderReady:n,children:C.jsx(Ut,{...i,children:i.children})})},_e=lt.default.forwardRef(Sn),Mn=({children:i,direction:a,positionH:t,positionV:e})=>{const n=k.useContext(H),o=async()=>{await n.refresh(),n.dataUpdated()},s=()=>{n.toggleAutoLayout()},r=async()=>{await n.fullscreen(),n.dataUpdated()},l=async()=>{n.setZoom(100),n.moveToCenter(),n.enableCanvasAnimation(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300)},c=d=>{n.zoom(d),n.dataUpdated()},h=n&&n.options;return C.jsxs("div",{className:["rg-toolbar","rg-toolbar-h-"+(t||h.toolBarPositionH),"rg-toolbar-v-"+(e||h.toolBarPositionV),"rg-toolbar-"+(a||h.toolBarDirection)].join(" "),children:[C.jsx("div",{className:"rg-mb-button",onClick:()=>{r()},children:C.jsx(Q,{iconName:"icon-quanping"})}),C.jsxs(lt.default.Fragment,{children:[C.jsx("div",{className:"rg-mb-button",onClick:()=>{c(20)},children:C.jsx(Q,{iconName:"icon-fangda"})}),C.jsxs("div",{className:"rg-current-zoom",onClick:()=>{l()},children:[Math.round(h.canvasZoom),"%"]}),C.jsx("div",{className:"rg-mb-button",onClick:()=>{c(-20)},children:C.jsx(Q,{iconName:"icon-suoxiao"})})]}),h.layout.supportAutoLayout&&C.jsx("div",{title:h.layout.autoLayouting?"Stop force":"Start force",className:["rg-mb-button",h.layout.autoLayouting&&"rg-mb-button-on"].join(" "),onClick:()=>{s()},children:h.layout.autoLayouting?C.jsx(Q,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):C.jsx(Q,{iconName:"icon-zidong"})}),C.jsx("div",{className:"rg-mb-button",onClick:()=>{o()},children:C.jsx(Q,{iconName:"icon-ico_reset"})}),i,C.jsx("div",{style:{clear:"both"}})]})},Nn=({node:i,children:a})=>{const t=k.useRef(null),e=k.useContext(H);k.useContext(gt);const n=e.options,o=i.borderWidth===void 0?void 0:`${i.borderWidth}px`,s=i.width?`${i.width}px`:void 0,r=i.height?`${i.height}px`:void 0,l=()=>{const u=t.current;!u||u.offsetWidth===0&&u.offsetHeight===0||(i.el.offsetWidth!==u.offsetWidth||i.el.offsetHeight!==u.offsetHeight)&&e.updateNodeOffsetSize(i.id,u.offsetWidth,u.offsetHeight)};k.useEffect(()=>(l(),e.addNodeResizeListener(t.current,i),()=>{t.current&&e.removeNodeResizeListener(t.current)}),[]);const c=u=>{"button"in u&&u.button!==0||(u.stopPropagation(),e.onNodeDragStart(i,u.nativeEvent))},h=u=>{e.onNodeClick(i,u.nativeEvent)},d=["rg-node-peel",i.selected&&"rg-node-selected",i.dragging&&"rg-node-dragging",i.id===n.checkedNodeId&&"rg-node-peel-checked",i.className].filter(Boolean).join(" "),f=[`rg-node-shape-${i.nodeShape===void 0?1:i.nodeShape}`,`rg-node-type-${i.type}`,i.id===n.checkedNodeId?"rg-node-checked":"","rg-node"].filter(Boolean).join(" "),p={transform:`translate(${i.x}px, ${i.y}px)`,"--rg-node-z-index":i.zIndex,"--rg-node-opacity":i.opacity,pointerEvents:i.opacity===0?"none":void 0,"--rg-node-color":i.color||n.defaultNodeColor,"--rg-node-font-color":i.fontColor,"--rg-node-font-size":i.fontSize?`${i.fontSize}px`:void 0,"--rg-node-border-width":o,"--rg-node-border-radius":i.borderRadius?`${i.borderRadius}px`:void 0,"--rg-node-border-color":i.borderColor};return C.jsx("div",{ref:t,style:p,className:d,"data-id":i.id,children:C.jsx("div",{className:f,style:{width:s,height:r},onClick:h,onMouseDown:c,onTouchStart:c,children:a||C.jsx("div",{className:"rg-node-text",children:C.jsx("span",{children:i.text})})})})},Tn=({children:i})=>C.jsx(C.Fragment,{}),En=({children:i})=>{k.useContext(q);const a=k.useContext(H),t=a&&a.options;if(!t.editingController.show||t.snapshotting)return null;const e={width:t.editingController.width+"px",height:t.editingController.height+"px",transform:`translate(${t.editingController.x}px, ${t.editingController.y}px)`};return C.jsx("div",{className:"rg-editing-ctrl",style:e,children:i})},Dn=({disableResizeWidth:i,disableResizeHeight:a,beforeResizeStart:t})=>{const e=k.useContext(H);k.useContext(q);const n=e&&e.options,o=(s,r)=>{r.stopPropagation(),t&&t(),e.onResizeStart(s,r.nativeEvent)};return C.jsxs("div",{className:"rg-resize-ctl",children:[n.editingController.width>30&&!i&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tl",onMouseDown:s=>o("tl",s)}),n.editingController.width>30&&!i&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tr",onMouseDown:s=>o("tr",s)}),n.editingController.width>30&&!i&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-bl",onMouseDown:s=>o("bl",s)}),!i&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-br",onMouseDown:s=>o("br",s)}),(n.editingController.width>60||i)&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-t",onMouseDown:s=>o("t",s)}),(n.editingController.width>60||i)&&!a&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-b",onMouseDown:s=>o("b",s)}),(n.editingController.height>60||a)&&!i&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-l",onMouseDown:s=>o("l",s)}),(n.editingController.height>60||a)&&!i&&C.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-r",onMouseDown:s=>o("r",s)})]})},kn=({position:i="br",width:a,height:t})=>{const e=k.useContext(H);k.useContext(q);const n=e&&e.options,o=k.useRef(null),s=k.useRef(null);k.useEffect(()=>(n.showMiniView=!0,e.setMiniViewCanvas(s.current),()=>{n.showMiniView=!1}),[]);const r=c=>{e.onVisiableViewHandleDragStart(c.nativeEvent)},l=async c=>{e.resetByVisiableView(c.nativeEvent)};return C.jsx("div",{className:`rg-miniview rg-miniview-${i}`,ref:o,style:{"--miniview-width":a,"--miniview-height":t},children:C.jsxs("div",{className:"rg-miniview-container",children:[C.jsx("canvas",{ref:s,className:n.miniViewVisibleHandle.emptyContent?"rg-mv-canvas-reset":"",onClick:l}),C.jsx("div",{className:"rg-mv-visible-area",onMouseDown:r,style:{left:`${n.miniViewVisibleHandle.x}px`,top:`${n.miniViewVisibleHandle.y}px`,width:n.miniViewVisibleHandle.width+"px",height:n.miniViewVisibleHandle.height+"px"}})]})})},Rn=({children:i,forDisplay:a,forImage:t,position:e,width:n,height:o})=>{const s=k.useContext(H);k.useContext(q);const r=s&&s.options,l=k.useRef(null);k.useEffect(()=>(s.setWatermarkDom(l.current,t,a,e),()=>{s.setWatermarkDom(null,a,t)}),[n,o]);let c=!1;return r.snapshotting?t===!1?c=!1:c=!0:a===!0?c=!0:c=!1,C.jsx("div",{className:`rg-watermark rg-watermark-${e||"br"}`,style:{display:c?"block":"none","--watermark-width":n,"--watermark-height":o},ref:l,children:i})},Pn=({children:i,forDisplay:a,forImage:t})=>{const e=k.useContext(H),n=k.useRef(null);return k.useEffect(()=>(n.current.style.backgroundColor="transparent",e.setBackgroundDom(n.current,a,t),()=>{e.setBackgroundDom(null,a,t)}),[]),C.jsx("div",{className:"rg-background",ref:n,children:i})},In=({position:i,children:a})=>{const t=i||"top";return C.jsx("div",{className:`rg-editing-bar rg-editing-bar-${t}`,children:a})},An=({textEditable:i=!0,moveLineVertexStart:a,moveLineVertexEnd:t,onLineTextDragEnd:e,onLineTextChanged:n,children:o})=>{const s=k.useContext(H);k.useContext(q);const l=s.options.editingLineController,c=l.line,h=l.show,d=c&&c.text,[f,p]=k.useState(!1),[u,g]=k.useState(""),x=k.useRef(0),y=k.useRef(null);k.useEffect(()=>{h||p(!1)},[h]),k.useEffect(()=>{d!==u&&g(d||"")},[d]),k.useEffect(()=>{s.updateEditingLineView()},[u,c==null?void 0:c.lineShape]),k.useEffect(()=>{f&&y.current&&y.current.focus()},[f]);const L=(P,$)=>{!c||(a&&a(P,c),s.startMoveLineVertex(P,$.nativeEvent,(Y,j,X)=>{t&&t(Y,j,X),s.defaultLineVertexBeChangedHandler(Y,j,X)}))},m=(P,$)=>{s.startMoveLine6CtrlPoint(P,$.nativeEvent)},w=(P,$)=>{s.startMoveLine44CtrlPoint(P,$.nativeEvent)},b=P=>{s.startMoveLineText(P.nativeEvent,()=>{c&&e&&e(c)})},M=()=>{x.current&&Date.now()-x.current<500&&p(!0),x.current=Date.now()},N=P=>{c&&c.text!==P.target.value&&(c.text=P.target.value,g(P.target.value),n&&n(c)),p(!1)};if(!h||!c)return null;const{startPoint:O,endPoint:E,ctrlPoint1:T,ctrlPoint2:D,line44Splits:R,text:_}=l,{lineShape:z}=c,F=`M ${O.x} ${O.y} L ${(T==null?void 0:T.x)||0} ${(T==null?void 0:T.y)||0}`,V=`M ${E.x} ${E.y} L ${(D==null?void 0:D.x)||0} ${(D==null?void 0:D.y)||0}`;return C.jsxs("div",{className:"rg-editing-line-ctrl",children:[o,C.jsx("svg",{className:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg",children:C.jsxs("g",{children:[z===6&&T&&C.jsx("path",{d:F}),z===6&&D&&C.jsx("path",{d:V})]})}),C.jsx("div",{className:"rg-line-ctrl-dot start-dot",style:{"--rg-ctl-x":O.x+"px","--rg-ctl-y":O.y+"px"},onMouseDown:P=>L("start",P)}),C.jsx("div",{className:"rg-line-ctrl-dot end-dot",style:{"--rg-ctl-x":E.x+"px","--rg-ctl-y":E.y+"px"},onMouseDown:P=>L("end",P)}),z===6&&T&&C.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":T.x+"px","--rg-ctl-y":T.y+"px"},onMouseDown:P=>m(0,P)}),z===6&&D&&C.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":D.x+"px","--rg-ctl-y":D.y+"px"},onMouseDown:P=>m(1,P)}),(z===44||z===49)&&R.map(P=>!P.hide&&C.jsx("div",{className:`rg-line-ctrl-dot ctrl-split ${P.optionName.startsWith("cp-")?"":"ctrl-split-core"} ${P.direction==="v"?"ctrl-split-v":""} ${P.direction==="h"?"ctrl-split-h":""}`,style:{"--rg-ctl-x":P.x+"px","--rg-ctl-y":P.y+"px"},onMouseDown:$=>w(P,$)},P.optionName)),i&&c&&C.jsx("div",{className:["rg-line-ctrl-text",f&&"rg-line-ctrl-text-editing"].filter(Boolean).join(" "),style:{"--rg-ctl-x":l.text.x+"px","--rg-ctl-y":l.text.y+"px"},onClick:M,onMouseDown:b,children:f?C.jsx("input",{ref:y,className:"rg-line-text-input",value:u,onChange:P=>g(P.target.value),onBlur:N}):u?C.jsx("p",{children:u}):C.jsx("p",{className:"empty-text",children:"Add Text..."})})]})},Le=({mouseUpOnJunctionPointWithOffset:i,mouseUpOnJunctionPoint:a})=>C.jsxs("div",{className:"rg-connect-ctl",onMouseUp:t=>a("",t),onTouchEnd:t=>a("",t),children:[C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseUp:t=>a("top",t),onTouchEnd:t=>a("top",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseUp:t=>a("bottom",t),onTouchEnd:t=>a("bottom",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseUp:t=>a("border",t),onTouchEnd:t=>a("border",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseUp:t=>a("left",t),onTouchEnd:t=>a("left",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseUp:t=>a("right",t),onTouchEnd:t=>a("right",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseUp:t=>a("lr",t),onTouchEnd:t=>a("lr",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseUp:t=>a("tb",t),onTouchEnd:t=>a("tb",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseUp:t=>i("bottom",t),onTouchEnd:t=>onMouseUpWithOffset("bottom",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseUp:t=>i("top",t),onTouchEnd:t=>onMouseUpWithOffset("top",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseUp:t=>i("left",t),onTouchEnd:t=>onMouseUpWithOffset("left",t)}),C.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseUp:t=>i("right",t),onTouchEnd:t=>onMouseUpWithOffset("right",t)})]}),Vn=({children:i})=>{const a=k.useContext(H);k.useContext(q);const t=k.useRef(),e=a&&a.options;if(!e.nodeConnectController.show)return C.jsx(C.Fragment,{});const n=(s,r)=>{a.onLineVertexBeDroppedOnConnectController(s,r,void 0,(l,c,h)=>{v("onLineVertexBeDropped:callback:",h)})},o=(s,r)=>{a.onLineVertexBeDroppedOnConnectController(s,r,t.current,(l,c,h)=>{v("onLineVertexBeDropped:callback:",h)})};return C.jsx("div",{className:"rg-editing-connect-ctrl",ref:t,style:{transform:`translate(${e.nodeConnectController.x}px, ${e.nodeConnectController.y}px)`,width:e.nodeConnectController.width+"px",height:e.nodeConnectController.height+"px"},children:i||C.jsx(Le,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:o})})},zn=({fromNode:i,lineTemplate:a,onConnectStart:t,onConnectEnd:e,children:n,className:o,style:s})=>{const r=k.useContext(H),l=c=>{t&&t(i,a,c.nativeEvent),c.stopPropagation(),r.startCreateLineFromNode(i,a,c.nativeEvent,(h,d,f)=>{e&&e(h,d,f),r.defaultLineConnectEndHandler(h,d,f)})};return C.jsx("div",{className:`rg-connect-source-handle ${o||""}`,style:s,onMouseDown:c=>l(c),onClick:c=>{c.stopPropagation()},children:n})},Bn=({children:i,className:a,style:t,junctionPoint:e,targetId:n,targetType:o,targetData:s,lineTemplate:r,disableDrop:l,disableDrag:c,onLineVertexBeDropped:h,onDragConnectStart:d,onDragConnectEnd:f})=>{const p=k.useContext(H),u=k.useRef(),[g,x]=k.useState();k.useEffect(()=>{const m=p.registerConnectTarget(u.current,n,o||B.CanvasPoint,e,s);return x(m),()=>{p.unregisterConnectTarget(n)}},[]);const y=(m,w)=>{w.stopPropagation(),!l&&p.onLineVertexBeDropped(m,w.nativeEvent,void 0,(b,M,N)=>{h&&h(b,M,N)})},L=m=>{if(m.stopPropagation(),c||p.options.creatingLinePlot)return;const w=Object.assign({},r||{});w.from||(w.from=(g==null?void 0:g.targetId)||n,w.fromType=(g==null?void 0:g.targetType)||o),w.fromJunctionPoint||(w.fromJunctionPoint=(g==null?void 0:g.junctionPoint)||e),w.fromType||(w.fromType=B.Node),d&&d(w,m.nativeEvent),p.startCreateLineFromNode(null,w,m.nativeEvent,(b,M,N)=>{f&&f(b,M,N)})};return C.jsx("div",{ref:u,className:`rg-connect-ctl-handler rg-connect-target ${a||""}`,style:t,"data-point":e,"data-target-id":n,"data-target-type":o||B.CanvasPoint,"data-target-data":JSON.stringify(s),onMouseDown:m=>L(m),onMouseUp:m=>y(e,m),onClick:m=>{m.stopPropagation()},children:i})},Xn=({showText:i,adsorption:a})=>{const t=k.useContext(H),e=t&&t.options;return k.useEffect(()=>(e.editingReferenceLine.show=!0,e.showReferenceLine=!0,e.referenceLineAdsorption=a||!1,()=>{e.editingReferenceLine.show=!1}),[e]),C.jsxs("div",{className:"rg-editing-referline",style:{display:e.editingReferenceLine.show?"block":"none"},children:[e.editingReferenceLine.directionV&&C.jsx("div",{className:"rg-referline rg-referline-v",style:{transform:`translate(${e.editingReferenceLine.v_x}px, ${e.editingReferenceLine.v_y}px)`,height:e.editingReferenceLine.v_height+"px"},children:C.jsx("div",{className:"referline",children:i!==!1&&C.jsxs("div",{children:[Math.round(e.editingReferenceLine.v_height),"px"]})})}),e.editingReferenceLine.directionH&&C.jsx("div",{className:"rg-referline rg-referline-h",style:{transform:`translate(${e.editingReferenceLine.h_x}px, ${e.editingReferenceLine.h_y}px)`,width:e.editingReferenceLine.h_width+"px"},children:C.jsx("div",{className:"referline",children:i!==!1&&C.jsxs("div",{children:[Math.round(e.editingReferenceLine.h_width),"px"]})})})]})},Fn=i=>{const a=k.useContext(H),t=k.useRef(),e={backgroundColor:"transparent",textWrap:"unset",position:"relative",width:"100%",height:"fit-content"};return k.useEffect(()=>{v("[RGCanvas mounted]"),a.setCanvasDom(t.current)},[]),C.jsxs("div",{style:{"--bg-background-color":a.options.backgroundColor,"--rg-node-color":a.options.defaultNodeColor,"--rg-line-color":a.options.defaultLineColor},className:["rg-map",a.options.canvasOpacity===1?"rg-map-ready":""].join(" "),children:[C.jsx("div",{style:{...e,position:"relative",pointerEvents:"all",userSelect:"text"},className:"rg-map-canvas rg-canvas-behind",children:C.jsx("div",{className:"rg-canvas-slot rg-canvas-slot-behind",children:i.canvasPlugBehindSlot})}),C.jsx("div",{ref:t,style:{...e,pointerEvents:"none",userSelect:"none",left:"0px",top:"0px",zIndex:9},className:"rg-map-canvas",children:C.jsx(ae,{svgDefs:i.svgDefs,lineSlot:i.lineSlot})})]})},Qt=i=>{const a=k.useContext(H);k.useContext(q);const t=k.useRef(),[e,n]=k.useState(!1);k.useEffect(()=>{te("React-Linker-Board"),a.setOptions(i.options||{});const u=ce(i);return v("[RelationGraph]mounted:listeners:",u),a.setListeners(u),v("[RelationGraph]setDom:",t.current),a.setDom(t.current),n(!0),a.ready(),a.dataUpdated(),i.links&&(v("[RelationGraph] apply data"),(async()=>await a.setJsonData({fakeLines:i.links}))()),()=>{a.beforeUnmount()}},[]);const o=a&&a.options;let s;const r=[],l=[],c=[],h=lt.default.Children.toArray(i.children).filter(u=>{if(u&&lt.default.isValidElement(u))if(u.type===It){const g=u.props.children;if(typeof g=="function")s=g;else throw new Error('RGSlotOnLine children must be a function, e.g. <RGSlotOnLine>{ (line: RGLine) => <g><path d="..." /><text>{line.text}</text></g> }</RGSlotOnLine>')}else{if(u.type===Mt)return r.push(u.props.children),!1;if(u.type===At)return l.push(u.props.children),!1;if(u.type===Vt)return!1;if(u.type===he)return c.push(u.props.children),!1}return!0}),d=r,f=l.concat(...h);if(s&&i.lineSlot)throw new Error("You can only provide lineSlot or RGSlotOnLine, but not both.");const p=s||i.lineSlot;return C.jsx("div",{ref:t,id:`relation-graph-ins-${o==null?void 0:o.instanceId}`,className:["relation-graph",(o==null?void 0:o.creatingLinePlot)&&"rg-creating-line"].filter(Boolean).join(" "),tabIndex:1,style:{width:"100%",height:"fit-content",opacity:e?1:0,"--rg-checked-line-bg-color":o==null?void 0:o.checkedItemBackgroundColor},children:e&&o&&C.jsxs(C.Fragment,{children:[C.jsx(Fn,{lineSlot:p,svgDefs:c,canvasPlugBehindSlot:f}),C.jsx(re,{}),C.jsx("div",{className:"rg-graph-plugs",children:C.jsx("div",{className:"rg-graph-slot",children:d})})]})})},Hn=(i,a)=>{const t=k.useContext(H),e=k.useRef(i.relationGraphInstance);k.useImperativeHandle(a,()=>({getInstance(){return t||e.current}}),[]),k.useEffect(()=>{},[]);const n=o=>{console.error("onProviderReady::Index",o),e.current=o,e.current._rgAsConnectArea=!0};return t&&!t._rgAsConnectArea&&(t._rgAsConnectArea=!0),t?C.jsx(Qt,{...i,children:i.children}):C.jsx(Gt,{relationGraphCore:i.relationGraphCore,onProviderReady:n,children:C.jsx(Qt,{...i,children:i.children})})},$n=lt.default.forwardRef(Hn),Gn={BaseLayouter:pt,BidirectionalTreeLayouter:fe,CenterLayouter:ue,CircleLayouter:ge,FixedLayouter:pe,ForceLayouter:ut,RGFolderLayouter:ye},jn={RGOptionsDataUtils:qe,RGLineDataUtils:je,RGNodeDataUtils:He,RGGraphMath:Z,RGNodesAnalyticUtils:A,RGEffectUtils:W};function Yn(){return k.useContext(H)}function Wn(){return k.useContext(q)}function Un(i){if(!i||!i.options.creatingLinePlot)return{creating:!1};const{line:a,from:t,to:e}=i.generateCreatingLineConfig();return{creating:!0,fromTarget:t,toTarget:e,lineJson:a}}function Zn(i){return!i||!i.options.creatingNodePlot?{creating:!1}:{creating:!0,nodeJson:i.options.newNodeTemplate}}const Jn={useGraphInstance:Yn,useAutoUpdateView:Wn,useCreatingLine:Un,useCreatingNode:Zn},qn=Kt,Qn=Ce,Kn=Gn,to=jn,eo=Nn,no=ie,oo=oe,io=Mn,so=ee,ao=le,ro=kn,lo=Pn,co=Rn,ho=En,fo=Dn,uo=In,go=An,po=Vn,yo=zn,mo=Bn,xo=Le,vo=Xn,Co=Mt,_o=Mt,Lo=Vt,wo=At,we=Tn,bo=It,Oo=$n,So=Gt,Mo=_e;exports.RGBackground=lo;exports.RGConnectSource=yo;exports.RGConnectTarget=mo;exports.RGDirection=de;exports.RGEditingConnectController=po;exports.RGEditingConnectPoints=xo;exports.RGEditingLineController=go;exports.RGEditingNearNodeWidget=uo;exports.RGEditingNodeController=ho;exports.RGEditingReferenceLine=vo;exports.RGEditingResize=fo;exports.RGEventNames=I;exports.RGFakeNode=eo;exports.RGHooks=Jn;exports.RGInnerConnectTargetType=B;exports.RGInstanceContext=H;exports.RGJunctionPoint=U;exports.RGLayout=Kn;exports.RGLinePath=no;exports.RGLineShape=G;exports.RGLineText=oo;exports.RGMiniToolBar=ao;exports.RGMiniView=ro;exports.RGNodeExpandHolder=so;exports.RGNodeShape=zt;exports.RGProvider=So;exports.RGSlotOnCanvas=wo;exports.RGSlotOnCanvasAbove=Lo;exports.RGSlotOnGraph=Co;exports.RGSlotOnLine=bo;exports.RGSlotOnNode=we;exports.RGSlotOnView=_o;exports.RGToolBar=io;exports.RGUpdateContext=gt;exports.RGUpdateSignalContext=q;exports.RGUpdateSingalContext=q;exports.RGUtils=to;exports.RGWatermark=co;exports.RelationGraph=Mo;exports.RelationGraphCore=Qn;exports.RelationGraphStoreContext=H;exports.RelationLinker=Oo;exports.default=_e;exports.version=qn;
250
+
251
+ ###### Method 3: ######
252
+ Initialize using the onReady event of the RelationGraph component. then use graphInstance to set the data.
253
+
254
+ ###### More Method: ######
255
+ https://www.relation-graph.com/docs.'
256
+ `,yi=`Please Initialize the graph using the new method:
257
+
258
+ ###### Method 1: ######
259
+ // Use graphInstance to set the data.
260
+ const graphInstance = this.graphInstance; // this.graphInstance is obtained through inject('graphInstance').
261
+ // Set Data Method 1:
262
+ // Now you can use graphInstance to manipulate the graph data and call APIs.
263
+ graphInstance.setJsonData(...); // Set your initial data\uFF0CThe data will be layout automatically(Use graphOptions.value.layout)
264
+
265
+ // Set Data Method 2:
266
+ // Or set json data by addNodes + addLines directly
267
+ graphInstance.addNodes([{ id:'a' }, { id: 'b'}, { id: 'c'}]);
268
+ graphInstance.addLines([{ from: 'a', to: 'b' }, { from: 'b', to: 'c' }]);
269
+ graphInstance.doLayout('a'); // Use graphOptions.value.layout as default layout algorithm, Use 'a' as the root node id.
270
+ // Tips: How to make different node groups use different layouts: https://www.relation-graph.com/docs/api/layout
271
+
272
+ // After setting data, you can call other APIs as needed
273
+ graphInstance.moveToCenter();
274
+ graphInstance.zoomToFit();
275
+
276
+ ###### Method 2: ######
277
+ Set the initial data using the "initialData" property of the RelationGraph component.
278
+
279
+ ###### Method 3: ######
280
+ Initialize using the onReady event of the RelationGraph component. then use graphInstance to set the data.
281
+
282
+ ###### More Method: ######
283
+ https://www.relation-graph.com/docs.'
284
+ `,Ke={Vue3GetInstance:xe(fi),ReactGetInstance:xe(gi),Vue2GetInstance:xe(ui),setJsonData:xe(pi),setJsonData4Vue2:xe(yi)},mi=(s,o)=>{const e=We(s.relationGraphCore);return I.useImperativeHandle(o,()=>({getInstance(){var t;return(t=s.options)!=null&&t.definitelyNoDataProviderNeeded||console.warn("[relation-graph]",Ke.ReactGetInstance),e},async setJsonData(){throw new Error(Ke.setJsonData)}}),[]),x.jsx($e,{graphInstance:e,children:x.jsx(xt,{...s})})},Mt=pe.default.forwardRef(mi);function vi(s={}){const o=We(s.relationGraphCore);return{RelationGraph:I.useMemo(()=>{console.log("Creating a MemoizedRelationGraph...");const t=n=>x.jsx($e,{graphInstance:o,children:x.jsx(xt,{...n,children:n.children})});return t.displayName="RelationGraph",t},[]),graphInstance:o}}const kt={useRelationGraph:vi,useGraphInstance:W,useAutoUpdateView:oe,useCreatingLine:Zt,useCreatingNode:Qt,useEditingNodes:Kt,useEditingLine:en,useViewInformation:nn,useSelection:on,useConnectingNode:tn,useCheckedItem:sn,useGraphStore:q},xi=({children:s})=>{const o=W();oe();const{options:e}=q(),[t,n]=I.useState(!1),i=()=>{n(!t)},a=()=>{o.printOptions()},r=()=>{o.getGraphJsonData()},l=()=>{o.enableDebugLog(!e.debug),C("debugLog:",e.debug),updateView()};return x.jsxs("div",{children:[x.jsx("div",{className:"rg-setting-panel-button",onClick:()=>{i()},children:"Debug"}),t&&x.jsxs("div",{className:"rg-setting-panel",children:[x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{a()},children:"print options in console"})}),x.jsx("div",{className:"c-debug-tools-row",children:x.jsx("button",{onClick:()=>{r()},children:"print json data in console"})}),x.jsxs("div",{className:"c-debug-tools-row",children:["debug log status: ",e.debug?"true":"false",x.jsxs("button",{onClick:()=>{l()},children:[e.debug?"disable":"enable"," debug log"]})]}),s]})]})},Ci=({children:s,direction:o,positionH:e,positionV:t})=>{const n=W(),{options:i}=q(),a=async()=>{await n.refresh(),n.dataUpdated()},r=()=>{n.toggleAutoLayout()},l=async()=>{await n.fullscreen(),n.dataUpdated()},c=async()=>{n.setZoom(100),n.moveToCenter(),n.enableCanvasAnimation(),n.zoomToFit(),setTimeout(()=>{n.disableCanvasAnimation()},300)},d=h=>{n.zoom(h),n.dataUpdated()};return x.jsxs("div",{className:["rg-toolbar","rg-toolbar-h-"+(e||i.toolBarPositionH),"rg-toolbar-v-"+(t||i.toolBarPositionV),"rg-toolbar-"+(o||i.toolBarDirection)].join(" "),children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{l()},children:x.jsx(ne,{iconName:"icon-quanping"})}),x.jsxs(pe.default.Fragment,{children:[x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(20)},children:x.jsx(ne,{iconName:"icon-fangda"})}),x.jsxs("div",{className:"rg-current-zoom",onClick:()=>{c()},children:[Math.round(i.canvasZoom),"%"]}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{d(-20)},children:x.jsx(ne,{iconName:"icon-suoxiao"})})]}),i.layout.supportAutoLayout&&x.jsx("div",{title:i.layout.autoLayouting?"Stop force":"Start force",className:["rg-mb-button",i.layout.autoLayouting&&"rg-mb-button-on"].join(" "),onClick:()=>{r()},children:i.layout.autoLayouting?x.jsx(ne,{iconName:"icon-lianjiezhong",className:"rg-loading-icon"}):x.jsx(ne,{iconName:"icon-zidong"})}),x.jsx("div",{className:"rg-mb-button",onClick:()=>{a()},children:x.jsx(ne,{iconName:"icon-ico_reset"})}),s,x.jsx("div",{style:{clear:"both"}})]})},Li=({node:s,children:o})=>{const e=I.useRef(null),t=W();oe();const{options:n}=q(),i=s.borderWidth===void 0?void 0:`${s.borderWidth}px`,a=s.width?s.width+"px":void 0,r=s.height?s.height+"px":void 0;I.useEffect(()=>(t.addNodeResizeListener(e.current,s),()=>{e.current&&t.removeNodeResizeListener(e.current)}),[]);const l=h=>{"button"in h&&h.button!==0||(h.stopPropagation(),t.onNodeDragStart(s,h.nativeEvent))},c=["rg-node-peel",s.selected&&"rg-node-selected",s.id===n.draggingNodeId&&"rg-node-dragging",s.id===n.checkedNodeId&&"rg-node-checked",`rg-node-shape-${s.nodeShape===void 0?1:s.nodeShape}`,`rg-node-type-${s.type}`,s.className].filter(Boolean).join(" "),d={transform:`translate(${s.x}px, ${s.y}px)`,"--rg-node-z-index":s.zIndex,"--rg-node-opacity":s.opacity,pointerEvents:s.opacity===0?"none":void 0,"--rg-node-color":s.color||n.defaultNodeColor,"--rg-node-font-color":s.fontColor,"--rg-node-font-size":s.fontSize?`${s.fontSize}px`:void 0,"--rg-node-border-width":i,"--rg-node-width":a,"--rg-node-height":r,"--rg-node-border-radius":s.borderRadius?`${s.borderRadius}px`:void 0,"--rg-node-border-color":s.borderColor};return x.jsx("div",{ref:e,style:d,className:c,"data-id":s.id,children:x.jsx("div",{className:"rg-node",onMouseDown:l,onTouchStart:l,children:o||x.jsx("div",{className:"rg-node-text",children:x.jsx("span",{children:s.text})})})})},wi=({children:s})=>x.jsx(x.Fragment,{}),Ni=({children:s})=>{const{options:o}=q();if(!o.editingController.show)return null;const e={width:o.editingController.width+"px",height:o.editingController.height+"px",transform:`translate(${o.editingController.x}px, ${o.editingController.y}px)`};return x.jsx("div",{className:"rg-editing-ctrl",style:e,children:s})},_i=({disableResizeWidth:s,disableResizeHeight:o,beforeResizeStart:e})=>{const t=W(),{options:n}=q(),i=(a,r)=>{r.stopPropagation(),e&&e(),t.onResizeStart(a,r.nativeEvent)};return x.jsxs("div",{className:"rg-resize-ctl",children:[n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tl",onMouseDown:a=>i("tl",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-tr",onMouseDown:a=>i("tr",a)}),n.editingController.width>30&&!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-bl",onMouseDown:a=>i("bl",a)}),!s&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-br",onMouseDown:a=>i("br",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-t",onMouseDown:a=>i("t",a)}),(n.editingController.width>60||s)&&!o&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-b",onMouseDown:a=>i("b",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-l",onMouseDown:a=>i("l",a)}),(n.editingController.height>60||o)&&!s&&x.jsx("div",{className:"rg-resize-ctl-handler rg-resize-ctl-r",onMouseDown:a=>i("r",a)})]})},bi=({className:s,style:o,position:e="br",width:t,height:n})=>{const i=W();oe();const{options:a}=q(),r=I.useRef(null),l=I.useRef(null);I.useEffect(()=>(i.onMiniViewMounted(),i.setMiniViewCanvas(l.current),()=>{i.onMiniViewUnMounted()}),[]);const c=h=>{i.onVisibleViewHandleDragStart(h.nativeEvent)},d=async h=>{i.resetByVisiableView(h.nativeEvent)};return x.jsx("div",{className:`rg-miniview rg-miniview-${e} ${s||""}`,ref:r,style:{...o,"--miniview-width":t,"--miniview-height":n},children:x.jsxs("div",{className:"rg-miniview-container",children:[x.jsx("canvas",{ref:l,className:a.miniViewVisibleHandle.emptyContent?"rg-mv-canvas-reset":"",onClick:d}),x.jsx("div",{className:"rg-mv-visible-area",onMouseDown:c,style:{transform:`translate(${a.miniViewVisibleHandle.x}px, ${a.miniViewVisibleHandle.y}px)`,width:a.miniViewVisibleHandle.width+"px",height:a.miniViewVisibleHandle.height+"px"}})]})})},Oi=({children:s,forDisplay:o,forImage:e,position:t,width:n,height:i})=>{const a=W();oe();const{options:r}=q(),l=I.useRef(null);I.useEffect(()=>(a.setWatermarkDom(l.current,e,o,t),()=>{a.setWatermarkDom(null,o,e)}),[n,i]);let c=!1;return r.snapshotting?e===!1?c=!1:c=!0:o===!0?c=!0:c=!1,x.jsx("div",{className:`rg-watermark rg-watermark-${t||"br"}`,style:{display:c?"block":"none","--watermark-width":n,"--watermark-height":i},ref:l,children:s})},Si=({children:s,forDisplay:o,forImage:e})=>{const t=W(),n=I.useRef(null);return I.useEffect(()=>(t.setBackgroundDom(n.current,o,e),()=>{t.setBackgroundDom(null,o,e)}),[]),x.jsx("div",{className:"rg-background",ref:n,children:s})},Pi=({position:s,children:o})=>{const e=s||"top";return x.jsx("div",{className:`rg-editing-bar rg-editing-bar-${e}`,children:o})},Ri=({textEditable:s=!0,onMoveLineVertexStart:o,onMoveLineVertexEnd:e,onLineTextDragEnd:t,onLineTextChanged:n,onLinePathChanged:i,children:a})=>{const r=W();oe();const{options:l}=q(),c=l.editingLineController,d=c.line,h=c.show,f=d&&d.text,[y,u]=I.useState(!1),[g,m]=I.useState(""),p=I.useRef(0),v=I.useRef(null);I.useEffect(()=>{h||u(!1)},[h]),I.useEffect(()=>{f!==g&&m(f||"")},[f]),I.useEffect(()=>{r.updateEditingLineView()},[g,d==null?void 0:d.lineShape]),I.useEffect(()=>{y&&v.current&&v.current.focus()},[y]);const L=(E,j)=>{!d||(o&&o(E,d),r.startMoveLineVertex(E,j.nativeEvent,($,K,Q)=>{e&&e($,K,Q),r.defaultLineVertexBeChangedHandler($,K,Q)}))},_=(E,j)=>{r.startMoveLine6CtrlPoint(E,j.nativeEvent,$=>{i&&i($,E)})},S=(E,j)=>{r.startMoveLine44CtrlPoint(E,j.nativeEvent,$=>{i&&i($,E)})},b=E=>{r.startMoveLineText(E.nativeEvent,()=>{d&&t&&t(d)})},O=()=>{p.current&&Date.now()-p.current<500&&u(!0),p.current=Date.now()},R=E=>{d&&d.text!==E.target.value&&(r.updateLine(d.id,{text:E.target.value}),m(E.target.value),n&&n(d)),u(!1)};if(!h||!d)return null;const{startPoint:M,endPoint:k,ctrlPoint1:P,ctrlPoint2:T,line44Splits:w,text:D}=c,{lineShape:V}=d,X=`M ${M.x} ${M.y} L ${(P==null?void 0:P.x)||0} ${(P==null?void 0:P.y)||0}`,G=`M ${k.x} ${k.y} L ${(T==null?void 0:T.x)||0} ${(T==null?void 0:T.y)||0}`;return x.jsxs("div",{className:"rg-editing-line-ctrl",children:[a,x.jsx("svg",{className:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg",children:x.jsxs("g",{children:[V===6&&P&&x.jsx("path",{d:X}),V===6&&T&&x.jsx("path",{d:G})]})}),x.jsx("div",{className:"rg-line-ctrl-dot start-dot",style:{"--rg-ctl-x":M.x+"px","--rg-ctl-y":M.y+"px"},onMouseDown:E=>L("start",E)}),x.jsx("div",{className:"rg-line-ctrl-dot end-dot",style:{"--rg-ctl-x":k.x+"px","--rg-ctl-y":k.y+"px"},onMouseDown:E=>L("end",E)}),V===6&&P&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":P.x+"px","--rg-ctl-y":P.y+"px"},onMouseDown:E=>_(0,E)}),V===6&&T&&x.jsx("div",{className:"rg-line-ctrl-dot ctrl-dot",style:{"--rg-ctl-x":T.x+"px","--rg-ctl-y":T.y+"px"},onMouseDown:E=>_(1,E)}),(V===44||V===49)&&w.map(E=>!E.hide&&x.jsx("div",{className:`rg-line-ctrl-dot ctrl-split ${E.optionName.startsWith("cp-")?"":"ctrl-split-core"} ${E.direction==="v"?"ctrl-split-v":""} ${E.direction==="h"?"ctrl-split-h":""}`,style:{"--rg-ctl-x":E.x+"px","--rg-ctl-y":E.y+"px"},onMouseDown:j=>S(E,j)},E.optionName)),s&&d&&x.jsx("div",{className:["rg-line-ctrl-text",y&&"rg-line-ctrl-text-editing"].filter(Boolean).join(" "),style:{"--rg-ctl-x":c.text.x+"px","--rg-ctl-y":c.text.y+"px"},onClick:O,onMouseDown:b,children:y?x.jsx("input",{ref:v,className:"rg-line-text-input",value:g,onChange:E=>m(E.target.value),onBlur:R}):g?x.jsx("p",{children:g}):x.jsx("p",{className:"empty-text",children:"Add Text..."})})]})},It=({mouseUpOnJunctionPointWithOffset:s,mouseUpOnJunctionPoint:o})=>x.jsxs("div",{className:"rg-connect-ctl",onMouseUp:e=>o("",e),onTouchEnd:e=>o("",e),children:[x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseUp:e=>o("top",e),onTouchEnd:e=>o("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseUp:e=>o("bottom",e),onTouchEnd:e=>o("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseUp:e=>o("border",e),onTouchEnd:e=>o("border",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseUp:e=>o("left",e),onTouchEnd:e=>o("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseUp:e=>o("right",e),onTouchEnd:e=>o("right",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseUp:e=>o("lr",e),onTouchEnd:e=>o("lr",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseUp:e=>o("tb",e),onTouchEnd:e=>o("tb",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseUp:e=>s("bottom",e),onTouchEnd:e=>onMouseUpWithOffset("bottom",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseUp:e=>s("top",e),onTouchEnd:e=>onMouseUpWithOffset("top",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseUp:e=>s("left",e),onTouchEnd:e=>onMouseUpWithOffset("left",e)}),x.jsx("div",{className:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseUp:e=>s("right",e),onTouchEnd:e=>onMouseUpWithOffset("right",e)})]}),Ti=({children:s})=>{const o=W();oe();const e=I.useRef(),{options:t}=q();if(!t.nodeConnectController.show)return x.jsx(x.Fragment,{});const n=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,void 0,(l,c,d)=>{C("onLineVertexBeDropped:callback:",d)})},i=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,e.current,(l,c,d)=>{C("onLineVertexBeDropped:callback:",d)})};return x.jsx("div",{className:"rg-editing-connect-ctrl",ref:e,style:{transform:`translate(${t.nodeConnectController.x}px, ${t.nodeConnectController.y}px)`,width:t.nodeConnectController.width+"px",height:t.nodeConnectController.height+"px"},children:s||x.jsx(It,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:i})})},Mi=({lineTemplate:s,onConnectStart:o,onConnectEnd:e,children:t,className:n,style:i})=>{const a=W(),r=l=>{o&&o(s,l.nativeEvent),l.stopPropagation(),a.startCreateLineFromNode(null,s,l.nativeEvent,(c,d,h)=>{e&&e(c,d,h),a.defaultLineConnectEndHandler(c,d,h)})};return x.jsx("div",{className:`rg-connect-source-handle ${n||""}`,style:i,onMouseDown:l=>r(l),onClick:l=>{l.stopPropagation()},children:t})},ki=({children:s,className:o,style:e,junctionPoint:t,targetId:n,targetType:i,targetData:a,lineTemplate:r,disableDrop:l,disableDrag:c,onLineVertexBeDropped:d,onDragConnectStart:h,onDragConnectEnd:f})=>{const y=W(),u=I.useRef(null);I.useEffect(()=>(y.registerConnectTarget(u.current,n,i||B.CanvasPoint,t,a),()=>{y.unregisterConnectTarget(n)}),[]);const g=(p,v)=>{v.stopPropagation(),!l&&y.onLineVertexBeDropped(p,v.nativeEvent,void 0,(L,_,S)=>{d&&d(L,_,S)})},m=p=>{if(p.stopPropagation(),c||y.options.creatingLinePlot)return;const v=Object.assign({},r||{});v.from||(v.from=n),v.fromType||(v.fromType=i||B.NodePoint),v.fromJunctionPoint||(v.fromJunctionPoint=t),h&&h(v,p.nativeEvent),y.startCreateLineFromNode(null,v,p.nativeEvent,(L,_,S)=>{f&&f(L,_,S)})};return x.jsx("div",{ref:u,className:`rg-connect-ctl-handler rg-connect-target ${o||""}`,style:e,"data-point":t,"data-target-id":n,"data-target-type":i||B.CanvasPoint,"data-target-data":JSON.stringify(a),onMouseDown:p=>m(p),onMouseUp:p=>g(t,p),onClick:p=>{p.stopPropagation()},children:s})},Ii=({showText:s,adsorption:o})=>{const e=W(),{options:t}=q();return I.useEffect(()=>(e.onReferenceLineMounted(o),()=>{e.onReferenceLineUnMounted()}),[t]),x.jsxs("div",{className:"rg-editing-referline",style:{display:t.editingReferenceLine.show?"block":"none"},children:[t.editingReferenceLine.directionV&&x.jsx("div",{className:"rg-referline rg-referline-v",style:{transform:`translate(var(--rg-refer-offset), 0px) translate(${t.editingReferenceLine.v_x}px, ${t.editingReferenceLine.v_y}px)`,height:t.editingReferenceLine.v_height+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.v_height),"px"]})})}),t.editingReferenceLine.directionH&&x.jsx("div",{className:"rg-referline rg-referline-h",style:{transform:`translate(0px, var(--rg-refer-offset)) translate(${t.editingReferenceLine.h_x}px, ${t.editingReferenceLine.h_y}px)`,width:t.editingReferenceLine.h_width+"px"},children:x.jsx("div",{className:"referline",children:s!==!1&&x.jsxs("div",{children:[Math.round(t.editingReferenceLine.h_width),"px"]})})})]})},Ei=s=>{const o=W();return I.useEffect(()=>{tt("React-Linker"),o.setOptions(s.options);const e=nt(s);C("[RelationGraph]mounted:listeners:",e),o.setListeners(e),o.ready(),o.dataUpdated()},[]),I.useEffect(()=>{o.setOptions(s.options||{}),o.dataUpdated()},[s.options]),I.useEffect(()=>{s.lines&&(C("[RelationGraph] apply data"),(async()=>(o.clearGraph(),o.addFakeLines(s.lines),o.dataUpdated()))())},[s.lines]),x.jsx(vt,{...s})},Di=s=>{const o=We(s.relationGraphCore,!0);return x.jsx($e,{graphInstance:o,children:x.jsx(Ei,{...s,children:s.children})})},Ai=s=>{const o=Rt(s.relationGraphCore);return x.jsx(Tt,{graphInstance:o,children:s.children})},Vi=et,Xi=Pt,zi={BaseLayout:ue,BidirectionalTreeLayout:Ct,CenterLayout:Lt,CircleLayout:wt,FixedLayout:Nt,ForceLayout:Se,RGFolderLayout:_t},Bi={RGOptionsDataUtils:Jt,RGLineDataUtils:jt,RGNodeDataUtils:Ut,RGGraphMath:Z,RGNodesAnalyticUtils:z,RGEffectUtils:J},Gi=Li,Fi=rt,Yi=at,Hi=xi,ji=Ci,Wi=ht,$i=gt,Ui=bi,qi=Si,Ji=Oi,Zi=Ni,Qi=_i,Ki=Pi,eo=Ri,to=Ti,no=Mi,io=ki,oo=It,so=Ii,ao=je,ro=je,lo=mt,co=yt,Et=wi,ho=pt,uo=Di,Dt=kt,fo=Dt.useRelationGraph,go=Ai,po=Mt;exports.RGBackground=qi;exports.RGConnectSource=no;exports.RGConnectTarget=io;exports.RGDebugView=Hi;exports.RGDirection=it;exports.RGEditingConnectController=to;exports.RGEditingConnectPoints=oo;exports.RGEditingLineController=eo;exports.RGEditingNearNodeWidget=Ki;exports.RGEditingNodeController=Zi;exports.RGEditingReferenceLine=so;exports.RGEditingResize=Qi;exports.RGEventNames=A;exports.RGFakeNode=Gi;exports.RGHooks=Dt;exports.RGInnerConnectTargetType=B;exports.RGInstanceContext=ye;exports.RGJunctionPoint=U;exports.RGLayouts=zi;exports.RGLinePath=Fi;exports.RGLineShape=F;exports.RGLineText=Yi;exports.RGMiniToolBar=$i;exports.RGMiniView=Ui;exports.RGNodeExpandHolder=Wi;exports.RGNodeShape=_e;exports.RGProvider=go;exports.RGSlotOnCanvas=co;exports.RGSlotOnCanvasAbove=lo;exports.RGSlotOnGraph=ao;exports.RGSlotOnLine=ho;exports.RGSlotOnNode=Et;exports.RGSlotOnView=ro;exports.RGToolBar=ji;exports.RGUpdateContext=ot;exports.RGUpdateSignalContext=Ee;exports.RGUpdateSingalContext=Ee;exports.RGUtils=Bi;exports.RGWatermark=Ji;exports.RelationGraph=po;exports.RelationGraphCore=Xi;exports.RelationGraphStoreContext=ye;exports.RelationLinker=uo;exports._RGHooks=kt;exports.default=Mt;exports.useRelationGraph=fo;exports.version=Vi;