@relation-graph/vue3 3.0.12 → 3.0.13
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.
- package/README-zh.md +9 -9
- package/README.md +9 -9
- package/package.json +4 -4
- package/relation-graph.js +10 -79
- package/relation-graph.mjs +5489 -4227
- package/relation-graph.ssr.mjs +5489 -4227
- package/relation-graph.umd.js +10 -79
- package/style.css +1 -1
- package/types/packages/platforms/react/src/index.d.ts +1 -1
- package/types/packages/platforms/react/src/index.shared.d.ts +33 -22
- package/types/packages/platforms/react/src/relation-graph/src/core4react/RGFakeNode.d.ts +3 -3
- package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLinePath.d.ts +3 -4
- package/types/packages/platforms/react/src/relation-graph/src/core4react/RGLineText.d.ts +2 -4
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGConnectSource.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGConnectTarget.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingConnectController.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingLineController.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingNearNodeWidget.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/editing/RGEditingNodeController.d.ts +4 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnCanvas.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnCanvasAbove.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnLineText.d.ts +3 -3
- package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnNodeExpandHandle.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/slots/RGSlotOnView.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphBackground.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphToolBar.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphWatermark.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/GraphXsToolBar.d.ts +2 -2
- package/types/packages/platforms/react/src/relation-graph/src/core4react/widgets/RGDebugView.d.ts +2 -2
- package/types/packages/platforms/svelte/src/hooks/useGraphInstance.d.ts +2 -2
- package/types/packages/platforms/svelte/src/index.d.ts +1 -1
- package/types/packages/platforms/vue2/src/core4vue/RGCanvas.vue.d.ts +1 -0
- package/types/packages/platforms/vue2/src/core4vue/RelationGraphUI.vue.d.ts +0 -1
- package/types/packages/platforms/vue2/src/core4vue/RelationLinker.vue.d.ts +1 -1
- package/types/packages/platforms/vue2/src/core4vue/editing/RGConnectTarget.vue.d.ts +33 -2
- package/types/packages/platforms/vue2/src/core4vue/editing/RGEditingNodeController.vue.d.ts +14 -2
- package/types/packages/platforms/vue2/src/core4vue/widgets/GraphWatermark.vue.d.ts +1 -1
- package/types/packages/platforms/vue2/src/index.d.ts +49 -6
- package/types/packages/platforms/vue3/src/index.d.ts +1 -1
- package/types/packages/relation-graph-models/data/RGLineDataUtils.d.ts +140 -4
- package/types/packages/relation-graph-models/data/RGNodeDataUtils.d.ts +7 -2
- package/types/packages/relation-graph-models/models/RelationGraphBase.d.ts +8 -1
- package/types/packages/relation-graph-models/models/RelationGraphWith1View.d.ts +9 -6
- package/types/packages/relation-graph-models/models/RelationGraphWith2Data4ConnectTarget.d.ts +73 -5
- package/types/packages/relation-graph-models/models/RelationGraphWith2Data5LineConfig.d.ts +20 -2
- package/types/packages/relation-graph-models/models/RelationGraphWith6Layout.d.ts +7 -3
- package/types/packages/relation-graph-models/models/RelationGraphWith7Event.d.ts +3 -2
- package/types/packages/relation-graph-models/models/RelationGraphWith95Dom.d.ts +24 -4
- package/types/packages/relation-graph-models/models/RelationGraphWith99API.d.ts +5 -3
- package/types/packages/relation-graph-models/models/RelationGraphWith9EasyView.d.ts +1 -0
- package/types/packages/relation-graph-models/utils/RGClassAndRender.d.ts +111 -0
- package/types/packages/types.ts +25 -1
package/relation-graph.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
* relation-graph v3.0.
|
|
1
|
+
(function(V,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(V=typeof globalThis<"u"?globalThis:V||self,l(V.RelationGraph={},V.Vue))})(this,function(V,l){"use strict";var Ka=Object.defineProperty;var Qa=(V,l,ye)=>l in V?Ka(V,l,{enumerable:!0,configurable:!0,writable:!0,value:ye}):V[l]=ye;var _=(V,l,ye)=>(Qa(V,typeof l!="symbol"?l+"":l,ye),ye);/*!
|
|
2
|
+
* relation-graph v3.0.13
|
|
3
3
|
* (c) 2026 WanLian <seeksdream@qq.com>
|
|
4
4
|
* Released under the MIT License.
|
|
5
|
-
* Repository: https://github.com/
|
|
6
|
-
*/const
|
|
5
|
+
* Repository: https://github.com/relation-graph/relation-graph
|
|
6
|
+
*/const ye="",er="",st="3.0.13",pn=Symbol("INSTALLED_KEY"),Le="RelationGraphProvideKey",fe=s=>{try{if("touches"in s&&s.touches||"targetTouches"in s&&s.targetTouches)return!0}catch{}return!1},ce=s=>{if(fe(s)){const o=("touches"in s&&s.touches.length>0?s.touches:void 0)||("targetTouches"in s&&s.targetTouches.length>0?s.targetTouches:void 0)||("changedTouches"in s&&s.changedTouches.length>0?s.changedTouches:void 0);if(!o||o.length===0)throw new Error("error touches");return{clientX:o[0].clientX,clientY:o[0].clientY}}if("clientX"in s&&"clientY"in s)return{clientX:s.clientX,clientY:s.clientY};throw new Error("error client coordinate")},w=(...s)=>{typeof window<"u"&&window.relationGraphDebug&&console.log("[relation-graph:debug]",...s)},ve=(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 ve(t,o,e)},ze=s=>new Promise(o=>setTimeout(o,s)),gn=()=>{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("")},mn=()=>{const s="c",o="o",e="n",t="s",n="o",i="l",a="e",r=new Date().getFullYear(),d=[];return r>1&&d.push(s),r>21&&d.push(o),r>35&&d.push(e),r>55&&d.push(t),r>189&&d.push(n),r>231&&d.push(i),r>1234&&d.push(a),d.join("")},at=s=>s.replace(/-/g,"").replace(/\*/g,"-"),rt=s=>{const o=mn(),e=gn(),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";typeof window<"u"&&window&&window[o]&&window[o][e](`%c ${at(t)} %c Version v${st}(${s}) %c More info: ${at(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")},yn=(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},xe=s=>{const o=s.target;return yn(o,"rel-text-editing")?!0:["input","textarea"].includes(document.activeElement.tagName.toLowerCase())},Xe=(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},vn={"icon-quanping":{data:`
|
|
7
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
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>
|
|
9
9
|
`},"icon-suoxiao":{data:`
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
`},"icon-lianjiezhong":{data:`
|
|
40
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>
|
|
41
41
|
|
|
42
|
-
`}},It=["innerHTML"],K=r.defineComponent({__name:"RGIcons",props:{iconName:{},className:{}},setup(l){const i=l,e=r.computed(()=>Et[i.iconName]);return(t,n)=>(r.openBlock(),r.createElementBlock("svg",{class:r.normalizeClass(["rg-icon",t.className]),viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",innerHTML:e.value.data},null,10,It))}}),je=r.defineComponent({__name:"RGNodeExpandHolder",props:{node:{},expandOrCollapseNode:{type:Function},expandHolderPosition:{}},setup(l){const i=l,e=r.computed(()=>i.node.expanded===!1?"c-expanded":"c-collapsed");return(t,n)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-node-expand-holder","c-expand-positon-"+t.expandHolderPosition])},[r.createElementVNode("div",{class:r.normalizeClass(["rg-node-expand-button",e.value]),onClick:n[0]||(n[0]=r.withModifiers((...o)=>t.expandOrCollapseNode&&t.expandOrCollapseNode(...o),["stop"])),onTouchend:n[1]||(n[1]=r.withModifiers((...o)=>t.expandOrCollapseNode&&t.expandOrCollapseNode(...o),["stop"]))},[t.node.expanded===!1?(r.openBlock(),r.createBlock(K,{key:0,iconName:"icon-fangda"})):(r.openBlock(),r.createBlock(K,{key:1,iconName:"icon-suoxiao"}))],34)],2))}});function H(){const l=r.inject(ye,null);if(!l)throw new Error("RGHooks.useGraphInstance must be used inside RGProvider or RelationGraph tag.");return l==null?void 0:l.graphInstance}const Dt=["data-id"],Vt={class:"rg-node-text"},qe=r.defineComponent({__name:"RGNodePeel",props:{nodeProps:{},defaultExpandHolderPosition:{},dragging:{type:Boolean},checked:{type:Boolean}},setup(l){const i=H(),e=l,t=r.ref(),n=r.computed(()=>e.nodeProps.borderColor),o=r.computed(()=>e.nodeProps.borderWidth===void 0?void 0:e.nodeProps.borderWidth+"px"),s=r.computed(()=>e.nodeProps.width?e.nodeProps.width+"px":void 0),a=r.computed(()=>e.nodeProps.height?e.nodeProps.height+"px":void 0),d=r.computed(()=>e.nodeProps.expandHolderPosition?e.nodeProps.expandHolderPosition!=="hide":e.defaultExpandHolderPosition&&e.defaultExpandHolderPosition!=="hide"&&e.nodeProps.rgChildrenSize>0),h=r.computed(()=>e.nodeProps.rgCalcedVisibility),c=p=>{i.expandOrCollapseNode(e.nodeProps,p)},f=p=>{i.onNodeDragStart(e.nodeProps,p)};return r.onMounted(()=>{i.addNodeResizeListener(t.value,e.nodeProps)}),r.onBeforeUnmount(()=>{i.removeNodeResizeListener(t.value)}),(p,m)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",{ref_key:"nodePeelRef",ref:t,style:r.normalizeStyle({transform:`translate(${p.nodeProps.x}px, ${p.nodeProps.y}px)`,"--rg-node-z-index":p.nodeProps.zIndex?p.nodeProps.zIndex:void 0,"--rg-node-color":p.nodeProps.color,"--rg-node-font-color":p.nodeProps.fontColor,"--rg-node-font-size":p.nodeProps.fontSize?p.nodeProps.fontSize+"px":void 0,"--rg-node-border-width":o.value,"--rg-node-border-radius":p.nodeProps.borderRadius&&p.nodeProps.borderRadius+"px","--rg-node-border-color":n.value,"--rg-node-width":s.value,"--rg-node-height":a.value,"--rg-node-opacity":p.nodeProps.opacity===void 0?void 0:p.nodeProps.opacity}),class:r.normalizeClass(["rg-node-peel",p.nodeProps.selected&&"rg-node-selected",p.dragging&&"rg-node-dragging",p.checked&&"rg-node-checked",(p.nodeProps.disablePointEvent||p.nodeProps.opacity===0)&&"rg-node-disable-events","rg-node-shape-"+(p.nodeProps.nodeShape===void 0?1:p.nodeProps.nodeShape),"rg-node-type-"+p.nodeProps.type,p.nodeProps.className]),"data-id":p.nodeProps.id},[d.value?r.renderSlot(p.$slots,"node-expand-button",{key:0,node:p.nodeProps,expandOrCollapseNode:c,expandHolderPosition:p.nodeProps.expandHolderPosition||p.defaultExpandHolderPosition},()=>[r.createVNode(je,{node:p.nodeProps,checked:p.checked,expandOrCollapseNode:c,expandHolderPosition:p.nodeProps.expandHolderPosition||p.defaultExpandHolderPosition},null,8,["node","checked","expandHolderPosition"])]):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"rg-node",onMousedown:r.withModifiers(f,["left","stop"]),onTouchstart:r.withModifiers(f,["stop"])},[r.renderSlot(p.$slots,"node",{node:p.nodeProps,checked:p.checked,dragging:p.dragging},()=>[r.createElementVNode("div",Vt,[r.createElementVNode("span",null,r.toDisplayString(p.nodeProps.text),1)])])],32)],14,Dt)),[[r.vShow,h.value]])}}),Bt={class:"rg-nodes-container"},At=r.defineComponent({__name:"RGCanvasContent4Nodes",props:{defaultExpandHolderPosition:{},draggingNodeId:{},checkedNodeId:{}},setup(l){const i=H(),e=r.computed(()=>i.getShouldRenderNodes(i.dataStores.shouldRenderNodesRef.value));return r.onMounted(()=>{L("[RGCanvas mounted]")}),(t,n)=>(r.openBlock(),r.createElementBlock("div",Bt,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.value,o=>(r.openBlock(),r.createBlock(qe,{key:o.id,"node-props":o,"default-expand-holder-position":t.defaultExpandHolderPosition,dragging:o.id===t.draggingNodeId,checked:o.id===t.checkedNodeId},{node:r.withCtx(s=>[r.renderSlot(t.$slots,"node",r.mergeProps({ref_for:!0},s))]),"node-expand-button":r.withCtx(s=>[r.renderSlot(t.$slots,"node-expand-button",r.mergeProps({ref_for:!0},s))]),_:2},1032,["node-props","default-expand-holder-position","dragging","checked"]))),128))]))}}),zt=["id","markerWidth","markerHeight","refX","refY","viewBox"],Xt=["d"],Gt=["id","markerWidth","markerHeight","refX","refY","viewBox"],Ft=["d"],Ze=r.defineComponent({__name:"RGGraphDefs",props:{forElementLines:{type:Boolean}},setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value);return(t,n)=>(r.openBlock(),r.createElementBlock("defs",null,[r.createElementVNode("marker",{id:e.value.instanceId+"-arrow-default",markerWidth:e.value.defaultLineMarker.markerWidth,markerHeight:e.value.defaultLineMarker.markerHeight,refX:e.value.defaultLineMarker.refX,refY:e.value.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:e.value.defaultLineMarker.viewBox},[r.createElementVNode("path",{style:{fill:"context-stroke"},d:e.value.defaultLineMarker.data},null,8,Xt)],8,zt),r.createElementVNode("marker",{id:e.value.instanceId+"-start-arrow-default",markerWidth:e.value.defaultLineMarker.markerWidth,markerHeight:e.value.defaultLineMarker.markerHeight,refX:e.value.defaultLineMarker.refX,refY:e.value.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:e.value.defaultLineMarker.viewBox},[r.createElementVNode("path",{style:{fill:"context-stroke"},d:e.value.defaultLineMarker.data},null,8,Ft)],8,Gt),r.renderSlot(t.$slots,"default")]))}});var D=(l=>(l.Node="node",l.NodePoint="NodePoint",l.HTMLElementId="HTMLElementId",l.CanvasPoint="CanvasPoint",l.ViewPoint="ViewPoint",l))(D||{}),W=(l=>(l.border="border",l.ltrb="ltrb",l.tb="tb",l.lr="lr",l.left="left",l.right="right",l.top="top",l.bottom="bottom",l))(W||{}),xe=(l=>(l[l.circle=0]="circle",l[l.rect=1]="rect",l))(xe||{}),Y=(l=>(l[l.StandardStraight=1]="StandardStraight",l[l.StandardCurve=6]="StandardCurve",l[l.Curve2=2]="Curve2",l[l.Curve3=3]="Curve3",l[l.Curve5=5]="Curve5",l[l.Curve7=7]="Curve7",l[l.Curve8=8]="Curve8",l[l.SimpleOrthogonal=4]="SimpleOrthogonal",l[l.StandardOrthogonal=44]="StandardOrthogonal",l[l.HardOrthogonal=49]="HardOrthogonal",l))(Y||{}),Ke=(l=>(l.Left="left",l.Top="top",l.Right="right",l.Bottom="bottom",l))(Ke||{}),I=(l=>(l.onReady="onReady",l.onNodeClick="onNodeClick",l.onNodeExpand="onNodeExpand",l.onNodeCollapse="onNodeCollapse",l.onLineClick="onLineClick",l.onNodeDragStart="onNodeDragStart",l.onNodeDragEnd="onNodeDragEnd",l.onNodeDragging="onNodeDragging",l.onCanvasDragEnd="onCanvasDragEnd",l.onCanvasDragging="onCanvasDragging",l.onContextmenu="onContextmenu",l.onFullscreen="onFullscreen",l.onCanvasClick="onCanvasClick",l.onCanvasSelectionEnd="onCanvasSelectionEnd",l.beforeZoomStart="beforeZoomStart",l.onZoomEnd="onZoomEnd",l.onViewResize="onViewResize",l.onResizeStart="onResizeStart",l.beforeNodeResize="beforeNodeResize",l.onResizeEnd="onResizeEnd",l.onLineVertexDropped="onLineVertexDropped",l.beforeCreateLine="beforeCreateLine",l.onLineBeCreated="onLineBeCreated",l.beforeAddNodes="beforeAddNodes",l.beforeAddLines="beforeAddLines",l.onKeyboardDown="onKeyboardDown",l.onKeyboardUp="onKeyboardUp",l.onCanvasDragStart="onCanvasDragStart",l.onForceLayoutFinish="onForceLayoutFinish",l.beforeScrollStart="beforeScrollStart",l))(I||{});const Ht={key:0},$t=["data-id"],Yt={key:1},Qe=r.defineComponent({__name:"RGLineText",props:{lineConfig:{},linePathInfo:{},checked:{type:Boolean}},setup(l){const i=H(),e=r.computed(()=>{var n;return(n=l.lineConfig)==null?void 0:n.line}),t=r.computed(()=>e.value.isFakeLine?i.dataStores.textContainer4FakeLineRef.value:i.dataStores.textContainer4NormalRef.value);return(n,o)=>e.value&&t.value?(r.openBlock(),r.createElementBlock("foreignObject",Ht,[(r.openBlock(),r.createBlock(r.Teleport,{to:t.value},[r.createElementVNode("div",{class:r.normalizeClass(["rg-line-peel",e.value.className,n.checked&&"rg-line-checked",(e.value.disablePointEvent||e.value.opacity===0)&&"rg-line-disable-events",e.value.selected&&"rg-line-selected"]),"data-id":e.value.id,style:r.normalizeStyle({"--rg-line-color":e.value.color,"--rg-line-fontsize":e.value.fontSize?`${e.value.fontSize}px`:void 0,"--rg-line-opacity":e.value.opacity,"--rg-line-fontcolor":e.value.fontColor,...e.value.cssVars||{}})},[r.renderSlot(n.$slots,"default")],14,$t)],8,["to"]))])):(r.openBlock(),r.createElementBlock("g",Yt,[r.createElementVNode("text",null,"Null-text-"+r.toDisplayString(!!e.value)+"-"+r.toDisplayString(!!t.value),1)]))}}),Wt=["data-id"],Ut=["d"],Jt=["id","d"],jt={key:0},qt=["dx","dy"],Zt=["xlink:href","startOffset","text-anchor"],et=r.defineComponent({__name:"RGLinePath",props:{lineConfig:{},linePathInfo:{},useTextOnPath:{type:Boolean},checked:{type:Boolean},graphInstanceId:{}},emits:["onLineClick"],setup(l,{emit:i}){const e=H(),t=i,n=r.computed(()=>l.lineConfig.line),o=r.computed(()=>e.getArrowMarkerId(l.lineConfig.line,!0)),s=r.computed(()=>e.getArrowMarkerId(l.lineConfig.line,!1)),a=r.computed(()=>e.generateLineTextStyle4TextOnPath(l.lineConfig)),d=r.computed(()=>l.lineConfig.line.lineWidth?l.lineConfig.line.lineWidth+"px":void 0),h=r.computed(()=>l.graphInstanceId+"-"+l.lineConfig.line.id),c=f=>{t("onLineClick",f)};return(f,p)=>(r.openBlock(),r.createElementBlock("g",{class:r.normalizeClass(["rg-line-peel",n.value.className,n.value.selected&&"rg-line-selected",(n.value.disablePointEvent||n.value.opacity===0)&&"rg-line-disable-events",f.checked&&"rg-line-checked"]),"data-id":n.value.id,style:r.normalizeStyle({"--rg-line-width":d.value,"--rg-line-color":n.value.color,"--rg-line-opacity":n.value.opacity,"--rg-line-fontcolor":n.value.fontColor,"--rg-line-marker-end":s.value,"--rg-line-marker-start":o.value,...n.value.cssVars||{}})},[r.createElementVNode("path",{d:f.linePathInfo.pathData,class:"rg-line-bg",onTouchstart:c,onClick:c},null,40,Ut),r.createElementVNode("path",{id:h.value,d:f.linePathInfo.pathData,class:r.normalizeClass(["rg-line",[n.value.dashType?"rg-line-dashtype-"+n.value.dashType:void 0,n.value.animation?"rg-line-anm-"+n.value.animation:void 0]])},null,10,Jt),f.useTextOnPath&&a.value?(r.openBlock(),r.createElementBlock("g",jt,[r.createElementVNode("text",{class:"rg-line-text rg-line-text-on-path",dx:a.value.textOffset.x+"px",dy:a.value.textOffset.y+"px",onTouchstart:c,onClick:c},[r.createElementVNode("textPath",{"xlink:href":"#"+h.value,startOffset:a.value.onPathStartOffset,"text-anchor":a.value.textAnchor,method:"align",spacing:"auto"},r.toDisplayString(a.value.text),9,Zt)],40,qt)])):r.createCommentVNode("",!0),r.renderSlot(f.$slots,"default")],14,Wt))}}),tt=r.defineComponent({__name:"RGLineContent",props:{lineConfig:{},checked:{type:Boolean},defaultLineTextOnPath:{type:Boolean},graphInstanceId:{}},setup(l){const i=H(),e=r.computed(()=>i.generateLinePath(l.lineConfig)),t=r.computed(()=>i.generateLineTextStyle(l.lineConfig,e.value)),n=r.computed(()=>l.lineConfig.line.useTextOnPath||l.defaultLineTextOnPath),o=r.computed(()=>n.value&&l.lineConfig.line.lineShape!==Y.StandardStraight),s=a=>{i.onLineClick(l.lineConfig.line,a)};return(a,d)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.createVNode(et,{lineConfig:a.lineConfig,linePathInfo:e.value,useTextOnPath:o.value,"graph-instance-id":a.graphInstanceId,checked:a.checked,onOnLineClick:s},null,8,["lineConfig","linePathInfo","useTextOnPath","graph-instance-id","checked"]),a.lineConfig.line.text&&!o.value?(r.openBlock(),r.createBlock(Qe,{key:0,lineConfig:a.lineConfig,linePathInfo:e.value,checked:a.checked},{default:r.withCtx(()=>[r.createElementVNode("div",{class:r.normalizeClass(`rg-line-label ${n.value?"rg-line-label-on-path":""}`),style:r.normalizeStyle({...t.value.cssStyles}),onTouchstart:s,onClick:s},r.toDisplayString(t.value.text),39)]),_:1},8,["lineConfig","linePathInfo","checked"])):r.createCommentVNode("",!0)],64))}}),Kt={key:0},nt=r.defineComponent({__name:"RGLinePeel",props:{line:{},checked:{type:Boolean},defaultLineTextOnPath:{type:Boolean},graphInstanceId:{}},setup(l){const i=H(),e=r.computed(()=>l.line.isFakeLine?i.generateFakeLineConfig(l.line):i.generateLineConfig(l.line));return(t,n)=>e.value?(r.openBlock(),r.createElementBlock("g",Kt,[r.renderSlot(t.$slots,"line",{lineConfig:e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,graphInstanceId:t.graphInstanceId,checked:t.checked},()=>[r.createVNode(tt,{"line-config":e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,"graph-instance-id":t.graphInstanceId,checked:t.checked},null,8,["line-config","defaultLineTextOnPath","graph-instance-id","checked"])])])):r.createCommentVNode("",!0)}}),Qt={class:"rg-lines-container rg-lines-container-el-lines"},en={class:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg"},tn=r.defineComponent({__name:"RGCanvasContent4FakeLines",props:{showEasyView:{type:Boolean},defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(l){const i=H(),e=r.computed(()=>i.getShouldRenderFakeLines(i.dataStores.shouldRenderFakeLinesRef.value));return r.onMounted(()=>{L("[RGCanvas mounted]")}),(t,n)=>(r.openBlock(),r.createElementBlock("div",Qt,[n[0]||(n[0]=r.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(r.openBlock(),r.createElementBlock("svg",en,[r.createVNode(Ze,{"for-element-lines":!0}),t.showEasyView?r.createCommentVNode("",!0):(r.openBlock(!0),r.createElementBlock(r.Fragment,{key:0},r.renderList(e.value,o=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:o.id},[o.hidden!==!0?(r.openBlock(),r.createBlock(nt,{key:0,line:o,defaultLineTextOnPath:t.defaultLineTextOnPath,checked:o.id===t.checkedLineId,"graph-instance-id":t.graphInstanceId},{line:r.withCtx(s=>[r.renderSlot(t.$slots,"line",r.mergeProps({ref_for:!0},s))]),_:2},1032,["line","defaultLineTextOnPath","checked","graph-instance-id"])):r.createCommentVNode("",!0)],64))),128))]))]))}}),nn={class:"rg-lines-container rg-lines-container-el-lines"},on={class:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg"},sn=r.defineComponent({__name:"RGCanvasContent4CreatingLine",props:{defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(l){const i=H(),e=r.computed(()=>i.generateCreatingLineConfig(i.dataStores.optionsRef.value));return r.onMounted(()=>{L("[RGCanvas mounted]")}),(t,n)=>(r.openBlock(),r.createElementBlock("div",nn,[n[0]||(n[0]=r.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(r.openBlock(),r.createElementBlock("svg",on,[r.renderSlot(t.$slots,"line",{lineConfig:e.value},()=>[r.createVNode(tt,{"line-config":e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,"graph-instance-id":t.graphInstanceId},null,8,["line-config","defaultLineTextOnPath","graph-instance-id"])])]))]))}}),an={class:"rg-lines-container rg-lines-container-normal-lines"},rn={class:"rg-lines-svg",xmlns:"http://www.w3.org/2000/svg"},ln=r.defineComponent({__name:"RGCanvasContent4Lines",props:{showEasyView:{type:Boolean},defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(l){const i=H(),e=r.computed(()=>i.getShouldRenderLines(i.dataStores.shouldRenderLinesRef.value));return r.onMounted(()=>{L("[RGCanvas mounted]")}),(t,n)=>(r.openBlock(),r.createElementBlock("div",an,[n[0]||(n[0]=r.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(r.openBlock(),r.createElementBlock("svg",rn,[r.createVNode(Ze),t.showEasyView?r.createCommentVNode("",!0):(r.openBlock(!0),r.createElementBlock(r.Fragment,{key:0},r.renderList(e.value,o=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:o.id},[o.hidden!==!0?(r.openBlock(),r.createBlock(nt,{key:"l-"+o.id,line:o,defaultLineTextOnPath:t.defaultLineTextOnPath,checked:o.id===t.checkedLineId,"graph-instance-id":t.graphInstanceId},{line:r.withCtx(s=>[r.renderSlot(t.$slots,"line",r.mergeProps({ref_for:!0},s))]),_:2},1032,["line","defaultLineTextOnPath","checked","graph-instance-id"])):r.createCommentVNode("",!0)],64))),128))]))]))}}),dn={class:"rg-single-graph"},cn={class:"rg-nodes-container-wrapper"},ot=r.defineComponent({__name:"RGCanvasContent",props:{showEasyView:{type:Boolean},creatingLine:{type:Boolean},defaultExpandHolderPosition:{},draggingNodeId:{},checkedNodeId:{},checkedLineId:{},graphInstanceId:{},defaultLineTextOnPath:{type:Boolean}},setup(l){return(i,e)=>(r.openBlock(),r.createElementBlock("div",dn,[r.withMemo([i.defaultLineTextOnPath,i.checkedLineId],()=>r.createVNode(ln,{showEasyView:i.showEasyView,defaultLineTextOnPath:i.defaultLineTextOnPath,"checked-line-id":i.checkedLineId,"graph-instance-id":i.graphInstanceId},{line:r.withCtx(t=>[r.renderSlot(i.$slots,"line",r.normalizeProps(r.guardReactiveProps(t)))]),_:3},8,["showEasyView","defaultLineTextOnPath","checked-line-id","graph-instance-id"]),e,0),r.createElementVNode("div",cn,[i.showEasyView?r.createCommentVNode("",!0):r.withMemo([i.draggingNodeId,i.checkedNodeId,i.defaultExpandHolderPosition],()=>(r.openBlock(),r.createBlock(At,{key:0,"default-expand-holder-position":i.defaultExpandHolderPosition,draggingNodeId:i.draggingNodeId,checkedNodeId:i.checkedNodeId},{node:r.withCtx(t=>[r.renderSlot(i.$slots,"node",r.normalizeProps(r.guardReactiveProps(t)))]),"node-expand-button":r.withCtx(t=>[r.renderSlot(i.$slots,"node-expand-button",r.normalizeProps(r.guardReactiveProps(t)))]),_:3},8,["default-expand-holder-position","draggingNodeId","checkedNodeId"])),e,1)]),r.createVNode(tn,{showEasyView:i.showEasyView,defaultLineTextOnPath:i.defaultLineTextOnPath,"checked-line-id":i.checkedLineId,"graph-instance-id":i.graphInstanceId},{line:r.withCtx(t=>[r.renderSlot(i.$slots,"line",r.normalizeProps(r.guardReactiveProps(t)))]),_:3},8,["showEasyView","defaultLineTextOnPath","checked-line-id","graph-instance-id"]),i.creatingLine?(r.openBlock(),r.createBlock(sn,{key:0,defaultLineTextOnPath:i.defaultLineTextOnPath,"checked-line-id":i.checkedLineId},{line:r.withCtx(t=>[r.renderSlot(i.$slots,"line",r.normalizeProps(r.guardReactiveProps(t)))]),_:3},8,["defaultLineTextOnPath","checked-line-id"])):r.createCommentVNode("",!0)]))}}),hn=r.defineComponent({__name:"RGEasyView",setup(l){const i=H(),e=r.ref(),t=r.computed(()=>i.dataStores.optionsRef.value);return r.onMounted(()=>{L("[RGEasyView mounted]"),i.setEasyViewCanvas&&i.setEasyViewCanvas(e.value)}),(n,o)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-easy-view",{"rg-easy-view-active":t.value.showEasyView}])},[r.createElementVNode("canvas",{ref_key:"$rgEasyCanvas",ref:e,style:{width:"100%",height:"100%"}},null,512)],2))}}),fn={class:"rg-map-background"},pn={class:"rg-canvas-slot rg-canvas-slot-behind"},un={class:"rg-canvas-slot rg-canvas-slot-above"},gn=r.defineComponent({__name:"RGCanvas",setup(l){const i=r.ref(),e=H(),t=r.computed(()=>e.dataStores.optionsRef.value),n=a=>{e.onCanvasDragStart(a)},o=a=>{e.onContextmenu(a)},s=r.computed(()=>{const a=e.dataStores.optionsRef.value;return{width:`${a.canvasSize.width}px`,height:`${a.canvasSize.height}px`,"background-color":"transparent",transform:`translate(${a.canvasOffset.x}px, ${a.canvasOffset.y}px) scale(${a.canvasZoom/100},${t.value.canvasZoom/100})`}});return r.onMounted(()=>{L("[RGCanvas mounted]"),e.setCanvasDom(i.value)}),(a,d)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-map",[t.value.canvasOpacity===1&&"rg-map-ready"]]),onContextmenu:d[0]||(d[0]=r.withModifiers(h=>o(h),["prevent"])),onMousedown:d[1]||(d[1]=r.withModifiers(h=>n(h),["left"])),onTouchstart:d[2]||(d[2]=h=>n(h))},[r.createElementVNode("div",fn,[r.renderSlot(a.$slots,"background")]),r.createElementVNode("div",{style:r.normalizeStyle(s.value),class:"rg-map-canvas rg-canvas-behind"},[r.createElementVNode("div",pn,[r.renderSlot(a.$slots,"canvas-plug-behind")])],4),r.createVNode(hn),r.createElementVNode("div",{ref_key:"rgCanvasRef",ref:i,style:r.normalizeStyle(s.value),class:"rg-map-canvas"},[r.createVNode(ot,{"show-easy-view":t.value.showEasyView,"creating-line":!!(t.value.creatingLinePlot&&t.value.newLinkTemplate.fromNode),"default-expand-holder-position":t.value.defaultExpandHolderPosition,draggingNodeId:t.value.draggingNodeId,checkedNodeId:t.value.checkedNodeId,defaultLineTextOnPath:t.value.defaultLineTextOnPath,"checked-line-id":t.value.checkedLineId,"graph-instance-id":t.value.instanceId},{line:r.withCtx(h=>[r.renderSlot(a.$slots,"line",r.normalizeProps(r.guardReactiveProps(h)))]),node:r.withCtx(h=>[r.renderSlot(a.$slots,"node",r.normalizeProps(r.guardReactiveProps(h)))]),"node-expand-button":r.withCtx(h=>[r.renderSlot(a.$slots,"node-expand-button",r.normalizeProps(r.guardReactiveProps(h)))]),_:3},8,["show-easy-view","creating-line","default-expand-holder-position","draggingNodeId","checkedNodeId","defaultLineTextOnPath","checked-line-id","graph-instance-id"])],4),r.createElementVNode("div",{style:r.normalizeStyle(s.value),class:"rg-map-canvas rg-canvas-above"},[r.createElementVNode("div",un,[r.renderSlot(a.$slots,"canvas-plug-above")])],4)],34))}}),mn=r.defineComponent({__name:"GraphMoveOperator",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=r.computed(()=>e.value.canvasMoveMode),n=o=>{i.startMoveCanvas(o,!0)};return(o,s)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-move-operator",{"rg-move-operator-active":t.value}])},[r.createElementVNode("div",{class:"rg-move-touchpad",onMousedown:n,onTouchstart:n},null,32)],2))}}),yn={class:"rg-graph-loading-message"},vn=r.defineComponent({__name:"GraphLoading",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=n=>{i.clearLoading()};return(n,o)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-graph-loading",{"rg-graph-loading-hide":!e.value.graphLoading}]),onClick:t},[r.createElementVNode("div",yn,[r.createVNode(K,{"icon-name":"icon-lianjiezhong","class-name":"rg-graph-loading-icon"}),r.createTextVNode(" "+r.toDisplayString(e.value.graphLoadingText||"Loading..."),1)])],2))}}),xn={key:0,class:"rg-operate"},Cn={class:"rg-creating-container"},it=r.defineComponent({__name:"GraphOperateStuff",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value);return(t,n)=>e.value?(r.openBlock(),r.createElementBlock("div",xn,[r.createElementVNode("div",Cn,[e.value.creatingNodePlot&&e.value.showTemplateNode?(r.openBlock(),r.createBlock(qe,{key:0,"node-props":e.value.newNodeTemplate},{node:r.withCtx(()=>[r.renderSlot(t.$slots,"node",{node:e.value.newNodeTemplate})]),_:3},8,["node-props"])):r.createCommentVNode("",!0),e.value.creatingSelection?(r.openBlock(),r.createElementBlock("div",{key:1,class:"rg-selection",style:r.normalizeStyle({transform:`translate(${e.value.selectionView.x}px, ${e.value.selectionView.y}px)`,width:e.value.selectionView.width+"px",height:e.value.selectionView.height+"px"})},null,4)):r.createCommentVNode("",!0)]),r.createVNode(mn),r.createVNode(vn)])):r.createCommentVNode("",!0)}}),Ln=["title"],st=r.defineComponent({__name:"GraphXsToolBar",props:{direction:{},positionH:{},positionV:{}},setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=()=>{i.toggleAutoLayout()},n=async()=>{i.enableCanvasAnimation(),i.setZoom(100),i.moveToCenter(),i.zoomToFit(),setTimeout(()=>{i.disableCanvasAnimation()},300)},o=async a=>{i.zoom(a)},s=async()=>{i.fullscreen()};return(a,d)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-toolbar rg-xs-toolbar",["rg-toolbar-h-"+(a.positionH||e.value.toolBarPositionH||"left"),"rg-toolbar-v-"+(a.positionV||e.value.toolBarPositionV||"bottom"),"rg-toolbar-"+(a.direction||e.value.toolBarDirection||"h")]])},[r.createElementVNode("div",{title:"Full Screen",class:"rg-mb-button",style:{"margin-top":"0px"},onClick:s},[r.createVNode(K,{"icon-name":"icon-quanping"})]),r.createElementVNode("div",{class:"rg-mb-button",onClick:d[0]||(d[0]=h=>o(20))},[r.createVNode(K,{"icon-name":"icon-fangda"})]),r.createElementVNode("div",{class:"rg-current-zoom",onClick:n},r.toDisplayString(Math.round(e.value.canvasZoom))+"%",1),r.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:d[1]||(d[1]=h=>o(-20))},[r.createVNode(K,{"icon-name":"icon-suoxiao"})]),e.value.layout.supportAutoLayout?(r.openBlock(),r.createElementBlock("div",{key:0,title:e.value.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",class:r.normalizeClass([{"rg-mb-button-on":e.value.layout.autoLayouting},"rg-mb-button"]),onClick:t},[e.value.layout.autoLayouting?(r.openBlock(),r.createBlock(K,{key:1,"icon-name":"icon-lianjiezhong","class-name":"rg-loading-icon"})):(r.openBlock(),r.createBlock(K,{key:0,"icon-name":"icon-zidong"}))],10,Ln)):r.createCommentVNode("",!0),r.renderSlot(a.$slots,"default"),d[2]||(d[2]=r.createElementVNode("div",{style:{clear:"both"}},null,-1))],2))}}),wn=["id"],_n={class:"rg-graph-plugs"},Nn={class:"rg-view-slot"},bn=r.defineComponent({__name:"RelationGraphUI",setup(l){const i=H(),e=r.ref(),t=r.computed(()=>i.dataStores.optionsRef.value),n=r.ref(!1);r.onMounted(()=>{i.setDom(e.value),n.value=!0}),r.onBeforeUnmount(()=>{i.beforeUnmount()});const o=s=>{i.onMouseWheel(s)};return r.onMounted(()=>{}),(s,a)=>{var d,h,c,f,p,m,u,g,y,v,x;return r.openBlock(),r.createElementBlock("div",{ref_key:"relationGraphRef$",ref:e,id:"relation-graph-ins-"+((d=t.value)==null?void 0:d.instanceId),tabindex:"1",class:r.normalizeClass(["relation-graph",t.value&&t.value.creatingLinePlot?"rg-creating-line":"",t.value&&t.value.dragEventAction==="move"?"rg-move-mode":"",t.value&&t.value.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",t.value&&t.value.enableCanvasTransformAnimation?"rg-enable-canvas-animation":""]),style:r.normalizeStyle({width:"100%",height:(h=t.value)!=null&&h.viewHeight?(c=t.value)==null?void 0:c.viewHeight:"100%",opacity:n.value?1:0,"--rg-checked-item-bg-color":(f=t.value)==null?void 0:f.checkedItemBackgroundColor,"--rg-background-color":(p=t.value)==null?void 0:p.backgroundColor,"--rg-node-color":(m=t.value)==null?void 0:m.defaultNodeColor,"--rg-node-border-color":(u=t.value)==null?void 0:u.defaultNodeBorderColor,"--rg-node-border-width":((g=t.value)==null?void 0:g.defaultNodeBorderWidth)+"px","--rg-node-border-radius":((y=t.value)==null?void 0:y.defaultNodeBorderRadius)+"px","--rg-line-color":(v=t.value)==null?void 0:v.defaultLineColor,"--rg-line-width":((x=t.value)==null?void 0:x.defaultLineWidth)+"px"}),onWheel:o},[t.value&&n.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[t.value.showToolBar?(r.openBlock(),r.createBlock(st,{key:0})):r.createCommentVNode("",!0),r.createVNode(gn,null,{node:r.withCtx(w=>[r.renderSlot(s.$slots,"node",r.normalizeProps(r.guardReactiveProps(w)))]),line:r.withCtx(w=>[r.renderSlot(s.$slots,"line",r.normalizeProps(r.guardReactiveProps(w)))]),"canvas-plug-behind":r.withCtx(()=>[r.renderSlot(s.$slots,"canvas"),r.renderSlot(s.$slots,"default")]),"canvas-plug-above":r.withCtx(()=>[r.renderSlot(s.$slots,"canvas-above")]),"node-expand-button":r.withCtx(w=>[r.renderSlot(s.$slots,"node-expand-button",r.normalizeProps(r.guardReactiveProps(w)))]),background:r.withCtx(()=>[r.renderSlot(s.$slots,"background")]),_:3}),r.createVNode(it,null,{node:r.withCtx(w=>[r.renderSlot(s.$slots,"node",r.normalizeProps(r.guardReactiveProps(w)))]),_:3}),r.createElementVNode("div",_n,[r.createElementVNode("div",Nn,[r.renderSlot(s.$slots,"view")])])],64)):r.createCommentVNode("",!0)],46,wn)}}});class kn{constructor(i){_(this,"$evCanvasCtx");_(this,"viewScale",1);_(this,"offset",{x:0,y:0});const e=i.getContext("2d");if(!e)throw new Error("\u65E0\u6CD5\u83B7\u53D6 Canvas 2D \u4E0A\u4E0B\u6587");this.$evCanvasCtx=e}setSize(i,e){const t=this.$evCanvasCtx.canvas;t.width=i*window.devicePixelRatio,t.height=e*window.devicePixelRatio,t.style.width=`${i}px`,t.style.height=`${e}px`,this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.applyCurrentViewTransform()}setScale(i){this.viewScale=i,this.applyCurrentViewTransform()}applyCurrentViewTransform(){this.$evCanvasCtx.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),this.$evCanvasCtx.scale(this.viewScale,this.viewScale)}setViewOffset(i,e){this.offset.x=i/this.viewScale,this.offset.y=e/this.viewScale}beforeDraw(){}evDrawNode4Rect(i,e,t,n,o,s,a=5,d){const h=this.$evCanvasCtx,c=this.offset.x+i,f=this.offset.y+e;let p=Math.max(0,a);t<2*p&&(p=t/2),n<2*p&&(p=n/2),h.beginPath(),h.globalAlpha=s,p===0?h.rect(c,f,t,n):(h.moveTo(c+p,f),h.arcTo(c+t,f,c+t,f+p,p),h.arcTo(c+t,f+n,c+t-p,f+n,p),h.arcTo(c,f+n,c,f+n-p,p),h.arcTo(c,f,c+p,f,p),h.closePath()),h.fillStyle=o,h.fill(),h.globalAlpha=1,h.strokeStyle=d,h.lineWidth=1,h.stroke()}evDrawNode4Circle(i,e,t,n,o,s,a){const d=this.$evCanvasCtx,h=this.offset.x+i+t/2,c=this.offset.y+e+n/2;d.beginPath(),d.globalAlpha=s,d.ellipse(h,c,t/2,n/2,0,0,2*Math.PI),d.fillStyle=o,d.fill(),d.strokeStyle=a,d.lineWidth=1,d.stroke(),d.globalAlpha=1}evDrawLine(i,e,t,n){const o=this.$evCanvasCtx;o.beginPath(),o.globalAlpha=n,this.evDrawSvgPathOnCanvas(o,i),o.strokeStyle=t,o.lineWidth=e*this.viewScale<.5?.5:e,o.stroke(),o.globalAlpha=1}getPointValue(i,e,t){return t?i+parseFloat(e):parseFloat(e)}evDrawSvgPathOnCanvas(i,e){const t=e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!t)return;let n=0,o=0,s=0,a=0,d=0,h=0,c=0,f=0,p="";i.beginPath(),t.forEach(m=>{const u=m.trim(),g=u.charAt(0),v=u.substring(1).trim().split(/[ ,]+/).filter(C=>C!=="").map(parseFloat);let x=0,w=0,k=0,T=0,O=0,b=0,N=0,P=0,R=0,S=0,M=0;switch(g){case"M":n=v[0],o=v[1],s=n,a=o,i.moveTo(n+this.offset.x,o+this.offset.y);for(let C=2;C<v.length;C+=2)n=v[C],o=v[C+1],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"L":for(let C=0;C<v.length;C+=2)n=v[C],o=v[C+1],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"l":for(let C=0;C<v.length;C+=2)n+=v[C],o+=v[C+1],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"H":for(let C=0;C<v.length;C++)n=v[C],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"h":for(let C=0;C<v.length;C++)n+=v[C],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"V":for(let C=0;C<v.length;C++)o=v[C],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"v":for(let C=0;C<v.length;C++)o+=v[C],i.lineTo(n+this.offset.x,o+this.offset.y);break;case"C":for(let C=0;C<v.length;C+=6)k=v[C],T=v[C+1],O=v[C+2],b=v[C+3],x=v[C+4],w=v[C+5],i.bezierCurveTo(k+this.offset.x,T+this.offset.y,O+this.offset.x,b+this.offset.y,x+this.offset.x,w+this.offset.y),n=x,o=w,d=O,h=b;break;case"c":for(let C=0;C<v.length;C+=6)k=n+v[C],T=o+v[C+1],O=n+v[C+2],b=o+v[C+3],x=n+v[C+4],w=o+v[C+5],i.bezierCurveTo(k+this.offset.x,T+this.offset.y,O+this.offset.x,b+this.offset.y,x+this.offset.x,w+this.offset.y),d=O,h=b,n=x,o=w;break;case"S":for(let C=0;C<v.length;C+=4)p.match(/[CS]/i)?(k=2*n-d,T=2*o-h):(k=n,T=o),O=v[C],b=v[C+1],x=v[C+2],w=v[C+3],i.bezierCurveTo(k+this.offset.x,T+this.offset.y,O+this.offset.x,b+this.offset.y,x+this.offset.x,w+this.offset.y),n=x,o=w,d=O,h=b;break;case"s":for(let C=0;C<v.length;C+=4)p.match(/[CS]/i)?(k=2*n-d,T=2*o-h):(k=n,T=o),O=n+v[C],b=o+v[C+1],x=n+v[C+2],w=o+v[C+3],i.bezierCurveTo(k+this.offset.x,T+this.offset.y,O+this.offset.x,b+this.offset.y,x+this.offset.x,w+this.offset.y),d=O,h=b,n=x,o=w;break;case"Q":for(let C=0;C<v.length;C+=4)k=v[C],T=v[C+1],x=v[C+2],w=v[C+3],i.quadraticCurveTo(k+this.offset.x,T+this.offset.y,x+this.offset.x,w+this.offset.y),n=x,o=w,c=k,f=T;break;case"q":for(let C=0;C<v.length;C+=4)k=n+v[C],T=o+v[C+1],x=n+v[C+2],w=o+v[C+3],i.quadraticCurveTo(k+this.offset.x,T+this.offset.y,x+this.offset.x,w+this.offset.y),c=k,f=T,n=x,o=w;break;case"T":for(let C=0;C<v.length;C+=2)p.match(/[QT]/i)?(k=2*n-c,T=2*o-f):(k=n,T=o),x=v[C],w=v[C+1],i.quadraticCurveTo(k+this.offset.x,T+this.offset.y,x+this.offset.x,w+this.offset.y),n=x,o=w,c=k,f=T;break;case"t":for(let C=0;C<v.length;C+=2)p.match(/[QT]/i)?(k=2*n-c,T=2*o-f):(k=n,T=o),x=n+v[C],w=o+v[C+1],i.quadraticCurveTo(k+this.offset.x,T+this.offset.y,x+this.offset.x,w+this.offset.y),c=k,f=T,n=x,o=w;break;case"A":for(let C=0;C<v.length;C+=7)N=v[C],P=v[C+1],R=v[C+2],S=v[C+3],M=v[C+4],x=v[C+5],w=v[C+6],this.drawArc(i,n,o,N,P,R,S,M,x,w),n=x,o=w;break;case"a":for(let C=0;C<v.length;C+=7)N=v[C],P=v[C+1],R=v[C+2],S=v[C+3],M=v[C+4],x=n+v[C+5],w=o+v[C+6],this.drawArc(i,n,o,N,P,R,S,M,x,w),n=x,o=w;break;case"Z":case"z":i.closePath(),n=s,o=a;break;default:console.warn(`\u672A\u652F\u6301\u7684SVG\u547D\u4EE4\u5B57\u7B26: ${g}`)}g.match(/[CSQT]/i)?p=g:p=""})}drawArc(i,e,t,n,o,s,a,d,h,c){if(n=Math.abs(n),o=Math.abs(o),n===0||o===0){i.lineTo(h+this.offset.x,c+this.offset.y);return}const f=s%360*Math.PI/180,p=Math.sin(f),m=Math.cos(f),u=m*(e-h)/2+p*(t-c)/2,g=-p*(e-h)/2+m*(t-c)/2,y=u*u/(n*n)+g*g/(o*o);y>1&&(n*=Math.sqrt(y),o*=Math.sqrt(y));let v=(a===d?-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(v)&&(v=0);const x=v*n*g/o,w=v*-o*u/n,k=m*x-p*w+(e+h)/2,T=p*x+m*w+(t+c)/2,O=(u-x)/n,b=(g-w)/o,N=(-u-x)/n,P=(-g-w)/o;let R=Math.atan2(b,O),S=Math.atan2(b*N-O*P,O*N+b*P);d===0&&S>0?S-=2*Math.PI:d===1&&S<0&&(S+=2*Math.PI);const M=R+S;i.ellipse?i.ellipse(k+this.offset.x,T+this.offset.y,n,o,f,R,M,d===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),i.lineTo(h+this.offset.x,c+this.offset.y))}}const z={getDescendantNodes(l,i=[]){return l.lot&&l.lot.childs&&l.lot.childs.forEach(e=>{i.push(e),z.getDescendantNodes(e,i)}),i},isVisibleNode(l,i=0){return typeof i!="number"&&(i=0),i>18?!0:l.hidden?!1:l.lot&&l.lot.parent?l.lot.parent.expanded===!1?!1:z.isVisibleNode(l.lot.parent,i+1):!0},isAllowShowNode(l,i=0){return z.isVisibleNode(l,i=0)},getNodeWidth(l){return l.el_W||l.width||50},getNodeHeight(l){return l.el_H||l.height||50},getNodeXByLotX(l,i){const e=i.lot.x||0;return l.alignItemsX==="end"?e-z.getNodeWidth(i):l.alignItemsX==="start"?e:e-z.getNodeWidth(i)/2},getNodeYByLotY(l,i){const e=i.lot.y||0;return l.alignItemsY==="end"?e-z.getNodeHeight(i):l.alignItemsY==="start"?e:e-z.getNodeHeight(i)/2},getNodeLotXY(l,i){let e=i.x||0,t=i.y||0;return l.alignItemsX==="end"?e=e+z.getNodeWidth(i):l.alignItemsX==="start"||(e=e+z.getNodeWidth(i)/2),l.alignItemsY==="end"?t=t+z.getNodeHeight(i):l.alignItemsY==="start"||(t=t+z.getNodeHeight(i)/2),{x:e,y:t}},isRectangleOverlap(l,i){const e=l.x,t=i.x,n=l.el_W,o=i.el_W,s=l.y,a=i.y,d=l.el_H,h=i.el_H;return!(t>=e+n||t+o<=e||a>=s+d||a+h<=s)},isXOverlap(l,i,e,t){return!(i>=l+e||i+t<=l)},isYOverlap(l,i,e,t){return!(i>=l+e||i+t<=l)},shapesOverlap(l,i,e=1,t=1){return this.isRectangleOverlap(l,i)},getNoOverlapLimitedPosition(l,i,e,t){const n=l.x,o=l.y,s=i,a=t.x,d=l.el_W,h=t.el_W,c=e,f=t.y,p=l.el_H,m=t.el_H;let u=l.x,g=l.y;const y=this.isXOverlap(n,a,d,h),v=this.isYOverlap(o,f,p,m);return y?c<f?(u=i,g=f-p):c>f&&(u=i,g=f+m):v&&(s<a?(u=a-d,g=e):s>a&&(u=a+h,g=e)),{x:u,y:g}},flatNodeData(l,i,e,t){l.forEach(n=>{e.push(n),i&&t.push({from:i.id,to:n.id});const o=n.children||n.childs;o&&o.length>0&&this.flatNodeData(o,n,e,t)})}},Ce=(l,i)=>l||l===0?l:i,Le=z,De={id:"rg-newNodeTemplate",x:0,y:0,text:""},we=(l,i,e)=>{if(l.id===void 0)throw console.log("node must has id:",l),new Error("node must has option[id]:");l.isShow!==void 0&&(l.hidden=!l.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),l.isHide!==void 0&&(l.hidden=l.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead."));const t=l.width||l.width===0?l.width:i==null?void 0:i.defaultNodeWidth,n=l.height||l.height===0?l.height:i==null?void 0:i.defaultNodeHeight,o={id:l.id,text:l.text!==void 0?l.text:"",type:l.type!==void 0?l.type:"",targetType:l.targetType!==void 0?l.targetType:D.Node,expanded:l.expanded!==void 0?l.expanded:!0,selected:l.selected!==void 0?l.selected:!1,className:l.className!==void 0?l.className:"",nodeShape:Ce(l.nodeShape,i==null?void 0:i.defaultNodeShape),borderWidth:l.borderWidth!==void 0?l.borderWidth:void 0,borderRadius:l.borderRadius!==void 0?l.borderRadius:void 0,borderColor:l.borderColor!==void 0?l.borderColor:void 0,fontColor:l.fontColor!==void 0?l.fontColor:void 0,fontSize:l.fontSize!==void 0?l.fontSize:void 0,color:l.color!==void 0?l.color:void 0,opacity:l.opacity!==void 0?l.opacity:void 0,fixed:l.fixed!==void 0?l.fixed:!1,width:t,height:n,force_weight:l.force_weight,x:l.x!==void 0?l.x:0,y:l.y!==void 0?l.y:0,expandHolderPosition:l.expandHolderPosition!==void 0?l.expandHolderPosition:void 0,disablePointEvent:l.disablePointEvent!==void 0?l.disablePointEvent:void 0,disableDrag:l.disableDrag!==void 0?l.disableDrag:!1,hidden:l.hidden!==void 0?l.hidden:!1,rgCalcedVisibility:!0,rgShouldRender:!0,rgChildrenSize:0,zIndex:l.zIndex||0,el_W:l.el_W||t||0,el_H:l.el_H||n||0,data:l.data!==void 0?l.data:{}};if(e&&e.has&&e.has(o.id)){const s=e.get(o.id);o.el_W||s&&(o.el_W=s[0]),o.el_H||s&&(o.el_H=s[1])}return o.lot={childs:[],parent:void 0,eached:!1,strength:0},o.width&&(o.el_W=o.width),o.height&&(o.el_H=o.height),o},On=["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=l=>{if(!l)return;const i={};return Object.keys(l).forEach(e=>{if(!On.includes(e)){const t=l[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===D.Node||e==="data"&&(!t||Object.keys(t).length===0)||(i[e]=t))}}),i},Pn=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:De,json2Node:we,transNodeToJson:Te,default:{json2Node:we,transNodeToJson:Te}},Symbol.toStringTag,{value:"Module"}));let _e={x:0,y:0};const Ne={x:0,y:0},se={x:0,y:0},at={passive:!1};let Ve,Be;const Ae=l=>ce(l),ee={startDrag(l,i,e,t){t?Ve=(n,o,s)=>{const a=n-se.x,d=o-se.y;t(a,d,Ne,se,s)}:Ve=(n,o)=>{_e.x=Ne.x+(n-se.x),_e.y=Ne.y+(o-se.y)},Be=e,_e=i,Ne.x=_e.x,Ne.y=_e.y;try{const n=Ae(l);se.x=n.clientX,se.y=n.clientY,de(l)?(document.body.addEventListener("touchmove",ee.onNodeMove,at),document.body.addEventListener("touchend",ee.onNodeDragend),document.body.addEventListener("mousemove",ee.onNodeMove),document.body.addEventListener("mouseup",ee.onNodeDragend),l.preventDefault()):(document.body.addEventListener("mousemove",ee.onNodeMove),document.body.addEventListener("mouseup",ee.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(l){const i=Ae(l);Ve(i.clientX,i.clientY,l)},onNodeDragend(l){if(de(l)?(document.body.removeEventListener("touchmove",ee.onNodeMove,at),document.body.removeEventListener("touchend",ee.onNodeDragend),document.body.removeEventListener("mousemove",ee.onNodeMove),document.body.removeEventListener("mouseup",ee.onNodeDragend)):(document.body.removeEventListener("mousemove",ee.onNodeMove),document.body.removeEventListener("mouseup",ee.onNodeDragend)),Be){const i=Ae(l),e=i.clientX,t=i.clientY,n=e-se.x,o=t-se.y;Be(n,o,l)}}},le=ee,he=(l,i)=>{if(l.from===void 0)throw console.log("error,line must has option[from](nodeId):",l),new Error("error,line must has option[from]:");if(l.to===void 0)throw console.log("error,line must has option[to](nodeId):",l),new Error("error,line must has option[to]:");if(typeof l.from!="string")throw console.log("error line from, must be string(nodeId):",l),new TypeError("error line from, must be string:");if(typeof l.to!="string")throw console.log("error line to, must be string(nodeId):",l),new TypeError("error line to, must be string:");return l.hidden===void 0&&l.isShow!==void 0&&(l.hidden=!l.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),l.hidden===void 0&&l.isHide!==void 0&&(l.hidden=l.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),{id:l.id,from:l.from,to:l.to,type:l.type!==void 0?l.type:"",isFakeLine:l.isFakeLine!==void 0?l.isFakeLine:!1,fromType:l.fromType!==void 0?l.fromType:l.isFakeLine?D.CanvasPoint:D.Node,toType:l.toType!==void 0?l.toType:l.isFakeLine?D.CanvasPoint:D.Node,selected:!1,text:l.text!==void 0?l.text:"",textOffsetX:l.textOffsetX!==void 0?l.textOffsetX:void 0,textOffsetY:l.textOffsetY!==void 0?l.textOffsetY:void 0,color:l.color!==void 0?l.color:void 0,opacity:l.opacity!==void 0?l.opacity:void 0,fontSize:l.fontSize!==void 0?l.fontSize:void 0,fontColor:l.fontColor!==void 0?l.fontColor:void 0,lineWidth:l.lineWidth!==void 0?l.lineWidth:void 0,lineShape:l.lineShape||i.defaultLineShape||1,className:l.className!==void 0?l.className:void 0,animation:l.animation!==void 0?l.animation:0,dashType:l.dashType!==void 0?l.dashType:0,disablePointEvent:l.disablePointEvent!==void 0?l.disablePointEvent:!1,showStartArrow:l.showStartArrow!==void 0?l.showStartArrow:!1,showEndArrow:l.showEndArrow!==void 0?l.showEndArrow:!0,useTextOnPath:l.useTextOnPath!==void 0?l.useTextOnPath:void 0,placeText:l.placeText!==void 0?l.placeText:void 0,startMarkerId:l.startMarkerId||"",endMarkerId:l.endMarkerId||"",textAnchor:l.textAnchor!==void 0?l.textAnchor:void 0,junctionOffset:l.junctionOffset,fromJunctionPoint:l.fromJunctionPoint,toJunctionPoint:l.toJunctionPoint,fromJunctionPointOffsetX:l.fromJunctionPointOffsetX||0,fromJunctionPointOffsetY:l.fromJunctionPointOffsetY||0,toJunctionPointOffsetX:l.toJunctionPointOffsetX||0,toJunctionPointOffsetY:l.toJunctionPointOffsetY||0,lineRadius:l.lineRadius,force_elastic:l.force_elastic,polyLineStartDistance:l.polyLineStartDistance,ctrlPointsFor49:l.ctrlPointsFor49,ctrlPointsFor44:l.ctrlPointsFor44,ctrlPoints:l.ctrlPoints,lineDirection:l.lineDirection!==void 0?l.lineDirection:void 0,forDisplayOnly:l.forDisplayOnly||l.from===l.to,hidden:l.hidden!==void 0?l.hidden:!1,cssVars:l.cssVars!==void 0?l.cssVars:void 0,data:l.data!==void 0?l.data:{}}},Tn=["arrow","isReverse","selected","shouldRender","rgCalcedVisibility"],be=l=>{if(!l)return;const i={};return Object.keys(l).forEach(e=>{if(!Tn.includes(e)){const t=l[e];t!==void 0&&(e==="isFakeLine"&&t===!1||e==="fromType"&&t===D.Node||e==="toType"&&t===D.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==="fromJunctionPointOffsetX"&&t===0||e==="fromJunctionPointOffsetY"&&t===0||e==="toJunctionPointOffsetX"&&t===0||e==="toJunctionPointOffsetY"&&t===0||e==="opacity"&&t===1||e==="hidden"&&t===!1||e==="data"&&(!t||Object.keys(t).length===0)||(i[e]=l[e]))}}),i},ze=l=>{if(!!l)return be(l.line)},Sn=Object.freeze(Object.defineProperty({__proto__:null,json2Line:he,transLineToJson:be,transLinkToJson:ze,default:{json2Line:he,transLinkToJson:ze}},Symbol.toStringTag,{value:"Module"}));function Rn(l,i,e,t,n,o,s,a,d){const h=n-l,c=o-i,f=Math.sqrt(h*h+c*c);if(f===0)return{x:l,y:i};const p=d*c/f,m=-(d*h)/f,u=l+p,g=i+m,y=l-e/2,v=l+e/2,x=i-t/2,w=i+t/2;let k=[];if(h!==0){let b=(y-u)/h,N=g+b*c;N>=x&&N<=w&&k.push({x:y,y:N});let P=(v-u)/h,R=g+P*c;R>=x&&R<=w&&k.push({x:v,y:R})}if(c!==0){let b=(x-g)/c,N=u+b*h;N>=y&&N<=v&&k.push({x:N,y:x});let P=(w-g)/c,R=u+P*h;R>=y&&R<=v&&k.push({x:R,y:w})}if(k.length===0&&h===0&&c===0)return{x:u,y:g};let T=null,O=1/0;return k.forEach(b=>{const N=Math.sqrt((b.x-n)**2+(b.y-o)**2);N<O&&(O=N,T=b)}),T}const Mn={getRectPoint(l,i,e,t,n,o,s,a,d=!1,h=1,c=0,f=14,p=!1){const m=l+n/2,u=i+o/2,g=e+s/2,y=t+a/2;if(h>1){const P=Math.min(f,n,o),R=-P/2,S=P/(h-1),M=d&&p||!d&&!p?R*-1-c*S:R+c*S,C=Rn(m,u,n,o,g,y,s,a,M);if(C)return C}const v=m<g?1:-1,x=u<y?1:-1;if(y===u)return{x:m+v*n/2,y:u};const w=Math.abs((g-m)/(y-u)),k=n/o;let T=0,O=0;w<k?(T=v*o/2*w,O=x*o/2):(T=v*n/2,O=x*n/2/w);const b=m+T,N=u+O;return{x:b,y:N}},getRectPointBasic(l,i,e,t,n,o,s,a){const d=l+n/2,h=i+o/2,c=e+s/2,f=t+a/2;let p=f===h?0:(c-d)/(f-h);p===0&&f===h&&c===d?p=1:p===0&&(p=(c-d)/(f-h+(f>h?-1:1)*1e-4));const m=n/o;let u=0,g=0,y="1";return Math.abs(p)<m?(y="2",h<=f?(g=o/2,u=g*p):(g=-o/2,u=g*p)):(y="3",d<=c?(u=n/2,g=p===0&&c===d?0:u/p):(u=-n/2,g=p===0&&c===d?0:u/p)),{x:d+u,y:h+g,_case:y}},getRectJoinPoint(l){const{from_x:i,from_y:e,to_x:t,to_y:n,f_W:o,f_H:s,t_W:a,t_H:d}=l,h=i+o/2,c=e+s/2,f=t+a/2,p=n+d/2,m=f-h,u=p-c,g=m/(o/2),y=u/(s/2);return Math.abs(g)>Math.abs(y)?g>0?{x:i+o,y:c}:{x:i,y:c}:y>0?{x:h,y:e+s}:{x:h,y:e}},getRectHJoinPoint(l){const{from_x:i,from_y:e,to_x:t,f_W:n,f_H:o,t_W:s}=l,a=o/2;return i+n<t?{x:i+n,y:e+a}:{x:i,y:e+a}},getRectLeftJoinPoint(l){const{from_x:i,from_y:e,f_H:t}=l;return{x:i,y:e+t/2}},getRectRightJoinPoint(l){const{from_x:i,from_y:e,f_W:t,f_H:n}=l;return{x:i+t,y:e+n/2}},getRectTopJoinPoint(l){const{from_x:i,from_y:e,f_W:t}=l;return{x:i+t/2,y:e}},getRectBottomJoinPoint(l){const{from_x:i,from_y:e,f_W:t,f_H:n}=l;return{x:i+t/2,y:e+n}},getRectHorizontalLineJoinPoint(l){return this.getRectVJoinPoint(l)},getRectVerticalLineLineJoinPoint(l){return this.getRectHJoinPoint(l)},getRectVJoinPoint(l){const{from_x:i,from_y:e,to_y:t,f_W:n,f_H:o,t_H:s}=l,a=n/2;return e+o<t?{y:e+o,x:i+a}:{y:e,x:i+a}},getBorderPoint(l,i,e,t,n,o,s,a,d){return d===0?this.getCirclePoint(l,i,e,t,n,o,s,a):this.getRectPoint(l,i,e,t,n,o,s,a)},getBorderPoint4MultiLine(l){const{from_x:i,from_y:e,to_x:t,to_y:n,f_W:o,f_H:s,t_W:a,t_H:d,nodeShape:h,isReverse:c=!1,isEndPoint:f,totalLinesBetweenNodes:p=1,currentLineIndex:m=0,lineDistance:u=50}=l;return h===0?this.getCirclePoint4MultiLine(i,e,t,n,o,s,a,d,c,p,m,u,f):this.getRectPoint(i,e,t,n,o,s,a,d,c,p,m,u,f)},getCirclePoint(l,i,e,t,n,o,s,a){const d=e+s/2,h=t+a/2,c=l+n/2,f=i+o/2,p=d-c;if(p===0)return{x:c,y:f-o/2*(h<f?1:-1)};const u=(h-f)/p,g=Math.sqrt(1/(1/(n/2)**2+u**2/(o/2)**2))*(d<c?1:-1),y=u*g;return{x:c-g,y:f-y}},getCirclePoint4MultiLine(l,i,e,t,n,o,s,a,d,h,c,f,p){let m=e+s/2;const u=t+a/2;let g=l+n/2;const y=i+o/2;let v=m-g;v>-1&&v<1&&(m=m-.5,g=g+.5,v=-1);let w=0;if(h>1){const M=Math.min(f,n,o),C=-M/2,E=M/(h-1);w=d&&p||!d&&!p?C*-1-c*E:C+c*E}const k=u-y,T=Math.sqrt(v**2+k**2)*w/v,O=k/v,b=n/2,N=o/2,P=g<m?-1:1,R=(-1*b**2*O*T+b*N*Math.sqrt(Math.abs(N**2+O**2*b**2-T**2))/P)/(N**2+b**2*O**2),S=O*R+T;return{x:g-R,y:y-S}},getCirclePointBasic(l,i,e,t,n,o,s,a,d){const h=l+n/2,c=i+o/2,f=e+s/2,p=t+a/2,m=f-h,u=p-c,g=Math.sqrt(m*m+u*u),y=g-d,v=y*m/g*-1,x=y*u/g*-1;return{x:f+v,y:p+x}},getCirclePointPlus(l,i,e,t,n,o,s,a){const d=l+n/2,h=i+o/2,c=e+s/2,f=t+a/2,p=c-d,m=f-h,u=Math.sqrt(p*p+m*m),g=(u-n/2)*p/u*-1,y=(u-o/2)*m/u*-1;return{x:c+g,y:f+y}},getOvalPoint(l,i,e,t,n,o=180){const s=t*(360/n),a=(180-o+s)*Math.PI/180;return{x:l+e*Math.sin(a),y:i+e*Math.cos(a)*-1}},getRotatedPoint(l,i,e,t,n){const o=n*Math.PI/180,s=Math.cos(o),a=Math.sin(o),d=(l-e)*s-(i-t)*a+e,h=(l-e)*a+(i-t)*s+t;return{x:d,y:h}},getFlippedX(l,i){return i-(l-i)},getFlippedY(l,i){return i-(l-i)},getAngleType(l,i){if(l>=0&&i>=0)return 1;if(l<0&&i>=0)return 2;if(l<0&&i<0)return 3;if(l>=0&&i<0)return 4},getTextAngle(l,i,e,t){let n=Math.atan2(t-i,e-l)*180/Math.PI;return n<0&&(n+=360),n>90&&n<=270&&(n+=180),n>=360&&(n-=360),Math.round(n)}},me=(l,i,e,t)=>{const n=l-e,o=i-t;return Math.sqrt(n**2+o**2)};function rt(l,i,e,t,n=0,o=0){let s=1,a=n,d=o,h=0;for(let c of e){const f=c.width,p=c.height;p>h&&(h=p),t(c,a,d),a+=f+i,s>l?(d+=h+i,s=1,a=0,h=0):s++}}const j=Mn;class En{constructor(i){_(this,"graphInstance");_(this,"initialized",!1);_(this,"isFolderLayout",!1);this.graphInstance=i}analyzeNetwork(i,e,t=!1,n=!1){this.initialized||(this.initialized=!0),i.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 o=this.markNodeParent(e);L("groupNodes:marked-tree-node:",o.networkNodes.length);const s=[],a={direct:1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},d={direct:-1,min_deep:0,max_deep:0,max_length:1,max_strength:1,levels:new Map},h=[e];this.expandLevelNodesWithDirection(s,h,0,t,n,a,d),this.calcStrengthWithChildsValue(s),this.calcStrengthFromValue(e,1),t&&this.calcStrengthFromValue(e,-1);const c=s.filter(u=>u.lot.level===1),f=c.length===0?1:c.map(u=>u.lot.strengthWithChilds).reduce((u,g)=>u+g,0);a.max_strength=f;const p=s.filter(u=>u.lot.level>=0);L("groupNodes:tree-nodes:",p.length,a);const m={tree:{networkNodes:p,analyticResult:a},reverseTree:{networkNodes:[],analyticResult:d}};if(t){const u=s.filter(v=>v.lot.level===-1),g=u.length===0?1:u.map(v=>v.lot.strengthWithChilds).reduce((v,x)=>v+x,0);d.max_strength=g;const y=s.filter(v=>v.lot.level<=0);L("groupNodes:reverse-tree-nodes:",y.length,d),m.reverseTree.networkNodes=y}for(const u of i)this.graphInstance.updateNode(u,{rgChildrenSize:u.lot.childrenSize});return m}markNodeParent(i){let e=[];return this._markNodeParent(e,[i],0),{networkNodes:e}}_markNodeParent(i,e,t){t===0&&e.forEach(o=>{o.lot.parent=void 0});const n=[];for(const o of e){i.includes(o)||i.push(o);for(const s of this.graphInstance.getNodeRelatedNodes(o))i.includes(s)||(i.push(s),s.lot.parent=o,n.push(s))}n.length>0&&this._markNodeParent(i,n,t+1)}expandLevelNodesWithDirection(i,e,t,n,o,s,a){const d=n&&t<0?a:s;L(`bothWay:${n}(deep:${o}) level ${t} size: ${e.length}`,d.direct),e.length>d.max_length&&(d.max_length=e.length),t>d.max_deep&&(d.max_deep=t),t<d.min_deep&&(d.min_deep=t),d.levels.has(t)||d.levels.set(t,{level:t,all_size:e.length,all_strength:0});const h=d.levels.get(t);e.forEach(u=>{u.lot.eached=!0,u.lot.subling=h,u.lot.level=t,i.push(u)});const c=[],f=[];let p=1,m=0;e.forEach(u=>{let g=[],y=[];n?o||t===0?(g=this.graphInstance.getNodeIncomingNodes(u),y=this.graphInstance.getNodeOutgoingNodes(u)):(t<0&&(p=-1),y=this.graphInstance.getNodeRelatedNodes(u)):y=this.graphInstance.getNodeRelatedNodes(u),this._appendNodeChildrenToNextLevelNodes(u,y,f,h,n,1),this._appendNodeChildrenToNextLevelNodes(u,g,c,h,n,-1),u.lot.index_of_level=m,m++}),h.all_strength>d.max_strength&&(d.max_strength=h.all_strength),f.length>0&&this.expandLevelNodesWithDirection(i,f,t+p,n,o,s,a),c.length>0&&this.expandLevelNodesWithDirection(i,c,t-1,n,o,s,a)}_appendNodeChildrenToNextLevelNodes(i,e,t,n,o,s){let a=0,d=0,h=0;if(e.forEach(c=>{c.lot||(c.lot={eached:!1,childs:[]}),c.lot.eached||(d++,c.lot.parent=i,z.isVisibleNode(c)&&(c.lot.eached=!0,c.lot.index_of_parent=h++,t.push(c),a++),i.lot.childs.push(c))}),s===1){const c=a>0?a:1;i.lot.strength=c,n.all_strength+=c,i.lot.strength_of_level=n.all_strength,i.lot.childrenSizeVisible=a,i.lot.childrenSize=d}}calcStrengthWithChildsValue(i){this.isFolderLayout?i.forEach(e=>{e.lot.strengthWithChilds=1,this.conductStrengthToParents(e)}):(i.forEach(e=>{e.lot.childrenSizeVisible>0&&(e.lot.strengthWithChilds=0)}),i.forEach(e=>{e.lot.childrenSizeVisible===0&&(e.lot.strengthWithChilds=1,this.conductStrengthToParents(e))}))}calcStrengthFromValue(i,e=1){this._calcStrengthFromValue([i],0,e===-1?-1:1)}_calcStrengthFromValue(i,e,t=1){const n=[];let o=0;i.forEach(s=>{if(s.lot.level===0||t===(s.lot.level<0?-1:1)){s.lot.childs.forEach(d=>{n.push(d)}),s.lot.parent&&o<s.lot.parent.lot.strengthWithChilds_from&&(o=s.lot.parent.lot.strengthWithChilds_from);const a=this.isFolderLayout?1:0;s.lot.strengthWithChilds_from=o+a,o+=s.lot.strengthWithChilds}}),n.length>0&&this._calcStrengthFromValue(n,e+(t<0?-1:1),t)}conductStrengthToParents(i){if(i.lot.parent){const e=Math.abs(i.lot.level)-1===Math.abs(i.lot.parent.lot.level);(this.isFolderLayout||e)&&(i.lot.parent.lot.strengthWithChilds+=1,this.conductStrengthToParents(i.lot.parent))}}}class In{constructor(i,e,t){_(this,"graphOptions");_(this,"layoutOptions");_(this,"graphInstance");_(this,"networkAnalyzer");_(this,"allNodes",[]);_(this,"isMainLayouer",!0);_(this,"requireLinks",!1);_(this,"allLinks",[]);_(this,"rootNode");this.layoutOptions=i,this.graphOptions=e,this.graphInstance=t,this.networkAnalyzer=new En(t)}setLinks(i){L("setLinks:",i.length),this.allLinks=i}generateCalcNodes(i){const e=[],t=new Map;for(const n of i){const o={rgNode:n,x:n.x,y:n.y,width:n.width||n.el_W||50,height:n.height||n.el_H||50};e.push(o),t.set(n.id,o)}return{calcNodes:e,calcNodeMap:t}}generateLevels(i){const e=[],t=new Map;for(const n of i){if(!n.lot||typeof n.lot.level!="number")continue;const o=n.lot.level;e.includes(o)||(e.push(o),t.set(o,[])),t.get(o).push(n)}return e.sort((n,o)=>n-o),{levels:e,levelNodesMap:t}}adjustNodePositions(i,e,t){if(!i||i.length===0)return[];for(let n=1;n<i.length;n++){const o=i[n],s=i[n-1];switch(e){case"right":o.x<s.x+s.width+t&&(o.x=s.x+s.width+t);break;case"left":o.x+o.width>s.x-t&&(o.x=s.x-o.width-t);break;case"bottom":o.y<s.y+s.height+t&&(o.y=s.y+s.height+t);break;case"top":o.y+o.height>s.y-t&&(o.y=s.y-o.height-t);break}}return i}getReverseAlignItems(i){return Dn[i]}updateNodePosition(i,e,t){this.graphInstance.updateNode(typeof i=="string"?i:i.id,{x:e,y:t})}layoutEnd(){this.graphInstance&&(this.graphInstance.dataProvider.updateShouldRenderGraphData(),this.graphInstance._dataUpdated())}}const Dn={start:"end",end:"start",center:"center"},fe=In;class Vn extends fe{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");_(this,"fastStart",!1);_(this,"skipInitLayout",!1);_(this,"maxLayoutTimes",300);_(this,"byNode",!0);_(this,"byLine",!0);_(this,"lockX",!1);_(this,"lockY",!1);_(this,"force_node_repulsion",1);_(this,"force_line_elastic",1);_(this,"disableLiveChanges",!1);_(this,"force_x_coefficient",1);_(this,"force_y_coefficient",1);_(this,"instanceId","");_(this,"calcNodes",[]);_(this,"_graphEventHandler");_(this,"layoutTimes",0);_(this,"prev10",[]);_(this,"visibleNodes",[]);_(this,"_onFinishCallback");_(this,"_onTickCallback");_(this,"calcNodeMap",new WeakMap);_(this,"forCalcNodes",[]);_(this,"recentGraphVelocity",[]);_(this,"graphVelocityBalancedValue",.1);_(this,"prevLogTime",0);_(this,"animationFrameTimer",0);_(this,"prevNodeLevel1Index",0);_(this,"prevNodeLevel2Index",0);_(this,"stoped",!1);_(this,"maxTractionLength",400);_(this,"zeroForceLength",40);_(this,"maxRepulsionDistance",600);_(this,"nodeCollisionRadius",40);_(this,"maxMoveSpeed",100);_(this,"n2nMaxForce",50);this.layoutOptions=e,this.updateOptions(e),this.requireLinks=!0,this.instanceId=n?n.generateNewUUID(5):"error-id"}updateOptions(e){e.fastStart!==void 0&&(this.fastStart=e.fastStart),e.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=e.maxLayoutTimes),e.byNode!==void 0&&(this.byNode=e.byNode),e.byLine!==void 0&&(this.byLine=e.byLine),e.force_node_repulsion!==void 0&&(this.force_node_repulsion=e.force_node_repulsion),e.force_line_elastic!==void 0&&(this.force_line_elastic=e.force_line_elastic),e.force_x_coefficient!==void 0&&(this.force_x_coefficient=e.force_x_coefficient),e.force_y_coefficient!==void 0&&(this.force_y_coefficient=e.force_y_coefficient),e.disableLiveChanges!==void 0&&(this.disableLiveChanges=e.disableLiveChanges),e.skipInitLayout!==void 0&&(this.skipInitLayout=e.skipInitLayout),e.maxTractionLength!==void 0&&(this.maxTractionLength=e.maxTractionLength),e.zeroForceLength!==void 0&&(this.zeroForceLength=e.zeroForceLength),e.maxRepulsionDistance!==void 0&&(this.maxRepulsionDistance=e.maxRepulsionDistance),e.nodeCollisionRadius!==void 0&&(this.nodeCollisionRadius=e.nodeCollisionRadius)}placeNodes(e,t){if(L("RGForceLayout["+this.instanceId+"].placeNodes"),this.calcNodes=e,this.allNodes.length===0&&(this.allNodes=e),this.rootNode=t,this.fastStart)L("RGForceLayout["+this.instanceId+"] fastStart"),this.calcNodes.forEach(n=>{if(n.fixed===!0)return;let o=n.x,s=n.y,a=!1;(Number.isNaN(o)||o===void 0)&&(o=Math.floor(Math.random()*200)-100,a=!0),(Number.isNaN(s)||s===void 0)&&(s=Math.floor(Math.random()*200)-100,a=!0),o===0&&s===0&&(o=Math.floor(Math.random()*200)-100,s=Math.floor(Math.random()*200)-100,a=!0),a&&this.updateNodePosition(n,o,s)});else if(!this.skipInitLayout){if(L("!!!initNodesPosition....."),t){L("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:o,analyticResult:s}=n;t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a=z.getNodeLotXY({alignItemsX:"center",alignItemsY:"center"},t);t.lot.x=a.x,t.lot.y=a.y,this.placeRelativePosition(t,o,s,1,[]),L("!!!initNodesPosition fixedRootNode:2:",t.x,t.y),o.forEach(d=>{if(d.fixed===!0||!d.rgCalcedVisibility||d===t)return;const h=d.lot.x-z.getNodeWidth(d)/2,c=d.lot.y-z.getNodeHeight(d)/2;this.updateNodePosition(d,h,c)})}}this.allNodes.forEach(n=>{let o=n.x,s=n.y,a=!1;(Number.isNaN(o)||o===void 0)&&(o=0,a=!0),(Number.isNaN(s)||s===void 0)&&(s=0,a=!0),a&&this.updateNodePosition(n,o,s)}),L("["+this.instanceId+"]Start Auto Layout....."),this.start()}getLevelR(e,t){if(e.length===0)return;let n=0;for(let o=0;o<t;o++)n+=e[o]||e[e.length-1];return n}placeRelativePosition(e,t,n,o,s){L("analyticResult:",this.layoutOptions,n,o,s);const a={x:e.lot.x,y:e.lot.y},d=t.filter(h=>h.lot.level===1);this.placeNodesInFanRegion(d,0,360,a,1,n.max_strength,s,1,o,0)}calculateMinimumRadius(e,t=0){if(e.length===0||e.length===1)return 0;const n=e.map(c=>{const f=c.width||c.el_W,p=c.height||c.el_H;return Math.sqrt(f*f+p*p)/2+t/2}),o=[];for(let c=0;c<n.length;c++){const f=(c+1)%n.length;o.push(n[c]+n[f])}let s=Math.max(...o)/2,a=o.reduce((c,f)=>c+f,0);const d=100;let h=a;for(let c=0;c<d;c++){const f=(s+a)/2;let p=0;for(const m of o){const u=m/(2*f);if(u>1){p=10;break}p+=2*Math.asin(u)}p>2*Math.PI?s=f:(a=f,h=f)}return h}placeNodesInFanRegion(e,t,n,o,s,a,d,h,c,f){var y,v;let p=t;const m=n-t,u=200;let g=this.getLevelR(d,s)||f+u*c;s===1&&c===1&&(!this.layoutOptions.levelGaps||this.layoutOptions.levelGaps.length===0)&&(g=this.calculateMinimumRadius(e,10),g=Math.min(Math.max(g,200),500));for(const x of e){const w=((y=x.lot)==null?void 0:y.strengthWithChilds)/a,k=o.x+g,T=o.y,O=w*m,b=p+O/2,N=j.getRotatedPoint(k,T,o.x,o.y,b);x.lot.x=N.x,x.lot.y=N.y,x.lot.childs&&x.lot.childs.length>0&&this.placeNodesInFanRegion(x.lot.childs,p,p+O,o,s+1,(v=x.lot)==null?void 0:v.strengthWithChilds,d,h+1,c,g),p+=O}}graphEventHandle(e,...t){if(e===I.onNodeDragStart){const n=t[0],o=this.calcNodeMap.get(n);o&&(o.dragging=!0)}else if(e===I.onNodeDragging){const n=t[0],o=t[1],s=t[2],a=this.calcNodeMap.get(n);a&&(a.x=o,a.y=s)}else if(e===I.onNodeDragEnd){const n=t[0],o=this.calcNodeMap.get(n);o&&(o.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||(L("node miss lot:",t.text),t.lot={x:t.x,y:t.y,childs:[]}),this.visibleNodes.push(t)}),this.resetCalcNodes(),L("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}})}L("Force Layout["+this.instanceId+"] finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(e){console.error(e)}}resetCalcNodes(){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)}),this.allLinks=this.graphInstance.getLinksBetweenNodes(this.visibleNodes)}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){L("["+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.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),this.layoutTimes<=this.maxLayoutTimes?(Date.now()-this.prevLogTime>3e3&&(L("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()}syncNodePosition(e,t,n){const o=this.allNodes.find(a=>a.id===e),s=this.calcNodeMap.get(o);s&&(s.x=t,s.y=n)}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 o=this.forCalcNodes[n];if(o.dragging)continue;this.addGravityByNode(t,o)}}}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),o=this.calcNodeMap.get(e.toNode);this.addElasticByLine(n,o,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),L("[RGForceLayout]["+this.instanceId+"]stop:",e.layout.autoLayouting,this.layoutTimes),this.layoutTimes=Number.MAX_VALUE,this.layoutFinished()}addElasticByLine(e,t,n=1){const o=e.x,s=e.y,a=t.x,d=t.y;let h=Math.sqrt((s-d)**2+(o-a)**2);if(h<this.zeroForceLength)return;h>this.maxTractionLength&&(h=this.maxTractionLength);const c=(h-this.zeroForceLength)*.02*this.force_line_elastic*n,f=c,p=c,m=(o-a)/h,u=(s-d)/h;this.addFtoNode(e,m*f*-1,u*f*-1),this.addFtoNode(t,m*p,u*p)}addGravityByNode(e,t,n=1){const o=e.x,s=e.y,a=t.x,d=t.y;if(n===1&&(Math.abs(o-a)>this.maxRepulsionDistance||Math.abs(s-d)>this.maxRepulsionDistance))return;const h=Math.sqrt((s-d)**2+(o-a)**2);if(n===1&&h>this.maxRepulsionDistance)return;let c=(this.maxRepulsionDistance-h)*.02*this.force_node_repulsion*n;h<this.nodeCollisionRadius&&(c=c*2);const f=(o-a)/h,p=(s-d)/h;this.addFtoNode(e,f*c,p*c)}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 o=e.force_weight||1;this.lockX||(e.Fx+=t*(1/o)),this.lockY||(e.Fy+=n*(1/o))}applyToNodePosition(e){if(e.fixed)return 0;if(e.dragging){const o=e.rgNode;return this.updateNodePosition(o,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.force_x_coefficient,e.y=e.y+n*this.force_y_coefficient,!this.disableLiveChanges){const o=e.rgNode;this.updateNodePosition(o,e.x,e.y)}e.Fx=0,e.Fy=0}}const ke=Vn;class Bn extends fe{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const o=this.layoutOptions.from;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="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)),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const s=this.layoutOptions.layoutExpansionDirection,a=s==="start"||s==="left"||s==="top"?"start":s==="end"||s==="right"||s==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=a,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(L("RGTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}L("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={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 s=z.getNodeLotXY(n,t);t.lot.x=s.x,t.lot.y=s.y;const a=e;if(L("groupNodes:2:",a.length,a.map(c=>c.text).join(",")),this.layoutOptions.simpleTree===!0){const{tree:c}=this.networkAnalyzer.analyzeNetwork(a,this.rootNode,!1);this.placeNodesPosition(this.rootNode,c.networkNodes,c.analyticResult)}else{const{tree:c,reverseTree:f}=this.networkAnalyzer.analyzeNetwork(a,this.rootNode,!0);this.placeNodesPosition(this.rootNode,c.networkNodes,c.analyticResult),this.placeNodesPosition(this.rootNode,f.networkNodes,f.analyticResult)}const d=this.layoutOptions.rotate||0,h={x:t.x,y:t.y};this.allNodes.forEach(c=>{if(c.fixed!==!0&&!!z.isVisibleNode(c)&&(Number.isNaN(c.lot.x)&&(L("bad lot x:",c.text,c.lot.x),c.lot.x=0),Number.isNaN(c.lot.y)&&(L("bad lot y:",c.text,c.lot.y),c.lot.y=0),c!==t)){if(d){const u=j.getRotatedPoint(c.lot.x,c.lot.y,h.x,h.y,d);c.lot.x=u.x,c.lot.y=u.y}const f=c.lot.level<0?o:n,p=z.getNodeXByLotX(f,c),m=z.getNodeYByLotY(f,c);this.updateNodePosition(c,p,m)}}),L("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeNodesPosition(e,t,n){this.placeRelativePosition(e,t,n)}placeRelativePosition(e,t,n){const o=this.layoutOptions.layoutExpansionDirection,{levels:s,levelNodesMap:a}=this.generateLevels(t),d=n.max_strength;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const h=this.layoutOptions.treeNodeGapH||20,c=this.layoutOptions.treeNodeGapV||20,f=new Map;for(const y of s){const v=a.get(y);f.set(y,Math.max(...v.map(x=>x.el_H)))}let p=0,m=0;for(const y of t){const v=y.el_W;p+=v,m++}const g=p/m+h;t.forEach(y=>{y.fixed!==!0&&y!==e&&(this.layoutOptions.from==="bottom"?y.lot.y=e.lot.y-this.getLevelDistance(y.lot.level,f,c+10):y.lot.y=e.lot.y+this.getLevelDistance(y.lot.level,f,c+10))}),t.forEach(y=>{y.fixed!==!0&&y.lot.level!==0&&(o==="start"?y.lot.x=e.lot.x-g*y.lot.strengthWithChilds_from:o==="end"?y.lot.x=e.lot.x+g*y.lot.strengthWithChilds_from:y.lot.x=e.lot.x+g*(d/-2+y.lot.strengthWithChilds_from+y.lot.strengthWithChilds/2))}),this.applyNodesGap(t,"v"),this.gatherNodes(t,"v",g)}else{const h=this.layoutOptions.treeNodeGapH||20,c=this.layoutOptions.treeNodeGapV||20,f=new Map;for(const y of s){const v=a.get(y);f.set(y,Math.max(...v.map(x=>x.el_W||x.width||50)))}let p=0,m=0;for(const y of t){const v=y.el_H;p+=v,m++}if(m===0)return;const g=p/m+c;t.forEach(y=>{y.fixed!==!0&&y!==e&&(this.layoutOptions.from==="right"?y.lot.x=e.lot.x-this.getLevelDistance(y.lot.level,f,h+50):y.lot.x=e.lot.x+this.getLevelDistance(y.lot.level,f,h+50))}),t.forEach(y=>{y.fixed!==!0&&y.lot.level!==0&&(o==="start"?y.lot.y=e.lot.y-g*y.lot.strengthWithChilds_from:o==="end"?y.lot.y=e.lot.y+g*y.lot.strengthWithChilds_from:y.lot.y=e.lot.y+g*(d/-2+y.lot.strengthWithChilds_from+y.lot.strengthWithChilds/2))}),this.applyNodesGap(t,"h"),this.gatherNodes(t,"h",g)}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let o=0;for(let s=0;s<e;s++){const a=t.get(s);o+=a+this.getLevelGap(s,n,a,e)}return o}else{let o=0;for(let s=0;s>e;s--){const a=t.get(s);o+=a+this.getLevelGap(s,n,a,e)}return-o}}getLevelGap(e,t,n,o){let s=t+(o===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(s=a)}return s}applyNodesGap(e,t){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:a,levelNodesMap:d}=this.generateLevels(e),h=new Map;for(const p of a){const m=d.get(p);h.set(p,Math.max(...m.map(u=>u.el_W)))}const{calcNodes:c,calcNodeMap:f}=this.generateCalcNodes(e);c.forEach(p=>{const m=p.rgNode.lot.level<0?o:n;p.x=z.getNodeXByLotX(m,p.rgNode),p.y=z.getNodeYByLotY(m,p.rgNode),p.width=p.rgNode.el_W,p.height=p.rgNode.el_H,p.buffY=0});for(const p of a){const m=d.get(p)||[];if(t==="h")if(s==="end"){m.sort((g,y)=>g.lot.y-y.lot.y);const u=m.map(g=>f.get(g.id));this.adjustNodePositions(u,"bottom",this.layoutOptions.treeNodeGapV);for(const g of u){const y=g.rgNode.lot.level<0?o:n;g.rgNode.lot.y=z.getNodeLotXY(y,g).y}}else{m.sort((g,y)=>y.lot.y-g.lot.y);const u=m.map(g=>f.get(g.id));this.adjustNodePositions(u,"top",this.layoutOptions.treeNodeGapV);for(const g of u){const y=g.rgNode.lot.level<0?o:n;g.rgNode.lot.y=z.getNodeLotXY(y,g).y}}else if(s==="end"){m.sort((g,y)=>g.lot.x-y.lot.x);const u=m.map(g=>f.get(g.id));this.adjustNodePositions(u,"right",this.layoutOptions.treeNodeGapH);for(const g of u){const y=g.rgNode.lot.level<0?o:n,v=z.getNodeLotXY(y,g);g.rgNode.lot.x=v.x}}else{m.sort((g,y)=>y.lot.x-g.lot.x);const u=m.map(g=>f.get(g.id));this.adjustNodePositions(u,"left",this.layoutOptions.treeNodeGapH);for(const g of u){const y=g.rgNode.lot.level<0?o:n;g.rgNode.lot.x=z.getNodeLotXY(y,g).x}}}if(t==="h"){const p=new Map,m=new Map;for(const w of a){const T=d.get(w).map(O=>f.get(O.id));p.set(w,Math.max(...T.map(O=>O.width))),m.set(w,Math.min(...T.map(O=>O.x)))}const u=this.layoutOptions.treeNodeGapH;let g=a.filter(w=>w>0).sort((w,k)=>w-k),y=a.filter(w=>w<0).sort((w,k)=>k-w),v=1;this.layoutOptions.from==="right"&&([y,g]=[g,y],v=-1);let x=0;for(const w of g){const k=w-v,T=m.get(k),O=p.get(k),b=m.get(w)+x;p.get(w);const N=T+O+u;if(N>b){const P=N-b;x=P;const R=d.get(w);for(const S of R)S.lot.x+=x;m.set(w,b+P)}else m.set(w,b)}x=0;for(const w of y){const k=w+v,T=m.get(k);p.get(k);const O=m.get(w)+x,b=p.get(w),N=T-u;if(O+b>N){const P=N-(O+b);x=P;const R=d.get(w);for(const S of R)S.lot.x+=x;m.set(w,O+P)}else m.set(w,O)}}else{const p=new Map,m=new Map;for(const w of a){const T=d.get(w).map(O=>f.get(O.id));p.set(w,Math.max(...T.map(O=>O.height))),m.set(w,Math.min(...T.map(O=>O.y)))}const u=this.layoutOptions.treeNodeGapV;let g=a.filter(w=>w>0).sort((w,k)=>w-k),y=a.filter(w=>w<0).sort((w,k)=>k-w),v=1;this.layoutOptions.from==="bottom"&&([y,g]=[g,y],v=-1);let x=0;for(const w of g){const k=w-v,T=m.get(k),O=p.get(k),b=m.get(w)+x;p.get(w);const N=T+O+u;if(N>b){const P=N-b;x=P;const R=d.get(w);for(const S of R)S.lot.y+=x;m.set(w,b+P)}else m.set(w,b)}x=0;for(const w of y){const k=w+v,T=m.get(k);p.get(k);const O=m.get(w)+x,b=p.get(w),N=T-u;if(O+b>N){const P=N-(O+b);x=P;const R=d.get(w);for(const S of R)S.lot.y+=x;m.set(w,O+P)}else m.set(w,O)}}}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const{calcNodes:o,calcNodeMap:s}=this.generateCalcNodes(e);o.forEach(d=>{d.movedNodeSizeBefore=1,d.movedNodeSizeAfter=1});const{levelNodesMap:a}=this.generateLevels(e);e.forEach(d=>{if(d.fixed!==!0&&d.lot.level!==0){const h=a.get(d.lot.level)||[];if(d.lot.strengthWithChilds===1&&d.lot.childrenSizeVisible<=1){const c=this.getBloomingNearByParent(d,d.lot.parent,h,t);if(c){const f=s.get(d.id);t==="h"?d.lot.y-c.lot.y>0?(d.lot.y=c.lot.y+n*f.movedNodeSizeAfter,f.movedNodeSizeAfter++):(d.lot.y=c.lot.y-n*f.movedNodeSizeBefore,f.movedNodeSizeBefore++):d.lot.x-c.lot.x>0?(d.lot.x=c.lot.x+n*f.movedNodeSizeAfter,f.movedNodeSizeAfter++):(d.lot.x=c.lot.x-n*f.movedNodeSizeBefore,f.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(e,t,n,o){let s=9999,a;for(const d of n)if(d.lot.childrenSizeVisible>1&&d.lot.parent===t){const h=o==="h"?d.lot.y-t.lot.y:d.lot.x-t.lot.x;Math.abs(h)<s&&(s=Math.abs(h),a=d)}if(a&&a!==e)return a}}const lt=Bn;class An extends ke{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");this.layoutOptions=e,this.layoutOptions.distanceCoefficient||(this.layoutOptions.distanceCoefficient=1),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps option in layoutOptions")}placeNodes(e,t){if(L("RGCenterLayout:placeNodes"),!t){L("root is null:",t);return}L("layout by root:",t),this.allNodes=e,this.calcNodes=e,this.rootNode=t;const{tree:n}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode),{networkNodes:o,analyticResult:s}=n;if(this.layoutOptions.genLotInfoOnly){L("only gen lot info, return");return}t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const a={alignItemsX:this.layoutOptions.alignItemsX||"center",alignItemsY:this.layoutOptions.alignItemsY||"center"},d=z.getNodeLotXY(a,t);t.lot.x=d.x,t.lot.y=d.y;const h=this.layoutOptions.rotate||0;L("root position:",t.lot.x,t.lot.y);const c=this.layoutOptions.distanceCoefficient||1,f=this.getLevelDistanceArr();this.placeRelativePosition(this.rootNode,o,s,c,f);const p={x:t.x,y:t.y};o.forEach(m=>{if(m.fixed!==!0&&!!m.rgCalcedVisibility&&m!==t){if(h){const v=j.getRotatedPoint(m.lot.x,m.lot.y,p.x,p.y,h);m.lot.x=v.x,m.lot.y=v.y}const u=a,g=z.getNodeXByLotX(u,m),y=z.getNodeYByLotY(u,m);this.updateNodePosition(m,g,y)}}),this.layoutEnd()}getLevelDistanceArr(){let e=[];if(this.layoutOptions.levelGaps){if(Array.isArray(this.layoutOptions.levelGaps))e=this.layoutOptions.levelGaps;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}}const dt=An;class zn extends ke{constructor(i,e,t){super(i,e,t)}placeNodes(i,e){if(e)L("layout by root:",e);else{L("root is null:",e);return}this.allNodes=i,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=this.layoutOptions.rotate||0,o=z.getNodeLotXY(t,e);e.lot.x=o.x,e.lot.y=o.y;const s=this.allNodes.filter(h=>h.rgCalcedVisibility),a=s.length;let d=a*90/Math.PI/2;d<200&&(d=200),d>800&&(d=800),s.forEach((h,c)=>{const f=j.getOvalPoint(o.x,o.y,d,c,a);h.lot.x=f.x,h.lot.y=f.y}),s.forEach(h=>{if(h.fixed===!0||!h.rgCalcedVisibility)return;if(n){const m=j.getRotatedPoint(h.lot.x,h.lot.y,e.lot.x,e.lot.y,n);h.lot.x=m.x,h.lot.y=m.y}const c=t,f=z.getNodeXByLotX(c,h),p=z.getNodeYByLotY(c,h);this.updateNodePosition(h,f,p)}),this.layoutEnd()}}const ct=zn;class Xn extends fe{constructor(e,t,n){super(e,t,n);_(this,"graphOptions");_(this,"layoutOptions");_(this,"allNodes",[]);this.layoutOptions=e,this.graphOptions=t}placeNodes(e,t){if(t)L("layout by root:",t);else{L("root is null:",t);return}L("allNodes:",e.length),this.networkAnalyzer.analyzeNetwork(e,t,!1,!1),L("[Fixed layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize),this.layoutEnd()}}const ht=Xn;class Gn extends fe{constructor(e,t,n){super(e,t,n);_(this,"graphInstance");_(this,"layoutOptions");_(this,"levelGaps",[]);this.layoutOptions=e,L("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 o=this.layoutOptions.from;o==="top"||o==="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)),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.requireLinks=!0,this.graphInstance=n}placeNodes(e,t){if(L("RGSmartTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,L("allNodes:",e.length);const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY},{tree:s,reverseTree:a}=this.networkAnalyzer.analyzeNetwork(e,this.rootNode,!0,!0);t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const d=z.getNodeLotXY(n,t);t.lot.x=d.x,t.lot.y=d.y,this.placeRelativePosition(t,[...s.networkNodes].concat(a.networkNodes),Math.max(s.analyticResult.max_strength,a.analyticResult.max_strength)),L("allNodes:",e.length);const h={left:0,top:90,right:180,bottom:270}[this.layoutOptions.from],c={x:t.x,y:t.y};this.allNodes.forEach(m=>{if(m.fixed===!0||!m.rgCalcedVisibility)return;if(Number.isNaN(m.lot.x)&&(L("bad lot x:",m.text,m.lot.x),m.lot.x=0),Number.isNaN(m.lot.y)&&(L("bad lot y:",m.text,m.lot.y),m.lot.y=0),h){const v=j.getRotatedPoint(m.lot.x,m.lot.y,c.x,c.y,h);m.lot.x=v.x,m.lot.y=v.y}const u=m.lot.level<0?o:n,g=z.getNodeXByLotX(u,m),y=z.getNodeYByLotY(u,m);this.updateNodePosition(m,g,y)}),L("create rootNode coordinates:1",t.x,t.y);const f=new ke({layoutName:"force",maxLayoutTimes:30,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0,disableLiveChanges:!0},this.graphOptions,this.graphInstance);f.isMainLayouer=!1,f.requireLinks=!0,this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?f.lockY=!0:f.lockX=!0;const p=t.fixed;t.fixed=!0,f.skipInitLayout=!0,f.resetCalcNodes(),setTimeout(()=>{t.fixed=p},800),f.onFinish(()=>{t.fixed=p,this.graphInstance&&(this.graphInstance.enableNodeXYAnimation(),this.graphInstance._dataUpdated()),this.applyNodesGap(this.allNodes),this.graphInstance&&(this.graphInstance._dataUpdated(),this.allNodes.forEach(m=>{this.graphInstance.updateNode(m,{x:m.x,y:m.y})}),setTimeout(()=>{this.graphInstance.disableNodeXYAnimation(),this.graphInstance._dataUpdated()},300))}),f.placeNodes(this.allNodes,t),this.layoutEnd()}placeRelativePosition(e,t,n){const o=this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?"v":"h";let s=this.layoutOptions.treeNodeGapH||300,a=this.layoutOptions.treeNodeGapV||10;o==="v"&&([s,a]=[a,s]);const{levels:d,levelNodesMap:h}=this.generateLevels(t),c=new Map;for(const g of d){const y=h.get(g);c.set(g,Math.max(...y.map(v=>v.el_W)))}let f=0,p=0;for(const g of t){const y=g.el_H;f+=y,p++}if(p===0)return;const u=f/p+a;t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.x=e.lot.x+this.getLevelDistance(g.lot.level,c,s))}),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:o}=this.generateLevels(e),s=new Map;for(const h of n){const c=o.get(h);s.set(h,Math.max(...c.map(f=>f.el_W)))}const{calcNodes:a,calcNodeMap:d}=this.generateCalcNodes(e);a.forEach(h=>{h.x=h.rgNode.x,h.y=h.rgNode.y,h.width=h.rgNode.el_W,h.height=h.rgNode.el_H,h.buffY=0});for(const h of n){const c=o.get(h)||[];if(t==="h"){const f=c.map(u=>d.get(u.id)),p=f.filter(u=>u.y<this.rootNode.y).sort((u,g)=>g.y-u.y),m=f.filter(u=>u.y>=this.rootNode.y).sort((u,g)=>u.y-g.y);this.adjustNodePositions(p,"top",5),this.adjustNodePositions(m,"bottom",5);for(const u of f)u.rgNode.y=u.y}else{const f=c.map(u=>d.get(u.id)),p=f.filter(u=>u.x<this.rootNode.x).sort((u,g)=>g.x-u.x),m=f.filter(u=>u.x>=this.rootNode.x).sort((u,g)=>u.x-g.x);this.adjustNodePositions(p,"left",5),this.adjustNodePositions(m,"right",5);for(const u of f)u.rgNode.x=u.x}}}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let o=0;for(let s=1;s<=e;s++){const a=t.get(s);o+=a+this.getLevelGap(s,n,a)}return o}else{let o=0;for(let s=-1;s>=e;s--){const a=t.get(s);o+=a+this.getLevelGap(s,n,a)}return-o}}getLevelGap(e,t,n){var s;let o=t+(e===-1?n/2:0);if(((s=this.layoutOptions.levelGaps)==null?void 0:s.length)>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(o=a)}return o}}const Fn=Gn;class Hn extends fe{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("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.bottomJunctionPointOffsetX===void 0&&(this.layoutOptions.bottomJunctionPointOffsetX=-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}placeNodes(e,t){if(L("RGFolderLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e;const n={alignItemsX:this.layoutOptions.alignItemsX,alignItemsY:this.layoutOptions.alignItemsY},o={alignItemsX:this.layoutOptions.alignParentItemsX,alignItemsY:this.layoutOptions.alignParentItemsY};t.fixed||this.layoutOptions.fixedRootNode||this.updateNodePosition(t,0,0);const s=z.getNodeLotXY(n,t);t.lot.x=s.x,t.lot.y=s.y,L("allNodes:",e.length),this.networkAnalyzer.isFolderLayout=!0;const{tree:a}=this.networkAnalyzer.analyzeNetwork(e,t,!1,!1);this.placeRelativePosition(t,a.networkNodes,a.analyticResult),L("networkNodes:",a.networkNodes.length),this.allNodes.forEach(d=>{if(d.fixed!==!0&&(Number.isNaN(d.lot.x)&&(L("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(L("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==t)){const h=d.lot.level<0?o:n,c=z.getNodeXByLotX(h,d),f=z.getNodeYByLotY(h,d);this.updateNodePosition(d,c,f)}}),L("create rootNode coordinates:1",t.x,t.y),this.layoutEnd()}placeRelativePosition(e,t,n){const o=this.layoutOptions.treeNodeGapH||20,s=this.layoutOptions.treeNodeGapV||20,a=new Map;let d=0,h=0;for(const p of t){const m=p.lot.level,u=p.width||p.el_W||50,g=p.height||p.el_H||50;d+=g,h++;const y=a.get(m);y===void 0?a.set(m,u):u>y&&a.set(m,y)}if(h===0)return;const f=d/h+s;t.forEach(p=>{p.fixed!==!0&&p!==e&&(this.layoutOptions.from==="right"?p.lot.x=e.lot.x-this.getLevelDistance(p.lot.level,a,o+50):p.lot.x=e.lot.x+this.getLevelDistance(p.lot.level,a,o+50))}),t.forEach(p=>{p.fixed!==!0&&p!==e&&p.lot.level!==0&&(p.lot.y=e.lot.y+f*p.lot.strengthWithChilds_from)}),this.gatherNodes(t,"h",f)}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const o={};e.forEach(s=>{if(s.lot.level!==0)return;const a=s.lot.level+"";o[a]||(o[a]=[]),o[a].push(s),s.lot.movedNodeSizeBefore=1,s.lot.movedNodeSizeAfter=1}),e.forEach(s=>{if(s.fixed!==!0&&s.lot.level!==0){const a=s.lot.level+"",d=o[a];if(s.lot.strengthWithChilds===1&&s.lot.childrenSizeVisible<=1){const h=this.getBloomingNearByParent(s,s.lot.parent,d,t);h&&(t==="h"?s.lot.y-h.lot.y>0?(s.lot.y=h.lot.y+n*h.lot.movedNodeSizeAfter,h.lot.movedNodeSizeAfter++):(s.lot.y=h.lot.y-n*h.lot.movedNodeSizeBefore,h.lot.movedNodeSizeBefore++):s.lot.x-h.lot.x>0?(s.lot.x=h.lot.x+n*h.lot.movedNodeSizeAfter,h.lot.movedNodeSizeAfter++):(s.lot.x=h.lot.x-n*h.lot.movedNodeSizeBefore,h.lot.movedNodeSizeBefore++))}}})}getBloomingNearByParent(e,t,n,o){let s=9999,a;for(const d of n)if(d.lot.childrenSizeVisible>1&&d.lot.parent===t){const h=o==="h"?d.lot.y-t.lot.y:d.lot.x-t.lot.x;Math.abs(h)<s&&(s=Math.abs(h),a=d)}if(a&&a!==e)return a}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let o=0;for(let s=0;s<e;s++)o+=t.get(s)+this.getLevelGap(s,n);return o}else{let o=e<-1?0:-t.get(e)/2;for(let s=e;s<0;s++)o+=t.get(s)+this.getLevelGap(s,n)+50;return-o}}getLevelGap(e,t){var o;let n=t;if(((o=this.layoutOptions.levelGaps)==null?void 0:o.length)>0){const s=this.layoutOptions.levelGaps[Math.abs(e)];s&&(n=s)}return n}}const ft=Hn,ae=l=>!l||l.length===0?"":l.map(i=>{switch(i.type){case"M":return`${i.type} ${i.x} ${i.y}`;case"l":return`${i.type} ${i.dx} ${i.dy}`;case"L":return`${i.type} ${i.x} ${i.y}`;case"h":return`${i.type} ${i.dx}`;case"v":return`${i.type} ${i.dy}`;case"c":return`${i.type} ${i.dx1} ${i.dy1} ${i.dx2} ${i.dy2} ${i.dx} ${i.dy}`;case"s":return`${i.type} ${i.dx2} ${i.dy2} ${i.dx} ${i.dy}`;case"q":return`${i.type} ${i.dx1} ${i.dy1} ${i.dx} ${i.dy}`;case"Q":return`${i.type} ${i.x1} ${i.y1} ${i.x} ${i.y}`;case"t":return`${i.type} ${i.dx} ${i.dy}`;case"a":return`${i.type} ${i.rx} ${i.ry} ${i.xAxisRotation} ${i.largeArcFlag} ${i.sweepFlag} ${i.dx} ${i.dy}`;case"Z":return i.type;default:return console.warn("\u672A\u77E5\u7684\u8DEF\u5F84\u547D\u4EE4\u7C7B\u578B:",i),""}}).join(" ").trim(),pt=l=>{const i=l.match(/[a-zA-Z][^a-zA-Z]*/g);let e=0,t=0,n=0,o=0,s=0,a=0,d=0,h=0;const c={x:0,y:0},f={x:0,y:0},p=[];for(const m of i){const u=m.trim().split(/[ ,]+/),g=u[0].toUpperCase(),y=u[0]===u[0].toLowerCase();switch(g){case"M":e=U(n,u[1],y),t=U(o,u[2],y),n=e,o=t;break;case"L":e=U(n,u[1],y),t=U(o,u[2],y),p.push({x:e,y:t});break;case"C":s=U(n,u[1],y),a=U(o,u[2],y),d=U(n,u[3],y),h=U(o,u[4],y),e=U(n,u[5],y),t=U(o,u[6],y),n=e,o=t;break;case"Q":s=U(n,u[1],y),a=U(o,u[2],y),e=U(n,u[3],y),t=U(o,u[4],y),n=e,o=t;break;case"V":t=U(o,u[1],y),o=t;break;case"H":e=U(n,u[1],y),n=e;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}m===i[0]&&(c.x=e,c.y=t),m===i[i.length-1]&&(f.x=e,f.y=t)}return{startPoint:c,ctrl1:{x:s,y:a},ctrl2:{x:d,y:h},endPoint:f,lines:p}},U=(l,i,e)=>e?l+parseFloat(i):parseFloat(i),$n=(l,i,e,t,n,o,s)=>{const a=JSON.parse(JSON.stringify(l));let d=!1;if(e<0||e>=l.length-1)return{newPoints:a,pointsChanged:d};a[e-1];const h=a[e],c=a[e+1];i[e-1];const f=i[e];i[e+1];let p=o,m=s;if(t.direction==="v"){const u=i[e-2],g=i[e+2],y=f.x+p;let v=3e3;if(u){const x=Math.abs(u.x-y);x<10&&x<v&&(v=x,p=u.x-f.x)}if(g){const x=Math.abs(g.x-y);x<10&&x<v&&(v=x,p=g.x-f.x)}}else{const u=i[e-2],g=i[e+2],y=f.y+m;let v=3e3;if(u){const x=Math.abs(u.y-y);x<10&&x<v&&(v=x,m=u.y-f.y)}if(g){const x=Math.abs(g.y-y);x<10&&x<v&&(v=x,m=g.y-f.y)}}if(t.direction==="v")if(e===0){const u=h.y<c.y?1:-1,g={x:h.x,y:h.y},y={x:h.x,y:h.y+20*u};h.x=y.x+p,h.y=y.y,a.splice(e,0,g,y),n.indexOffset+=2,d=!0}else if(e===l.length-2){const u=h.y<c.y?1:-1,g={x:f.x+p,y:c.y-20*u},y={x:c.x,y:c.y-20*u};a.splice(e+1,0,g,y),d=!0}else h.x=f.x+p,c.x=f.x+p;else if(e===0){const u=h.x<c.x?1:-1,g={x:h.x,y:h.y},y={x:h.x+20*u,y:h.y};h.x=y.x,h.y=f.y+m,a.splice(e,0,g,y),n.indexOffset+=2,d=!0}else if(e===l.length-2){const u=h.x<c.x?1:-1,g={x:c.x-20*u,y:f.y+m},y={x:c.x-20*u,y:c.y};a.splice(e+1,0,g,y),d=!0}else h.y=f.y+m,c.y=f.y+m;return{newPoints:a,pointsChanged:d}},Yn=(l,i={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:o}=l;i.rotate=j.getTextAngle(e,t,n,o),i.x=e+(n-e)/2,i.y=t+(o-t)/2,Number.isNaN(i.rotate)&&(i.rotate=0);const s=n-e,a=o-t,d=[{type:"M",x:e,y:t},{type:"l",dx:s,dy:a}],h=ae(d);return{pathCommands:d,pathData:h,textPosition:i,points:[]}},Wn=(l,i={x:0,y:0,rotate:0},e={})=>{const{line:t,fx:n,fy:o,fcx:s,fcy:a,f_W:d,f_H:h,tx:c,ty:f,tcx:p,tcy:m,t_W:u,t_H:g}=l,y=c-n,v=f-o,x=n-s,w=o-a,k=c-p,T=f-m,O=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0;let b=Math.min(O,Math.abs(y))*(n<c?1:-1),N=Math.min(O,Math.abs(v))*(o<f?1:-1);const P=t.fromJunctionPoint||e.defaultJunctionPoint||W.border,R=t.toJunctionPoint||e.defaultJunctionPoint||W.border,S=t.lineDirection||(P===W.tb||P===W.top||P===W.bottom?"v":"h")||(Math.abs(x)>=d/2?"h":"v"),M=t.lineDirection||(R===W.tb||R===W.top||R===W.bottom?"v":"h")||(Math.abs(k)>=u/2?"h":"v"),C=[];let E=0,V=0;if(S==="v"){const A=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(f-o)/2),15),G=w>0?A:-A;if(t.placeText==="start"?(E=n,V=o+(w>0?20:-5)):t.placeText==="center"||t.placeText==="middle"?(E=n+(c-n)/2,V=o+G):(E=c,V=f-(w>0?20:-5)),C.push({type:"M",x:Math.round(n),y:Math.round(o)},{type:"v",dy:Math.round(G-N)},{type:"c",dx1:0,dy1:Math.round(N),dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)}),M==="v")C.push({type:"h",dx:Math.round(c-n-b*2)},{type:"c",dx1:Math.round(b),dy1:0,dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)},{type:"v",dy:Math.round(f-o-G-N)});else{const $=Math.min(30,Math.abs(c-n)/2),J=k>0?-$:$;C.push({type:"h",dx:Math.round(c-n+J-b)},{type:"c",dx1:Math.round(b),dy1:0,dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)},{type:"v",dy:Math.round(f-o-G-N)},{type:"h",dx:Math.round(J-b)})}}else{const A=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(c-n)/2),15),G=x>0?A:-A;if(t.placeText==="start"?(E=n+(x>0?10:-50),V=o):t.placeText==="center"||t.placeText==="middle"?(E=n+G,V=o+(f-o)/2):(E=c-(x>0?10:-50),V=f),b=Math.min(O,Math.abs(y))*(n>s?1:-1),N=Math.min(O,Math.abs(v))*(o<f?1:-1),C.push({type:"M",x:Math.round(n),y:Math.round(o)},{type:"h",dx:Math.round(G-b)},{type:"c",dx1:Math.round(b),dy1:0,dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)}),M==="v"){b=Math.min(O,Math.abs(y))*(f<m?1:-1),N=Math.min(O,Math.abs(v))*(f<m?1:-1);const $=Math.min(30,Math.abs(f-o)/2),J=T>0?-$:$;C.push({type:"v",dy:Math.round(f-o+J-N)},{type:"h",dx:Math.round(c-n-G-b)},{type:"c",dx1:0,dy1:Math.round(N),dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)},{type:"v",dy:Math.round(J-N)})}else b=Math.min(O,Math.abs(y))*(n+G<c?1:-1),N=Math.min(O,Math.abs(v))*(f>o?1:-1),C.push({type:"v",dy:Math.round(f-o-N*2)},{type:"c",dx1:0,dy1:Math.round(N),dx2:Math.round(b),dy2:Math.round(N),dx:Math.round(b),dy:Math.round(N)},{type:"h",dx:Math.round(c-n-G-b)})}i.x=E,i.y=V;const X=ae(C);return{pathCommands:C,pathData:X,textPosition:i,points:[]}},Se={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},Un=({source:l,sourcePosition:i="bottom",target:e})=>i==="left"||i==="right"?l.x<e.x?{x:1,y:0}:{x:-1,y:0}:l.y<e.y?{x:0,y:1}:{x:0,y:-1},ut=(l,i)=>Math.sqrt(Math.pow(i.x-l.x,2)+Math.pow(i.y-l.y,2));function Xe({source:l,sourcePosition:i="bottom",target:e,targetPosition:t="top",center:n,sourceOffset:o,targetOffset:s}){const a=Se[i],d=Se[t],h={x:l.x+a.x*o,y:l.y+a.y*o},c={x:e.x+d.x*s,y:e.y+d.y*s},f=Un({source:h,sourcePosition:i,target:c}),p=f.x!==0?"x":"y",m=f[p];let u=[],g,y;const v={x:0,y:0},x={x:0,y:0};let w=0;if(a[p]*d[p]===-1){g=n.x,y=n.y;const T=[{x:g,y:h.y},{x:g,y:c.y}],O=[{x:h.x,y},{x:c.x,y}];a[p]===m?(w=1.1,u=p==="x"?T:O):(w=1.2,u=p==="x"?O:T)}else{const T=[{x:h.x,y:c.y}],O=[{x:c.x,y:h.y}];if(p==="x"?u=a.x===m?O:T:u=a.y===m?T:O,i===t){w=2.1;const S=Math.abs(l[p]-e[p]),M=a[p]===m?o:s;if(S<=M){const C=Math.min(M-1,M-S);a[p]===m?v[p]=(h[p]>l[p]?-1:1)*C:x[p]=(c[p]>e[p]?-1:1)*C}}if(i!==t){w=2.2;const S=p==="x"?"y":"x",M=a[p]===d[S],C=h[S]>c[S],E=h[S]<c[S];(a[p]===1&&(!M&&C||M&&E)||a[p]!==1&&(!M&&E||M&&C))&&(u=p==="x"?T:O)}const b={x:h.x+v.x,y:h.y+v.y},N={x:c.x+x.x,y:c.y+x.y},P=Math.max(Math.abs(b.x-u[0].x),Math.abs(N.x-u[0].x)),R=Math.max(Math.abs(b.y-u[0].y),Math.abs(N.y-u[0].y));P>=R?(g=(b.x+N.x)/2,y=u[0].y):(g=u[0].x,y=(b.y+N.y)/2)}return[[l,{x:h.x+v.x,y:h.y+v.y},...u,{x:c.x+x.x,y:c.y+x.y},e],g,y,0,0,w]}const Re=l=>{const i=[];for(let e=0;e<l.length;e++){const t=l[e];if(t.x=Math.round(t.x),t.y=Math.round(t.y),e===0||e===l.length-1)i.push(t);else{const n=i[i.length-1];t.x===n.x&&t.y===n.y||i.push(t)}}for(let e=2;e<i.length;e++){const t=i[e-2],n=i[e-1],o=i[e],s=t.x===n.x?"v":"h",a=n.x===o.x?"v":"h";s===a&&(n.merged=!0)}return i.filter(e=>e.merged!==!0)};function Jn(l,i,e,t){const n=Math.min(ut(l,i)/2,ut(i,e)/2,t),{x:o,y:s}=i;if(l.x===o&&o===e.x||l.y===s&&s===e.y)return[{type:"L",x:o,y:s}];if(l.y===s){const h=l.x<e.x?-1:1,c=l.y<e.y?1:-1;return[{type:"L",x:o+n*h,y:s},{type:"Q",x1:o,y1:s,x:o,y:s+n*c}]}const a=l.x<e.x?1:-1,d=l.y<e.y?-1:1;return[{type:"L",x:o,y:s+n*d},{type:"Q",x1:o,y1:s,x:o+n*a,y:s}]}const gt=(l,i)=>{const e=[];return l.forEach((t,n)=>{if(n===0)e.push({type:"M",x:Math.round(t.x),y:Math.round(t.y)});else if(n===l.length-1){const o=l[n-1];let s=o.x===t.x?0:o.x<t.x?-1:1,a=o.y===t.y?0:o.y<t.y?-1:1;l.length===2&&(s=0,a=0),e.push({type:"l",dx:Math.round(t.x-o.x+i*s),dy:Math.round(t.y-o.y+i*a)})}else{const o=Jn(l[n-1],t,l[n+1],i);e.push(...o)}}),e};var re=(l=>(l.border="border",l.ltrb="ltrb",l.tb="tb",l.lr="lr",l.left="left",l.right="right",l.top="top",l.bottom="bottom",l))(re||{});const Me=(l,i,e,t,n,o,s,a)=>l==="left"?"left":l==="right"?"right":l==="top"?"top":l==="bottom"?"bottom":l==="horizontalLine"?t?o>a?"bottom":"top":o<a?"bottom":"top":l==="verticalLine"?t?n>s?"right":"left":n<s?"right":"left":i===1?"right":i===-1?"left":e===1?"bottom":e===-1?"top":"left",mt=l=>l==="left"?"right":l==="right"?"left":l==="top"?"bottom":l==="bottom"?"top":"left",yt=l=>{if(l.length<2)throw new Error("At least two points are required to form a polyline.");let i=0;const e=[];for(let o=1;o<l.length;o++){const s=l[o].x-l[o-1].x,a=l[o].y-l[o-1].y,d=Math.sqrt(s*s+a*a);e.push(d),i+=d}const t=i/2;let n=0;for(let o=0;o<e.length;o++)if(n+=e[o],n>=t){const s=l[o],a=l[o+1],d=e[o],c=(t-(n-d))/d,f=s.x+(a.x-s.x)*c,p=s.y+(a.y-s.y)*c;return{x:f,y:p}}return{x:0,y:0}},jn=(l,i={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:o,lineDirection:s,lineShape:a,fx:d,fy:h,fcx:c,fcy:f,f_W:p,f_H:m,tx:u,ty:g,tcx:y,tcy:v,t_W:x,t_H:w}=l,k=d-c,T=h-f;let O=k>1?1:k<-1?-1:0,b=T>1?1:T<-1?-1:0;Math.abs(O)===1&&Math.abs(b)===1&&(Math.abs(k)>Math.abs(T)?b=0:O=0),O===0&&b===0&&(O=1);const N=u-y,P=g-v;let R=N>1?1:N<-1?-1:0,S=P>1?1:P<-1?-1:0;Math.abs(R)===1&&Math.abs(S)===1&&(Math.abs(N)>Math.abs(P)?S=0:R=0),R===0&&S===0&&(O=-1);const M=Me(n,O,b,!1,d,h,u,g),C=Me(o,R,S,!0,d,h,u,g),E=M,V=C,X=d+(u-d)/2,A=h+(g-h)/2;let G={x:0,y:0},$=20,J=20;t.ctrlOptionsFor44&&(G={x:t.ctrlOptionsFor44.cx,y:t.ctrlOptionsFor44.cy},$+=t.ctrlOptionsFor44.fd,J+=t.ctrlOptionsFor44.td);const ie=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,[te]=Xe({source:{x:d,y:h},sourcePosition:E,target:{x:u,y:g},targetPosition:V,center:{x:X+G.x,y:A+G.y},sourceOffset:$,targetOffset:J}),ne=Re(te),Q=gt(ne,ie),Z=ae(Q),oe=yt(te);if(i.x=oe.x,i.y=oe.y,s==="v"){const q=T>1?1:T<-1?-1:0,F=P>1?1:P<-1?-1:0;t.placeText==="start"?(i.x=d,i.y=h+q*10):t.placeText==="end"&&(i.x=u,i.y=g+F*10)}else{const q=k>1?1:k<-1?-1:0,F=N>1?1:N<-1?-1:0;t.placeText==="start"?(i.x=d+q*10,i.y=h):t.placeText==="end"&&(i.x=u+F*10,i.y=g)}return{pathCommands:Q,pathData:Z,textPosition:i,points:ne,startDirection:E,endDirection:V}},qn=(l,i={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:o,lineDirection:s,lineShape:a,fx:d,fy:h,fcx:c,fcy:f,f_W:p,f_H:m,tx:u,ty:g,tcx:y,tcy:v,t_W:x,t_H:w}=l,k=d-c,T=h-f;let O=k>3?1:k<-3?-1:0,b=T>3?1:T<-3?-1:0;Math.abs(O)===1&&Math.abs(b)===1&&(Math.abs(k)>Math.abs(T)?b=0:O=0),O===0&&b===0&&(O=1);const N=u-y,P=g-v;let R=N>3?1:N<-3?-1:0,S=P>3?1:P<-3?-1:0;Math.abs(R)===1&&Math.abs(S)===1&&(Math.abs(N)>Math.abs(P)?S=0:R=0),R===0&&S===0&&(O=-1);let M=Me(n,O,b,!1,d,h,u,g),C=Me(o,R,S,!0,d,h,u,g);const E=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,V=t.ctrlPointsFor49;let X={x:Math.round(d),y:Math.round(h)},A={x:Math.round(u),y:Math.round(g)},G={x:Math.round(V[0].x),y:Math.round(V[0].y)},$={x:Math.round(V[V.length-1].x),y:Math.round(V[V.length-1].y)},J=[...V];if(t.isReverse&&([M,C]=[C,M]),Math.abs(X.x-G.x)>3||Math.abs(X.y-G.y)>3){const Z=X.x+(G.x-X.x)/2,oe=X.y+(G.y-X.y)/2,q=mt(M),[F]=Xe({source:X,sourcePosition:M,target:G,targetPosition:q,center:{x:Z,y:oe},sourceOffset:20,targetOffset:5});J=Re([...F,...J])}if(Math.abs(A.x-$.x)>3||Math.abs(A.y-$.y)>3){const Z=$.x+(A.x-$.x)/2,oe=$.y+(A.y-$.y)/2,q=mt(C),[F]=Xe({source:$,sourcePosition:q,target:A,targetPosition:C,center:{x:Z,y:oe},sourceOffset:5,targetOffset:20});J=Re([...J,...F])}const ie=J,te=gt(ie,E),ne=ae(te),Q=yt(V);return i.x=Q.x,i.y=Q.y,{pathCommands:[],pathData:ne,textPosition:i,points:ie,startDirection:M,endDirection:C}},Zn=(l,i={x:0,y:0,rotate:0})=>{const{line:e,lineShape:t,fx:n,fy:o,fcx:s,fcy:a,tx:d,ty:h,tcx:c,tcy:f}=l,p=d-n,m=h-o;let u=n-s,g=o-a,y=d-c,v=h-f,{fromJunctionPoint:x,toJunctionPoint:w}=e;e.isReverse&&([x,w]=[w,x]),(x===W.left||x===W.right)&&(g=0),(x===W.top||x===W.bottom)&&(u=0),(w===W.left||w===W.right)&&(v=0),(w===W.top||w===W.bottom)&&(y=0);const k=Math.min(200,Math.max(100,Math.abs(p/2))),T=Math.min(200,Math.max(100,Math.abs(m/2))),O=u/(Math.abs(u)+Math.abs(g))*k,b=g/(Math.abs(u)+Math.abs(g))*T;let N={x:O,y:b};const P=y/(Math.abs(y)+Math.abs(v))*k+p,R=v/(Math.abs(y)+Math.abs(v))*T+m;let S={x:P,y:R};e.ctrlPoints&&e.ctrlPoints.length>0&&(e.isReverse?(N.x+=e.ctrlPoints[1].x,N.y+=e.ctrlPoints[1].y,S.x+=e.ctrlPoints[0].x,S.y+=e.ctrlPoints[0].y):(N.x+=e.ctrlPoints[0].x,N.y+=e.ctrlPoints[0].y,S.x+=e.ctrlPoints[1].x,S.y+=e.ctrlPoints[1].y));const M={x:n+N.x,y:o+N.y},C={x:n+S.x,y:o+S.y},E={x:n+p,y:o+m},V=[{type:"M",x:n,y:o},{type:"c",dx1:N.x,dy1:N.y,dx2:S.x,dy2:S.y,dx:p,dy:m}];t===8&&V.push({type:"Z"});const X=vt({x:n,y:o},M,C,E,t<6?.8:.5);i.x=X.x,i.y=X.y;const A=ae(V);return{pathCommands:V,pathData:A,textPosition:i,points:[]}},vt=(l,i,e,t,n=.5)=>{const o={x:(1-n)*l.x+n*i.x,y:(1-n)*l.y+n*i.y},s={x:(1-n)*i.x+n*e.x,y:(1-n)*i.y+n*e.y},a={x:(1-n)*e.x+n*t.x,y:(1-n)*e.y+n*t.y},d={x:(1-n)*o.x+n*s.x,y:(1-n)*o.y+n*s.y},h={x:(1-n)*s.x+n*a.x,y:(1-n)*s.y+n*a.y};return{x:(1-n)*d.x+n*h.x,y:(1-n)*d.y+n*h.y}},Kn=(l,i={x:0,y:0,rotate:0})=>{const{line:e,totalLinesBetweenNodes:t,currentLineIndex:n,lineDirection:o,lineShape:s,fx:a,fy:d,fcx:h,fcy:c,f_W:f,f_H:p,tx:m,ty:u,tcx:g,tcy:y,t_W:v,t_H:x}=l,w=m-a,k=u-d,T=m>a?1:-1,O=u>d?1:-1,b=o==="v"?O:T,N=a-h,P=d-c,R=m-g,S=u-y,M=1/(t+1)*(n+1);let C={x:0,y:0},E={x:0,y:0};if(s===Y.Curve2)C=o==="v"?{x:0,y:b*30}:{x:b*30,y:0},E=o==="v"?{x:w*M,y:b*-10}:{x:b*-10,y:k*M};else if(s===Y.Curve3)C=o==="v"?{x:0,y:k*M}:{x:b*30,y:0},E=o==="v"?{x:0,y:0}:{x:b*-10,y:k*M};else if(s===Y.Curve5)C={x:0,y:0},E=o==="v"?{x:0,y:k*M}:{x:w*M,y:0};else if(s===Y.Curve7||s===Y.Curve8){const ne=N/(Math.abs(N)+Math.abs(P))*30,Q=P/(Math.abs(N)+Math.abs(P))*30;C={x:ne,y:Q};const Z=R/(Math.abs(R)+Math.abs(S))*30+w,oe=S/(Math.abs(R)+Math.abs(S))*30+k;E={x:Z,y:oe}}const V={x:a+C.x,y:d+C.y},X={x:a+E.x,y:d+E.y},A={x:a+w,y:d+k},G=[{type:"M",x:a,y:d},{type:"c",dx1:C.x,dy1:C.y,dx2:E.x,dy2:E.y,dx:w,dy:k}];s===8&&G.push({type:"Z"});const $=vt({x:a,y:d},V,X,A,s<6?.8:.5);i.x=$.x,i.y=$.y;const J=ae(G);return{pathCommands:G,pathData:J,textPosition:i,points:[]}};class Qn{constructor(){_(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]});_(this,"options",{});_(this,"runtimeDATA4NodeMap",new Map);_(this,"runtimeDATA4Links",[]);_(this,"runtimeDATA4LinkMap",new Map);_(this,"runtimeDATA4ConnectTargets",[]);_(this,"runtimeDATA4ElLineTargets",[]);_(this,"runtimeDATA4ShouldRenderItems",{nodes:[],lines:[],fakeLines:[]})}}class eo extends Qn{constructor(){super()}getOptions(){return this.options}getNodeById(i){return this.runtimeDATA4NodeMap.get(i)}getLineById(i){var e;return(e=this.runtimeDATA4LinkMap.get(i))==null?void 0:e.line}getLinkByLineId(i){return this.runtimeDATA4LinkMap.get(i)}getFakeLineById(i){return this.graphData.fakeLines.find(e=>e.id===i)}getNodes(){return this.graphData.nodes}getLinks(){return this.runtimeDATA4Links}getFakeLines(){return this.graphData.fakeLines}getLines(){return this.runtimeDATA4Links.map(i=>i.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(i){if(!i)throw new Error("[getConnectTargetById]targetId is empty");for(let e=0;e<this.runtimeDATA4ConnectTargets.length;e++){const t=this.runtimeDATA4ConnectTargets[e];if(t.targetId===i)return t}}getElLineTargets(){return this.runtimeDATA4ElLineTargets}getElLineTargetById(i){return this.runtimeDATA4ElLineTargets.find(e=>e.id===i)}calcShouldRenderNodes(){const i=[];return this.graphData.nodes.forEach(e=>{e.rgShouldRender!==!1&&e.rgCalcedVisibility!==!1&&i.push(e)}),i}calcShouldRenderLines(){const i=[];return this.runtimeDATA4Links.forEach(e=>{e.rgShouldRender!==!1&&e.line.hidden!==!0&&e.rgCalcedVisibility!==!1&&i.push(e.line)}),i}calcShouldRenderFakeLines(){return this.graphData.fakeLines}findNodeByXy(i){const e=this.graphData.nodes;for(let t=e.length-1;t>=0;t--){const n=e[t],o=n.x,s=n.y,a=n.el_W||n.width||50,d=n.el_H||n.height||50;if(i.x>o&&i.x<o+a&&i.y>s&&i.y<s+d)return n}return null}}class to{constructor(){_(this,"map");this.map=new Map}_key(i,e){return i<=e?`${i}${e}`:`${e}${i}`}addEdge(i,e){const t=this._key(i,e),n=this.map.get(t)||0;return this.map.set(t,n+1),n}getCount(i,e){const t=this._key(i,e);return this.map.get(t)||0}clear(){this.map.clear()}}const Ge=(l={})=>{const i={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:"h",toolBarPositionH:"left",toolBarPositionV:"bottom",defaultNodeColor:"#ffffff",defaultNodeBorderColor:"#666666",defaultNodeBorderWidth:1,defaultNodeBorderRadius:4,defaultNodeShape:xe.rect,defaultNodeWidth:void 0,defaultNodeHeight:void 0,defaultLineColor:"#cccccc",defaultLineWidth:2,defaultLineShape:Y.StandardStraight,defaultLineTextOffsetX:void 0,defaultLineTextOffsetY:void 0,defaultJunctionPoint:W.border,defaultLineJunctionOffset:3,defaultPolyLineRadius:5,placeOtherGroup:!0,defaultLineTextOnPath:!1,lineTextMaxLength:66,multiLineDistance:30,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:we(JSON.parse(JSON.stringify(De)),{}),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},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};i.newLineTemplate=he(i.newLineTemplate,i);const e=Object.keys(i);return l&&Object.keys(l).forEach(t=>{const n=l[t];if(!e.includes(t)){L("RGOptions: unknow option key:",t);return}if(typeof n=="object"){L("RGOptions:user setting object:",t,n);const o=i[t];if(t==="layout")i[t]=JSON.parse(JSON.stringify(n));else if(o&&!Array.isArray(o)&&n)Object.keys(o).forEach(s=>{o[s]=n[s]});else if(Array.isArray(o)){const s=[];n.forEach(a=>{a&&typeof a=="object"?s.push(JSON.parse(JSON.stringify(a))):s.push(a)}),i[t]=s}else i[t]=n}else i[t]=n}),i},xt=l=>{const i=l.layoutName||"";if(i==="center"){const e=l;e.layoutDirection=void 0}else if(i.includes("tree")){const e=l;e.from===void 0&&(e.from="left"),e.levelGaps===void 0&&(e.levelGaps=[]),(e.from==="top"||e.from==="bottom")&&(e.layoutDirection===void 0&&(e.layoutDirection="v"),L("set layoutDirection=v"),L("set defaultJunctionPoint=tb")),(e.from==="left"||e.from==="right")&&(e.layoutDirection===void 0&&(e.layoutDirection="h"),L("set defaultJunctionPoint=lr"))}else(i==="fixed"||i==="force")&&(l.layoutDirection=void 0)},no=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:Ge,appendDefaultOptions4Layout:xt,default:{createDefaultConfig:Ge}},Symbol.toStringTag,{value:"Module"}));class Oe extends eo{constructor(){super();_(this,"commits");_(this,"updateViewHook",e=>{});this.options=Ge({}),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.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,Object.assign(this.options,e),this.isPerformanceMode()&&!this.options.showEasyView){const t=Object.keys(e);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,o=this.options.viewSize.height/2,s=this.options.canvasZoom/100;this.setCanvasOffset(n-e*s,o-t*s)}removeNodeById(e){this.beforeNodeBeRemove(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),n--,t++);for(const n of e)this.runtimeDATA4NodeMap.delete(n);L("Removed node\uFF1A",e,t),this.commits.nodesListChanged=!0}removeLineByIds(e){L("_removeLineByIds:",e.length,e),this.removeFakeLineByIds(e);let t=0;for(let n=0;n<this.graphData.normalLines.length;n++){const o=this.graphData.normalLines[n];e.includes(o.id)&&(this.graphData.normalLines.splice(n,1),n--,t++)}L("_removeLineByIds:",t),this.removeLinkByLineIds(e),this.updateLinks(),this.commits.linesListChanged=!0}removeFakeLineByIds(e){L("_removeFakeLineByIds:",e.length,e);let t=0;for(let n=0;n<this.graphData.fakeLines.length;n++){const o=this.graphData.fakeLines[n];e.includes(o.id)&&(this.graphData.fakeLines.splice(n,1),n--,t++)}this.commits.fakeLinesListChanged=!0,L("_removeFakeLineByIds:",t)}removeLinkByLineIds(e){L("_removeLinkByLineIds:",e.length,e);let t=0;for(let n=0;n<this.runtimeDATA4Links.length;n++){const o=this.runtimeDATA4Links[n];e.includes(o.lineId)&&(this.runtimeDATA4Links.splice(n,1),this.runtimeDATA4LinkMap.delete(o.lineId),n--,t++)}this.commits.fakeLinesListChanged=!0,L("_removeLinkByLineIds:",t)}removeConnectTarget(e){const t=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===e);if(t!==-1){const n=this.runtimeDATA4ConnectTargets[t];(n.targetType===D.NodePoint||n.targetType===D.CanvasPoint)&&this.runtimeDATA4ConnectTargets.splice(t,1)}this.commits.connectTargetsListChanged=!0}updateLinks(e=[]){const t=new to;for(const n of this.runtimeDATA4Links){const{from:o,to:s}=n.line,a=t.addEdge(o,s);a!==n.currentLineIndex&&(n.currentLineIndex=a,this.commitLine(n.lineId))}for(const n of this.runtimeDATA4Links){const{from:o,to:s}=n.line,a=t.getCount(o,s);a!==n.totalLinesBetweenNodes&&(n.totalLinesBetweenNodes=a,this.commitLine(n.lineId))}t.clear()}beforeNodeBeRemove(e){for(let t=0;t<this.runtimeDATA4Links.length;t++){const n=this.runtimeDATA4Links[t];(e.includes(n.fromNode.id)||e.includes(n.toNode.id))&&(L("Removed Node-line\uFF1A",n.lineId),this.removeLineByIds([n.lineId]),t--)}for(let t=0;t<this.graphData.fakeLines.length;t++){const n=this.graphData.fakeLines[t];let o=!1;if(n.fromType===D.Node&&e.includes(n.from))o=!0;else if(n.fromType===D.CanvasPoint||n.fromType===D.NodePoint){const s=this.getConnectTargetById(n.from);s&&s.nodeId&&e.includes(s.nodeId)&&(o=!0)}else if(n.toType===D.CanvasPoint||n.toType===D.NodePoint){const s=this.getConnectTargetById(n.to);s&&s.nodeId&&e.includes(s.nodeId)&&(o=!0)}o&&(this.graphData.fakeLines.splice(t,1),L("Removed Node-fakeLine\uFF1A",n.id),t--,this.commits.fakeLinesListChanged=!0)}L("Removed Node connect-target\uFF1A");for(let t=0;t<this.runtimeDATA4ConnectTargets.length;t++){const n=this.runtimeDATA4ConnectTargets[t];n.nodeId&&e.includes(n.nodeId)&&(this.runtimeDATA4ConnectTargets.splice(t,1),L("Removed Node-connect-target\uFF1A",n.targetId),this.commitConnectTarget(n.targetId),t--)}}addFakeLines(e){for(const t of e)if(t.id||console.warn("[relation-graph]Must have id for fake line:",t),this.graphData.fakeLines.some(n=>n.id===t.id))console.log("[relation-graph]Ignore duplicate fake line id:",t.id);else{t.isFakeLine=!0;const n=he(t,this.options);n.id||(n.id=Ie(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 o=this.getNodeById(n.from),s=this.getNodeById(n.to),a={lineId:n.id,line:n,fromNode:o,toNode:s,currentLineIndex:0,totalLinesBetweenNodes:1,rgShouldRender:!0,rgCalcedVisibility:!0};this.runtimeDATA4LinkMap.set(a.lineId,a),t.push(a)}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 o=t.hidden!==void 0&&n.hidden!==t.hidden;if(Object.assign(n,t,{id:e}),o){const s=Le.getDescendantNodes(n);this.updateNodesVisibleProperty([n].concat(s))}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}Object.assign(n,t,{id:e}),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 o=Le.isVisibleNode(n);n.rgCalcedVisibility!==o&&(n.rgCalcedVisibility=o,this.commitNode(n.id))}for(const n of this.runtimeDATA4Links)if(t||e.includes(n.fromNode)||e.includes(n.toNode)){const s=this.calcLinkVisibility(n);n.rgCalcedVisibility=s,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},o={x:n.x+e.viewSize.width/t,y:n.y+e.viewSize.height/t},s=e.snapshotting;for(const a of this.getNodes()){let d=!0;s||a.alwaysRender?d=!0:((a.x>o.x||a.y>o.y)&&(d=!1),(a.x+a.el_W<n.x||a.y+a.el_H<n.y)&&(d=!1)),a.rgShouldRender=d}for(const a of this.runtimeDATA4Links){if(s){a.rgShouldRender=!0;continue}a.rgShouldRender=a.fromNode.rgShouldRender||a.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 oo{constructor(){_(this,"listeners");_(this,"useReactiveDataToAutoUpdateView",!1);_(this,"instanceId");_(this,"dataProvider");_(this,"options");_(this,"_dataUpdatedRequested",!1);_(this,"eventHandlers",[]);_(this,"_emitHook");this.dataProvider=new Oe,this.options=this.dataProvider.getOptions(),this.listeners={},this.instanceId="RG-"+this.generateNewUUID(5)}generateNewUUID(i=5){return Ie(i)}enableDebugLog(i){this.dataProvider.updateOptions({debug:i}),typeof window<"u"&&window&&(window.relationGraphDebug=i)}_dataUpdated(){this._requestDataUpdate()}_requestDataUpdate(){typeof window>"u"||!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(i){console.error("[relation-graph]Error:",i)}finally{this._dataUpdatedRequested=!1}}addEventHandler(i){this.eventHandlers.includes(i)||this.eventHandlers.push(i)}removeEventHandler(i){const e=this.eventHandlers.indexOf(i);e!==-1&&this.eventHandlers.splice(e,1)}setEventEmitHook(i){this._emitHook=i}emitEvent(i,...e){let{result:t,handled:n}=this.defaultEventHandler(i,...e);for(const o of this.eventHandlers){const s=o(i,...e);s!==void 0&&(t=s,n=!0)}if(n||this._emitHook&&this._emitHook(i,...e,o=>{o!==void 0&&(t=o)}),t!==void 0)return L("[custom event hook]Event:",i," => returnValue:",t),t}defaultEventHandler(i,...e){let t,n=!1;if(i===I.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(i===I.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(e[0],e[1]));else if(i===I.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const o=e[0],s=e[1],a=e[2],d=e[3],h=e[4],c=e[5];t=this.listeners.onNodeDragging(o,s,a,d,h,c)}}else if(i===I.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const o=e[0],s=e[1],a=e[2],d=e[3];t=this.listeners.onCanvasDragging(o,s,a,d)}}else if(i===I.onNodeDragEnd){const o=e[0],s=e[1],a=e[2],d=e[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(o,s,a,d))}else if(i===I.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(i===I.onNodeClick){if(this.listeners.onNodeClick){n=!0;const o=e[0],s=e[1];this.listeners.onNodeClick(o,s)}}else if(i===I.onLineClick){if(this.listeners.onLineClick){n=!0;const o=e[0],s=e[1],a=e[2];this.listeners.onLineClick(o,s,a)}}else if(i===I.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const o=e[0],s=e[1];this.listeners.onNodeExpand(o,s)}}else if(i===I.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const o=e[0],s=e[1];this.listeners.onNodeCollapse(o,s)}}else if(i===I.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const o=e[0];this.listeners.onCanvasDragEnd(o)}}else if(i===I.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const o=e[0];this.listeners.onCanvasClick(o)}}else if(i===I.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const o=e[0],s=e[1];this.listeners.onCanvasSelectionEnd(o,s)}}else if(i===I.onContextmenu){if(this.listeners.onContextmenu){n=!0;const o=e[0],s=e[1],a=e[2],d=e[3],h=e[4];this.listeners.onContextmenu(o,s,a,d,h)}}else if(i===I.onFullscreen){if(this.listeners.onFullscreen){n=!0;const o=e[0],s=e[1];t=this.listeners.onFullscreen(o,s)}}else if(i===I.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const o=e[0];t=this.listeners.beforeAddNodes(o)}}else if(i===I.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const o=e[0];t=this.listeners.beforeAddLines(o)}}else if(i===I.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const o=e[0];t=this.listeners.onKeyboardDown(o)}}else if(i===I.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const o=e[0];t=this.listeners.onKeyboardUp(o)}}else if(i===I.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const o=e[0];t=this.listeners.onLineBeCreated(o)}}else if(i===I.onCanvasDragStart){if(this.listeners.onCanvasDragStart){n=!0;const o=e[0],s=e[1],a=e[2];t=this.listeners.onCanvasDragStart(o,s,a)}}else if(i===I.onResizeEnd){if(this.listeners.onResizeEnd){n=!0;const o=e[0],s=e[1],a=e[2],d=e[3];t=this.listeners.onResizeEnd(o,s,a,d)}}else if(i===I.onResizeStart){if(this.listeners.onResizeStart){n=!0;const o=e[0],s=e[1];t=this.listeners.onResizeStart(o,s)}}else if(i===I.beforeNodeResize){if(this.listeners.beforeNodeResize){n=!0;const o=e[0],s=e[1],a=e[2],d=e[3],h=e[4];t=this.listeners.beforeNodeResize(o,s,a,d,h)}}else if(i===I.onViewResize&&this.listeners.onViewResize){n=!0;const o=e[0];t=this.listeners.onViewResize(o)}return{result:t,handled:n}}setEventListener(i){Object.assign(this.listeners,i)}}class io extends oo{constructor(){super(...arguments);_(this,"$dom");_(this,"$canvasDom");_(this,"_rgAsConnectArea",!1);_(this,"$lineTextContainer4NormalLine");_(this,"$lineTextContainer4FakeLine");_(this,"viewBoundingClientRect",null)}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.dataStores.textContainer4NormalRef&&(this.dataStores.textContainer4NormalRef.value=this.$lineTextContainer4NormalLine)),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container"),this.dataStores.textContainer4FakeLineRef&&(this.dataStores.textContainer4FakeLineRef.value=this.$lineTextContainer4FakeLine)),this.$lineTextContainer4FakeLine)}getViewBoundingClientRect(){var t;if(!this.$dom)return this.viewBoundingClientRect||console.error("[getViewBoundingClientRect] RelationGraph DOM is not set yet!"),this.viewBoundingClientRect;const e=(t=this.$dom)==null?void 0:t.getBoundingClientRect();return this.viewBoundingClientRect=e,e}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=ce(e),n={x:t.clientX,y:t.clientY};return this.getViewXyByClientXy(n)}getViewXyByClientXy(e){const t=this.getViewBoundingClientRect();return{x:e.x-t.x,y:e.y-t.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,o={x:e.x-t.canvasOffset.x,y:e.y-t.canvasOffset.y};return{x:o.x/n,y:o.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=ve(e,"rg-node-peel","rg-map");if(!!t)return this.dataProvider.getNodeById(t.dataset.id)}isLine(e){const t=ve(e,"rg-line-peel","relation-graph");if(!!t)return this.dataProvider.getLineById(t.dataset.id)}isLink(e){throw new Error("Please use isLine")}}class so extends Oe{constructor(e,t,n,o){super();_(this,"dataStores");this.dataStores=e;const s=Object.assign({},this.options,n);this.options=n,Object.assign(this.options,s),this.graphData=t,this.runtimeDATA4Links=o.runtimeDATA4Links,this.runtimeDATA4ShouldRenderItems=o.runtimeDATA4ShouldRenderItems,this.runtimeDATA4ConnectTargets=o.runtimeDATA4ConnectTargets,this.runtimeDATA4NodeMap=o.runtimeDATA4NodeMap,this.runtimeDATA4LinkMap=o.runtimeDATA4LinkMap,this.runtimeDATA4ElLineTargets=o.runtimeDATA4ElLineTargets,this.updateViewHook=a=>{if(a.optionsChanged&&this.dataStores.store4Options.set(this.getOptions()),a.nodesListChanged&&this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),a.linesListChanged){const d=this.getShouldRenderLines();this.dataStores.store4ShouldRenderLines.set(d)}if(a.fakeLinesListChanged){const d=this.getShouldRenderFakeLines();this.dataStores.store4ShouldRenderFakeLines.set(d)}}}}class ao extends Oe{constructor(i,e,t){super(),this.graphData=i,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 ro extends Oe{constructor(e,t){super();_(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()),(n.nodesListChanged||n.linesListChanged||n.changedLines.length>0)&&this.dataStores.store4ShouldRenderLines.set(this.getShouldRenderLines()),(n.fakeLinesListChanged||n.changedFakeLines.length>0)&&this.dataStores.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()])}}}class lo extends Oe{constructor(i,e){super(),e(),this.updateViewHook=t=>{if(t.optionsChanged&&i.store4Options.set(this.getOptions()),t.linesListChanged||t.changedLines.length>0||t.nodesListChanged||t.changedNodes.length>0){const n=this.getShouldRenderNodes();i.store4ShouldRenderNodes.set([...n])}if(t.linesListChanged||t.changedLines.length>0){const n=this.getShouldRenderLines();i.store4ShouldRenderLines.set(n)}t.fakeLinesListChanged?i.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()]):t.changedFakeLines.length>0&&i.store4ShouldRenderFakeLines.set(this.getShouldRenderFakeLines())}}}class co extends io{constructor(){super();_(this,"_initRawPropertyFn",(e,t,n)=>{});_(this,"dataStores")}setReactiveData4Vue2(e,t,n,o){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new ao(e,t,n),this._initRawPropertyFn=o,this.options=this.dataProvider.options,this.dataStores={shouldRenderNodesStore:n.runtimeDATA4ShouldRenderItems.nodes,shouldRenderLinesStore:n.runtimeDATA4ShouldRenderItems.lines,shouldRenderFakeLinesStore:n.runtimeDATA4ShouldRenderItems.fakeLines}}setReactiveData4Vue3(e,t,n,o,s){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new so(e,t,n,o),this._initRawPropertyFn=s,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,textContainer4NormalRef:e.textContainer4NormalRef,textContainer4FakeLineRef:e.textContainer4FakeLineRef}}setReactiveData4React(e,t){this.dataProvider=new lo(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 ro(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines}}generateNewNodeId(e=5){const t=Ie(e);return this.dataProvider.getNodeById(t)?this.generateNewNodeId(e+1):t}}class ho extends co{constructor(){super()}getOptions(){return this.dataProvider.getOptions()}getNodeById(i){return this.dataProvider.getNodeById(i)}getLineById(i){return this.dataProvider.getLineById(i)}getLinkByLineId(i){return this.dataProvider.getLinkByLineId(i)}getLinkByLine(i){return this.getLinkByLineId(i.id)}getLines(){return this.dataProvider.getLines()}getElementLineById(i){return this.getFakeLineById(i)}getElementLines(){return this.getFakeLines()}getFakeLines(){return this.dataProvider.getFakeLines()}getFakeLineById(i){return this.dataProvider.getFakeLineById(i)}getNodes(){return this.dataProvider.getNodes()}getLinks(){return this.dataProvider.getLinks()}_getAllLinks(){const i=this.getLinks();return this._getFakeLineLinks().concat(i)}getNodeByTargetId(i){const e=this.dataProvider.getConnectTargetById(i);if(e&&e.nodeId)return this.getNodeById(e.nodeId)}_getFakeLineLinks(){const i=[];for(const e of this.getFakeLines())if(!e.forDisplayOnly&&(e.fromType===D.Node||e.fromType===D.NodePoint||e.fromType===D.CanvasPoint)&&(e.toType===D.Node||e.toType===D.NodePoint||e.toType===D.CanvasPoint)){let t=null,n=null;e.fromType===D.Node?t=this.getNodeById(e.from):(e.fromType===D.NodePoint||e.fromType===D.CanvasPoint)&&(t=this.getNodeByTargetId(e.from)),e.toType===D.Node?n=this.getNodeById(e.to):(e.toType===D.NodePoint||e.toType===D.CanvasPoint)&&(n=this.getNodeByTargetId(e.to)),t&&n&&i.push({lineId:e.id,line:e,fromNode:t,toNode:n,totalLinesBetweenNodes:1,currentLineIndex:0,rgShouldRender:!0,rgCalcedVisibility:!0})}return i}getConnectTargets(){return this.dataProvider.getConnectTargets()}getConnectTargetById(i){return this.dataProvider.getConnectTargetById(i)}}class fo extends ho{constructor(){super()}getRelatedLinesByNode(i){const e=[];for(const t of this._getAllLinks())(i===t.fromNode||i===t.toNode)&&e.push(t.line);return e}getLinksBetweenNodes(i){const e=[],t=this._getAllLinks();for(const n of t)i.includes(n.fromNode)&&i.includes(n.toNode)&&e.push(n);return e}getLinesBetweenNodes(i){return this.getLinksBetweenNodes(i).map(e=>e.line)}getNodeRelatedNodes(i,e={incoming:!0,outgoing:!0}){const t=[];for(const n of this.getLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:o,toNode:s}=n;e.outgoing&&o===i&&(t.includes(s)||t.push(s)),e.incoming&&s===i&&(t.includes(o)||t.push(o))}for(const n of this._getFakeLineLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:o,toNode:s}=n;e.outgoing&&o===i&&(t.includes(s)||t.push(s)),e.incoming&&s===i&&(t.includes(o)||t.push(o))}return t}getNodeIncomingNodes(i){return this.getNodeRelatedNodes(i,{incoming:!0,outgoing:!1})}getNodeOutgoingNodes(i){return this.getNodeRelatedNodes(i,{incoming:!1,outgoing:!0})}findGroupNodes(i,e=[]){return this._getNetworkNodesByNode(i,e)}getGroupNodesByNode(i,e=[]){return this._getNetworkNodesByNode(i,e)}getNetworkNodesByNode(i){return this._getNetworkNodesByNode(i)}_getNetworkNodesByNode(i,e=[]){if(!i)throw new Error("Call graphInstance.getNetworkNodesByNode:error: node is undefined");e.includes(i)||e.push(i);for(const t of this.getNodeRelatedNodes(i))e.includes(t)||this._getNetworkNodesByNode(t,e);return e}getStuffSize(i){return console.warn("Please use getNodesRectBox instead of getStuffSize, this method is compatible with older api versions."),this.getNodesRectBox(i)}getNodesViewInfo(i){return console.warn("Please use getNodesRectBox instead of getNodesViewInfo, this method is compatible with older api versions."),this.getNodesRectBox(i)}getNodesRectBox(i){const t=(i||this.getNodes()).filter(c=>c.rgCalcedVisibility!==!1);if(t.length===0)return{width:10,height:10,minX:0,minY:0,maxX:0,maxY:0};let n=9999999,o=9999999,s=-9999999,a=-9999999;t.forEach(c=>{c.x<n&&(n=c.x),c.x+(c.width||c.el_W)>s&&(s=c.x+(c.width||c.el_W)),c.y<o&&(o=c.y);const p=c.y+(c.height||c.el_H);p>a&&(a=p)});const d=s-n,h=a-o;return{width:d<0?0:d,height:h<0?0:h,minX:n===9999999?0:n,minY:o===9999999?0:o,maxX:s===-9999999?0:s,maxY:a===-9999999?0:a}}getNodesCenter(i){const e=this.getNodesRectBox(i);L("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(i){return Le.getDescendantNodes(i)}getNodesInSelectionView(i){const e=this.getCanvasXyByViewXy({x:i.x,y:i.y}),t=this.getCanvasXyByViewXy({x:i.x+i.width,y:i.y+i.height}),n=[];return this.getNodes().forEach(o=>{const s=o.x+o.el_W/2,a=o.y+o.el_H/2;s>e.x&&a>e.y&&s<t.x&&a<t.y&&n.push(o)}),n}getShouldRenderNodes(i){return this.dataProvider.isPerformanceMode()&&i?i:this.dataProvider.getShouldRenderNodes()}getShouldRenderLines(i){return this.dataProvider.isPerformanceMode()&&i?i:this.dataProvider.getShouldRenderLines()}getShouldRenderFakeLines(i){return this.dataProvider.isPerformanceMode()&&i?i:this.dataProvider.getShouldRenderFakeLines()}}class po extends fo{constructor(){super();_(this,"_elLineUpdateTimer");_(this,"_canvasCurrentInfo",{x:0,y:0,scale:1});_(this,"_nodeResizeEffectTimer");_(this,"prevAddNodeTimestamp",0);_(this,"_nodesElSizeMap",new Map)}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){L("removeLineById:",e),this.dataProvider.removeFakeLineByIds([e]),this._dataUpdated()}removeLink(e){L("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.removeNodesByIds(e.map(t=>t.id))}removeNode(e){this.removeNodes([e])}removeELementLineById(e){L("removeELementLineById:",e),this.removeFakeLineById(e)}addNode(e){if(L("addNode:",e),e&&Array.isArray(e)){console.error("addNode: node is array:",e);return}this._addNodes([e]),this._dataUpdated()}addNodes(e){if(L("addNodes:",e),e&&!Array.isArray(e)){console.error("addNodes: nodes is not array:",e);return}this._addNodes(e),this._dataUpdated()}addLine(e){if(L("addLine:",e),e&&Array.isArray(e)){console.error("addLine: line is array:",e);return}this.addLines([e])}addLines(e){if(L("addLines:",e),e&&!Array.isArray(e)){console.error("addLines: lines is not array:",e);return}if(e.length===0)return;const t=e.filter(o=>!o.isFakeLine);this._addLines(t);const n=e.filter(o=>o.isFakeLine);this.addFakeLines(n),this._dataUpdated()}_addFakeLines(e){this.dataProvider.addFakeLines(e)}addFakeLines(e){L("addFakeLines:",e),this._addFakeLines(e),this._dataUpdated()}updateElementLines(){this.dataProvider.getElLineTargets().length!==0&&(L("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,o=(t.y-this._canvasCurrentInfo.y)/this._canvasCurrentInfo.scale,s=t.width/this._canvasCurrentInfo.scale,a=t.height/this._canvasCurrentInfo.scale;return{x:n,y:o,el_W:s,el_H:a}}addElementLines(e){L("addElementLines:",e),e.forEach(t=>{t.fromType=D.HTMLElementId,t.toType=D.HTMLElementId,t.isFakeLine=!0,t.id||(t.id=this.generateNewUUID(6)),t.forDisplayOnly=!0}),this.addFakeLines(e),this.updateElementLines()}updateNodeOffsetSize(e,t,n){const o=this.getNodeById(e);if(!o)return;const s=o.el_W,a=o.el_H;(s!==t||a!==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===D.HTMLElementId||t.toType===D.HTMLElementId)&&e.push(t.id);this.dataProvider.removeFakeLineByIds(e),this._dataUpdated()}_addNodes(e){this.emitEvent(I.beforeAddNodes,e);const t={};this.getNodes().forEach(s=>{t[s.id]=s});const n=[],o=this.getOptions();e.forEach(s=>{let a=t[s.id];if(!a){let{text:d,id:h}=s;!d&&s.label&&(d=s.label,console.warn('Use "label" as "text":',s.label)),d===void 0&&h&&(d=h,console.warn('Use "id" as "text":',h)),a=we(Object.assign({},s,{text:d}),o,this._nodesElSizeMap),this._initRawPropertyFn&&this._initRawPropertyFn(a,"lot",a.lot),a&&(t[a.id]=a,n.push(a))}}),this.dataProvider.addNodes(n),n.length>0&&(this.prevAddNodeTimestamp=Date.now())}_addLines(e){this.emitEvent(I.beforeAddLines,e);const t=[];e.forEach(n=>{let{from:o,to:s,text:a}=n;if(!o)if(n.source)o=n.source,console.warn('Use "source" as "from":',n.source);else{console.error('JsonLine Must have field:"from"',n);return}if(!s)if(n.target)s=n.target,console.warn('Use "target" as "to":',n.target);else{console.error('JsonLine Must have field:"to"',n);return}if(a||n.label&&(a=n.label,console.warn('Use "label" as "text":',n.label)),!this.getNodeById(o)){console.error("Can not found from node:",n);return}if(!this.getNodeById(s)){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(p=>p.id===n.id)){console.warn("Duplicate line id in new lines:",n.id);return}}else n.id="L-"+this.generateNewUUID(6);const c=he(Object.assign({},n,{from:o,to:s,text:a}),this.getOptions());t.push(c)}),this.dataProvider.addLines(t)}updateNode(e,t){this.dataProvider.updateNode(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateNodePosition(e,t,n){var s;const o=typeof e=="string"?e:e.id;this.dataProvider.updateNode(o,{x:t,y:n}),this.getOptions().layout.autoLayouting&&((s=this.layoutor)==null||s.syncNodePosition(o,t,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,o){Le.flatNodeData(e,t,n,o)}backupNodesElSize(){for(const e of this.getNodes())this._nodesElSizeMap.set(e.id,[e.el_W,e.el_H])}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||[],o=[],s=[];this.flatNodeData(t,null,o,s),n.forEach(a=>{s.push(a)}),this._addNodes(o),L("Nodes is initialized"),this._addLines(s),this._dataUpdated(),e.fakeLines&&this.addFakeLines(e.fakeLines),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)),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.backupNodesElSize(),this.dataProvider.clearReactiveData(),this.dataProvider.clearChecked(),this.dataProvider.setEditingLine(null),this.dataProvider.setEditingNodes([])}_setJsonData(e,t=!1){this._clearGraph(),this.loadGraphJsonData(e)}}class uo extends po{constructor(){super();_(this,"canvasConnectTargetsMap",new Map);_(this,"nodeConnectTargetsMap",new Map);_(this,"connectTargetElementMap",new Map);_(this,"_connectTargetUpdateRequestedSet",new Map);_(this,"_updateTimer");_(this,"_removedConnectTargetMap",new Map)}updateConnectTargetsOnCanvas(e,t){if(!t)return;const n=t.classList.contains("rg-canvas-slot-above")?"above":"behind",o=this.canvasConnectTargetsMap.get(n);o&&o.length>0&&this.updateConnectTargetList(e,t,o)}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 o=this.nodeConnectTargetsMap.get(t)||[];o.length!==0&&this.updateConnectTargetList(e,n,o)}updateConnectTargetList(e,t,n){const o=this.dataProvider.getCanvasScale();for(const s of n){const a=this.connectTargetElementMap.get(s.targetId);if(!a){console.error("Can not find el for connectTarget:",s.targetId,s);continue}this._requestUpdateConnectTargetOffset(e,s,a,t,o)}}_requestUpdateConnectTargetOffset(e,t,n,o,s){this._connectTargetUpdateRequestedSet.set(t.targetId,{stableTimes:0,connectTarget:t,by:e,connectTargetEl:n,relativeEl:o}),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(this._connectTargetUpdateRequestedSet.size+10,50))}_updateAllRequestedConnectTargetOffsets(){let e=0;for(const t of this._connectTargetUpdateRequestedSet.values()){const{by:n,connectTargetEl:o,relativeEl:s,connectTarget:a}=t;if(this.dataProvider.isPerformanceMode()&&a.nodeId){const f=this.getNodeById(a.nodeId);if(!f||!f.rgShouldRender||!f.rgCalcedVisibility)continue}if(!this.dataProvider.getConnectTargetById(a.targetId))continue;const h=this.dataProvider.getCanvasScale();this._updateConnectTargetOffset(n,a,o,s,h)?e++:t.stableTimes++,t.stableTimes>2&&this._connectTargetUpdateRequestedSet.delete(a.targetId)}e>0?(clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(e/2+10,100)),this._dataUpdated()):(this._connectTargetUpdateRequestedSet.clear(),this._dataUpdated())}_updateConnectTargetOffset(e,t,n,o,s){const a=o.getBoundingClientRect(),d=n.getBoundingClientRect(),h=Math.round(d.x-a.x),c=Math.round(d.y-a.y),f=this.dataProvider.getCanvasScale(),p=Math.round(h/f),m=Math.round(c/f),u=Math.round(d.width/f),g=Math.round(d.height/f),y=t.offsetX!==p,v=t.offsetY!==m,x=u!==0&&t.width!==u,w=g!==0&&t.height!==g;return y||v||x||w?(this.dataProvider.updateConnectTarget(t.targetId,{offsetX:p,offsetY:m,width:u,height:g}),!0):!1}_onConnectTargetMounted(e,t,n,o){const s=this.dataProvider.getCanvasScale();this._requestUpdateConnectTargetOffset(e,t,n,o,s)}getNodeElByChildrenTarget(e){return ve(e,"rg-node-peel","rg-map")}registerConnectTarget(e,t,n,o,s={}){if(n!==D.NodePoint&&n!==D.CanvasPoint)return;if(!e){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${t}`);return}const a=this.getNodeElByChildrenTarget(e),d=a==null?void 0:a.dataset.id;if(d==="rg-newNodeTemplate")return;let h=this.dataProvider.getConnectTargetById(t);if(!h){const f={targetId:t,targetType:n,junctionPoint:o,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:s||{}};this.reuseConnectTarget(f),h=this.dataProvider.addConnectTarget(f)}return this.connectTargetElementMap.set(h.targetId,e),(d?this.getNodeById(d):null)?this._addConnectTargetToNodeMap(d,h,e,a):this._addConnectTargetToCanvasMap(h,e),h}_addConnectTargetToNodeMap(e,t,n,o){this.dataProvider.updateConnectTarget(t.targetId,{junctionPoint:t.junctionPoint,targetType:D.NodePoint,nodeId:e,targetData:Object.assign({},t.targetData||{},{nodeId:e})});let s=this.nodeConnectTargetsMap.get(e);s?s.some(a=>a.targetId===t.targetId)||s.push(t):this.nodeConnectTargetsMap.set(e,[t]),this._onConnectTargetMounted("NT-Mounted",t,n,o)}_addConnectTargetToCanvasMap(e,t){let n=ve(t,"rg-canvas-slot","rg-map");if(!!n&&n){const o=n.classList.contains("rg-canvas-slot-above")?"above":"behind";this.dataProvider.updateConnectTarget(e.targetId,{junctionPoint:e.junctionPoint,targetType:D.CanvasPoint,targetData:Object.assign({},e.targetData||{})});const s=this.canvasConnectTargetsMap.get(o);s?s.some(a=>a.targetId===e.targetId)||s.push(e):this.canvasConnectTargetsMap.set(o,[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{const o=this.canvasConnectTargetsMap.get("behind");if(o){let s=o.findIndex(a=>a.targetId===e);s!==-1?n=this.canvasConnectTargetsMap.get("behind"):(s=this.canvasConnectTargetsMap.get("above").findIndex(a=>a.targetId===e),s!==-1&&(n=this.canvasConnectTargetsMap.get("above")))}}if(n){const o=n.findIndex(s=>s.targetId===e);o!==-1&&n.splice(o,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 go extends uo{constructor(){super();_(this,"fakeLineTargetRender")}generateCreatingLineConfig(e){e||(e=this.dataProvider.getOptions());const{newLinkTemplate:t,newLineTemplate:n}=e,o=t.fromNode;if(!o)return{line:n,from:null,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const s=t.toNode,a=s.targetType===D.Node?t.toNode:this.getFakeLineTarget(s.targetType,s.id,n);return{line:Object.assign({},n,{isFakeLine:!1}),from:this.getFakeLineTarget(o.targetType,o.id,n),to:a,totalLinesBetweenNodes:1,currentLineIndex:0}}generateLineConfig(e){const t=this.getLinkByLine(e);return!t||!t.rgCalcedVisibility?!1:{line:t.line,from:t.fromNode,to:t.toNode,totalLinesBetweenNodes:t.totalLinesBetweenNodes,currentLineIndex:t.currentLineIndex}}generateFakeLineConfig(e){let t=1,n=0;if(e.fromType===D.HTMLElementId&&e.toType===D.HTMLElementId){const a=this.dataProvider.getFakeLines().filter(d=>d.from===e.from&&d.to===e.to);a.length>1&&(console.warn("sameTargetLines element-line:",e),t=a.length,n=a.indexOf(e))}let o=this.getFakeLineTarget(e.fromType,e.from,e),s=this.getFakeLineTarget(e.toType,e.to,e);return!o&&e.fromType===D.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",e.fromType,e.from,e),!1):!s&&e.fromType===D.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",e.toType,e.to,e),!1):{line:e,from:o,to:s,totalLinesBetweenNodes:t,currentLineIndex:n}}setFakeLineTargetRender(e){this.fakeLineTargetRender=e}getFakeLineTarget(e,t,n){if(e===D.HTMLElementId){let o=this.dataProvider.getElLineTargets().find(s=>s.id===t);return o||(o={x:300,y:300,targetType:D.HTMLElementId,nodeShape:1,id:t,el_W:40,el_H:40,hidden:!0},this.dataProvider.addElLineTarget(o),this.updateElementLines()),o.hidden?null:o}else{if(e===D.Node)return this.getNodeById(t);if(e===D.NodePoint||e===D.CanvasPoint){const o=this.dataProvider.getConnectTargetById(t);if(!o)return;if(o.nodeId){const s=this.getNodeById(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_W+o.offsetX,y:s.y+o.offsetPercentY*s.el_H+o.offsetY,targetType:D.NodePoint,targetData:o.targetData,nodeShape:0,id:t,el_W:o.width,el_H:o.height,hidden:!1}}else return{x:o.offsetX,y:o.offsetY,targetType:D.CanvasPoint,targetData:o.targetData,nodeShape:0,id:t,el_W:o.width,el_H:o.height,hidden:!1}}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(e,t,n)}}class mo extends go{constructor(){super()}_updateOptions(i){!i.instanceId&&this.getOptions().instanceId!==i.instanceId&&(i.instanceId=this.instanceId);const e=Object.assign({},i);if(e.layouts)throw new Error('Graph options do not support setting layouts properties, Please use "layout"!');if(e.lineUseTextPath)throw new Error('Graph options do not support setting layouts properties, Please use "defaultLineTextOnPath"!');if(e.debug!==void 0){const t=e.debug===!0;t&&L("RGOptions:user instance options:",e),typeof window<"u"&&window&&(window.relationGraphDebug=t)}e.layout?(this.dataProvider.updateOptions({...e,layout:{...this.getOptions().layout,...e.layout}}),this.layoutor&&this.layoutor.updateOptions&&this.layoutor.updateOptions(e.layout)):this.dataProvider.updateOptions(e)}resetViewSize(i=!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}):i&&(t.canvasZoom=100,t.canvasOffset={x:t.viewSize.width/2,y:t.viewSize.height/2}),this.dataProvider.updateOptions(t),L("resetViewSize:1:",t),this._dataUpdated()}loading(i=""){this.dataProvider.updateOptions({graphLoading:!0,graphLoadingText:i}),this._dataUpdated()}clearLoading(){this.dataProvider.updateOptions({graphLoading:!1,graphLoadingText:""}),this._dataUpdated()}setCheckedNode(i){this.dataProvider.updateOptions({checkedNodeId:i?typeof i=="string"?i:i.id:""}),this._dataUpdated()}setCheckedLine(i){this.dataProvider.updateOptions({checkedLineId:i?typeof i=="string"?i:i.id:""})}clearChecked(){this.dataProvider.clearChecked(),this._dataUpdated()}clearSelected(){const i=this.getNodes().filter(n=>n.selected),e=this.getLines().filter(n=>n.selected),t=this.getFakeLines().filter(n=>n.selected);i.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(i,e){this.dataProvider.setCanvasOffset(i,e),this._updateEditingControllerView(),this.updateShouldRenderGraphData(),this._dataUpdated()}setCanvasMoveMode(i){this.dataProvider.updateOptions({canvasMoveMode:i}),this._dataUpdated()}onMiniViewMounted(){this.dataProvider.updateOptions({showMiniView:!0}),this._dataUpdated()}onMiniViewUnMounted(){this.dataProvider.updateOptions({showMiniView:!1})}onReferenceLineMounted(i){this.dataProvider.updateOptions({referenceLineAdsorption:i||!1,showReferenceLine:!0})}onReferenceLineUnMounted(){this.dataProvider.updateOptions({referenceLineAdsorption:!1,showReferenceLine:!1})}}class yo extends mo{constructor(){super()}getCreatingLine(i){if(i||(i=this.getOptions()),!i.creatingLinePlot)return{creating:!1};const{line:e,from:t,to:n}=this.generateCreatingLineConfig();return{creating:!0,fromTarget:t,toTarget:n,lineJson:e}}getCreatingNode(i){return i||(i=this.getOptions()),i.creatingNodePlot?{creating:i.creatingNodePlot,nodeJson:i.newNodeTemplate}:{creating:!1}}}const vo=l=>{const i=Math.sin(l)*1e4;return i-Math.floor(i)},Ct=(l,i,e,t,n,o)=>{const a=e-l,d=t-i,h=Math.sqrt(a*a+d*d),c=Math.max(2,Math.floor(h/12)),f=-d/h,p=a/h,m=[{type:"M",x:l,y:i}];let u=l,g=i;for(let y=1;y<=c;y++){let v=l+a*y/c,x=i+d*y/c;if(y<c){const w=vo(n+y)-.5;v+=f*w*o,x+=p*w*o}m.push({type:"l",dx:v-u,dy:x-g}),u=v,g=x}return m},xo=(l,i={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:o}=l;i.rotate=j.getTextAngle(e,t,n,o),i.x=e+(n-e)/2,i.y=t+(o-t)/2,Number.isNaN(i.rotate)&&(i.rotate=0);const s=e+t+n+o,a=Ct(e,t,n,o,s,2.5),d=Ct(e,t,n,o,s+99,1.5),h=`${ae(a)} ${ae(d)}`;return{pathCommands:[...a,...d],pathData:h,textPosition:i,points:[]}};class Co extends yo{constructor(){super()}_getJunctionPoint(i,e){return i===W.border?j.getBorderPoint4MultiLine(e):i===W.ltrb?j.getRectJoinPoint(e):i===W.tb?j.getRectVJoinPoint(e):i===W.lr?j.getRectHJoinPoint(e):i===W.left?j.getRectLeftJoinPoint(e):i===W.right?j.getRectRightJoinPoint(e):i===W.top?j.getRectTopJoinPoint(e):i===W.bottom?j.getRectBottomJoinPoint(e):i==="horizontalLine"?j.getRectHorizontalLineJoinPoint(e):i==="verticalLine"?j.getRectVerticalLineLineJoinPoint(e):j.getBorderPoint4MultiLine(e)}createLinePath(i,e,t){throw new Error("createLinePath() is deprecated, please use createLineDrawInfo() instead.")}createLineDrawInfo(i,e){let t,n,o=1,s=0;if(i&&(s=i.currentLineIndex,o=i.totalLinesBetweenNodes),i)t=i.fromNode,n=i.toNode;else{const a=e;if(t=this.getFakeLineTarget(a.fromType,a.from,a),n=this.getFakeLineTarget(a.toType,a.to,a),!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:o,currentLineIndex:s})}_getLineDefaultOptions(){const i=this.getOptions();return{layoutDirection:i.layout.layoutDirection,multiLineDistance:i.multiLineDistance,defaultJunctionPoint:i.defaultJunctionPoint,lineRadius:i.defaultPolyLineRadius,defaultLineJunctionOffset:i.defaultLineJunctionOffset,defaultNodeShape:i.defaultNodeShape}}generateLinePath(i){i.totalLinesBetweenNodes===void 0&&(i.totalLinesBetweenNodes=1),i.currentLineIndex===void 0&&(i.currentLineIndex=0),i.defaultOptions===void 0&&(i.defaultOptions=this._getLineDefaultOptions());try{const e=this.withLineJunctionPoints(i);return this.createLinePathData(e)}catch(e){if(e.rgError)return this.createErrorLineValue(e.errorCode,e.x,e.y);throw e}}throwLineError(i,e,t){return{rgError:!0,errorCode:i,x:e,y:t}}createErrorLineValue(i,e,t){const n={x:0,y:0,rotate:0},o=[{type:"M",x:0,y:0},{type:"l",dx:e,dy:t}];return{pathCommands:o,pathData:ae(o),textPosition:n,points:[]}}withLineJunctionPoints({line:i,from:e,to:t,totalLinesBetweenNodes:n,currentLineIndex:o,defaultOptions:s}){if(!e||!t)throw L("error from-to:",e,t),this.throwLineError("F",-10,0);let a=i.lineShape||1;const d=i.lineDirection||s.layoutDirection||"h";let h=e.x||0,c=e.y||0,f=t.x||0,p=t.y||0;if(Number.isNaN(h)||Number.isNaN(c))throw L("error start node:",e.text,e.x,e.y),this.throwLineError("A",-10,-10);if(Number.isNaN(f)||Number.isNaN(p))throw L("error end point:",t.text,t.x,t.y),this.throwLineError("B",10,-10);let m=e.el_W||60,u=e.el_H||60;if(Number.isNaN(m)||Number.isNaN(u))throw this.throwLineError("C",-10,10);let g=t.el_W||60,y=t.el_H||60;if(Number.isNaN(g)||Number.isNaN(y))throw this.throwLineError("D",10,10);if(h===0&&f===0&&c===0&&p===0)throw this.throwLineError("D",10,10);const v=f-h+(p-c)>0,x=i.isReverse?t:e,w=i.isReverse?e:t,k=Ce(x.nodeShape,s.defaultNodeShape),T=i.junctionOffset||s.defaultLineJunctionOffset||0;h-=T,c-=T,f-=T,p-=T,m+=T*2,u+=T*2,g+=T*2,y+=T*2;const O={from_x:h,from_y:c,to_x:f,to_y:p,f_W:m,f_H:u,t_W:g,t_H:y,nodeShape:k,isReverse:v,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:o,lineDistance:s.multiLineDistance||30},b=Ce(w.nodeShape,s.defaultNodeShape),N={from_x:f,from_y:p,to_x:h,to_y:c,f_W:g,f_H:y,t_W:m,t_H:u,nodeShape:b,isReverse:v,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:o,lineDistance:s.multiLineDistance||50},P=s.defaultJunctionPoint||W.border;let R=i.fromJunctionPoint||P,S=i.toJunctionPoint||P,M=i.fromJunctionPointOffsetX||0,C=i.fromJunctionPointOffsetY||0,E=i.toJunctionPointOffsetX||0,V=i.toJunctionPointOffsetY||0;i.isReverse&&([R,S]=[S,R],[M,C,E,V]=[E,V,M,C]),(e===t||h===0&&f===0&&c===0&&p===0)&&M===0&&C===0&&E===0&&V===0&&((a===Y.StandardStraight||a===Y.Curve2||a===Y.Curve3||a===Y.SimpleOrthogonal||a===Y.Curve5)&&(a=Y.StandardCurve),V=20);const X=this._getJunctionPoint(R,O);X.x+=M,X.y+=C;const A=this._getJunctionPoint(S,N);if(A.x+=E,A.y+=V,!X||!A)throw this.throwLineError("E",-20,-20);const G=h+m/2,$=c+u/2,J=f+g/2,ie=p+y/2;R==="horizontalLine"?(X.x=A.x,(a===44||a===49)&&(X.x+=(A.x>J?1:-1)*30)):R==="verticalLine"&&(X.y=A.y,(a===44||a===49)&&(X.y+=(A.y>ie?1:-1)*30)),S==="horizontalLine"?(A.x=X.x,(a===44||a===49)&&(A.x+=(X.x>G?1:-1)*30)):S==="verticalLine"&&(A.y=X.y,(a===44||a===49)&&(A.y+=(X.y>$?1:-1)*30));const te=X.x,ne=X.y,Q=A.x,Z=A.y;if(Number.isNaN(te)||Number.isNaN(ne))throw L("error start point:",e.text),this.throwLineError("F",-10,0);if(Number.isNaN(Q)||Number.isNaN(Z))throw L("error end point:",t.text),this.throwLineError("G",10,0);return{line:i,totalLinesBetweenNodes:n,currentLineIndex:o,lineDirection:d==="v"?"v":"h",lineShape:a,lineRadius:s.lineRadius||0,fromJunctionPoint:R,toJunctionPoint:S,fx:te,fy:ne,fcx:G,fcy:$,f_W:m,f_H:u,tx:Q,ty:Z,tcx:J,tcy:ie,t_W:g,t_H:y}}createLinePathData(i){const{lineShape:e}=i;let t;return e===Y.SimpleOrthogonal?t=Wn(i,void 0,this._getLineDefaultOptions()):e===Y.StandardOrthogonal?t=jn(i,void 0,this._getLineDefaultOptions()):e===Y.HardOrthogonal?t=qn(i,void 0,this._getLineDefaultOptions()):e===Y.StandardCurve?t=Zn(i):e===Y.Curve2||e===Y.Curve3||e===Y.Curve5||e===Y.Curve7?t=Kn(i):e===Y.Curve8?t=xo(i):t=Yn(i),t}getArrowMarkerId(i,e=!1){let t=i.showStartArrow===!0,n=i.showEndArrow!==!1;if(i.isReverse&&([t,n]=[n,t]),e){if(!t)return;if(i.startMarkerId)return`url('#${i.startMarkerId}')`}else{if(!n)return;if(i.endMarkerId)return`url('#${i.endMarkerId}')`}return`url('#${this.getLineArrow(i.color,e,!1)}')`}getLineArrow(i,e=!1,t=!1){const n=e?"start-":"";return`${this.getOptions().instanceId}-${n}arrow-default`}getTextTransform(i,e){if(!i||!e)return"translate(0,0)";const{x:t,y:n,rotate:o}=e;if(Number.isNaN(t)||Number.isNaN(n))return"translate(0,0)";const s=this.getOptions(),a=i.textOffsetX||s.defaultLineTextOffsetX||0,d=i.textOffsetY||s.defaultLineTextOffsetY||0,h=i.lineShape||1;return h===Y.StandardStraight||h===Y.SimpleOrthogonal?`translate(-50%, -50%) translate(${t+a}px,${n+d}px) rotate(${o||0}deg)`:`translate(-50%, -50%) translate(${t+a}px,${n+d}px)`}generateLineTextStyle(i,e){const t=this.getOptions(),n={transform:"",transformOrigin:"0 0"};if(!i||!e)return{cssStyles:n};const{line:o}=i,{textPosition:s}=e;if(!o||!s)return{cssStyles:n};let a=o.text||"";a.length>t.lineTextMaxLength&&(a=a.substring(0,t.lineTextMaxLength||15)+"...");const{x:d,y:h,rotate:c}=s;if(Number.isNaN(d)||Number.isNaN(h))return{text:a,cssStyles:n};const f=[],p=o.textAnchor||"center";p==="start"?f.push("translate(0%, -50%)"):p==="end"?f.push("translate(-100%, -50%)"):f.push("translate(-50%, -50%)"),f.push(`translate(${d}px,${h}px)`);const m=o.textOffsetX||t.defaultLineTextOffsetX||0,u=o.textOffsetY||t.defaultLineTextOffsetY||0,g=o.lineShape||1;return(o.useTextOnPath||t.defaultLineTextOnPath)&&g===1&&c&&f.push(`rotate(${c||0}deg)`),g===Y.StandardStraight?(n.transformOrigin="50% 50%",f.push(`translate(${m}px,${u}px)`)):f.push(`translate(${m}px,${u}px)`),n.transform=f.join(" "),{text:a,cssStyles:n}}generateLineTextStyle4TextOnPath(i){const{line:e,from:t,to:n}=i;let o=e.text;if(!o||!n||!t)return null;let s=0;const a=this.getOptions();o.length>a.lineTextMaxLength&&(o=o.substring(0,a.lineTextMaxLength||15)+"...");const d=e.textOffsetX||a.defaultLineTextOffsetX||0,h=e.textOffsetY||a.defaultLineTextOffsetY||0,c={x:d,y:h-6};let f="50%";e.placeText==="start"?(f="0%",c.x+=20):e.placeText==="end"?(f="100%",c.x-=20):e.placeText==="center"?f="50%":e.placeText&&(f=e.placeText);let p="middle";return e.textAnchor&&(p=e.textAnchor),{text:o,textOffset:c,textAnchor:p,onPathStartOffset:f,textRotate:s}}}class Lo extends Co{constructor(){super()}getClampedZoom(i){const e=this.getOptions();return Math.max(e.minCanvasZoom,Math.min(e.maxCanvasZoom,i))}applyZoom(i,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions(),o=this.getClampedZoom(i),s=o-n.canvasZoom,a=e.x!==n.canvasOffset.x||e.y!==n.canvasOffset.y;if(!(s===0&&!a))try{const d=this.emitEvent(I.beforeZoomStart,n.canvasZoom,s,t);if(L("[zoom]","abortZoom:",d),d===!0)return;const h=n.canvasZoom;this._performanceModeLogicHook(h,o),this.dataProvider.updateOptions({canvasOffset:{x:e.x,y:e.y},canvasZoom:o}),this.emitEvent(I.onZoomEnd,o,h)}finally{this._updateEditingControllerView(),this._dataUpdated()}}zoom(i,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions(),o=this.getViewBoundingClientRect(),s=this.getClampedZoom(n.canvasZoom+i);e||(e={x:o.x+o.width/2,y:o.y+o.height/2});const a=e.x-o.left,d=e.y-o.top,h=n.canvasZoom/100,c=s/100,f=a-(a-n.canvasOffset.x)*(c/h),p=d-(d-n.canvasOffset.y)*(c/h);this.applyZoom(s,{x:f,y:p},t)}setZoomAndOffset(i,e,t){this.applyZoom(i,e,t)}_performanceModeLogicHook(i,e){const t=this.getOptions();i<=40?e>40&&(t.performanceMode&&this.updateShouldRenderGraphData(!0),this.dataProvider.updateOptions({showEasyView:!1}),L("zoom:hide:showEasyView",i,e),this.updateElementLines()):i>40&&e<=40&&(L("zoom:show:showEasyView",i,e),t.performanceMode&&this.dataProvider.updateOptions({showEasyView:!0}))}setZoom(i,e){const t=this.getOptions(),n=i-t.canvasZoom;this.zoom(n,e)}}class wo extends Lo{constructor(){super()}fitContentHeight(i=20){this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated();const e=this.getOptions(),t=this.getNodesRectBox(),n=t.height,o=t.width,s=e.viewSize.width-i*2,a=t.minX+t.width/2,d=t.minY+t.height/2;this.dataProvider.setCanvasCenter(a,d);const h=Math.min(1,s/o),c=n*h+i*2;this.dataProvider.updateOptions({viewSize:{...e.viewSize,height:c},viewHeight:c+"px"}),setTimeout(()=>{this.setZoom(h*100),this._moveToCenter(),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()},200)}_moveToCenter(i){const e=this.getNodesCenter(i);this.dataProvider.setCanvasCenter(e.x,e.y),this._dataUpdated()}setCanvasCenter(i,e){this.dataProvider.setCanvasCenter(i,e),this._dataUpdated()}zoomToFit(i){const e=this.getOptions(),t=this.getCanvasSlotRectItems(),n=t.length>0?[...t,...i||this.getNodes()]:i,o=this.getNodesRectBox(n),s=50,a=e.viewSize.width/(o.width+s*2),d=e.viewSize.height/(o.height+s*2),h=Math.min(a,d,1);L("zoomToFit:",{stuffSize:o,zoomPercent:h,zoomPercentX:a,zoomPercentY:d,viewSize:e.viewSize}),this._moveToCenter(n),this.setZoom(h*100),this._dataUpdated()}async zoomToFitWithAnimation(i){this.enableCanvasAnimation(),this.zoomToFit(i),await this.sleep(330),this.disableCanvasAnimation()}async moveToCenterWithAnimation(i){this.enableCanvasAnimation(),this.moveToCenter(i),await this.sleep(330),this.disableCanvasAnimation()}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(i){const e=this.getNodeById(i);e&&this.focusNode(e)}focusRootNode(){throw new Error("focusRootNode is deprecated, please use focusNodeById instead.")}focusNode(i){L("checked:",i);const e=this.getOptions();this.setZoom(100);const t=i.width||50,n=i.height||50,o=i.x*-1+e.viewSize.width/2-t/2,s=i.y*-1+e.viewSize.height/2-n/2;this.dataProvider.setCanvasOffset(o,s),this.dataProvider.updateOptions({checkedNodeId:i.id})}}class _o extends fe{constructor(e,t,n){super(e,t,n);_(this,"rotate",0);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,L("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const o=this.layoutOptions.from;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))):(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)),this.layoutOptions.ignoreNodeSize===void 0&&(this.layoutOptions.ignoreNodeSize=!1);const s=this.layoutOptions.layoutExpansionDirection,a=s==="start"||s==="left"||s==="top"?"start":s==="end"||s==="right"||s==="bottom"?"end":"center";this.layoutOptions.layoutExpansionDirection=a,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(L("RGTreeLayout:placeNodes"),t)L("layout by root:",t);else{console.error("root is null");return}L("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;L("groupNodes:2:",n.length,n.map(s=>s.text).join(",")),this.rotate,this.networkAnalyzer.analyzeNetwork(n,this.rootNode,!1),this.placeNodesPosition(t,n);const o={x:t.x,y:t.y};this.allNodes.forEach(s=>{if(s.fixed!==!0&&!!z.isVisibleNode(s)&&(Number.isNaN(s.lot.x)&&(L("bad lot x:",s.text,s.lot.x),s.lot.x=0),Number.isNaN(s.lot.y)&&(L("bad lot y:",s.text,s.lot.y),s.lot.y=0),s!==t)){this.layoutOptions.from==="right"&&(s.lot.x=j.getFlippedX(s.lot.x,o.x)),this.layoutOptions.from==="bottom"&&(s.lot.y=j.getFlippedY(s.lot.y,o.y));const a=this.layoutOptions.from==="right"?z.getNodeXByLotX({alignItemsX:"end"},s):s.lot.x,d=this.layoutOptions.from==="bottom"?z.getNodeYByLotY({alignItemsY:"end"},s):s.lot.y;this.updateNodePosition(s,a,d)}});for(const s of this.allNodes)this.graphInstance.updateNode(s,{rgChildrenSize:s.lot.childs.length});L("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 o=Math.max(...n.map(h=>h.lot.level)),s=this.layoutOptions.from==="left"||this.layoutOptions.from==="right";this.reduceNodeRect(n,o,s),s?this.placeNodeChildrenH(n,0):this.placeNodeChildrenV(n,0);let a=e.lot.x-e.x,d=e.lot.y-e.y;this.layoutOptions.from==="right"&&(a+=e.lot.width),this.layoutOptions.from==="bottom"&&(d+=e.lot.height),n.forEach(h=>{h.fixed!==!0&&(h.lot.x-=a,h.lot.y-=d)})}buildNetwork(e,t,n){n===0&&t.push(...e);const o=[];e.forEach(s=>{if(!z.isVisibleNode(s))return;const a=this.graphInstance.getNodeIncomingNodes(s).filter(z.isVisibleNode),h=this.graphInstance.getNodeOutgoingNodes(s).filter(z.isVisibleNode).filter(f=>!t.includes(f));t.push(...h);const c=a.filter(f=>!t.includes(f));t.push(...c),s.lot.level=n,s.lot.toNodes=h,s.lot.fromNodes=c;for(const f of c.concat(h))f.lot.parent=s,o.includes(f)||o.push(f)}),o.length>0&&this.buildNetwork(o,t,n+1)}reduceNodeRect(e,t,n=!1){let o=this.layoutOptions.treeNodeGapH,s=this.layoutOptions.treeNodeGapV;const a=o,d=s,h=e.filter(c=>c.lot.level===t);for(const c of h){if(!z.isVisibleNode(c))continue;let f=c.width||c.el_W||50,p=c.height||c.el_H||50;if(c.lot.width=f,c.lot.height=p,c.lot.toNodes.length===0&&c.lot.fromNodes.length===0)c.lot.width_with_childs=f,c.lot.height_with_childs=p;else if(n){let m=0,u=0;for(const v of c.lot.fromNodes)v.lot.height_with_childs>u&&(u=v.lot.height_with_childs),m+=v.lot.width_with_childs+d;let g=0,y=0;for(const v of c.lot.toNodes)v.lot.height_with_childs>y&&(y=v.lot.height_with_childs),g+=v.lot.width_with_childs+d;this.layoutOptions.changeNodeSizeDuringLayout&&(p=0),p=Math.max(u+a/2,p/2)+Math.max(y+a/2,p/2),c.lot.width_with_childs=f+Math.max(m,g)+d,c.lot.height_with_childs=p}else{let m=0,u=0;for(const v of c.lot.fromNodes)v.lot.width_with_childs>m&&(m=v.lot.width_with_childs),u+=v.lot.height_with_childs+d;let g=0,y=0;for(const v of c.lot.toNodes)v.lot.width_with_childs>g&&(g=v.lot.width_with_childs),y+=v.lot.height_with_childs+d;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),f=Math.max(m+a/2,f/2)+Math.max(g+a/2,f/2),c.lot.width_with_childs=f,c.lot.height_with_childs=p+Math.max(u,y)+d}}t>=0&&this.reduceNodeRect(e,t-1,n)}placeNodeChildrenV(e,t){const n=this.layoutOptions.treeNodeGapH,o=this.layoutOptions.treeNodeGapV,s=n,a=o;let d=0;const h=e.filter(c=>c.lot.level===t);for(const c of h){d++;let f=c.lot.width;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),t===0&&(c.lot.groupStartX=c.lot.x+f/2-c.lot.width_with_childs/2);const p=c.lot.groupStartX,m=c.lot.y;let u=0,g=0;for(const v of c.lot.fromNodes)v.lot.width_with_childs>u&&(u=v.lot.width_with_childs);for(const v of c.lot.toNodes)v.lot.width_with_childs>g&&(g=v.lot.width_with_childs);const y=p+Math.max(u+s/2,f/2);if(c.lot.fromNodes.length>0){let v=c.lot.height+a;for(const x of c.lot.fromNodes)x.lot.groupStartX=y-x.lot.width_with_childs-s/2,x.lot.y=m+v+a,v+=x.lot.height_with_childs+a}if(c.lot.toNodes.length>0){let v=c.lot.height+a;for(const x of c.lot.toNodes)x.lot.groupStartX=y+s/2,x.lot.y=m+v+a,v+=x.lot.height_with_childs+a}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(c.lot.x=p,c.width=c.lot.width_with_childs):c.lot.x=y-c.lot.width/2:c.lot.x=p}d>0&&this.placeNodeChildrenV(e,t+1)}placeNodeChildrenH(e,t){const n=this.layoutOptions.treeNodeGapH,o=this.layoutOptions.treeNodeGapV,s=n,a=o;let d=0;const h=e.filter(c=>c.lot.level===t);for(const c of h){d++;let f=c.lot.height;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),t===0&&(c.lot.groupStartY=c.lot.y+f/2-c.lot.height_with_childs/2);const p=c.lot.groupStartY,m=c.lot.x;let u=0,g=0;for(const v of c.lot.fromNodes)v.lot.height_with_childs>u&&(u=v.lot.height_with_childs);for(const v of c.lot.toNodes)v.lot.height_with_childs>g&&(g=v.lot.height_with_childs);const y=p+Math.max(u+s/2,f/2);if(c.lot.fromNodes.length>0){let v=c.lot.width+a;for(const x of c.lot.fromNodes)x.lot.groupStartY=y-x.lot.height_with_childs-s/2,x.lot.x=m+v+a,v+=x.lot.width_with_childs+a}if(c.lot.toNodes.length>0){let v=c.lot.width+a;for(const x of c.lot.toNodes)x.lot.groupStartY=y+s/2,x.lot.x=m+v+a,v+=x.lot.width_with_childs+a}u>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(c.lot.y=p,c.height=c.lot.height_with_childs):c.lot.y=y-c.lot.height/2:c.lot.y=p}d>0&&this.placeNodeChildrenH(e,t+1)}getLevelDistance(e,t,n){if(e===0)return 0;if(e>0){let o=0;for(let s=0;s<e;s++){const a=t.get(s);o+=a+this.getLevelGap(s,n,a,e)}return o}else{let o=0;for(let s=0;s>e;s--){const a=t.get(s);o+=a+this.getLevelGap(s,n,a,e)}return-o}}getLevelGap(e,t,n,o){let s=t+(o===-1&&e===0?n/2:0);if(this.layoutOptions.levelGaps.length>0){const a=this.layoutOptions.levelGaps[Math.abs(e)];a&&(s=a)}return s}}const No=_o;class bo extends wo{constructor(){super();_(this,"_layoutTimer",null);_(this,"_layoutPromise",null);_(this,"_layoutResolve",null);_(this,"layoutor")}async doLayout(e){const t=Date.now()-this.prevAddNodeTimestamp;return t<300&&(this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated(),await Ee(300-t)),this._layoutPromise||(this._layoutPromise=new Promise(n=>{this._layoutResolve=n})),clearTimeout(this._layoutTimer),this._layoutTimer=setTimeout(async()=>{var n;try{await this._doLayout(e),this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated()}finally{(n=this._layoutResolve)==null||n.call(this),this._layoutResolve=null,this._layoutPromise=null}},50),this._layoutPromise}async _doLayout(e){this.updateNodesVisibleProperty();const t=this.getNodes();L("node size\uFF1A",t.length);let n=this.dataProvider.getRootNode();if(e&&(n=typeof e=="string"?this.getNodeById(e):e),n||(n=t[0],this._rgAsConnectArea||(L("[relation-graph]No root node, use first node as root:",n),L("[relation-graph]You can set rootNode call doLayout(rootNode | nodeId) with a node id"))),!n)throw new Error("custom rootNode not found, id:"+e);const o=this.getOptions();this.dataProvider.setRootNodeId(n?n.id:""),this.stopAutoLayout();const s=this.createLayout(o.layout,!0);if(s.layoutOptions.layoutName==="force")s.isMainLayouer=!0,s.onFinish(()=>{this.emitEvent(I.onForceLayoutFinish)}),await Ee(100),L("doLayout:start force:",t.length),s.placeNodes(t,n);else{this.enableNodeXYAnimation();let a=[];n&&(a=this.getNetworkNodesByNode(n),s.placeNodes(a,n)),L("doLayout:placeOtherNodes:all:",t.length,"mainGroupNodes:",a.length),this.placeOtherNodes(a),setTimeout(()=>{this.disableNodeXYAnimation()},300),L("doLayout:placeOtherNodes ok!")}t.forEach(a=>this.dataProvider.updateNode(a.id,{x:a.x||0,y:a.y||0,rgChildrenSize:a.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 o=[],s=[],a=this.getNodes();a.forEach(h=>{if(h.fixed===!0||e.includes(h))return;this.getNodeRelatedNodes(h).length===0?s.push(h):o.push(h)}),L("doLayout:allNodes:",a.length),L("doLayout:mainGroupNodes:",e.length),L("doLayout:notInMainGroupNodes:",o.length),L("doLayout:singleNodes:",s.length);const d=[{nodes:e}];this.placeNextNetwork(o,[...e],d),this.placeSingleNodes(s),d.push({nodes:s}),this.sortGroups(d),this._dataUpdated()}placeSingleNodes(e){if(e.length>0){const t=Math.ceil(Math.sqrt(e.length));rt(t,30,e.map(o=>({width:o.el_W,height:o.el_H,node:o})),(o,s,a)=>{const d=o.node;d.x=s,d.y=a,d.lot||(d.lot={childs:[]})}),L("[placeSingleNodes]Single nodes:",e.length)}}sortGroups(e){L("[placeSingleNodes]sortGroups groupList:",e.length,e.map(s=>s.nodes.length));const t=e.map(s=>{const a=this.getNodesRectBox(s.nodes);return{width:a.width,height:a.height,nodes:s.nodes,orignX:a.minX,orignY:a.minY}});if(t.length===0)return;const n=Math.floor(Math.sqrt(t.length))||1;rt(n,100,t,(s,a,d)=>{const h=a-s.orignX,c=d-s.orignY;L(`[placeNextNetwork]Move ${s.nodes.length} Nodes :`,h,c,s," > ");for(const f of s.nodes)this.updateNodePosition(f,f.x+h,f.y+c)},t[0].orignX,t[0].orignY)}placeNextNetwork(e,t,n){if(e.length>0){const o=this.getOptions();L("[placeNextNetwork]notPlacedNodes nodes:",e.length);const s=JSON.parse(JSON.stringify(o.layout)),a=e[0],d=this.createLayout(s);if(d.isMainLayouer=!1,L("[placeNextNetwork]layoutName:",d.layoutOptions.layoutName,"root:",a.text),d.layoutOptions.layoutName==="force"){const f=d;f.maxLayoutTimes=0}a.fixed?L("[placeNextNetwork]fixed root x,y:",a.x,a.y,a.text):(this.updateNodePosition(a,0,0),L("[placeNextNetwork]set root x,y:",a.x,a.y,a.text)),d.layoutOptions.fixedRootNode=!0;const h=this.getNetworkNodesByNode(a);L("[placeNextNetwork]thisNetworkNodes:",e.length),d.placeNodes(h,a),t.push(...h),n.push({nodes:h});const c=[];e.forEach(f=>{t.includes(f)||c.push(f)}),o.placeOtherGroup&&this.placeNextNetwork(c,t,n),this._dataUpdated()}else L("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){const e=this.getOptions();L("toggleAutoLayout:to:",e.layout.autoLayouting),e.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){var e;(e=this.layoutor)!=null&&e.start&&(L("Start force layout:"+this.layoutor.instanceId),this.layoutor.start())}stopAutoLayout(){var e;(e=this.layoutor)!=null&&e.stop&&(L("Stop force layout:"+this.layoutor.instanceId),this.layoutor.stop())}createLayout(e,t=!1){L("########createLayout:",e);const n=this.getOptions();xt(e);let o=null;if(e.layoutName==="tree"?o=new lt(e,n,this):e.layoutName==="center"?o=new dt(e,n,this):e.layoutName==="circle"?o=new ct(e,n,this):e.layoutName==="force"?o=new ke(e,n,this):e.layoutName==="fixed"?o=new ht(e,n,this):e.layoutName==="smart-tree"?o=new Fn(e,n,this):e.layoutName==="io-tree"?o=new No(e,n,this):e.layoutName==="folder"&&(o=new ft(e,n,this)),!o)throw new Error("unknown layout: "+e.layoutName);return L("########supportAutoLayout:",o.autoLayout!==void 0,e.disableAsForceLayout),this.setLayoutor(o,t,o.autoLayout!==void 0&&e.disableAsForceLayout!==!0),o}setLayoutor(e,t,n=!1){e.isMainLayouer=t,e.layoutOptions.fixedRootNode=!0,t&&(this.layoutor=e,this._updateOptions({layout:{supportAutoLayout:n}}))}}const ko=async(l,i)=>{const e=l||document.documentElement;i?await Oo(e):await Po()},Oo=async l=>{l.requestFullscreen?await l.requestFullscreen():l.mozRequestFullScreen?await l.mozRequestFullScreen():l.webkitRequestFullscreen?await l.webkitRequestFullscreen():l.msRequestFullscreen&&await l.msRequestFullscreen()},Po=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class To extends bo{constructor(){super();_(this,"_prevClickNodeTime",0);_(this,"_nodeXYMappingBeforeDrag",{});_(this,"canvasAutoMoving",e=>{const t=this.getOptions(),n=t.viewSize,o=40;let s=0,a=0;e.x<o?s=o-e.x:n.width-o<e.x&&(s=n.width-o-e.x),e.y<o?a=o-e.y:n.height-o<e.y&&(a=n.height-o-e.y);const d=s!==0||a!==0;d&&(s=Math.max(Math.min(s/5,30),-30),a=Math.max(Math.min(a/5,30),-30));const h=t.canvasOffset.x+s,c=t.canvasOffset.y+a;return this.onCanvasDragging(h,c,s,a),d});_(this,"_canvasMovingTimer");_(this,"_relayoutTaskTimer");_(this,"_onMovingWhenCreatingLine");_(this,"_step1EventTime",0);_(this,"_onCreateLineCallback");_(this,"_mouseWheelTimer");_(this,"_mouseWheelEventPrevApplyTime",0);_(this,"_mouseWheelForce",{x:0,y:0});_(this,"_fullscreenchangeHandler")}onNodeClick(e,t){if("button"in t&&t.button===2)return;if(Date.now()-this._prevClickNodeTime<200){L("[node]click abort : time < 200");return}this._prevClickNodeTime=Date.now();const n=this.getOptions();if(n.creatingLinePlot){this.onNodeClickWhenCreatingLinePlot(e);return}const o=e.disablePointEvent===void 0?n.disableNodePointEvent:e.disablePointEvent;L("[node]node click",e.text,n.creatingLinePlot,o),!t.shiftKey&&!o&&(n.checkedLineId="",this.dataProvider.updateOptions({checkedLineId:"",checkedNodeId:e.id})),this.emitEvent(I.onNodeClick,e,t),this._prevClickNodeTime=Date.now()}onNodeDragStart(e,t){if(!e||ge(t))return;const n=this.getOptions();if((e.disableDrag||n.disableDragNode)&&!(t.target&&t.target.closest(".rg-node-drag-handler"))){const g=y=>{this.onNodeClick(e,y),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 s=!1;const a=(u,g,y)=>{y.stopPropagation(),s=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.dataProvider.updateOptions({draggingNodeId:"",editingReferenceLine:{...n.editingReferenceLine,show:!1}}),this._onNodeDragEnd(e,u,g,y),c?this.emitEvent(I.onNodeDragEnd,e,y,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 d=this.getCanvasXyByViewXy(this.getViewXyByEvent(t)),h={x:e.x,y:e.y};let c=!1;this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer);let f;const p=()=>{if(!f||s)return;const u=this.getViewXyByEvent(f),g=this.getCanvasXyByViewXy(u),y=g.x-d.x,v=g.y-d.y;let x=y+h.x,w=v+h.y,k=x-h.x,T=w-h.y;const O=this.emitEvent(I.onNodeDragging,e,x,w,k,T,f);O&&(typeof O.x=="number"&&(x=O.x,k=x-h.x),typeof O.y=="number"&&(w=O.y,T=w-h.y)),this.canvasAutoMoving(u),this.draggingSelectedNodes(e,x,w,k,T),this._dataUpdated()},m=()=>{p(),this._canvasMovingTimer=requestAnimationFrame(m)};le.startDrag(t,h,a,(u,g,y,v,x)=>{c?f=x:Math.abs(u)+Math.abs(g)>4&&(L("[node]onNodeDragStart...",de(x),x),this.emitEvent(I.onNodeDragStart,e,x),c=!0,this.dataProvider.updateOptions({draggingNodeId:e.id}),this._canvasMovingTimer=requestAnimationFrame(m)),this.updateElementLines(),this._dataUpdated()})}_onNodeDragEnd(e,t,n,o){this.updateElementLines()}onLineClick(e,t){if("button"in t&&t.button===2)return;const n=this.getLinkByLineId(e.id);L("onLineClick:","line:",e,"link:",n);const o=this.getOptions();(e.disablePointEvent===void 0?o.disableLinePointEvent:e.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLine(e)),this.emitEvent(I.onLineClick,e,n,t),this._dataUpdated()}expandOrCollapseNode(e,t){t.stopPropagation(),e.expanded===!1?this.expandNode(e,t):this.collapseNode(e,t)}expandNode(e,t){L("onNodeExpand:",e),this.dataProvider.updateNode(e.id,{expanded:!0}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(I.onNodeExpand,e,t)}collapseNode(e,t){L("onNodeCollapse:",e),this.dataProvider.updateNode(e.id,{expanded:!1}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(I.onNodeCollapse,e,t)}_effectWhenExpandedOrCollapsed(e){const t=this.getDescendantNodes(e);this.updateNodesVisibleProperty([e].concat(t)),this._relayoutTaskTimer&&clearTimeout(this._relayoutTaskTimer),this._relayoutTaskTimer=setTimeout(()=>{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(I.onCanvasDragEnd,e)}onCanvasClick(e){if("button"in e&&e.button===2)return;if(this.getOptions().creatingLinePlot)this.onCanvasClickWhenCreatingLinePlot(e);else{if(this.dataProvider.isPerformanceMode()){const n=this.getNodeAtEvent(e);if(n){this.emitEvent(I.onNodeClick,n,e);return}}this.emitEvent(I.onCanvasClick,e)}}getNodeAtEvent(e){const t=this.getCanvasXyByClientXy(e);return this.dataProvider.findNodeByXy(t)}onCanvasSelectionEnd(e,t){this.emitEvent(I.onCanvasSelectionEnd,e,t),L("[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=we(JSON.parse(JSON.stringify(De)),this.getOptions()),o=de(e);this.dataProvider.updateOptions({newNodeTemplate:Object.assign({},n,t.templateNode),creatingNodePlot:!0,showTemplateNode:!o});let s=(u,g)=>{const y=this.getOptions().newNodeTemplate,v={width:y.width||50,height:y.height||50};this.dataProvider.updateOptions({newNodeTemplate:{...y,x:u-v.width/2,y:g-v.height/2}}),this._dataUpdated()};const a=this.getViewBoundingClientRect();L("[CreatingNodePlot]startCreatingNodePlot:");const d=ce(e),h=d.clientX-a.x+10,c=d.clientY-a.y+10;o||s(h,c);const f=u=>{L("[CreatingNodePlot]objectTemplateMove");const g=this.getViewXyByEvent(u);t.templateMove&&t.templateMove(g.x,g.y),s(g.x,g.y)},p=u=>{L("[CreatingNodePlot]user abort!"),this.$dom.removeEventListener("mousemove",f),this.$dom.removeEventListener("click",m),this.$dom.removeEventListener("contextmenu",p),this.dataProvider.updateOptions({creatingNodePlot:!1})},m=u=>{let g=!1;if(this.getOptions().creatingNodePlot||(g=!0),this.$dom.removeEventListener("mousemove",f),this.$dom.removeEventListener("click",m),this.$dom.removeEventListener("contextmenu",p),this.dataProvider.updateOptions({creatingNodePlot:!1}),g){L("[CreatingNodePlot]action be abort!");return}const y=ce(u),v=y.clientX-a.x+10,x=y.clientY-a.y+10;if(Math.abs(h-v)<30&&Math.abs(c-x)<30){L("[CreatingNodePlot]create node be abort!");return}const w=this.getCanvasXyByClientXy({x:y.clientX,y:y.clientY});L("[CreatingNodePlot]objectBePlaced:",w),t.onCreateNode(w.x,w.y,this.getOptions().newNodeTemplate),this._dataUpdated()};setTimeout(()=>{this.$dom.addEventListener("click",m),this.$dom.addEventListener("contextmenu",p)},300),o||this.$dom.addEventListener("mousemove",f)}startCreatingLinePlot(e,t){const n=de(e);t&&t.onCreateLine&&(this._onCreateLineCallback=t.onCreateLine);const o=he({from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},this.getOptions());t&&t.template&&Object.assign(o,t.template),this.dataProvider.updateOptions({newLineTemplate:Object.assign(o,{isReverse:t.isReverse||!1})}),this.dataProvider.updateOptions({newLineTemplate:Object.assign(o,{isReverse:t.isReverse||!1,disablePointEvent:!0}),creatingLinePlot:!0});const s=Object.assign({},this.getOptions().newLinkTemplate,{fromNode:null,toNode:{id:"",targetType:D.Node,x:0,y:0,el_W:2,el_H:2},toNodeObject:null});t&&t.fromNode&&(s.toNode.x=t.fromNode.x+50,s.toNode.y=t.fromNode.y+50,s.fromNode=t.fromNode,this._step1EventTime=Date.now()),this.dataProvider.updateOptions({newLinkTemplate:s}),L("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),n||(L("[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(){L("[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){L("[CreatingLinePlot]mousemove");const t=this.getCanvasXyByClientXy({x:e.clientX,y:e.clientY}),n=this.getOptions(),o=e.target;let s="",a=D.Node;const d=this.isNode(o);let h=!1,c={x:0,y:0,el_W:5,el_H:5,nodeShape:0};d&&(s=d.id,d===this.getOptions().newLinkTemplate.fromNode?this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}):(this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:d,show:!0}}),this._updateEditingConnectControllerView()));const f=o.closest(".rg-connect-ctl-handler");if(f){let p=this.getOptions().nodeConnectController.node;L("[CreatingLinePlot]content point:",f.dataset.point);let m=f.dataset.point||"border";if(f.classList.contains("rg-connect-target")){const{width:u,height:g,x:y,y:v}=f.getBoundingClientRect(),x=this.getCanvasXyByClientXy({x:y,y:v}),w=this.dataProvider.getCanvasScale(),k={x:x.x,y:x.y,el_W:u/w,el_H:g/w,nodeShape:1,id:f.dataset.targetId,targetData:JSON.parse(f.dataset.targetData||"{}"),targetType:f.dataset.targetType};h=!0,c.x=k.x,c.y=k.y,c.el_W=k.el_W,c.el_H=k.el_H,c.nodeShape=k.nodeShape,this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:k,show:!1}}),m=f.dataset.point,n.newLinkTemplate.toNode&&(s=k.id,a=k.targetType,this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,nodeShape:k.nodeShape}}})),this._updateEditingConnectControllerView()}else p&&(a=D.Node,h=!0,c.x=p.x,c.y=p.y,c.el_W=p.el_W,c.el_H=p.el_H,c.nodeShape=p.nodeShape,o.dataset.innode==="true"&&(c.x=t.x,c.y=t.y,c.el_W=2,c.el_H=2,c.nodeShape=1));n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:m}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:m}})}else L("[CreatingLinePlot]point:",o.dataset.point),n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:W.border}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:W.border}}),n.newLinkTemplate.toNode&&(a=D.Node);n.newLinkTemplate.toNode&&(s&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,id:s}}}),this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,targetType:a}}})),n.newLinkTemplate.fromNode&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,x:h?c.x:t.x,y:h?c.y:t.y,el_W:c.el_W,el_H:c.el_H,nodeShape:c.nodeShape}}}),this._dataUpdated()}onCanvasClickWhenCreatingLinePlot(e){if(Date.now()-this._step1EventTime<500){L("[CreatingLinePlot]step1EventTime:",this._step1EventTime);return}const t=this.getOptions();if(!t.newLinkTemplate.fromNode){L("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let n=!1;if(!t.newLinkTemplate.toNodeObject){L("[CreatingLinePlot]CreatingLinePlot:toNodeObject not set!");const o=ce(e),s=this.getCanvasXyByClientXy({x:o.clientX,y:o.clientY});n=this.onReadyToCreateLine(t.newLinkTemplate.fromNode,s)}n!==!0&&this.stopCreatingLinePlot()}onNodeClickWhenCreatingLinePlot(e){const t=this.getOptions();t.newLinkTemplate.fromNode?(L("[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()):(L("[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){L("[CreatingLinePlot][fire-event]onCreateLine:",e,t);const n=this.getOptions(),o=he(n.newLineTemplate,this.getOptions());n.newLineTemplate.isReverse?(o.from=t?t.id:"",o.to=e?e.id:"",o.isReverse=void 0,[e,t]=[t,e]):(o.from=e?e.id:"",o.to=t?t.id:""),o.disablePointEvent=!1;const s=this.emitEvent(I.beforeCreateLine,{lineJson:o,fromNode:e,toNode:t});if(L("[CreatingLinePlot]onCreateLine:abort-flag:",s),s===!0){L("[CreatingLinePlot]onCreateLine:abort!");return}if(this._onCreateLineCallback){L("[CreatingLinePlot]onCreateLine:callback");try{this._onCreateLineCallback(e,t,o)}catch(d){return console.warn("[Custom Reject Connect By Throw Error:",d),!1}}return L("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(I.onLineBeCreated,{lineJson:o,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")),L("contextmenu:objectType",t,n);const o=ce(e),s=this.getCanvasXyByClientXy({x:o.clientX,y:o.clientY}),a=this.getViewXyByCanvasXy(s);this.emitEvent(I.onContextmenu,e,t,n,s,a)}async fullscreen(e){const t=this.getOptions();if(e!==void 0&&e===t.fullscreen)return;L("fullscreen:newValue:",e),e===void 0&&(e=!t.fullscreen);let n=this.$dom;t.fullscreenElementXPath&&(n=document.querySelector(t.fullscreenElementXPath)||this.$dom),await ko(n,e),this.dataProvider.updateOptions({fullscreen:e}),this.emitEvent(I.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:o,deltaMode:s}=e;s===1?(n*=40,o*=40):s===2&&(n*=800,o*=800),this._mouseWheelForce.x+=n,this._mouseWheelForce.y+=o,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 o=e.ctrlKey||e.metaKey,s=this.getOptions();if(!o&&s.wheelEventAction==="scroll"){let a=Math.max(Math.abs(t),Math.abs(n));const d=t/a,h=n/a;a>200&&(a=200);const c=s.mouseWheelSpeed/10*-d*a,f=s.mouseWheelSpeed/10*-h*a,p=this.emitEvent(I.beforeScrollStart,c,f,e);if(L("[scroll]","abortScroll:",p),p===!0)return;this.scrollView(c,f)}else if(!(!o&&s.wheelEventAction==="none")){const a={x:e.clientX,y:e.clientY};let d=s.mouseWheelSpeed/20*-n;d=Math.max(Math.min(d,20),-20),this.zoom(d,a,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){L("onLineDragStart...");const n=this.getLinkByLine(e),o={x:n.fromNode.x,y:n.fromNode.y},s={x:n.toNode.x,y:n.toNode.y},a=(d,h,c,f,p)=>{const m=this.dataProvider.getCanvasScale();n.fromNode.x=o.x+d/m,n.fromNode.y=o.y+h/m,n.toNode.x=s.x+d/m,n.toNode.y=s.y+h/m,this._updateEditingControllerView(),this._dataUpdated()};le.startDrag(t,{x:0,y:0},(...d)=>{this.onLineDragEnd(...d)},a)}onLineDragEnd(e,t,n){L("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(e){if(ge(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(de(e)){let f,p,m,u,g,y=0,v=100;const x=N=>{if("touches"in N&&N.touches.length>0)return N.touches;if("targetTouches"in N&&N.targetTouches.length>0)return N.targetTouches},w=N=>({x:N.clientX,y:N.clientY}),k=(N,P)=>Math.hypot(P.x-N.x,P.y-N.y),T=(N,P)=>({x:(N.x+P.x)/2,y:(N.y+P.y)/2}),O=(N,P)=>{if(f="pan",P)p={x:P.touch.x,y:P.touch.y},m={x:P.offset.x,y:P.offset.y};else{p=w(N);const R=this.getOptions();m={x:R.canvasOffset.x,y:R.canvasOffset.y}}},b=(N,P)=>{f="pinch";const R=w(N),S=w(P),M=this.getOptions();y=k(R,S),v=M.canvasZoom,g={x:M.canvasOffset.x,y:M.canvasOffset.y},u=this.getViewXyByClientXy(T(R,S))};n=(N,P,R,S,M)=>{const C=x(M);if(!(!C||C.length===0))if(M.cancelable&&M.preventDefault(),C.length>1){const E=C[0],V=C[1];f!=="pinch"&&b(E,V);const X=w(E),A=w(V),G=k(X,A);if(!u||!g||y<=0||G<=0){b(E,V);return}const $=this.getViewXyByClientXy(T(X,A)),J=G-y,ie=$.x-u.x,te=$.y-u.y;if(Math.abs(J)<6&&Math.abs(ie)<2&&Math.abs(te)<2)return;const ne=G/y,Q=Math.pow(ne,.85),Z=v*Q,oe=v/100,q=this.getClampedZoom(Z)/100,F=$.x-(u.x-g.x)*(q/oe),gs=$.y-(u.y-g.y)*(q/oe);this.setZoomAndOffset(Z,{x:F,y:gs})}else{const E=C[0];if(f!=="pan"&&O(E,f===void 0?{touch:S,offset:R}:void 0),!p||!m){O(E);return}const V=w(E),X=V.x-p.x,A=V.y-p.y,G=m.x+X,$=m.y+A;this.onCanvasDragging(G,$,X,A),this._updateEditingControllerView(),this._dataUpdated()}}}else n=(d,h,c,f,p)=>{const m=c.x+d,u=c.y+h;this.onCanvasDragging(m,u,d,h),this._updateEditingControllerView(),this._dataUpdated()};const o=this.getOptions(),s={x:o.canvasOffset.x,y:o.canvasOffset.y};let a=t;le.startDrag(e,s,(d,h,c)=>{this.onCanvasDragStop(d,h,c)},(d,h,c,f,p)=>{const m="touches"in p&&p.touches?p.touches.length:0;a||(m>1||Math.abs(d)+Math.abs(h)>4)&&(this.emitEvent(I.onCanvasDragStart,c,f,p),a=!0),a&&n(d,h,c,f,p)})}onCanvasDragging(e,t,n,o){const s=this.emitEvent(I.onCanvasDragging,e,t,n,o);s!==!1&&(s&&(typeof s.x=="number"&&(e=s.x),typeof s.y=="number"&&(t=s.y)),this.dataProvider.setCanvasOffset(e,t))}onCanvasDragStop(e,t,n){const o=this.getOptions();if(o.creatingSelection){this.dataProvider.updateOptions({creatingSelection:!1}),this.onCanvasSelectionEnd(o.selectionView,n);return}if(Math.abs(e)+Math.abs(t)<4){L("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else L("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(e){const t=()=>{if(!n||s)return;const c=this.getViewXyByEvent(n);this.canvasAutoMoving(c)&&this._updateEditingControllerView();const p=this.getViewXyByCanvasXy(a),m=c.x-p.x,u=c.y-p.y;m<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:p.x+m,width:Math.abs(m)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:p.x,width:Math.abs(m)}}),u<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:p.y+u,height:Math.abs(u)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:p.y,height:u}}),this._dataUpdated()};let n,o=!1,s=!0;const a=this.getCanvasXyByViewXy(this.getViewXyByEvent(e)),d=()=>{t(),this._canvasMovingTimer=requestAnimationFrame(d)},h=(c,f,p,m,u)=>{if(n=u,o)n=u;else if(Math.abs(c)+Math.abs(f)>6){o=!0,s=!1;const g=this.getOptions();g.selectionView.width=5,g.selectionView.height=5,this.dataProvider.updateOptions({creatingSelection:!0}),this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this._canvasMovingTimer=requestAnimationFrame(d)}this._dataUpdated()};le.startDrag(e,{x:0,y:0},(...c)=>{s=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.onCanvasDragStop(...c)},h)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let e=!1;document.fullscreenElement?(L("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(L("relation-graph is fullscreen!"),e=!0)):L("div exited fullscreen mode"),e!==this.getOptions().fullscreen&&(this.dataProvider.updateOptions({fullscreen:e}),this._dataUpdated(),setTimeout(async()=>{this.resetViewSize(),this._moveToCenter(),this.zoomToFit(),L("relation-graph reset complete!")},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}defaultLineConnectEndHandler(e,t,n){L("defaultLineConnectEndHandler:",e,t,n)}defaultLineVertexBeChangedHandler(e,t,n){L("defaultLineVertexBeChangedHandler:",n&&n.isReverse)}async sleep(e){await Ee(e)}forceLayoutTickCallback(){this._updateEditingControllerView(),this.dataProvider.updateShouldRenderGraphData(),this._dataUpdated()}}class So extends To{constructor(){super();_(this,"$easyViewCanvas");_(this,"$rgWebglPainter");_(this,"_updateEasyViewRequested",!1);_(this,"_easyViewOffset",{x:0,y:0})}setEasyViewCanvas(e){this.$easyViewCanvas=e,this.$rgWebglPainter=new kn(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);const o=this.dataProvider.getCanvasScale();this.$rgWebglPainter.setScale(o),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 o=Ce(t.nodeShape,e);this.evDrawNode(t,o)}}evDrawNode(e,t){t===xe.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,o=e.opacity||.8,s=this.getNodeColor(e),a=e.borderRadius===void 0?3:e.borderRadius,d=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Rect(e.x,e.y,t,n,s,o,a,d)}evDrawNode4Circle(e){const t=e.el_W,n=e.el_H,o=e.opacity||.8,s=this.getNodeColor(e),a=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Circle(e.x,e.y,t,n,s,o,a)}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),o=t.opacity||1,s=this.getOptions(),a=t.color||s.defaultLineColor||"#888888",d=t.lineWidth||s.defaultLineWidth||1;this.$rgWebglPainter.evDrawLine(n.pathData,d,a,o)}}class Ro extends So{constructor(){super();_(this,"_onResizing");_(this,"_onResizeEnd");_(this,"_startPoint",{x:0,y:0});_(this,"_startEventCanvasXy",{x:0,y:0});_(this,"_startSizeCanvasXy",{x:0,y:0});_(this,"_startSize",{x:0,y:0,width:0,height:0,widthOnCanvas:0,heightOnCanvas:0});_(this,"_resizeType","l");_(this,"_nodeStartSizeMap",new WeakMap);_(this,"resizeMinLimit",{width:10,height:10});_(this,"_resizeDraggingTimer");_(this,"_resizeDraggingEvent");_(this,"_resizeDraggingStoped",!0);_(this,"_startCreateLineFromNodeTime",0)}setEditingNodes(e){if(e===null||e.length===0)this.dataProvider.setEditingNodes([]);else{const t=e.map(o=>o.id),n=this.getNodes().filter(o=>t.includes(o.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:o,maxY:s}=this.getNodesRectBox(e.editingController.nodes),a=e.editingController.nodes.length>1?5:0,d=this.dataProvider.getCanvasScale();let h=o-t,c=s-n;if(h<0&&(h=0),c<0&&(c=0),h>0&&c>0){const f=this.getViewXyByCanvasXy({x:t,y:n}),p=f.x-a*d,m=f.y-a*d,u=h*d+a*2*d,g=c*d+a*2*d;this.dataProvider.updateOptions({editingController:{...e.editingController,x:p,y:m,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 o=this.dataProvider.getCanvasScale();this._startSize.widthOnCanvas=n.editingController.width/o,this._startSize.heightOnCanvas=n.editingController.height/o;for(const d of n.editingController.nodes)this._nodeStartSizeMap.set(d,{x:d.x,y:d.y,width:d.el_W,height:d.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 s=this.onResizingRequest.bind(this),a=()=>{s(),this._resizeDraggingTimer=requestAnimationFrame(a)};this._resizeDraggingTimer=requestAnimationFrame(a),this.emitEvent(I.onResizeStart,n.editingController.nodes,t)}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),o=e.x-t.x,s=e.y-t.y,a=this.getOptions();let d=a.editingController.width,h=a.editingController.height,c=a.editingController.x,f=a.editingController.y;const p=this.dataProvider.getCanvasScale();this._resizeType==="tl"?(c=t.x+o,f=t.y+s,d=this._startSize.widthOnCanvas*p-o,h=this._startSize.heightOnCanvas*p-s):this._resizeType==="tr"?(f=t.y+s,c=n.x,d=this._startSize.widthOnCanvas*p+o,h=this._startSize.heightOnCanvas*p-s):this._resizeType==="bl"?(c=t.x+o,f=n.y,d=this._startSize.widthOnCanvas*p-o,h=this._startSize.heightOnCanvas*p+s):this._resizeType==="br"?(c=n.x,f=n.y,d=this._startSize.widthOnCanvas*p+o,h=this._startSize.heightOnCanvas*p+s):this._resizeType==="t"?(f=t.y+s,h=this._startSize.heightOnCanvas*p-s):this._resizeType==="r"?(c=n.x,d=this._startSize.widthOnCanvas*p+o):this._resizeType==="b"?(h=this._startSize.heightOnCanvas*p+s,f=n.y):this._resizeType==="l"&&(c=t.x+o,d=this._startSize.widthOnCanvas*p-o),d<this.resizeMinLimit.width&&(d=this.resizeMinLimit.width),h<this.resizeMinLimit.width&&(h=this.resizeMinLimit.height),this.dataProvider.updateOptions({editingController:{...a.editingController,x:c,y:f,width:d,height:h}}),this._applyResizeScale(this._resizeDraggingEvent),this._updateEditingControllerView(),this._dataUpdated()}_applyResizeScale(e){const t=this.getOptions(),n=this.dataProvider.getCanvasScale(),o=t.editingController.width/n/this._startSize.widthOnCanvas,s=t.editingController.height/n/this._startSize.heightOnCanvas,a=this._startSizeCanvasXy,d=this.getCanvasXyByViewXy({x:t.editingController.x,y:t.editingController.y});let h=!0,c=!0;this._resizeType==="t"||this._resizeType==="b"?h=!1:(this._resizeType==="r"||this._resizeType==="l")&&(c=!1);for(const f of t.editingController.nodes){const p=this._nodeStartSizeMap.get(f),m=p.width*o,u=p.height*s,g=d.x+o*(p.x-a.x),y=d.y+s*(p.y-a.y),v=m,x=u;this.emitEvent(I.beforeNodeResize,f,g,y,v,x)===!1||(h&&this.dataProvider.updateNode(f.id,{x:g,width:v,el_W:v}),c&&this.dataProvider.updateNode(f.id,{y,height:x,el_H:x}))}}onResizeEnd(e){cancelAnimationFrame(this._resizeDraggingTimer),this._resizeDraggingStoped=!0;const t=this.getViewXyByEvent(e),n=t.x-this._startPoint.x,o=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,L("onResizeEnd:",this.getOptions().editingController.nodes,n,o),this.emitEvent(I.onResizeEnd,this.getOptions().editingController.nodes,n,o,e)}draggingSelectedNodes(e,t,n,o,s){const a=this.updateReferenceLineView(e,t,n,o,s);if(a){const{showV:h,fixedX:c,showH:f,fixedY:p}=a;h&&(o+=c-t,t=c),f&&(s+=p-n,n=p)}const d=this.getOptions();if(!d.editingController.nodes.includes(e))this.dataProvider.updateNode(e.id,{x:t,y:n}),this._updateEditingLineView();else{for(const h of d.editingController.nodes){const c=this._nodeXYMappingBeforeDrag[h.id];c&&this.dataProvider.updateNode(h.id,{x:c.x+o,y:c.y+s})}this._updateEditingControllerView()}}_updateEditingConnectControllerView(){const e=this.getOptions();if(!e.nodeConnectController.show)return;const t=e.nodeConnectController.node,n=t.x,o=t.y,s=t.x+t.el_W,a=t.y+t.el_H,d=0,h=this.dataProvider.getCanvasScale(),c=n,f=o,p=s-n,m=a-o,u=this.getViewXyByCanvasXy({x:c,y:f});this.dataProvider.updateOptions({nodeConnectController:{...e.nodeConnectController,x:u.x-d*h,y:u.y-d*h,width:p*h+d*2*h,height:m*h+d*2*h}})}setEditingLine(e){this.dataProvider.setEditingLine(e),this._updateEditingLineView(),this._dataUpdated()}updateReferenceLineView(e,t,n,o,s){const a=this.getOptions();if(!a.showReferenceLine)return;if(!a.editingReferenceLine.show){const M=Math.abs(o),C=Math.abs(s);M+C>2&&this.dataProvider.updateOptions({editingReferenceLine:{...a.editingReferenceLine,show:!0}})}if(!a.editingReferenceLine.show)return;const d=t,h=e.el_W,c=e.el_H,f=t+h/2,p=t+h,m=n,u=n+c/2,g=n+c,y=this.getViewXyByCanvasXy({x:f,y:u});let v=!1,x=!1,w=0,k=0;const T=this.getNodes().filter(M=>this._nodeXYMappingBeforeDrag[M.id]?!1:Math.abs(M.x-f)<600&&Math.abs(M.y-u)<600);T.sort((M,C)=>{const E=me(f,u,M.x+M.el_W/2,M.y+M.el_H/2),V=me(f,u,C.x+C.el_W/2,C.y+C.el_H/2);return E<V?-1:1});let{v_x:O,v_y:b,v_height:N,h_x:P,h_y:R,h_width:S}=a.editingReferenceLine;for(const M of T){const C=M.x,E=M.el_W,V=M.el_H,X=M.x+E/2,A=M.x+E,G=M.y,$=M.y+V/2,J=M.y+V,ie=Math.abs(d-C),te=Math.abs(f-X),ne=Math.abs(p-A),Q=Math.abs(m-G),Z=Math.abs(u-$),oe=Math.abs(g-J),q=5;if(te<800&&Z<800){if(!x&&te<q){const F=this.getViewXyByCanvasXy({x:X,y:$});O=F.x,b=y.y>F.y?F.y:y.y,N=Math.round(Math.abs(y.y-F.y)),x=!0,w=X-h/2}if(!x&&ie<q){const F=this.getViewXyByCanvasXy({x:C,y:$});O=F.x,b=y.y>F.y?F.y:y.y,N=Math.round(Math.abs(y.y-F.y)),x=!0,w=C}if(!x&&ne<q){const F=this.getViewXyByCanvasXy({x:A,y:$});O=F.x,b=y.y>F.y?F.y:y.y,N=Math.round(Math.abs(y.y-F.y)),x=!0,w=A-h}if(!v&&Z<q){const F=this.getViewXyByCanvasXy({x:X,y:$});R=F.y,P=y.x>F.x?F.x:y.x,S=Math.round(Math.abs(y.x-F.x)),v=!0,k=$-c/2}if(!v&&Q<q){const F=this.getViewXyByCanvasXy({x:X,y:G});R=F.y,P=y.x>F.x?F.x:y.x,S=Math.round(Math.abs(y.x-F.x)),v=!0,k=G}if(!v&&oe<q){const F=this.getViewXyByCanvasXy({x:X,y:J});R=F.y,P=y.x>F.x?F.x:y.x,S=Math.abs(y.x-F.x),v=!0,k=J-c}if(v&&x)break}}if(this.dataProvider.updateOptions({editingReferenceLine:{...a.editingReferenceLine,v_x:O,v_y:b,v_height:N,h_x:P,h_y:R,h_width:S,directionH:v,directionV:x}}),a.referenceLineAdsorption)return{showV:x,fixedX:w,showH:v,fixedY:k}}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 o,s,a;const d=this.createLineDrawInfo(n,t);if(!d){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}if(t.lineShape===Y.StandardOrthogonal){let{textPosition:k,pathData:T,points:O,startDirection:b,endDirection:N}=d;a=k,o=O[0],s=O[O.length-1];const P=[];for(let R=0;R<O.length-1;R++){const S=O[R],M=O[R+1],C={pIndex:R,optionName:"cp-"+R,x:0,y:0,direction:"v",startDirection:b,endDirection:N};S.x!==M.x&&(C.direction="h");const E=this.getViewXyByCanvasXy({x:(S.x+M.x)/2,y:(S.y+M.y)/2});C.x=E.x,C.y=E.y,P.push(C)}if(P.length!==1){if(P.length!==2)if(P.length===3){const R=O[0],S=O[1],M=O[3];if(P[1].direction==="v"){const C=R.x,E=S.x,V=M.x;if(Math.max(C,E,V)!==E&&Math.min(C,E,V)!==E)P[1].optionName="cx";else{const A=Math.abs(E-C),G=Math.abs(E-V);A>=G?P[1].optionName="td":A<G&&(P[1].optionName="fd")}}else{const C=R.y,E=S.y,V=M.y;if(Math.max(C,E,V)!==E&&Math.min(C,E,V)!==E)P[1].optionName="cy";else{const A=Math.abs(E-C),G=Math.abs(E-V);A>=G?P[1].optionName="td":A<G&&(P[1].optionName="fd")}}}else P.length===4?(P[1].optionName="fd",P[2].optionName="td"):P.length===5&&(P[1].optionName="fd",P[2].direction==="v"?P[2].optionName="cx":P[2].optionName="cy",P[3].optionName="td")}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:P,line49Points:O}})}else if(t.lineShape===Y.HardOrthogonal){let{textPosition:k,pathData:T,points:O,startDirection:b,endDirection:N}=d;a=k;const P=[];O=t.ctrlPointsFor49,o=O[0],s=O[O.length-1];const R=O;for(let S=0;S<R.length-1;S++){const M=R[S],C=R[S+1],E={pIndex:S,optionName:"cp-"+S,x:0,y:0,direction:"v",startDirection:b,endDirection:N};M.x!==C.x?(E.direction="h",Math.abs(M.x-C.x)<15&&(E.hide=!0)):Math.abs(M.y-C.y)<15&&(E.hide=!0);const V=this.getViewXyByCanvasXy({x:(M.x+C.x)/2,y:(M.y+C.y)/2});E.x=V.x,E.y=V.y,P.push(E)}for(let S=0;S<P.length;S++){const M=P[S-1],C=P[S],E=P[S+1];S===0&&C.direction===E.direction&&(C.hide=!0),S===P.length-1&&C.direction===M.direction&&(C.hide=!0)}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:P,line49Points:R}})}else if(t.lineShape!==1){a=d.textPosition;const k=pt(d.pathData);let T,O;t.isReverse?(o=k.endPoint,s=k.startPoint,T=this.getViewXyByCanvasXy(k.ctrl1),O=this.getViewXyByCanvasXy(k.ctrl2)):(o=k.startPoint,s=k.endPoint,T=this.getViewXyByCanvasXy(k.ctrl1),O=this.getViewXyByCanvasXy(k.ctrl2)),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,ctrlPoint1:T,ctrlPoint2:O}})}else{a=d.textPosition;const k=d.pathData,T=pt(k);o=T.startPoint,s=T.endPoint}const h=this.getViewXyByCanvasXy(t.isReverse?s:o),c=this.getViewXyByCanvasXy(t.isReverse?o:s);this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,startPoint:h,endPoint:c}});const f=this.getViewXyByCanvasXy(a),p=this.$canvasDom.querySelector(`g[data-id='${t.id}']`);let m=0,u=0,g=t.textOffsetX||0,y=t.textOffsetY||0;const v=this.dataProvider.getCanvasScale();let x=20,w=20;if(p){const k=p.querySelector("text.rg-line-text");if(k){g=Math.floor(parseFloat(k.getAttribute("x")||"0")),y=Math.floor(parseFloat(k.getAttribute("y")||"0"));const T=k.clientWidth,O=k.clientHeight;x=T,w=O}}x+=40,w+=10,x>120&&(x=120),w>20&&(w=20),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,text:{...this.getOptions().editingLineController.text,width:x,height:w,x:f.x+m+g*v,y:f.y+u+y*v}}})}startMoveLineVertex(e,t,n){t.stopPropagation();const o=this.getOptions().editingLineController.line,s=this.getLinkByLine(o);let a,d;if(s)a=s.fromNode,d=s.toNode;else{const{from:f,to:p}=this.generateFakeLineConfig(o);a=f,d=p}let h=a;this.dataProvider.setEditingLine(null),s?this.removeLine(o):this.removeFakeLine(o);let c=!1;o.lineShape===Y.HardOrthogonal&&(o.lineShape=Y.StandardOrthogonal),e==="start"?(o.fromJunctionPointOffsetX=0,o.fromJunctionPointOffsetY=0,h=d,c=!0):(o.toJunctionPointOffsetX=0,o.toJunctionPointOffsetY=0),this.startCreatingLinePlot(t,{template:o,fromNode:h,isReverse:c,onCreateLine:n})}startCreateLineFromNode(e,t,n,o){n.stopPropagation();const s=JSON.parse(JSON.stringify(t));if(this._startCreateLineFromNodeTime=Date.now(),!s.from){if(!e){const d=this.getOptions().editingController.nodes;d.length===1&&(e=d[0])}e&&(s.from=e.id,s.fromType=e.targetType)}if(!s.from)throw console.error("Error:lineTemplate:",s),Error("Error:startCreateLineByTemplate: lineTemplate must has [fromType, from]");const a=this.getFakeLineTarget(s.fromType,s.from,s);if(!a)throw console.error("Error:fakeTarget[fromType, from]:",s.fromType,s.from,s),Error(`Error:startCreateLineByTemplate: error from fakeTarget[fromType, from]:${s.fromType}, ${s.from}`);s.lineShape||(s.lineShape=6),this.startCreatingLinePlot(n,{template:s,fromNode:a,isReverse:!1,onCreateLine:o})}onLineVertexBeDropped(e,t,n={x:0,y:0},o){t.stopPropagation();const s=this.getOptions();if(!s.creatingLinePlot||Date.now()-this._startCreateLineFromNodeTime<500)return;const a=s.nodeConnectController.node;let{toJunctionPoint:d,toJunctionPointOffsetX:h,toJunctionPointOffsetY:c,fromJunctionPoint:f,fromJunctionPointOffsetX:p,fromJunctionPointOffsetY:m}=s.newLineTemplate;if(!s.newLinkTemplate.fromNode)s.newLineTemplate.isReverse?(d=e,h=n.x,c=n.y):(f=e,p=n.x,m=n.y),this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:f,fromJunctionPointOffsetX:p,fromJunctionPointOffsetY:m,toJunctionPoint:d,toJunctionPointOffsetX:h,toJunctionPointOffsetY:c},newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:a}});else{s.newLineTemplate.isReverse?(f=e,p=n.x,m=n.y):(d=e,h=n.x,c=n.y);const u=this.getOptions().newLinkTemplate.fromNode;this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:f,fromJunctionPointOffsetX:p,fromJunctionPointOffsetY:m,toJunctionPoint:d,toJunctionPointOffsetX:h,toJunctionPointOffsetY:c},newLinkTemplate:{...this.getOptions().newLinkTemplate,toNodeObject:a}});const g=a;try{const y={newLineTemplate:this.getOptions().newLineTemplate,fromNode:u,toNode:g};this.emitEvent(I.onLineVertexDropped,y),o&&o(y.fromNode,y.toNode,y.newLineTemplate),this.onReadyToCreateLine(this.getOptions().newLinkTemplate.fromNode,this.getOptions().nodeConnectController.node)!==!0&&this.stopCreatingLinePlot()}catch(y){this.stopCreatingLinePlot(),console.warn("[Custom Reject onCreateLine By Throw Error:",y)}}}startMoveLineText(e,t){if(ge(e))return;const n=this.getViewXyByEvent(e),s=this.getOptions().editingLineController.line,a=s.textOffsetX||0,d=s.textOffsetY||0;let h=!1;const c=p=>{const m=this.dataProvider.getCanvasScale(),u=this.getViewXyByEvent(p),g=u.x-n.x,y=u.y-n.y;(g>0||y>0)&&(h=!0);const v=Math.round(a+g/m),x=Math.round(d+y/m);this.dataProvider.updateLine(s.id,{textOffsetX:v,textOffsetY:x}),this._updateEditingLineView(),this._dataUpdated()},f=p=>{this.$dom.removeEventListener("mousemove",c),this.$dom.removeEventListener("mouseup",f),h&&t&&t(),this._dataUpdated()};this.$dom.addEventListener("mousemove",c),this.$dom.addEventListener("mouseup",f)}startMoveLine6CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const a=this.getOptions().editingLineController.line;let d=a.ctrlPoints||[];d.length===0&&(d.push({x:0,y:0}),d.push({x:0,y:0})),this.dataProvider.updateLine(a.id,{ctrlPoints:d}),d=a.ctrlPoints,a.isReverse&&(e=d.length-1-e);const h=this.dataProvider.getCanvasScale(),c=d[e],{x:f,y:p}=c,m=()=>{n(a),this._dataUpdated()};le.startDrag(t,{x:0,y:0},m,(u,g)=>{c.x=f+u/h,c.y=p+g/h,this.dataProvider.updateLine(a.id,{ctrlPoints:d}),this._updateEditingLineView(),this._dataUpdated()})}startMoveLine44CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const s=this.getOptions().editingLineController,a=s.line;let d=a.ctrlOptionsFor44;d||(d={cx:0,cy:0,fd:0,td:0},this.dataProvider.updateLine(a.id,{ctrlOptionsFor44:d}),d=a.ctrlOptionsFor44);const h=d[e.optionName],c={indexOffset:0};let f=a.ctrlPointsFor49?JSON.parse(JSON.stringify(a.ctrlPointsFor49)):null;const p=(u,g)=>{const y=this.dataProvider.getCanvasScale();if(a.lineShape===Y.StandardOrthogonal){if(e.optionName==="cx"){const x=h+u/y*1;d.cx=x,this.dataProvider.updateLine(a.id,{ctrlOptionsFor44:d})}else if(e.optionName==="cy"){const x=h+g/y*1;d.cy=x,this.dataProvider.updateLine(a.id,{ctrlOptionsFor44:d})}else if(e.optionName==="fd"){const v=Se[e.startDirection],x=e.direction==="v"?u*v.x:g*v.y;d.fd=h+x/y,this.dataProvider.updateLine(a.id,{ctrlOptionsFor44:d})}else if(e.optionName==="td"){const v=Se[e.endDirection],x=e.direction==="v"?u*v.x:g*v.y;d.td=h+x/y,this.dataProvider.updateLine(a.id,{ctrlOptionsFor44:d})}else if(e.direction==="v"&&Math.abs(u)>5||e.direction==="h"&&Math.abs(g)>5){const v=s.line49Points;f=JSON.parse(JSON.stringify(v)),this.dataProvider.updateLine(a.id,{ctrlPointsFor49:f}),this.dataProvider.updateLine(a.id,{lineShape:Y.HardOrthogonal})}}else if(a.lineShape===Y.HardOrthogonal){const{newPoints:v,pointsChanged:x}=$n(a.ctrlPointsFor49,f,e.pIndex+c.indexOffset,e,c,u/y,g/y);x&&(f=JSON.parse(JSON.stringify(v))),this.dataProvider.updateLine(a.id,{ctrlPointsFor49:v})}},m=()=>{if(a.lineShape===Y.HardOrthogonal){const u=Re(a.ctrlPointsFor49);this.dataProvider.updateLine(a.id,{ctrlPointsFor49:u})}this._updateEditingLineView(),n&&n(a),this._dataUpdated()};le.startDrag(t,{x:0,y:0},m,(u,g)=>{p(u,g),this._updateEditingLineView(),this._dataUpdated()})}onLineVertexBeDroppedOnConnectController(e,t,n,o){if(L("onLineVertexBeDroppedOnConnectController",e,t,n),t.stopPropagation(),!n){this.onLineVertexBeDropped(e,t,void 0,o);return}const s=ce(t),a=n.getBoundingClientRect(),d={x:a.left,y:a.top+a.height/2},h={x:a.left+a.width/2,y:a.top},c={x:a.left+a.width,y:a.top+a.height/2},f={x:a.left+a.width/2,y:a.top+a.height};let p=re.left;const m={x:0,y:0};if(e)p=e,p===re.top||p===re.bottom?m.x=s.clientX-f.x:p===re.right?m.y=s.clientY-c.y:m.y=s.clientY-d.y;else{const g=me(s.clientX,s.clientY,d.x,d.y),y=me(s.clientX,s.clientY,h.x,h.y),v=me(s.clientX,s.clientY,c.x,c.y),x=me(s.clientX,s.clientY,f.x,f.y),w=Math.min(g,y,v,x);w===g?(p=re.left,m.x=s.clientX-d.x,m.y=s.clientY-d.y):w===y?(p=re.top,m.x=s.clientX-h.x,m.y=s.clientY-h.y):w===v?(p=re.right,m.x=s.clientX-c.x,m.y=s.clientY-c.y):w===x&&(p=re.bottom,m.x=s.clientX-f.x,m.y=s.clientY-f.y)}const u=this.dataProvider.getCanvasScale();m.x=m.x/u,m.y=m.y/u,L("onMouseUpWithOffset:",e,m),this.onLineVertexBeDropped(p,t,m,o)}}class Mo extends Ro{constructor(){super();_(this,"$miniViewCanvas");_(this,"$mvCanvasCtx");_(this,"_canvasDomScale",1);_(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});_(this,"visibleArea",{x:0,y:0});_(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,o=-9999999,s=0;for(const x of this.getNodes())if(x.rgCalcedVisibility&&x.opacity!==0){x.x<e&&(e=x.x),x.y<t&&(t=x.y);const w=x.x+x.el_W,k=x.y+x.el_H;w>n&&(n=w),k>o&&(o=k),s++}const a=1,d=50,h=50;s===0?(this.miniViewBox.canvas_start_x=-100-d,this.miniViewBox.canvas_start_y=-100-h,this.miniViewBox.canvas_end_x=100+d,this.miniViewBox.canvas_end_y=100+h,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-d,this.miniViewBox.canvas_start_y=t-h,this.miniViewBox.canvas_end_x=n+d,this.miniViewBox.canvas_end_y=o+h,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 c=this.$miniViewCanvas.parentElement.getBoundingClientRect(),f=c.width,p=c.height;let m=0,u=0,g=1;f/this.miniViewBox.canvas_width<p/this.miniViewBox.canvas_height?(g=f/this.miniViewBox.canvas_width*a,m=f,u=f/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=p/this.miniViewBox.canvas_height*a,m=p/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,u=p),this.miniViewBox.miniview_width=f,this.miniViewBox.miniview_height=p,this.$miniViewCanvas.width=f,this.$miniViewCanvas.height=p,this.$mvCanvasCtx.canvas.width=f*window.devicePixelRatio,this.$mvCanvasCtx.canvas.height=p*window.devicePixelRatio,this.$mvCanvasCtx.canvas.style.width=`${f}px`,this.$mvCanvasCtx.canvas.style.height=`${p}px`;const y=(p-u)/2,v=(f-m)/2;this.miniViewBox.canvas_start_x-=v/g,this.miniViewBox.canvas_start_y-=y/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}),o=this._canvasDomScale,s=n.x-e.x,a=n.y-e.y;this.miniViewBox.visibleAreaStart=e,this.miniViewBox.visibleAreaEnd=n;const d=o*s,h=o*a,c=e.x-this.miniViewBox.canvas_start_x,f=e.y-this.miniViewBox.canvas_start_y,p=o*c,m=o*f;let u=!1;(p+d<0||m+h<0||m>this.miniViewBox.miniview_height||p>this.miniViewBox.miniview_width)&&(u=!0);const g=this.getOptions().miniViewVisibleHandle;(g.emptyContent!==u||g.width!==d||g.height!==h||g.x!==d||g.y!==h)&&this.dataProvider.updateOptions({miniViewVisibleHandle:{emptyContent:u,width:d,height:h,x:p,y:m}})}mvDrawAllNodes(){const e=this._canvasDomScale,t=this.getOptions().defaultNodeShape;for(const n of this.getNodes())if(n.rgCalcedVisibility&&n.opacity!==0){let o=n.el_W,s=n.el_H;e*o<this._canvasItemMiniSizeLimit&&(o=this._canvasItemMiniSizeLimit/this._canvasDomScale),e*s<this._canvasItemMiniSizeLimit&&(s=this._canvasItemMiniSizeLimit/this._canvasDomScale);const a=Ce(n.nodeShape,t);this.mvDrawNode(n,a,o,s)}}mvDrawNode(e,t,n,o){t===xe.circle?this.mvDrawNode4Circle(e,n,o):this.mvDrawNode4Rect(e,n,o)}mvDrawNode4Rect(e,t,n){const o=this.$mvCanvasCtx,s=e.x-this.miniViewBox.canvas_start_x,a=e.y-this.miniViewBox.canvas_start_y;o.beginPath(),o.globalAlpha=e.opacity||1,o.rect(s,a,t,n),o.fillStyle=this.getNodeColor(e),o.fill(),o.strokeStyle="#666666",o.lineWidth=2,o.stroke(),o.globalAlpha=1}mvDrawNode4Circle(e,t,n){const o=this.$mvCanvasCtx,s=e.x+t/2-this.miniViewBox.canvas_start_x,a=e.y+n/2-this.miniViewBox.canvas_start_y;o.beginPath(),o.globalAlpha=e.opacity||1,o.ellipse(s,a,t/2,n/2,0,0,2*Math.PI),o.fillStyle=this.getNodeColor(e),o.fill(),o.strokeStyle="#666666",o.lineWidth=2,o.stroke(),o.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,o=this.createLineDrawInfo(e,t);n.beginPath(),n.globalAlpha=t.opacity||1,this.mvDrawSvgPathOnCanvas(n,o.pathData);const s=this.getOptions();n.strokeStyle=t.color||s.defaultLineColor||"#888888",n.lineWidth=t.lineWidth||s.defaultLineWidth||1,n.stroke(),n.globalAlpha=1}mvDrawSvgPathOnCanvas(e,t){const n=t.match(/[a-zA-Z][^a-zA-Z]*/g);let o=0,s=0,a=0,d=0,h=0,c=0,f=0,p=0,m=!1;n.forEach(u=>{const g=u.trim().split(/[ ,]+/),y=g[0].toUpperCase(),v=g[0]===g[0].toLowerCase();switch(y){case"M":o=U(a,g[1],v)-this.miniViewBox.canvas_start_x,s=U(d,g[2],v)-this.miniViewBox.canvas_start_y,a=o,d=s,m&&(e.closePath(),m=!1),e.moveTo(o,s);break;case"L":o=U(a,g[1],v)-this.miniViewBox.canvas_start_x,s=U(d,g[2],v)-this.miniViewBox.canvas_start_y,e.lineTo(o,s);break;case"C":h=U(a,g[1],v),c=U(d,g[2],v),f=U(a,g[3],v),p=U(d,g[4],v),o=U(a,g[5],v),s=U(d,g[6],v),a=o,d=s,e.bezierCurveTo(h,c,f,p,o,s);break;case"Q":h=U(a,g[1],v),c=U(d,g[2],v),o=U(a,g[3],v),s=U(d,g[4],v),a=o,d=s;break;case"V":s=U(d,g[1],v),d=s,e.lineTo(o,s);break;case"H":o=U(a,g[1],v),a=o,e.lineTo(o,s);break;case"Z":e.closePath(),m=!1;break;default:L(`Unsupported command: ${y}`)}})}onVisibleViewHandleDragStart(e){e.preventDefault(),e.stopPropagation();const t=this.getOptions(),n=t.canvasOffset.x,o=t.canvasOffset.y,s=this.miniViewBox.canvas_width,a=this.miniViewBox.canvas_height,d=()=>{const u=p/this.miniViewBox.miniview_width,g=m/this.miniViewBox.miniview_height,y=this.dataProvider.getCanvasScale(),v=s*u*y,x=a*g*y;this.dataProvider.setCanvasOffset(n-v,o-x),this._updateEditingControllerView(),this.updateMiniViewVisibleArea(),this.updateShouldRenderGraphData(),this.dataProvider.dataUpdated()};let h;const c=(u,g,y)=>{h&&clearInterval(h),this.onCanvasDragEnd(y)};let f=!1,p=0,m=0;le.startDrag(e,{x:0,y:0},c,(u,g)=>{p=u,m=g,!f&&Math.abs(u)+Math.abs(g)>3&&(f=!0,h=setInterval(()=>{d()},50))})}resetByVisiableView(e){!this.getOptions().miniViewVisibleHandle.emptyContent||(this.setZoom(100),this._moveToCenter(),this.zoomToFit())}}class Eo extends Mo{constructor(){super();_(this,"$watermarkDom",null);_(this,"$watermarkPosition","br");_(this,"$backgroundDom",null);_(this,"_originBackgroundColor","");_(this,"graphStatusBeforeImageGeneration",{orignCanvasOffsetX:0,orignCanvasOffsetY:0,orignZoom:0,forceLayouting:!1})}setWatermarkDom(e,t=!0,n=!1,o="br"){t&&(this.$watermarkDom=e),this.$watermarkPosition=o}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.updateShouldRenderGraphData(),this.updateElementLines(),await this.moveItemsAndFitContent(),this._dataUpdated(),this.$canvasDom.parentElement}async restoreAfterImageGeneration(){const{orignCanvasOffsetX:e,orignCanvasOffsetY:t,orignZoom:n,forceLayouting:o}=this.graphStatusBeforeImageGeneration;this.$canvasDom.parentElement.style.width="100%",this.$canvasDom.parentElement.style.height="100%",this.setZoom(n),this.dataProvider.updateOptions({canvasOffset:{x:e,y:t}}),this._dataUpdated(),o&&this.startAutoLayout(),this.clearLoading()}async moveItemsAndFitContent(){const e=this.getOptions(),t=e.canvasZoom,n=e.canvasOffset.x,o=e.canvasOffset.y,s=e.layout.autoLayouting===!0;s&&(this.stopAutoLayout(),await this.sleep(200)),this.loading("Generating..."),this.dataProvider.updateOptions({snapshotting:!0}),this.dataProvider.clearChecked(),this.setZoom(100),this.updateShouldRenderGraphData(!0),this._dataUpdated(),await this.sleep(200);const a=this.getNodesRectBox(),d=this.getCanvasSlotRectItems(),h=this.getNodesRectBox(d),c=100,f=Math.min(a.minX,h.minX)-c,p=Math.min(a.minY,h.minY)-c,m=Math.max(a.maxX,h.maxX)+c,u=Math.max(a.maxY,h.maxY)+c,g=f,y=p,v=m-f,x=u-p;this.graphStatusBeforeImageGeneration={orignCanvasOffsetX:n,orignCanvasOffsetY:o,orignZoom:t,forceLayouting:s},this.dataProvider.updateOptions({canvasOffset:{x:-g,y:-y}}),this._dataUpdated(),this.setZoom(100),this.$canvasDom.parentElement.style.width=v+"px",this.$canvasDom.parentElement.style.height=x+"px",L("export image:",{imageWidth:v,imageHeight:x,minX:f,minY:p,maxX:m,maxY:u,devicePixelRatio:window.devicePixelRatio}),await this.sleep(200)}}class Io extends Eo{constructor(){super();_(this,"resizeObserver");_(this,"resizeListenerMap",new WeakMap);_(this,"domToNodeIdMap",new WeakMap);_(this,"_trackpadGestureActive",!1);_(this,"_trackpadGestureStartZoom",100);_(this,"_trackpadGestureAnchorView");_(this,"_trackpadGestureStartOffset");_(this,"_mouseMoveHandler");_(this,"_gestureStartHandler");_(this,"_gestureChangeHandler");_(this,"_gestureEndHandler");_(this,"_lastMouseClientXy");_(this,"mutationObserver4Nodes");_(this,"mutationObserver4CanvasSlotBehind");_(this,"mutationObserver4CanvasSlotAbove");_(this,"_updateCanvasConnectTargetsTask");_(this,"onKeyDownHanlder");_(this,"onKeyUpHanlder")}setDom(e){L("relation-graph mounted on:",this.instanceId,e),this.$dom=e}setCanvasDom(e){L("relation-graph canvas dom mounted!"),this.$canvasDom=e,this.$lineTextContainer4NormalLine=null,this.$lineTextContainer4FakeLine=null,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 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)}})),this.resizeObserver}initDom(){this.addResizeListener(this.$dom,(e,t)=>{L("resizeListener:this.$dom"),this.resetViewSize(),this.updateEasyView(),this._rgAsConnectArea&&this.updateCanvasConnectTargetsPosition("View Resize"),this._updateEditingLineView(),this._updateEditingControllerView(),this._dataUpdated(),setTimeout(()=>{L("resizeListener:updateShouldRenderGraphData"),this.emitEvent(I.onViewResize,{width:e,height:t}),this._dataUpdated()},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener(),this.removeTrackpadGestureListeners(),this.addTrackpadGestureListeners())}updateCanvasConnectTargetsPosition(e="api"){this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-above"))}reinitMutationObservers(){this.destroyMutationObserver();const e=this.$canvasDom.querySelector(".rg-nodes-container-wrapper");if(e)this.mutationObserver4Nodes=new MutationObserver(o=>{if(this.dataProvider.getConnectTargets().length>0)for(const s of o){const a=this.getNodeElByChildrenTarget(s.target),d=this.domToNodeIdMap.get(a);d&&this.updateConnectTargetsOnNode("Mutation",d,a)}}),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(o=>{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(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)}getTrackpadGestureAnchorView(){const e=this.getViewBoundingClientRect();return e?this._lastMouseClientXy?this.getViewXyByClientXy({x:this._lastMouseClientXy.x,y:this._lastMouseClientXy.y}):{x:e.width/2,y:e.height/2}:{x:0,y:0}}addTrackpadGestureListeners(){this._mouseMoveHandler=e=>{this._lastMouseClientXy={x:e.clientX,y:e.clientY}},this._gestureStartHandler=e=>{const t=e;ge(t)||(t.cancelable&&t.preventDefault(),t.stopPropagation(),this._trackpadGestureActive=!0,this._trackpadGestureStartZoom=this.getOptions().canvasZoom,this._trackpadGestureStartOffset={x:this.getOptions().canvasOffset.x,y:this.getOptions().canvasOffset.y},this._trackpadGestureAnchorView=this.getTrackpadGestureAnchorView())},this._gestureChangeHandler=e=>{const t=e;if(!this._trackpadGestureActive||!this._trackpadGestureAnchorView||!this._trackpadGestureStartOffset)return;t.cancelable&&t.preventDefault(),t.stopPropagation();const n=t.scale;if(!n||!Number.isFinite(n)||n<=0)return;const o=.01;if(Math.abs(n-1)<o)return;const s=this._trackpadGestureStartZoom*n,a=this._trackpadGestureStartZoom/100,d=this.getClampedZoom(s)/100,h=this._trackpadGestureAnchorView.x-(this._trackpadGestureAnchorView.x-this._trackpadGestureStartOffset.x)*(d/a),c=this._trackpadGestureAnchorView.y-(this._trackpadGestureAnchorView.y-this._trackpadGestureStartOffset.y)*(d/a);this.setZoomAndOffset(s,{x:h,y:c})},this._gestureEndHandler=e=>{const t=e;t.cancelable&&t.preventDefault(),t.stopPropagation(),this._trackpadGestureActive=!1,this._trackpadGestureAnchorView=void 0,this._trackpadGestureStartOffset=void 0},this.$dom.addEventListener("mousemove",this._mouseMoveHandler),this.$dom.addEventListener("gesturestart",this._gestureStartHandler),this.$dom.addEventListener("gesturechange",this._gestureChangeHandler),this.$dom.addEventListener("gestureend",this._gestureEndHandler)}removeTrackpadGestureListeners(){this._mouseMoveHandler&&this.$dom.removeEventListener("mousemove",this._mouseMoveHandler),this._gestureStartHandler&&this.$dom.removeEventListener("gesturestart",this._gestureStartHandler),this._gestureChangeHandler&&this.$dom.removeEventListener("gesturechange",this._gestureChangeHandler),this._gestureEndHandler&&this.$dom.removeEventListener("gestureend",this._gestureEndHandler),this._trackpadGestureActive=!1,this._trackpadGestureAnchorView=void 0,this._trackpadGestureStartOffset=void 0,this._mouseMoveHandler=void 0,this._gestureStartHandler=void 0,this._gestureChangeHandler=void 0,this._gestureEndHandler=void 0}addKeyboardListener(){this.onKeyDownHanlder=e=>{ge(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!1&&this.setCanvasMoveMode(!0)),this.emitEvent(I.onKeyboardDown,e))},this.onKeyUpHanlder=e=>{ge(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!0&&this.setCanvasMoveMode(!1)),this.emitEvent(I.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 o=this.domToNodeIdMap.get(e);this._onNodeResize(e,o,t,n)}_onNodeResize(e,t,n,o){n===0||o===0||(this.updateConnectTargetsOnNode("Node-Created",t,e),this.updateNodeOffsetSize(t,n,o))}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):L("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(e){this.resizeListenerMap.delete(e),this.resizeObserver&&this.resizeObserver.unobserve(e)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}getCanvasSlotList(){return this.$dom.querySelectorAll(".rg-map > .rg-map-canvas > .rg-canvas-slot")}getCanvasSlotRectItems(){if(!this.$dom)return[];const e=this.getCanvasSlotList(),t=[];for(const n of e)for(const o of n.children){const s=o,a={x:s.offsetLeft||0,y:s.offsetTop||0,nodeShape:1,el_W:s.scrollWidth,el_H:s.scrollHeight};t.push(a)}return t}}class Do extends Io{constructor(){super()}dataUpdated(){this._requestDataUpdate()}setOptions(i){L("setOptions:",i),this._updateOptions(i),this._dataUpdated()}updateOptions(i){L("updateOptions:",i),this._updateOptions(i),this._dataUpdated()}moveToCenter(i){this._moveToCenter(i),this._dataUpdated()}transToLinker(i=!0){this._rgAsConnectArea=i,this.resetViewSize(),this.updateCanvasConnectTargetsPosition("Linker"),this.removeKeyboardListener(),this._rgAsConnectArea||this.addKeyboardListener(),this._dataUpdated()}setRootNodeId(i){L("setRootNodeId:",i),this.dataProvider.setRootNodeId(i)}getRootNode(){return this.dataProvider.getRootNode()}getCheckedNode(){return this.getNodeById(this.getOptions().checkedNodeId)}getCheckedLine(){const i=this.getLineById(this.getOptions().checkedLineId);return i||this.getFakeLineById(this.getOptions().checkedLineId)}getSelectedNodes(){return this.getNodes().filter(i=>i.selected)}getEditingNodes(){return[...this.getOptions().editingController.nodes]}async setJsonData(i){this._setJsonData(i),await this.doLayout(i.rootId)}async appendJsonData(i,e=!0){L("appendData:",i),this.loadGraphJsonData(i),e&&await this.doLayout()}async applyInitialData(i){L("applyInitialData:",i),await this.setJsonData(i),this.moveToCenter(),this.zoomToFit()}getGraphJsonData(){var o;const i=[],e=[],t=[];this.getNodes().forEach(s=>{const a=Te(s);a&&i.push(a)}),this.getLines().forEach(s=>{const a=be(s);a&&e.push(a)}),this.getFakeLines().forEach(s=>{const a=be(s);a&&t.push(a)});const n={rootId:((o=this.dataProvider.getRootNode())==null?void 0:o.id)||"",nodes:i,lines:e};return t.length>0&&(n.fakeLines=t),n}transRGNodeToJsonObject(i){return Te(i)}transRGLinkToJsonObject(i){return ze(i)}transRGLineToJsonObject(i){return be(i)}getGraphJsonOptions(){const i={},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)||(i[n]=t[n])}),i}clearGraph(){this._clearGraph(),this._dataUpdated()}printOptions(){this.getGraphJsonOptions()}printData(){this.getGraphJsonData()}printGraphJsonData(){this.printOptions(),this.printData()}}class Lt extends Do{constructor(){super();_(this,"viewComponentUnmounted",!1)}setListeners(e){this.listeners=e}ready(){this.initDom(),this.resetViewSize(),this.addFullscreenListener(),this.emitEvent(I.onReady,this),this.viewComponentUnmounted=!1}beforeUnmount(){this.viewComponentUnmounted=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.removeTrackpadGestureListeners(),this.destroyMutationObserver(),this.destroyResizeObserver()}}function wt(l,i=!1){const e=r.markRaw(l?Reflect.construct(l,[]):new Lt);return e._rgAsConnectArea=i,e}function _t(l,i=!1){const e=r.inject(ye,null);return e?e.graphInstance:wt(l,i)}const Fe=l=>({get value(){return l()}});function He(l){return r.defineComponent({name:"RGDataProvider",props:{options:{required:!1,type:Object}},setup(i,{slots:e}){if(!r.inject(ye,null)){const n=r.ref({rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]}),o=r.ref({}),s=r.ref({nodes:[],lines:[],fakeLines:[]}),a=r.ref(null),d=r.ref(null),h=r.ref([]),c=r.ref([]),f=r.ref([]),p=r.ref(new Map),m=r.ref(new Map),u=Fe(()=>s.value.nodes),g=Fe(()=>s.value.lines),y=Fe(()=>s.value.fakeLines),T={store4Options:{set:O=>{}},store4ShouldRenderNodes:{set:O=>{}},store4ShouldRenderLines:{set:O=>{}},store4ShouldRenderFakeLines:{set:O=>{}},optionsRef:o,shouldRenderNodesRef:u,shouldRenderLinesRef:g,shouldRenderFakeLinesRef:y,textContainer4FakeLineRef:a,textContainer4NormalRef:d};l.setReactiveData4Vue3(T,n.value,o.value,{runtimeDATA4Links:f.value,runtimeDATA4ElLineTargets:h.value,runtimeDATA4ConnectTargets:c.value,runtimeDATA4NodeMap:p.value,runtimeDATA4LinkMap:m.value,runtimeDATA4ShouldRenderItems:s.value},(O,b,N)=>{O[b]=r.markRaw(N)}),l.setOptions(i.options||{}),r.provide(ye,{graphInstance:l})}return r.onMounted(()=>{}),()=>e.default?e.default():null}})}const $e={onReady:l=>!0,onNodeClick:(l,i)=>!0,onNodeExpand:(l,i)=>!0,onNodeCollapse:(l,i)=>!0,onLineClick:(l,i,e)=>!0,onNodeDragStart:(l,i)=>!0,onNodeDragEnd:(l,i,e,t)=>!0,onNodeDragging:(l,i,e,t,n,o)=>!0,onCanvasDragEnd:l=>!0,onCanvasDragging:(l,i,e,t)=>!0,onContextmenu:(l,i,e,t,n)=>!0,onFullscreen:(l,i)=>!0,onCanvasClick:l=>!0,onCanvasSelectionEnd:(l,i)=>!0,beforeZoomStart:()=>!0,onZoomEnd:()=>!0,onViewResize:()=>!0,onResizeStart:(l,i)=>!0,beforeNodeResize:(l,i,e,t,n)=>!0,onResizeEnd:(l,i,e,t)=>!0,onLineVertexDropped:l=>!0,beforeCreateLine:l=>!0,onLineBeCreated:l=>!0,beforeAddNodes:l=>!0,beforeAddLines:l=>!0,onKeyboardDown:l=>!0,onKeyboardUp:l=>!0,onCanvasDragStart:(l,i,e)=>!0,onForceLayoutFinish:()=>!0,beforeScrollStart:(l,i,e)=>!0};function Nt({relationGraphCore:l}={}){const i=_t(l),e=He(i);return{RelationGraph:r.defineComponent({name:"RelationGraph",props:{options:{required:!1,type:Object},initialData:{required:!1,type:Object},emitProxy:{required:!1,type:Function}},emits:$e,setup(t,{slots:n,emit:o}){return r.onMounted(()=>{const s=t.emitProxy||o;i.setEventEmitHook((a,...d)=>{s(a,...d)}),Je("Vue3"),t.options&&i.setOptions(t.options||{}),i.ready(),t.initialData&&i.applyInitialData(t.initialData)}),r.onBeforeUnmount(()=>{i.beforeUnmount()}),()=>r.h(e,{options:t.options},{default:()=>r.h(bn,t,n)})}}),graphInstance:i}}const Pe=l=>l,Vo=`graphRef.value.getInstance() will be deprecated
|
|
42
|
+
`}},xn=["innerHTML"],Q=l.defineComponent({__name:"RGIcons",props:{iconName:{},className:{}},setup(s){const o=s,e=l.computed(()=>vn[o.iconName]);return(t,n)=>(l.openBlock(),l.createElementBlock("svg",{class:l.normalizeClass(["rg-icon",t.className]),viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",innerHTML:e.value.data},null,10,xn))}}),lt=l.defineComponent({__name:"RGNodeExpandHolder",props:{node:{},expandOrCollapseNode:{type:Function},expandHolderPosition:{}},setup(s){const o=s,e=l.computed(()=>o.node.expanded===!1?"c-expanded":"c-collapsed");return(t,n)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-node-expand-holder","c-expand-positon-"+t.expandHolderPosition])},[l.createElementVNode("div",{class:l.normalizeClass(["rg-node-expand-button",e.value]),onClick:n[0]||(n[0]=l.withModifiers((...i)=>t.expandOrCollapseNode&&t.expandOrCollapseNode(...i),["stop"])),onTouchend:n[1]||(n[1]=l.withModifiers((...i)=>t.expandOrCollapseNode&&t.expandOrCollapseNode(...i),["stop"]))},[t.node.expanded===!1?(l.openBlock(),l.createBlock(Q,{key:0,iconName:"icon-fangda"})):(l.openBlock(),l.createBlock(Q,{key:1,iconName:"icon-suoxiao"}))],34)],2))}});function $(){const s=l.inject(Le,null);if(!s)throw new Error("RGHooks.useGraphInstance must be used inside RGProvider or RelationGraph tag.");return s==null?void 0:s.graphInstance}const Cn=["data-id"],wn={class:"rg-node-text"},dt=l.defineComponent({__name:"RGNodePeel",props:{nodeProps:{},defaultExpandHolderPosition:{},dragging:{type:Boolean},checked:{type:Boolean}},setup(s){const o=$(),e=s,t=l.ref(),n=l.computed(()=>e.nodeProps.borderColor),i=l.computed(()=>e.nodeProps.borderWidth===void 0?void 0:e.nodeProps.borderWidth+"px"),a=l.computed(()=>e.nodeProps.width?e.nodeProps.width+"px":void 0),r=l.computed(()=>e.nodeProps.height?e.nodeProps.height+"px":void 0),d=l.computed(()=>e.nodeProps.expandHolderPosition?e.nodeProps.expandHolderPosition!=="hide":e.defaultExpandHolderPosition&&e.defaultExpandHolderPosition!=="hide"&&e.nodeProps.rgChildrenSize>0),c=l.computed(()=>e.nodeProps.rgCalcedVisibility),h=u=>{o.expandOrCollapseNode(e.nodeProps,u)},f=u=>{o.onNodeDragStart(e.nodeProps,u)};return l.onMounted(()=>{o.addNodeResizeListener(t.value,e.nodeProps)}),l.onBeforeUnmount(()=>{o.removeNodeResizeListener(t.value)}),(u,y)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",{ref_key:"nodePeelRef",ref:t,style:l.normalizeStyle({transform:`translate(${u.nodeProps.x}px, ${u.nodeProps.y}px)`,"--rg-node-z-index":u.nodeProps.zIndex?u.nodeProps.zIndex:void 0,"--rg-node-color":u.nodeProps.color,"--rg-node-font-color":u.nodeProps.fontColor,"--rg-node-font-size":u.nodeProps.fontSize?u.nodeProps.fontSize+"px":void 0,"--rg-node-border-width":i.value,"--rg-node-border-radius":u.nodeProps.borderRadius&&u.nodeProps.borderRadius+"px","--rg-node-border-color":n.value,"--rg-node-width":a.value,"--rg-node-height":r.value,"--rg-node-opacity":u.nodeProps.opacity===void 0?void 0:u.nodeProps.opacity}),class:l.normalizeClass(["rg-node-peel",u.nodeProps.selected&&"rg-node-selected",u.dragging&&"rg-node-dragging",u.checked&&"rg-node-checked",(u.nodeProps.disablePointEvent||u.nodeProps.opacity===0)&&"rg-node-disable-events","rg-node-shape-"+(u.nodeProps.nodeShape===void 0?1:u.nodeProps.nodeShape),"rg-node-type-"+u.nodeProps.type,u.nodeProps.className]),"data-id":u.nodeProps.id},[d.value?l.renderSlot(u.$slots,"node-expand-button",{key:0,node:u.nodeProps,expandOrCollapseNode:h,expandHolderPosition:u.nodeProps.expandHolderPosition||u.defaultExpandHolderPosition},()=>[l.createVNode(lt,{node:u.nodeProps,checked:u.checked,expandOrCollapseNode:h,expandHolderPosition:u.nodeProps.expandHolderPosition||u.defaultExpandHolderPosition},null,8,["node","checked","expandHolderPosition"])]):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"rg-node",onMousedown:l.withModifiers(f,["left","stop"]),onTouchstart:l.withModifiers(f,["stop"])},[l.renderSlot(u.$slots,"node",{node:u.nodeProps,checked:u.checked,dragging:u.dragging},()=>[l.createElementVNode("div",wn,[l.createElementVNode("span",null,l.toDisplayString(u.nodeProps.text),1)])])],32)],14,Cn)),[[l.vShow,c.value]])}}),Ln={class:"rg-nodes-container"},_n=l.defineComponent({__name:"RGCanvasContent4Nodes",props:{defaultExpandHolderPosition:{},draggingNodeId:{},checkedNodeId:{}},setup(s){const o=$(),e=l.computed(()=>o.getShouldRenderNodes(o.dataStores.shouldRenderNodesRef.value));return l.onMounted(()=>{w("[RGCanvas mounted]")}),(t,n)=>(l.openBlock(),l.createElementBlock("div",Ln,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(e.value,i=>(l.openBlock(),l.createBlock(dt,{key:i.id,"node-props":i,"default-expand-holder-position":t.defaultExpandHolderPosition,dragging:i.id===t.draggingNodeId,checked:i.id===t.checkedNodeId},{node:l.withCtx(a=>[l.renderSlot(t.$slots,"node",l.mergeProps({ref_for:!0},a))]),"node-expand-button":l.withCtx(a=>[l.renderSlot(t.$slots,"node-expand-button",l.mergeProps({ref_for:!0},a))]),_:2},1032,["node-props","default-expand-holder-position","dragging","checked"]))),128))]))}}),bn=["id","markerWidth","markerHeight","refX","refY","viewBox"],Nn=["d"],Tn=["id","markerWidth","markerHeight","refX","refY","viewBox"],kn=["d"],ct=l.defineComponent({__name:"RGGraphDefs",props:{forElementLines:{type:Boolean}},setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value);return(t,n)=>(l.openBlock(),l.createElementBlock("defs",null,[l.createElementVNode("marker",{id:e.value.instanceId+"-arrow-default",markerWidth:e.value.defaultLineMarker.markerWidth,markerHeight:e.value.defaultLineMarker.markerHeight,refX:e.value.defaultLineMarker.refX,refY:e.value.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto",viewBox:e.value.defaultLineMarker.viewBox},[l.createElementVNode("path",{style:{fill:"context-stroke"},d:e.value.defaultLineMarker.data},null,8,Nn)],8,bn),l.createElementVNode("marker",{id:e.value.instanceId+"-start-arrow-default",markerWidth:e.value.defaultLineMarker.markerWidth,markerHeight:e.value.defaultLineMarker.markerHeight,refX:e.value.defaultLineMarker.refX,refY:e.value.defaultLineMarker.refY,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",viewBox:e.value.defaultLineMarker.viewBox},[l.createElementVNode("path",{style:{fill:"context-stroke"},d:e.value.defaultLineMarker.data},null,8,kn)],8,Tn),l.renderSlot(t.$slots,"default")]))}});var I=(s=>(s.Node="node",s.NodePoint="NodePoint",s.HTMLElementId="HTMLElementId",s.CanvasPoint="CanvasPoint",s.ViewPoint="ViewPoint",s))(I||{}),Y=(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))(Y||{}),_e=(s=>(s[s.circle=0]="circle",s[s.rect=1]="rect",s))(_e||{}),W=(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))(W||{}),ht=(s=>(s.Left="left",s.Top="top",s.Right="right",s.Bottom="bottom",s))(ht||{}),D=(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))(D||{});const Pn={key:0},En=["data-id"],Sn={key:1},ft=l.defineComponent({__name:"RGLineText",props:{lineConfig:{},linePathInfo:{},checked:{type:Boolean}},setup(s){const o=$(),e=l.computed(()=>{var n;return(n=s.lineConfig)==null?void 0:n.line}),t=l.computed(()=>e.value.isFakeLine?o.dataStores.textContainer4FakeLineRef.value:o.dataStores.textContainer4NormalRef.value);return(n,i)=>e.value&&t.value?(l.openBlock(),l.createElementBlock("foreignObject",Pn,[(l.openBlock(),l.createBlock(l.Teleport,{to:t.value},[l.createElementVNode("div",{class:l.normalizeClass(["rg-line-peel",e.value.className,n.checked&&"rg-line-checked",(e.value.disablePointEvent||e.value.opacity===0)&&"rg-line-disable-events",e.value.selected&&"rg-line-selected"]),"data-id":e.value.id,style:l.normalizeStyle({"--rg-line-color":e.value.color,"--rg-line-fontsize":e.value.fontSize?`${e.value.fontSize}px`:void 0,"--rg-line-opacity":e.value.opacity,"--rg-line-fontcolor":e.value.fontColor,...e.value.cssVars||{}})},[l.renderSlot(n.$slots,"default")],14,En)],8,["to"]))])):(l.openBlock(),l.createElementBlock("g",Sn,[l.createElementVNode("text",null,"Null-text-"+l.toDisplayString(!!e.value)+"-"+l.toDisplayString(!!t.value),1)]))}}),On=["data-id"],Rn=["d"],Mn=["id","d"],In={key:0},Dn=["dx","dy"],Bn=["xlink:href","startOffset","text-anchor"],ut=l.defineComponent({__name:"RGLinePath",props:{lineConfig:{},linePathInfo:{},useTextOnPath:{type:Boolean},checked:{type:Boolean},graphInstanceId:{}},emits:["onLineClick"],setup(s,{emit:o}){const e=$(),t=o,n=l.computed(()=>s.lineConfig.line),i=l.computed(()=>e.getArrowMarkerId(s.lineConfig.line,!0)),a=l.computed(()=>e.getArrowMarkerId(s.lineConfig.line,!1)),r=l.computed(()=>e.generateLineTextStyle4TextOnPath(s.lineConfig)),d=l.computed(()=>s.lineConfig.line.lineWidth?s.lineConfig.line.lineWidth+"px":void 0),c=l.computed(()=>s.graphInstanceId+"-"+s.lineConfig.line.id),h=f=>{t("onLineClick",f)};return(f,u)=>(l.openBlock(),l.createElementBlock("g",{class:l.normalizeClass(["rg-line-peel",n.value.className,n.value.selected&&"rg-line-selected",(n.value.disablePointEvent||n.value.opacity===0)&&"rg-line-disable-events",f.checked&&"rg-line-checked"]),"data-id":n.value.id,style:l.normalizeStyle({"--rg-line-width":d.value,"--rg-line-color":n.value.color,"--rg-line-opacity":n.value.opacity,"--rg-line-fontcolor":n.value.fontColor,"--rg-line-marker-end":a.value,"--rg-line-marker-start":i.value,...n.value.cssVars||{}})},[l.createElementVNode("path",{d:f.linePathInfo.pathData,class:"rg-line-bg",onTouchstart:h,onClick:h},null,40,Rn),l.createElementVNode("path",{id:c.value,d:f.linePathInfo.pathData,class:l.normalizeClass(["rg-line",[n.value.dashType?"rg-line-dashtype-"+n.value.dashType:void 0,n.value.animation?"rg-line-anm-"+n.value.animation:void 0]])},null,10,Mn),f.useTextOnPath&&r.value?(l.openBlock(),l.createElementBlock("g",In,[l.createElementVNode("text",{class:"rg-line-text rg-line-text-on-path",dx:r.value.textOffset.x+"px",dy:r.value.textOffset.y+"px",onTouchstart:h,onClick:h},[l.createElementVNode("textPath",{"xlink:href":"#"+c.value,startOffset:r.value.onPathStartOffset,"text-anchor":r.value.textAnchor,method:"align",spacing:"auto"},l.toDisplayString(r.value.text),9,Bn)],40,Dn)])):l.createCommentVNode("",!0),l.renderSlot(f.$slots,"default")],14,On))}}),pt=l.defineComponent({__name:"RGLineContent",props:{lineConfig:{},checked:{type:Boolean},defaultLineTextOnPath:{type:Boolean},graphInstanceId:{}},setup(s){const o=$(),e=l.computed(()=>o.generateLinePath(s.lineConfig)),t=l.computed(()=>o.generateLineTextStyle(s.lineConfig,e.value)),n=l.computed(()=>s.lineConfig.line.useTextOnPath||s.defaultLineTextOnPath),i=l.computed(()=>n.value&&s.lineConfig.line.lineShape!==W.StandardStraight),a=r=>{o.onLineClick(s.lineConfig.line,r)};return(r,d)=>(l.openBlock(),l.createElementBlock(l.Fragment,null,[l.createVNode(ut,{lineConfig:r.lineConfig,linePathInfo:e.value,useTextOnPath:i.value,"graph-instance-id":r.graphInstanceId,checked:r.checked,onOnLineClick:a},null,8,["lineConfig","linePathInfo","useTextOnPath","graph-instance-id","checked"]),r.lineConfig.line.text&&!i.value?(l.openBlock(),l.createBlock(ft,{key:0,lineConfig:r.lineConfig,linePathInfo:e.value,checked:r.checked},{default:l.withCtx(()=>[l.createElementVNode("div",{class:l.normalizeClass(`rg-line-label ${n.value?"rg-line-label-on-path":""}`),style:l.normalizeStyle({...t.value.cssStyles}),onTouchstart:a,onClick:a},l.toDisplayString(t.value.text),39)]),_:1},8,["lineConfig","linePathInfo","checked"])):l.createCommentVNode("",!0)],64))}}),Vn={key:0},gt=l.defineComponent({__name:"RGLinePeel",props:{line:{},checked:{type:Boolean},defaultLineTextOnPath:{type:Boolean},graphInstanceId:{}},setup(s){const o=$(),e=l.computed(()=>s.line.isFakeLine?o.generateFakeLineConfig(s.line):o.generateLineConfig(s.line));return(t,n)=>e.value?(l.openBlock(),l.createElementBlock("g",Vn,[l.renderSlot(t.$slots,"line",{lineConfig:e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,graphInstanceId:t.graphInstanceId,checked:t.checked},()=>[l.createVNode(pt,{"line-config":e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,"graph-instance-id":t.graphInstanceId,checked:t.checked},null,8,["line-config","defaultLineTextOnPath","graph-instance-id","checked"])])])):l.createCommentVNode("",!0)}}),An={class:"rg-lines-container rg-lines-container-el-lines"},zn={class:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg"},Xn=l.defineComponent({__name:"RGCanvasContent4FakeLines",props:{showEasyView:{type:Boolean},defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(s){const o=$(),e=l.computed(()=>o.getShouldRenderFakeLines(o.dataStores.shouldRenderFakeLinesRef.value));return l.onMounted(()=>{w("[RGCanvas mounted]")}),(t,n)=>(l.openBlock(),l.createElementBlock("div",An,[n[0]||(n[0]=l.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(l.openBlock(),l.createElementBlock("svg",zn,[l.createVNode(ct,{"for-element-lines":!0}),t.showEasyView?l.createCommentVNode("",!0):(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:0},l.renderList(e.value,i=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:i.id},[i.hidden!==!0?(l.openBlock(),l.createBlock(gt,{key:0,line:i,defaultLineTextOnPath:t.defaultLineTextOnPath,checked:i.id===t.checkedLineId,"graph-instance-id":t.graphInstanceId},{line:l.withCtx(a=>[l.renderSlot(t.$slots,"line",l.mergeProps({ref_for:!0},a))]),_:2},1032,["line","defaultLineTextOnPath","checked","graph-instance-id"])):l.createCommentVNode("",!0)],64))),128))]))]))}}),Fn={class:"rg-lines-container rg-lines-container-el-lines"},Gn={class:"rg-lines-svg rg-lines-svg-el-lines",xmlns:"http://www.w3.org/2000/svg"},$n=l.defineComponent({__name:"RGCanvasContent4CreatingLine",props:{defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(s){const o=$(),e=l.computed(()=>o.generateCreatingLineConfig(o.dataStores.optionsRef.value));return l.onMounted(()=>{w("[RGCanvas mounted]")}),(t,n)=>(l.openBlock(),l.createElementBlock("div",Fn,[n[0]||(n[0]=l.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(l.openBlock(),l.createElementBlock("svg",Gn,[l.renderSlot(t.$slots,"line",{lineConfig:e.value},()=>[l.createVNode(pt,{"line-config":e.value,defaultLineTextOnPath:t.defaultLineTextOnPath,"graph-instance-id":t.graphInstanceId},null,8,["line-config","defaultLineTextOnPath","graph-instance-id"])])]))]))}}),Hn={class:"rg-lines-container rg-lines-container-normal-lines"},Yn={class:"rg-lines-svg",xmlns:"http://www.w3.org/2000/svg"},Wn=l.defineComponent({__name:"RGCanvasContent4Lines",props:{showEasyView:{type:Boolean},defaultLineTextOnPath:{type:Boolean},checkedLineId:{},graphInstanceId:{}},setup(s){const o=$(),e=l.computed(()=>o.getShouldRenderLines(o.dataStores.shouldRenderLinesRef.value));return l.onMounted(()=>{w("[RGCanvas mounted]")}),(t,n)=>(l.openBlock(),l.createElementBlock("div",Hn,[n[0]||(n[0]=l.createElementVNode("div",{class:"rg-linetext-container"},null,-1)),(l.openBlock(),l.createElementBlock("svg",Yn,[l.createVNode(ct),t.showEasyView?l.createCommentVNode("",!0):(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:0},l.renderList(e.value,i=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:i.id},[i.hidden!==!0?(l.openBlock(),l.createBlock(gt,{key:"l-"+i.id,line:i,defaultLineTextOnPath:t.defaultLineTextOnPath,checked:i.id===t.checkedLineId,"graph-instance-id":t.graphInstanceId},{line:l.withCtx(a=>[l.renderSlot(t.$slots,"line",l.mergeProps({ref_for:!0},a))]),_:2},1032,["line","defaultLineTextOnPath","checked","graph-instance-id"])):l.createCommentVNode("",!0)],64))),128))]))]))}}),Un={class:"rg-single-graph"},jn={class:"rg-nodes-container-wrapper"},mt=l.defineComponent({__name:"RGCanvasContent",props:{showEasyView:{type:Boolean},creatingLine:{type:Boolean},defaultExpandHolderPosition:{},draggingNodeId:{},checkedNodeId:{},checkedLineId:{},graphInstanceId:{},defaultLineTextOnPath:{type:Boolean}},setup(s){return(o,e)=>(l.openBlock(),l.createElementBlock("div",Un,[l.withMemo([o.defaultLineTextOnPath,o.checkedLineId],()=>l.createVNode(Wn,{showEasyView:o.showEasyView,defaultLineTextOnPath:o.defaultLineTextOnPath,"checked-line-id":o.checkedLineId,"graph-instance-id":o.graphInstanceId},{line:l.withCtx(t=>[l.renderSlot(o.$slots,"line",l.normalizeProps(l.guardReactiveProps(t)))]),_:3},8,["showEasyView","defaultLineTextOnPath","checked-line-id","graph-instance-id"]),e,0),l.createElementVNode("div",jn,[o.showEasyView?l.createCommentVNode("",!0):l.withMemo([o.draggingNodeId,o.checkedNodeId,o.defaultExpandHolderPosition],()=>(l.openBlock(),l.createBlock(_n,{key:0,"default-expand-holder-position":o.defaultExpandHolderPosition,draggingNodeId:o.draggingNodeId,checkedNodeId:o.checkedNodeId},{node:l.withCtx(t=>[l.renderSlot(o.$slots,"node",l.normalizeProps(l.guardReactiveProps(t)))]),"node-expand-button":l.withCtx(t=>[l.renderSlot(o.$slots,"node-expand-button",l.normalizeProps(l.guardReactiveProps(t)))]),_:3},8,["default-expand-holder-position","draggingNodeId","checkedNodeId"])),e,1)]),l.createVNode(Xn,{showEasyView:o.showEasyView,defaultLineTextOnPath:o.defaultLineTextOnPath,"checked-line-id":o.checkedLineId,"graph-instance-id":o.graphInstanceId},{line:l.withCtx(t=>[l.renderSlot(o.$slots,"line",l.normalizeProps(l.guardReactiveProps(t)))]),_:3},8,["showEasyView","defaultLineTextOnPath","checked-line-id","graph-instance-id"]),o.creatingLine?(l.openBlock(),l.createBlock($n,{key:0,defaultLineTextOnPath:o.defaultLineTextOnPath,"checked-line-id":o.checkedLineId},{line:l.withCtx(t=>[l.renderSlot(o.$slots,"line",l.normalizeProps(l.guardReactiveProps(t)))]),_:3},8,["defaultLineTextOnPath","checked-line-id"])):l.createCommentVNode("",!0)]))}}),Jn=l.defineComponent({__name:"RGEasyView",setup(s){const o=$(),e=l.ref(),t=l.computed(()=>o.dataStores.optionsRef.value);return l.onMounted(()=>{w("[RGEasyView mounted]"),o.setEasyViewCanvas&&o.setEasyViewCanvas(e.value)}),(n,i)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-easy-view",{"rg-easy-view-active":t.value.showEasyView}])},[l.createElementVNode("canvas",{ref_key:"$rgEasyCanvas",ref:e,style:{width:"100%",height:"100%"}},null,512)],2))}}),qn={class:"rg-map-background"},Zn={class:"rg-canvas-slot rg-canvas-slot-behind"},Kn={class:"rg-canvas-slot rg-canvas-slot-above"},Qn=l.defineComponent({__name:"RGCanvas",setup(s){const o=l.ref(),e=l.ref(),t=$(),n=l.computed(()=>t.dataStores.optionsRef.value),i=c=>{t.onCanvasDragStart(c)},a=c=>{t.onContextmenu(c)},r=c=>{t.onMouseWheel(c)},d=l.computed(()=>{const c=t.dataStores.optionsRef.value;return{width:`${c.canvasSize.width}px`,height:`${c.canvasSize.height}px`,"background-color":"transparent",transform:`translate(${c.canvasOffset.x}px, ${c.canvasOffset.y}px) scale(${c.canvasZoom/100},${n.value.canvasZoom/100})`}});return l.onMounted(()=>{var c;w("[RGCanvas mounted]"),t.setCanvasDom(o.value),(c=e.value)==null||c.addEventListener("wheel",r,{passive:!1})}),l.onBeforeUnmount(()=>{var c;(c=e.value)==null||c.removeEventListener("wheel",r)}),(c,h)=>(l.openBlock(),l.createElementBlock("div",{ref_key:"rgMapRef",ref:e,class:l.normalizeClass(["rg-map",[n.value.canvasOpacity===1&&"rg-map-ready"]]),onContextmenu:h[0]||(h[0]=l.withModifiers(f=>a(f),["prevent"])),onMousedown:h[1]||(h[1]=l.withModifiers(f=>i(f),["left"])),onTouchstart:h[2]||(h[2]=f=>i(f))},[l.createElementVNode("div",qn,[l.renderSlot(c.$slots,"background")]),l.createElementVNode("div",{style:l.normalizeStyle(d.value),class:"rg-map-canvas rg-canvas-behind"},[l.createElementVNode("div",Zn,[l.renderSlot(c.$slots,"canvas-plug-behind")])],4),l.createVNode(Jn),l.createElementVNode("div",{ref_key:"rgCanvasRef",ref:o,style:l.normalizeStyle(d.value),class:"rg-map-canvas"},[l.createVNode(mt,{"show-easy-view":n.value.showEasyView,"creating-line":!!(n.value.creatingLinePlot&&n.value.newLinkTemplate.fromNode),"default-expand-holder-position":n.value.defaultExpandHolderPosition,draggingNodeId:n.value.draggingNodeId,checkedNodeId:n.value.checkedNodeId,defaultLineTextOnPath:n.value.defaultLineTextOnPath,"checked-line-id":n.value.checkedLineId,"graph-instance-id":n.value.instanceId},{line:l.withCtx(f=>[l.renderSlot(c.$slots,"line",l.normalizeProps(l.guardReactiveProps(f)))]),node:l.withCtx(f=>[l.renderSlot(c.$slots,"node",l.normalizeProps(l.guardReactiveProps(f)))]),"node-expand-button":l.withCtx(f=>[l.renderSlot(c.$slots,"node-expand-button",l.normalizeProps(l.guardReactiveProps(f)))]),_:3},8,["show-easy-view","creating-line","default-expand-holder-position","draggingNodeId","checkedNodeId","defaultLineTextOnPath","checked-line-id","graph-instance-id"])],4),l.createElementVNode("div",{style:l.normalizeStyle(d.value),class:"rg-map-canvas rg-canvas-above"},[l.createElementVNode("div",Kn,[l.renderSlot(c.$slots,"canvas-plug-above")])],4)],34))}}),eo=l.defineComponent({__name:"GraphMoveOperator",setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=l.computed(()=>e.value.canvasMoveMode),n=i=>{o.startMoveCanvas(i,!0)};return(i,a)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-move-operator",{"rg-move-operator-active":t.value}])},[l.createElementVNode("div",{class:"rg-move-touchpad",onMousedown:n,onTouchstart:n},null,32)],2))}}),to={class:"rg-graph-loading-message"},no=l.defineComponent({__name:"GraphLoading",setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=n=>{o.clearLoading()};return(n,i)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-graph-loading",{"rg-graph-loading-hide":!e.value.graphLoading}]),onClick:t},[l.createElementVNode("div",to,[l.createVNode(Q,{"icon-name":"icon-lianjiezhong","class-name":"rg-graph-loading-icon"}),l.createTextVNode(" "+l.toDisplayString(e.value.graphLoadingText||"Loading..."),1)])],2))}}),oo={key:0,class:"rg-operate"},io={class:"rg-creating-container"},yt=l.defineComponent({__name:"GraphOperateStuff",setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value);return(t,n)=>e.value?(l.openBlock(),l.createElementBlock("div",oo,[l.createElementVNode("div",io,[e.value.creatingNodePlot&&e.value.showTemplateNode?(l.openBlock(),l.createBlock(dt,{key:0,"node-props":e.value.newNodeTemplate},{node:l.withCtx(()=>[l.renderSlot(t.$slots,"node",{node:e.value.newNodeTemplate})]),_:3},8,["node-props"])):l.createCommentVNode("",!0),e.value.creatingSelection?(l.openBlock(),l.createElementBlock("div",{key:1,class:"rg-selection",style:l.normalizeStyle({transform:`translate(${e.value.selectionView.x}px, ${e.value.selectionView.y}px)`,width:e.value.selectionView.width+"px",height:e.value.selectionView.height+"px"})},null,4)):l.createCommentVNode("",!0)]),l.createVNode(eo),l.createVNode(no)])):l.createCommentVNode("",!0)}}),so=["title"],vt=l.defineComponent({__name:"GraphXsToolBar",props:{direction:{},positionH:{},positionV:{}},setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=()=>{o.toggleAutoLayout()},n=async()=>{o.enableCanvasAnimation(),o.setZoom(100),o.moveToCenter(),o.zoomToFit(),setTimeout(()=>{o.disableCanvasAnimation()},300)},i=async r=>{o.zoom(r)},a=async()=>{o.fullscreen()};return(r,d)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-toolbar rg-xs-toolbar",["rg-toolbar-h-"+(r.positionH||e.value.toolBarPositionH||"left"),"rg-toolbar-v-"+(r.positionV||e.value.toolBarPositionV||"bottom"),"rg-toolbar-"+(r.direction||e.value.toolBarDirection||"h")]])},[l.createElementVNode("div",{title:"Full Screen",class:"rg-mb-button",style:{"margin-top":"0px"},onClick:a},[l.createVNode(Q,{"icon-name":"icon-quanping"})]),l.createElementVNode("div",{class:"rg-mb-button",onClick:d[0]||(d[0]=c=>i(20))},[l.createVNode(Q,{"icon-name":"icon-fangda"})]),l.createElementVNode("div",{class:"rg-current-zoom",onClick:n},l.toDisplayString(Math.round(e.value.canvasZoom))+"%",1),l.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:d[1]||(d[1]=c=>i(-20))},[l.createVNode(Q,{"icon-name":"icon-suoxiao"})]),e.value.layout.supportAutoLayout?(l.openBlock(),l.createElementBlock("div",{key:0,title:e.value.layout.autoLayouting?"Stop Force Layout":"Start Force Layout",class:l.normalizeClass([{"rg-mb-button-on":e.value.layout.autoLayouting},"rg-mb-button"]),onClick:t},[e.value.layout.autoLayouting?(l.openBlock(),l.createBlock(Q,{key:1,"icon-name":"icon-lianjiezhong","class-name":"rg-loading-icon"})):(l.openBlock(),l.createBlock(Q,{key:0,"icon-name":"icon-zidong"}))],10,so)):l.createCommentVNode("",!0),l.renderSlot(r.$slots,"default"),d[2]||(d[2]=l.createElementVNode("div",{style:{clear:"both"}},null,-1))],2))}}),ao=["id"],ro={class:"rg-graph-plugs"},lo={class:"rg-view-slot"},co=l.defineComponent({__name:"RelationGraphUI",setup(s){const o=$(),e=l.ref(),t=l.computed(()=>o.dataStores.optionsRef.value),n=l.ref(!1);return l.onMounted(()=>{o.setDom(e.value),n.value=!0}),l.onBeforeUnmount(()=>{o.beforeUnmount()}),l.onMounted(()=>{}),(i,a)=>{var r,d,c,h,f,u,y,p,g,m,v;return l.openBlock(),l.createElementBlock("div",{ref_key:"relationGraphRef$",ref:e,id:"relation-graph-ins-"+((r=t.value)==null?void 0:r.instanceId),tabindex:"1",class:l.normalizeClass(["relation-graph",t.value&&t.value.creatingLinePlot?"rg-creating-line":"",t.value&&t.value.dragEventAction==="move"?"rg-move-mode":"",t.value&&t.value.enableNodeXYAnimation?"rg-enable-node-xy-animation":"",t.value&&t.value.enableCanvasTransformAnimation?"rg-enable-canvas-animation":""]),style:l.normalizeStyle({width:"100%",height:(d=t.value)!=null&&d.viewHeight?(c=t.value)==null?void 0:c.viewHeight:"100%",opacity:n.value?1:0,"--rg-checked-item-bg-color":(h=t.value)==null?void 0:h.checkedItemBackgroundColor,"--rg-background-color":(f=t.value)==null?void 0:f.backgroundColor,"--rg-node-color":(u=t.value)==null?void 0:u.defaultNodeColor,"--rg-node-border-color":(y=t.value)==null?void 0:y.defaultNodeBorderColor,"--rg-node-border-width":((p=t.value)==null?void 0:p.defaultNodeBorderWidth)+"px","--rg-node-border-radius":((g=t.value)==null?void 0:g.defaultNodeBorderRadius)+"px","--rg-line-color":(m=t.value)==null?void 0:m.defaultLineColor,"--rg-line-width":((v=t.value)==null?void 0:v.defaultLineWidth)+"px"})},[t.value&&n.value?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[t.value.showToolBar?(l.openBlock(),l.createBlock(vt,{key:0})):l.createCommentVNode("",!0),l.createVNode(Qn,null,{node:l.withCtx(x=>[l.renderSlot(i.$slots,"node",l.normalizeProps(l.guardReactiveProps(x)))]),line:l.withCtx(x=>[l.renderSlot(i.$slots,"line",l.normalizeProps(l.guardReactiveProps(x)))]),"canvas-plug-behind":l.withCtx(()=>[l.renderSlot(i.$slots,"canvas"),l.renderSlot(i.$slots,"default")]),"canvas-plug-above":l.withCtx(()=>[l.renderSlot(i.$slots,"canvas-above")]),"node-expand-button":l.withCtx(x=>[l.renderSlot(i.$slots,"node-expand-button",l.normalizeProps(l.guardReactiveProps(x)))]),background:l.withCtx(()=>[l.renderSlot(i.$slots,"background")]),_:3}),l.createVNode(yt,null,{node:l.withCtx(x=>[l.renderSlot(i.$slots,"node",l.normalizeProps(l.guardReactiveProps(x)))]),_:3}),l.createElementVNode("div",ro,[l.createElementVNode("div",lo,[l.renderSlot(i.$slots,"view")])])],64)):l.createCommentVNode("",!0)],14,ao)}}}),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,d=s.el_H,c=o.el_H;return!(t>=e+n||t+i<=e||r>=a+d||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,d=s.el_W,c=t.el_W,h=e,f=t.y,u=s.el_H,y=t.el_H;let p=s.x,g=s.y;const m=this.isXOverlap(n,r,d,c),v=this.isYOverlap(i,f,u,y);return m?h<f?(p=o,g=f-u):h>f&&(p=o,g=f+y):v&&(a<r?(p=r-d,g=e):a>r&&(p=r+c,g=e)),{x:p,y:g}},flatNodeData(s,o,e,t){s.forEach(n=>{e.push(n),o&&t.push({id:`${o.id}-to-${n.id}`,from:o.id,to:n.id});const i=n.children||n.childs;i&&i.length>0&&this.flatNodeData(i,n,e,t)})}},Ce=(s,o)=>s||s===0?s:o,be=z,Fe={id:"rg-newNodeTemplate",x:0,y:0,text:""},Ne=(s,o,e)=>{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 t=s.width||s.width===0?s.width:o==null?void 0:o.defaultNodeWidth,n=s.height||s.height===0?s.height:o==null?void 0:o.defaultNodeHeight,i={id:s.id,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"",targetType:s.targetType!==void 0?s.targetType:I.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:Ce(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:t,height:n,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||t||0,el_H:s.el_H||n||0,data:s.data!==void 0?s.data:{}};if(e&&e.has&&e.has(i.id)){const a=e.get(i.id);i.el_W||a&&(i.el_W=a[0]),i.el_H||a&&(i.el_H=a[1])}return i.lot={childs:[],parent:void 0,eached:!1,strength:0},i.width&&(i.el_W=i.width),i.height&&(i.el_H=i.height),i},ho=["Fx","Fy","appended","dragging","el","el_W","el_H","targetFrom","targetNodes","targetTo","lot","seeks_id","shouldRender","rgCalcedVisibility","rgShouldRender","rgChildrenSize","origin_x","origin_y","selected"],xt=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!ho.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===I.Node||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=t))}}),o},fo=(s,o,e="resolved")=>{if(!s)return;const t=xt(s)||{},n=e==="node"||s.width||s.width===0?s.width:o==null?void 0:o.defaultNodeWidth,i=e==="node"||s.height||s.height===0?s.height:o==null?void 0:o.defaultNodeHeight,a={...t,id:s.id,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"",targetType:s.targetType!==void 0?s.targetType:I.Node,expanded:s.expanded!==void 0?s.expanded:!0,disablePointEvent:s.disablePointEvent===void 0?o==null?void 0:o.disableNodePointEvent:s.disablePointEvent,disableDrag:Boolean(s.disableDrag||(o==null?void 0:o.disableDragNode)),className:s.className!==void 0?s.className:"",nodeShape:Ce(s.nodeShape,o==null?void 0:o.defaultNodeShape),borderColor:s.borderColor!==void 0?s.borderColor:o==null?void 0:o.defaultNodeBorderColor,borderWidth:s.borderWidth!==void 0?s.borderWidth:o==null?void 0:o.defaultNodeBorderWidth,borderRadius:s.borderRadius!==void 0?s.borderRadius:o==null?void 0:o.defaultNodeBorderRadius,color:s.color!==void 0?s.color:o==null?void 0:o.defaultNodeColor,opacity:s.opacity!==void 0?s.opacity:1,fixed:s.fixed!==void 0?s.fixed:!1,x:s.x!==void 0?s.x:0,y:s.y!==void 0?s.y:0,zIndex:s.zIndex||0,data:s.data!==void 0?s.data:{},expandHolderPosition:s.expandHolderPosition!==void 0?s.expandHolderPosition:o==null?void 0:o.defaultExpandHolderPosition,hidden:s.hidden!==void 0?s.hidden:!1,...n!==void 0?{width:n}:{},...i!==void 0?{height:i}:{}};return delete a.el_W,delete a.el_H,a},Te=(s,o={})=>o.mode==="effective"?fo(s,o.graphOptions,o.effectiveSizeMode):xt(s),uo=Object.freeze(Object.defineProperty({__proto__:null,newNodeTemplate:Fe,json2Node:Ne,transNodeToJson:Te,default:{json2Node:Ne,transNodeToJson:Te}},Symbol.toStringTag,{value:"Module"})),ue=(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.hidden===void 0&&s.isShow!==void 0&&(s.hidden=!s.isShow,console.warn("[relation-graph Warning] line option[isShow] is deprecated, please use [hidden] instead.")),s.hidden===void 0&&s.isHide!==void 0&&(s.hidden=s.isHide,console.warn("[relation-graph Warning] line option[isHide] is deprecated, please use [hidden] instead.")),{id:s.id,from:s.from,to:s.to,type:s.type!==void 0?s.type:"",isFakeLine:s.isFakeLine!==void 0?s.isFakeLine:!1,fromType:s.fromType!==void 0?s.fromType:s.isFakeLine?I.CanvasPoint:I.Node,toType:s.toType!==void 0?s.toType:s.isFakeLine?I.CanvasPoint:I.Node,selected:!1,text:s.text!==void 0?s.text:"",textOffsetX:s.textOffsetX!==void 0?s.textOffsetX:void 0,textOffsetY:s.textOffsetY!==void 0?s.textOffsetY: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,useTextOnPath:s.useTextOnPath!==void 0?s.useTextOnPath:void 0,placeText:s.placeText!==void 0?s.placeText: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,fromJunctionPointOffsetX:s.fromJunctionPointOffsetX||0,fromJunctionPointOffsetY:s.fromJunctionPointOffsetY||0,toJunctionPointOffsetX:s.toJunctionPointOffsetX||0,toJunctionPointOffsetY:s.toJunctionPointOffsetY||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:{}}},po=["arrow","isReverse","selected","shouldRender","rgCalcedVisibility"],Ct=s=>{if(!s)return;const o={};return Object.keys(s).forEach(e=>{if(!po.includes(e)){const t=s[e];t!==void 0&&(e==="isFakeLine"&&t===!1||e==="fromType"&&t===I.Node||e==="toType"&&t===I.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==="fromJunctionPointOffsetX"&&t===0||e==="fromJunctionPointOffsetY"&&t===0||e==="toJunctionPointOffsetX"&&t===0||e==="toJunctionPointOffsetY"&&t===0||e==="opacity"&&t===1||e==="hidden"&&t===!1||e==="data"&&(!t||Object.keys(t).length===0)||(o[e]=s[e]))}}),o},go=(s,o)=>{if(!s)return;const e=Ct(s)||{},t=s.isFakeLine===!0;return{...e,id:s.id,from:s.from,to:s.to,text:s.text!==void 0?s.text:"",type:s.type!==void 0?s.type:"",isFakeLine:t,fromType:s.fromType!==void 0?s.fromType:t?I.CanvasPoint:I.Node,toType:s.toType!==void 0?s.toType:t?I.CanvasPoint:I.Node,color:s.color!==void 0?s.color:o==null?void 0:o.defaultLineColor,lineWidth:s.lineWidth!==void 0?s.lineWidth:o==null?void 0:o.defaultLineWidth,opacity:s.opacity!==void 0?s.opacity:1,lineShape:s.lineShape||(o==null?void 0:o.defaultLineShape)||1,showStartArrow:s.showStartArrow!==void 0?s.showStartArrow:!1,showEndArrow:s.showEndArrow!==void 0?s.showEndArrow:!0,startMarkerId:s.startMarkerId||"",endMarkerId:s.endMarkerId||"",useTextOnPath:s.useTextOnPath||(o==null?void 0:o.defaultLineTextOnPath)||!1,textOffsetX:s.textOffsetX||(o==null?void 0:o.defaultLineTextOffsetX)||0,textOffsetY:s.textOffsetY||(o==null?void 0:o.defaultLineTextOffsetY)||0,disablePointEvent:s.disablePointEvent===void 0?o==null?void 0:o.disableLinePointEvent:s.disablePointEvent,data:s.data!==void 0?s.data:{},animation:s.animation!==void 0?s.animation:0,dashType:s.dashType!==void 0?s.dashType:0,lineRadius:s.lineRadius!==void 0?s.lineRadius:o==null?void 0:o.defaultPolyLineRadius,forDisplayOnly:s.forDisplayOnly||s.from===s.to,junctionOffset:s.junctionOffset||(o==null?void 0:o.defaultLineJunctionOffset)||0,fromJunctionPoint:s.fromJunctionPoint||(o==null?void 0:o.defaultJunctionPoint)||Y.border,toJunctionPoint:s.toJunctionPoint||(o==null?void 0:o.defaultJunctionPoint)||Y.border,fromJunctionPointOffsetX:s.fromJunctionPointOffsetX||0,fromJunctionPointOffsetY:s.fromJunctionPointOffsetY||0,toJunctionPointOffsetX:s.toJunctionPointOffsetX||0,toJunctionPointOffsetY:s.toJunctionPointOffsetY||0,hidden:s.hidden!==void 0?s.hidden:!1}},pe=(s,o={})=>o.mode==="effective"?go(s,o.graphOptions):Ct(s),Re=(s,o={})=>{if(!!s)return pe(s.line,o)},mo=Object.freeze(Object.defineProperty({__proto__:null,json2Line:ue,transLineToJson:pe,transLinkToJson:Re,default:{json2Line:ue,transLinkToJson:Re}},Symbol.toStringTag,{value:"Module"})),yo=1500,vo=2,wt=["rg-node-checked","rg-node-selected","rg-node-dragging","rg-node-hover"],xo=["rg-line-checked","rg-line-selected"],Co=new Set(["class","id","tabindex"]),Ge="[value]",Me="{{text}}",wo=["self","before","after"],Lt={self:null,before:"::before",after:"::after"},_t={self:0,before:1,after:2},$e="http://www.w3.org/2000/svg",Lo=new Set(["azimuth","border-collapse","border-spacing","caption-side","caret-color","color","cursor","direction","empty-cells","fill","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","hyphenate-character","hyphenate-limit-chars","hyphens","image-rendering","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","orphans","paint-order","pointer-events","quotes","resize","speak","stroke","tab-size","text-align","text-align-last","text-combine-upright","text-indent","text-justify","text-orientation","text-rendering","text-shadow","text-transform","text-underline-position","visibility","white-space","widows","word-break","word-spacing","word-wrap","writing-mode"]),bt=new WeakMap;async function _o(s,o={}){var u,y;const e=[],t=bo(e),n=No(t);if(!s.dom||!s.canvasDom)return n.meta.degraded=!0,n.meta.reason="graph-dom-not-ready",n;if(s.showEasyView)return n.meta.degraded=!0,n.meta.reason="show-easy-view-enabled",n;if(s.performanceMode)return n.meta.degraded=!0,n.meta.reason="performance-mode-partial-dom-render",n;o.waitForStable!==!1&&(await To(s,{timeoutMs:(u=o.timeoutMs)!=null?u:yo,stableFrames:(y=o.stableFrames)!=null?y:vo})||e.push("render-stability-timeout"));const i=Nt(s),a=Tt(s);i.length===0&&a.length===0&&e.push("no-visible-dom-items-detected");const r=new Map,d=new Map,c=new Map,h=[],f=[];for(const p of i){const g=s.getNodeById(p.nodeId);if(!g)continue;const m=Eo(g,s.graphOptions),v=Oo(p,s.graphOptions),x=je(v),L=Xo(r,x,v);L.nodeIds.push(p.nodeId);const P=St(p.nodeEl,"signature"),E=je(P),T=Fo(d,E);T.nodeIds.push(p.nodeId),T.samples.push({nodeId:p.nodeId,nodeJson:m,renderDescriptor:St(p.nodeEl,"raw"),rootElement:p.nodeEl}),h.push({...m,nodeId:p.nodeId,styleClassId:L.id,renderClassId:T.id})}for(const p of a){const g=So(s,p);if(!g)continue;const m=Ro(p),v=je(m),x=di(c,v,m.pathStyle,m.textStyle);x.lineIds.push(p.lineId),f.push({...g,lineId:p.lineId,styleClassId:x.id,isFakeLine:p.isFakeLine,textMode:p.textMode})}return{meta:{...t,warnings:e,renderedAt:Date.now()},nodeStyleClasses:[...r.values()],nodeRenderClasses:Go([...d.values()],o.includeNormalizedHtml!==!1,e),lineStyleClasses:[...c.values()],nodes:h,lines:f}}function bo(s){return{degraded:!1,warnings:s,renderedAt:Date.now()}}function No(s){return{meta:s,nodeStyleClasses:[],nodeRenderClasses:[],lineStyleClasses:[],nodes:[],lines:[]}}async function To(s,o){await ko(s);const e=Date.now();let t="",n=0;for(;Date.now()-e<o.timeoutMs;){await Ie(s.dom);const i=Po(s);if(i===t){if(n+=1,n>=o.stableFrames)return!0}else n=0,t=i}return!1}async function ko(s){var t;const o=(t=s.dom)==null?void 0:t.ownerDocument;if(!o)return;const e=o.fonts;if(!e||!e.ready){await Ie(s.dom),await Ie(s.dom);return}await Promise.race([e.ready.then(()=>{}),s.sleep(400)]),await Ie(s.dom)}function Ie(s){var e;const o=(e=s==null?void 0:s.ownerDocument)==null?void 0:e.defaultView;return o!=null&&o.requestAnimationFrame?new Promise(t=>{o.requestAnimationFrame(()=>t())}):new Promise(t=>setTimeout(t,16))}function Po(s){const o=Nt(s),e=Tt(s),t=o.map(i=>{const a=i.nodeEl.getBoundingClientRect();return`${i.nodeId}:${De(a.width)}x${De(a.height)}`}).join("|"),n=e.map(i=>{var d;const a=(d=i.pathPeel)==null?void 0:d.querySelector(".rg-line"),r=a?De(a.getBoundingClientRect().width):0;return`${i.lineId}:${i.textMode}:${r}`}).join("|");return`${t}::${n}`}function Nt(s){if(!s.canvasDom)return[];const o=s.canvasDom.querySelectorAll(".rg-nodes-container-wrapper .rg-node-peel[data-id]"),e=[];return o.forEach(t=>{const n=t,i=n.dataset.id;if(!i||!s.getNodeById(i))return;const a=hi(n,"rg-node");if(!a)return;const r=a.getBoundingClientRect();r.width===0||r.height===0||e.push({nodeId:i,peel:n,nodeEl:a})}),e.sort((t,n)=>t.nodeId.localeCompare(n.nodeId)),e}function Tt(s){if(!s.canvasDom)return[];const o=new Map;s.canvasDom.querySelectorAll(".rg-lines-container .rg-line-peel[data-id]").forEach(i=>{const a=i,r=a.dataset.id;if(!r)return;const d=kt(o,s,r);d.pathPeel=a}),s.canvasDom.querySelectorAll(".rg-lines-container .rg-linetext-container").forEach(i=>{i.querySelectorAll(".rg-line-peel[data-id]").forEach(a=>{const r=a,d=r.dataset.id;if(!d)return;const c=kt(o,s,d);c.textPeel=r})});const n=[...o.values()].filter(i=>!!(i.isFakeLine?s.getFakeLineById(i.lineId):s.getLineById(i.lineId)));return n.forEach(i=>{var a,r;if((a=i.textPeel)!=null&&a.querySelector(".rg-line-label")){i.textMode="html-label";return}if((r=i.pathPeel)!=null&&r.querySelector(".rg-line-text")){i.textMode="svg-text-path";return}i.textMode="none"}),n.sort((i,a)=>i.lineId.localeCompare(a.lineId)),n}function kt(s,o,e){const t=s.get(e);if(t)return t;const n=!o.getLineById(e)&&!!o.getFakeLineById(e),i={lineId:e,isFakeLine:n,textMode:"none"};return s.set(e,i),i}function Eo(s,o){return Te(s,{mode:"effective",graphOptions:o,effectiveSizeMode:"node"})||{id:s.id}}function So(s,o){if(o.isFakeLine){const n=s.getFakeLineById(o.lineId);return n?pe(n,{mode:"effective",graphOptions:s.graphOptions}):void 0}const e=s.getLinkByLineId(o.lineId);if(e)return Re(e,{mode:"effective",graphOptions:s.graphOptions});const t=s.getLineById(o.lineId);return t?pe(t,{mode:"effective",graphOptions:s.graphOptions}):void 0}function Oo(s,o){return Pt(s.peel,wt,()=>{const e=ae(s.nodeEl),t=ae(s.peel),n=s.nodeEl.querySelector(".rg-node-text")||s.nodeEl,i=ae(n),a=s.nodeEl.getBoundingClientRect(),r=fi(o);return{width:$t(a.width/r),height:$t(a.height/r),backgroundColor:q(e.backgroundColor),borderTopWidth:q(e.borderTopWidth),borderTopColor:q(e.borderTopColor),borderTopLeftRadius:q(e.borderTopLeftRadius),color:q(i.color),fontSize:q(i.fontSize||e.fontSize),opacity:q(t.opacity)}})}function Ro(s){return Do([s.pathPeel,s.textPeel],xo,()=>{var n,i,a;const o=(n=s.pathPeel)==null?void 0:n.querySelector(".rg-line"),e=ae(o),t={stroke:q(e.stroke),strokeWidth:q(e.strokeWidth),strokeDasharray:q(e.strokeDasharray),strokeDashoffset:q(e.strokeDashoffset),opacity:q(e.opacity)};if(s.textMode==="html-label"){const r=(i=s.textPeel)==null?void 0:i.querySelector(".rg-line-label");return{pathStyle:t,textStyle:r?Mo(r):He("none")}}if(s.textMode==="svg-text-path"){const r=(a=s.pathPeel)==null?void 0:a.querySelector(".rg-line-text");return{pathStyle:t,textStyle:r?Io(r):He("none")}}return{pathStyle:t,textStyle:He("none")}})}function He(s){return{mode:s,backgroundColor:s==="svg-text-path"?"transparent":"",fontSize:"",color:""}}function Mo(s){const o=ae(s);return{mode:"html-label",backgroundColor:q(o.backgroundColor),fontSize:q(o.fontSize),color:q(o.color)}}function Io(s){const o=ae(s);return{mode:"svg-text-path",backgroundColor:"transparent",fontSize:q(o.fontSize),color:q(o.fill||o.color)}}function Do(s,o,e){const t=s.filter(n=>!!n).map(n=>Et(n,o));try{return e()}finally{t.reverse().forEach(n=>n())}}function Pt(s,o,e){const t=Et(s,o);try{return e()}finally{t()}}function Et(s,o){const e=[];return o.forEach(t=>{s.classList.contains(t)&&(s.classList.remove(t),e.push(t))}),()=>{e.forEach(t=>{s.classList.add(t)})}}function St(s,o="signature"){const e=Ot(s.childNodes,o);return{kind:"element",tag:"fragment",classes:[],attrs:{},children:e}}function Ot(s,o){const e=Array.from(s),t=[];return e.forEach(n=>{const i=Bo(n,o);i&&t.push(i)}),t}function Bo(s,o){var a;if(s.nodeType===Node.TEXT_NODE){const r=(a=s.textContent)==null?void 0:a.replace(/\s+/g," ").trim();return r?{kind:"text",text:o==="signature"?Me:r}:null}if(s.nodeType!==Node.ELEMENT_NODE)return null;const e=s,t=Array.from(e.classList).sort(),n=Vo(e,o),i=Ot(e.childNodes,o);return{kind:"element",tag:e.tagName.toLowerCase(),classes:t,attrs:n,children:i}}function Vo(s,o){const e={};for(const t of Array.from(s.attributes))Co.has(t.name)||t.name.startsWith("data-")||t.name.startsWith("aria-")||(e[t.name]=Ao(t.name,t.value,o));return e}function Ao(s,o,e){const t=o.trim();return t?e==="raw"||s==="type"||s==="role"?t:Ge:""}function Ye(s){if(s.kind==="text")return s.text;if(s.tag==="fragment")return s.children.map(Ye).join("");const o=s.classes.length>0?` class="${s.classes.join(" ")}"`:"",e=Object.keys(s.attrs).sort().map(n=>{const i=s.attrs[n];return i===""?` ${n}`:` ${n}="${zo(i)}"`}).join(""),t=s.children.map(Ye).join("");return`<${s.tag}${o}${e}>${t}</${s.tag}>`}function zo(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Xo(s,o,e){const t=s.get(o);if(t)return t;const n={id:`node-style-${s.size+1}`,signature:o,style:e,nodeIds:[]};return s.set(o,n),n}function Fo(s,o){const e=s.get(o);if(e)return e;const t={id:`node-render-${s.size+1}`,signature:o,nodeIds:[],samples:[]};return s.set(o,t),t}function Go(s,o,e){return s.map(t=>{const n=si(t.samples),i=$o(t.samples),a=ni(t.samples,i,e);return{id:t.id,signature:t.signature,renderDescriptor:n,renderStyleRules:i,renderKeyframes:a,normalizedHtml:o?Ye(n):void 0,nodeIds:t.nodeIds}})}function $o(s){if(s.length===0)return[];const o=s.map(n=>Ho(n.rootElement)),e=o[0],t=[];for(const n of Array.from(e.keys()).sort(ei)){let i=Zo(e.get(n));if(!i||Object.keys(i).length===0)continue;for(let d=1;d<o.length&&(i=Ko(i,o[d].get(n)),!(!i||Object.keys(i).length===0));d+=1);if(!i||Object.keys(i).length===0)continue;const{path:a,pseudo:r}=We(n);t.push({path:a,pseudo:r,style:It(i)})}return t}function Ho(s){return Pt(s.parentElement||s,wt,()=>{const o=Yo(s),e=new Map;return o.forEach(t=>{wo.forEach(n=>{const i=Wo(t.element,n);Object.keys(i).length!==0&&e.set(Qo(t.path,n),i)})}),e})}function Yo(s){return Rt(s.childNodes,"")}function Rt(s,o){const e=Array.from(s),t=[];let n=0;return e.forEach(i=>{var d;if(i.nodeType===Node.TEXT_NODE){if(!((d=i.textContent)==null?void 0:d.replace(/\s+/g," ").trim()))return;n+=1;return}if(i.nodeType!==Node.ELEMENT_NODE)return;const a=i,r=o?`${o}/${n}`:`${n}`;t.push({path:r,element:a}),t.push(...Rt(a.childNodes,r)),n+=1}),t}function Wo(s,o){const e=ae(s,Lt[o]),t=Jo(s,o),n=ae(o==="self"?s.parentElement:s),i=Uo(e,s),a={};return i.forEach(r=>{if(jo(r))return;const d=q(e.getPropertyValue(r));if(!d)return;const c=q(t.getPropertyValue(r));if(d!==c){if(Lo.has(r)){const h=q(n.getPropertyValue(r));if(d===h)return}a[r]=d}}),It(a)}function Uo(s,o){const e=new Set;for(let t=0;t<s.length;t+=1){const n=s.item(t);n&&e.add(n)}if(o instanceof HTMLElement||o instanceof SVGElement)for(let t=0;t<o.style.length;t+=1){const n=o.style.item(t);n&&e.add(n)}return Array.from(e).sort()}function jo(s){return!!(!s||s.startsWith("--rg-"))}function Jo(s,o){const e=s.ownerDocument,t=`${s.namespaceURI===$e?"svg":"html"}|${s.tagName.toLowerCase()}|${o}`;let n=bt.get(e);if(!n){const c=e.createElement("div");c.setAttribute("data-rg-render-style-baseline","true"),c.style.setProperty("all","initial"),c.style.setProperty("position","fixed"),c.style.setProperty("left","-99999px"),c.style.setProperty("top","-99999px"),c.style.setProperty("visibility","hidden"),c.style.setProperty("pointer-events","none"),c.style.setProperty("contain","layout style paint"),(e.body||e.documentElement).appendChild(c),n={container:c,cache:new Map},bt.set(e,n)}const i=n.cache.get(t);if(i)return Mt(i);const a=s.namespaceURI===$e?e.createElementNS($e,s.tagName.toLowerCase()):e.createElement(s.tagName.toLowerCase());n.container.appendChild(a);const r=ae(a,Lt[o]),d=qo(r);return a.remove(),n.cache.set(t,d),Mt(d)}function qo(s){const o={};for(let e=0;e<s.length;e+=1){const t=s.item(e);if(!t)continue;const n=q(s.getPropertyValue(t));n&&(o[t]=n)}return o}function Mt(s){return new Proxy(s,{get(o,e){return e==="getPropertyValue"?t=>o[t]||"":e==="item"?t=>Object.keys(o).sort()[t]||"":e==="length"?Object.keys(o).length:o[e]||""}})}function Zo(s){if(!!s)return{...s}}function Ko(s,o){if(!s||!o)return;const e={};return Object.keys(s).forEach(t=>{o[t]===s[t]&&(e[t]=s[t])}),e}function It(s){return Object.keys(s).sort().reduce((o,e)=>(o[e]=s[e],o),{})}function Qo(s,o){return`${s}::${o}`}function We(s){const o=s.lastIndexOf("::");return o<0?{path:s,pseudo:"self"}:{path:s.slice(0,o),pseudo:s.slice(o+2)}}function ei(s,o){const e=We(s),t=We(o),n=ti(e.path,t.path);return n!==0?n:_t[e.pseudo]-_t[t.pseudo]}function ti(s,o){const e=s.split("/").map(i=>Number(i)),t=o.split("/").map(i=>Number(i)),n=Math.max(e.length,t.length);for(let i=0;i<n;i+=1){const a=e[i],r=t[i];if(Number.isNaN(a)||Number.isNaN(r))return s.localeCompare(o);if(a!==r)return a-r}return e.length-t.length}function ni(s,o,e){if(s.length===0||o.length===0)return[];const t=oi(o);if(t.length===0)return[];const n=s[0].rootElement.ownerDocument,i=ii(n,e),a=[];return t.forEach(r=>{const d=i.get(r);if(!d){At(e,"render-keyframes-missing-definition");return}a.push({name:r,cssText:d})}),a}function oi(s){const o=new Set;return s.forEach(e=>{const t=e.style["animation-name"];!t||t.split(",").forEach(n=>{const i=n.trim();!i||i==="none"||o.add(i)})}),Array.from(o).sort()}function ii(s,o){const e=new Map,t=new Set;return Array.from(s.styleSheets).forEach(n=>{Dt(n,e,o,t)}),e}function Dt(s,o,e,t){if(!s||t.has(s))return;t.add(s);let n;try{n=s.cssRules}catch{At(e,"stylesheet-rules-inaccessible");return}Array.from(n).forEach(i=>{if(i instanceof CSSImportRule){Dt(i.styleSheet,o,e,t);return}if(i instanceof CSSKeyframesRule){o.set(i.name,i.cssText);return}Vt(i)&&Bt(i.cssRules,o)})}function Bt(s,o){Array.from(s).forEach(e=>{if(e instanceof CSSKeyframesRule){o.set(e.name,e.cssText);return}Vt(e)&&Bt(e.cssRules,o)})}function Vt(s){return"cssRules"in s}function At(s,o){s.includes(o)||s.push(o)}function si(s){return s.length===0?{kind:"element",tag:"fragment",classes:[],attrs:{},children:[]}:zt(s.map(o=>({nodeJson:o.nodeJson,renderDescriptor:o.renderDescriptor})))}function zt(s){var i;const o=(i=s[0])==null?void 0:i.renderDescriptor;if(!o)return{kind:"text",text:Me};if(o.kind==="text")return{kind:"text",text:Xt(s.map(a=>a.renderDescriptor.kind==="text"?a.renderDescriptor.text:""),s.map(a=>a.nodeJson),"text")};const e=Array.from(new Set(s.flatMap(a=>a.renderDescriptor.kind==="element"?Object.keys(a.renderDescriptor.attrs):[]))).sort(),t={};e.forEach(a=>{t[a]=Xt(s.map(r=>{var d;return r.renderDescriptor.kind==="element"&&(d=r.renderDescriptor.attrs[a])!=null?d:""}),s.map(r=>r.nodeJson),"attr")});const n=o.children.map((a,r)=>zt(s.map(d=>{const c=d.renderDescriptor;return{nodeJson:d.nodeJson,renderDescriptor:c.children[r]}})));return{kind:"element",tag:o.tag,classes:o.classes,attrs:t,children:n}}function Xt(s,o,e){if(s.length===0)return e==="text"?Me:Ge;const t=s[0];if(s.every(a=>a===t))return t;const i=ai(s,o,e);return i?`{{${i}}}`:e==="text"?Me:Ge}function ai(s,o,e){if(s.length!==o.length||s.length===0)return;const n=Ft(o[0],e).filter(i=>s.every((a,r)=>{const c=Ft(o[r],e).find(h=>h.expression===i.expression);return!!c&&c.value===a})).map(i=>i.expression);if(n.length!==0)return n.sort(li)[0]}function Ft(s,o){const e=[];return Ue(s,"node",o,e),e}function Ue(s,o,e,t){if(s!=null){if(typeof s=="string"||typeof s=="number"||typeof s=="boolean"){t.push({expression:o,value:ri(s,e)});return}if(Array.isArray(s)){s.forEach((n,i)=>{Ue(n,`${o}[${i}]`,e,t)});return}typeof s=="object"&&Object.keys(s).sort().forEach(n=>{Ue(s[n],`${o}.${n}`,e,t)})}}function ri(s,o){const e=String(s);return o==="text"?e.replace(/\s+/g," ").trim():e.trim()}function li(s,o){const e=Gt(o)-Gt(s);return e!==0?e:s.localeCompare(o)}function Gt(s){return s==="node.text"?400:s==="node.id"?390:s==="node.type"?380:s.startsWith("node.data.")?300-s.split(".").length:s.startsWith("node.")?200-s.split(".").length:0}function di(s,o,e,t){const n=s.get(o);if(n)return n;const i={id:`line-style-${s.size+1}`,signature:o,pathStyle:e,textStyle:t,lineIds:[]};return s.set(o,i),i}function ae(s,o){var e;return!s||!((e=s.ownerDocument)!=null&&e.defaultView)?ci():s.ownerDocument.defaultView.getComputedStyle(s,o||null)}function ci(){const s={};return new Proxy(s,{get(o,e){return e==="getPropertyValue"?t=>o[t]||"":e==="item"?()=>"":e==="length"?0:o[e]||""}})}function hi(s,o){for(const e of Array.from(s.children))if(e instanceof HTMLElement&&e.classList.contains(o))return e;return null}function q(s){return s?s.replace(/\s+/g," ").replace(/\s*,\s*/g,",").trim():""}function De(s){return Number.parseFloat(s.toFixed(2))}function fi(s){const o=s.canvasZoom||s.canvasZoom===0?s.canvasZoom/100:1;return o>0?o:1}function $t(s){return`${De(s)}px`}function je(s){return JSON.stringify(Je(s))}function Je(s){if(Array.isArray(s))return s.map(Je);if(s&&typeof s=="object"){const o={};return Object.keys(s).sort().forEach(e=>{o[e]=Je(s[e])}),o}return s}class ui{constructor(o){_(this,"$evCanvasCtx");_(this,"viewScale",1);_(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,d){const c=this.$evCanvasCtx,h=this.offset.x+o,f=this.offset.y+e;let u=Math.max(0,r);t<2*u&&(u=t/2),n<2*u&&(u=n/2),c.beginPath(),c.globalAlpha=a,u===0?c.rect(h,f,t,n):(c.moveTo(h+u,f),c.arcTo(h+t,f,h+t,f+u,u),c.arcTo(h+t,f+n,h+t-u,f+n,u),c.arcTo(h,f+n,h,f+n-u,u),c.arcTo(h,f,h+u,f,u),c.closePath()),c.fillStyle=i,c.fill(),c.globalAlpha=1,c.strokeStyle=d,c.lineWidth=1,c.stroke()}evDrawNode4Circle(o,e,t,n,i,a,r){const d=this.$evCanvasCtx,c=this.offset.x+o+t/2,h=this.offset.y+e+n/2;d.beginPath(),d.globalAlpha=a,d.ellipse(c,h,t/2,n/2,0,0,2*Math.PI),d.fillStyle=i,d.fill(),d.strokeStyle=r,d.lineWidth=1,d.stroke(),d.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,d=0,c=0,h=0,f=0,u="";o.beginPath(),t.forEach(y=>{const p=y.trim(),g=p.charAt(0),v=p.substring(1).trim().split(/[ ,]+/).filter(C=>C!=="").map(parseFloat);let x=0,L=0,P=0,E=0,T=0,N=0,b=0,k=0,O=0,S=0,R=0;switch(g){case"M":n=v[0],i=v[1],a=n,r=i,o.moveTo(n+this.offset.x,i+this.offset.y);for(let C=2;C<v.length;C+=2)n=v[C],i=v[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"L":for(let C=0;C<v.length;C+=2)n=v[C],i=v[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"l":for(let C=0;C<v.length;C+=2)n+=v[C],i+=v[C+1],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"H":for(let C=0;C<v.length;C++)n=v[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"h":for(let C=0;C<v.length;C++)n+=v[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"V":for(let C=0;C<v.length;C++)i=v[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"v":for(let C=0;C<v.length;C++)i+=v[C],o.lineTo(n+this.offset.x,i+this.offset.y);break;case"C":for(let C=0;C<v.length;C+=6)P=v[C],E=v[C+1],T=v[C+2],N=v[C+3],x=v[C+4],L=v[C+5],o.bezierCurveTo(P+this.offset.x,E+this.offset.y,T+this.offset.x,N+this.offset.y,x+this.offset.x,L+this.offset.y),n=x,i=L,d=T,c=N;break;case"c":for(let C=0;C<v.length;C+=6)P=n+v[C],E=i+v[C+1],T=n+v[C+2],N=i+v[C+3],x=n+v[C+4],L=i+v[C+5],o.bezierCurveTo(P+this.offset.x,E+this.offset.y,T+this.offset.x,N+this.offset.y,x+this.offset.x,L+this.offset.y),d=T,c=N,n=x,i=L;break;case"S":for(let C=0;C<v.length;C+=4)u.match(/[CS]/i)?(P=2*n-d,E=2*i-c):(P=n,E=i),T=v[C],N=v[C+1],x=v[C+2],L=v[C+3],o.bezierCurveTo(P+this.offset.x,E+this.offset.y,T+this.offset.x,N+this.offset.y,x+this.offset.x,L+this.offset.y),n=x,i=L,d=T,c=N;break;case"s":for(let C=0;C<v.length;C+=4)u.match(/[CS]/i)?(P=2*n-d,E=2*i-c):(P=n,E=i),T=n+v[C],N=i+v[C+1],x=n+v[C+2],L=i+v[C+3],o.bezierCurveTo(P+this.offset.x,E+this.offset.y,T+this.offset.x,N+this.offset.y,x+this.offset.x,L+this.offset.y),d=T,c=N,n=x,i=L;break;case"Q":for(let C=0;C<v.length;C+=4)P=v[C],E=v[C+1],x=v[C+2],L=v[C+3],o.quadraticCurveTo(P+this.offset.x,E+this.offset.y,x+this.offset.x,L+this.offset.y),n=x,i=L,h=P,f=E;break;case"q":for(let C=0;C<v.length;C+=4)P=n+v[C],E=i+v[C+1],x=n+v[C+2],L=i+v[C+3],o.quadraticCurveTo(P+this.offset.x,E+this.offset.y,x+this.offset.x,L+this.offset.y),h=P,f=E,n=x,i=L;break;case"T":for(let C=0;C<v.length;C+=2)u.match(/[QT]/i)?(P=2*n-h,E=2*i-f):(P=n,E=i),x=v[C],L=v[C+1],o.quadraticCurveTo(P+this.offset.x,E+this.offset.y,x+this.offset.x,L+this.offset.y),n=x,i=L,h=P,f=E;break;case"t":for(let C=0;C<v.length;C+=2)u.match(/[QT]/i)?(P=2*n-h,E=2*i-f):(P=n,E=i),x=n+v[C],L=i+v[C+1],o.quadraticCurveTo(P+this.offset.x,E+this.offset.y,x+this.offset.x,L+this.offset.y),h=P,f=E,n=x,i=L;break;case"A":for(let C=0;C<v.length;C+=7)b=v[C],k=v[C+1],O=v[C+2],S=v[C+3],R=v[C+4],x=v[C+5],L=v[C+6],this.drawArc(o,n,i,b,k,O,S,R,x,L),n=x,i=L;break;case"a":for(let C=0;C<v.length;C+=7)b=v[C],k=v[C+1],O=v[C+2],S=v[C+3],R=v[C+4],x=n+v[C+5],L=i+v[C+6],this.drawArc(o,n,i,b,k,O,S,R,x,L),n=x,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)?u=g:u=""})}drawArc(o,e,t,n,i,a,r,d,c,h){if(n=Math.abs(n),i=Math.abs(i),n===0||i===0){o.lineTo(c+this.offset.x,h+this.offset.y);return}const f=a%360*Math.PI/180,u=Math.sin(f),y=Math.cos(f),p=y*(e-c)/2+u*(t-h)/2,g=-u*(e-c)/2+y*(t-h)/2,m=p*p/(n*n)+g*g/(i*i);m>1&&(n*=Math.sqrt(m),i*=Math.sqrt(m));let v=(r===d?-1:1)*Math.sqrt(Math.max(0,(n*n*i*i-n*n*g*g-i*i*p*p)/(n*n*g*g+i*i*p*p)));isNaN(v)&&(v=0);const x=v*n*g/i,L=v*-i*p/n,P=y*x-u*L+(e+c)/2,E=u*x+y*L+(t+h)/2,T=(p-x)/n,N=(g-L)/i,b=(-p-x)/n,k=(-g-L)/i;let O=Math.atan2(N,T),S=Math.atan2(N*b-T*k,T*b+N*k);d===0&&S>0?S-=2*Math.PI:d===1&&S<0&&(S+=2*Math.PI);const R=O+S;o.ellipse?o.ellipse(P+this.offset.x,E+this.offset.y,n,i,f,O,R,d===0):(console.warn("ctx.ellipse is not supported. Arc will be drawn as a line."),o.lineTo(c+this.offset.x,h+this.offset.y))}}let ke={x:0,y:0};const Pe={x:0,y:0},re={x:0,y:0},Ht={passive:!1};let qe,Ze;const Ke=s=>ce(s),te={startDrag(s,o,e,t){t?qe=(n,i,a)=>{const r=n-re.x,d=i-re.y;t(r,d,Pe,re,a)}:qe=(n,i)=>{ke.x=Pe.x+(n-re.x),ke.y=Pe.y+(i-re.y)},Ze=e,ke=o,Pe.x=ke.x,Pe.y=ke.y;try{const n=Ke(s);re.x=n.clientX,re.y=n.clientY,fe(s)?(document.body.addEventListener("touchmove",te.onNodeMove,Ht),document.body.addEventListener("touchend",te.onNodeDragend),document.body.addEventListener("mousemove",te.onNodeMove),document.body.addEventListener("mouseup",te.onNodeDragend),s.preventDefault()):(document.body.addEventListener("mousemove",te.onNodeMove),document.body.addEventListener("mouseup",te.onNodeDragend))}catch(n){console.error(n.message)}},onNodeMove(s){const o=Ke(s);qe(o.clientX,o.clientY,s)},onNodeDragend(s){if(fe(s)?(document.body.removeEventListener("touchmove",te.onNodeMove,Ht),document.body.removeEventListener("touchend",te.onNodeDragend),document.body.removeEventListener("mousemove",te.onNodeMove),document.body.removeEventListener("mouseup",te.onNodeDragend)):(document.body.removeEventListener("mousemove",te.onNodeMove),document.body.removeEventListener("mouseup",te.onNodeDragend)),Ze){const o=Ke(s),e=o.clientX,t=o.clientY,n=e-re.x,i=t-re.y;Ze(n,i,s)}}},he=te;function pi(s,o,e,t,n,i,a,r,d){const c=n-s,h=i-o,f=Math.sqrt(c*c+h*h);if(f===0)return{x:s,y:o};const u=d*h/f,y=-(d*c)/f,p=s+u,g=o+y,m=s-e/2,v=s+e/2,x=o-t/2,L=o+t/2;let P=[];if(c!==0){let N=(m-p)/c,b=g+N*h;b>=x&&b<=L&&P.push({x:m,y:b});let k=(v-p)/c,O=g+k*h;O>=x&&O<=L&&P.push({x:v,y:O})}if(h!==0){let N=(x-g)/h,b=p+N*c;b>=m&&b<=v&&P.push({x:b,y:x});let k=(L-g)/h,O=p+k*c;O>=m&&O<=v&&P.push({x:O,y:L})}if(P.length===0&&c===0&&h===0)return{x:p,y:g};let E=null,T=1/0;return P.forEach(N=>{const b=Math.sqrt((N.x-n)**2+(N.y-i)**2);b<T&&(T=b,E=N)}),E}const gi={getRectPoint(s,o,e,t,n,i,a,r,d=!1,c=1,h=0,f=14,u=!1){const y=s+n/2,p=o+i/2,g=e+a/2,m=t+r/2;if(c>1){const k=Math.min(f,n,i),O=-k/2,S=k/(c-1),R=d&&u||!d&&!u?O*-1-h*S:O+h*S,C=pi(y,p,n,i,g,m,a,r,R);if(C)return C}const v=y<g?1:-1,x=p<m?1:-1;if(m===p)return{x:y+v*n/2,y:p};const L=Math.abs((g-y)/(m-p)),P=n/i;let E=0,T=0;L<P?(E=v*i/2*L,T=x*i/2):(E=v*n/2,T=x*n/2/L);const N=y+E,b=p+T;return{x:N,y:b}},getRectPointBasic(s,o,e,t,n,i,a,r){const d=s+n/2,c=o+i/2,h=e+a/2,f=t+r/2;let u=f===c?0:(h-d)/(f-c);u===0&&f===c&&h===d?u=1:u===0&&(u=(h-d)/(f-c+(f>c?-1:1)*1e-4));const y=n/i;let p=0,g=0,m="1";return Math.abs(u)<y?(m="2",c<=f?(g=i/2,p=g*u):(g=-i/2,p=g*u)):(m="3",d<=h?(p=n/2,g=u===0&&h===d?0:p/u):(p=-n/2,g=u===0&&h===d?0:p/u)),{x:d+p,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:d}=s,c=o+i/2,h=e+a/2,f=t+r/2,u=n+d/2,y=f-c,p=u-h,g=y/(i/2),m=p/(a/2);return Math.abs(g)>Math.abs(m)?g>0?{x:o+i,y:h}:{x:o,y:h}:m>0?{x:c,y:e+a}:{x:c,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,d){return d===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:d,nodeShape:c,isReverse:h=!1,isEndPoint:f,totalLinesBetweenNodes:u=1,currentLineIndex:y=0,lineDistance:p=50}=s;return c===0?this.getCirclePoint4MultiLine(o,e,t,n,i,a,r,d,h,u,y,p,f):this.getRectPoint(o,e,t,n,i,a,r,d,h,u,y,p,f)},getCirclePoint(s,o,e,t,n,i,a,r){const d=e+a/2,c=t+r/2,h=s+n/2,f=o+i/2,u=d-h;if(u===0)return{x:h,y:f-i/2*(c<f?1:-1)};const p=(c-f)/u,g=Math.sqrt(1/(1/(n/2)**2+p**2/(i/2)**2))*(d<h?1:-1),m=p*g;return{x:h-g,y:f-m}},getCirclePoint4MultiLine(s,o,e,t,n,i,a,r,d,c,h,f,u){let y=e+a/2;const p=t+r/2;let g=s+n/2;const m=o+i/2;let v=y-g;v>-1&&v<1&&(y=y-.5,g=g+.5,v=-1);let L=0;if(c>1){const R=Math.min(f,n,i),C=-R/2,M=R/(c-1);L=d&&u||!d&&!u?C*-1-h*M:C+h*M}const P=p-m,E=Math.sqrt(v**2+P**2)*L/v,T=P/v,N=n/2,b=i/2,k=g<y?-1:1,O=(-1*N**2*T*E+N*b*Math.sqrt(Math.abs(b**2+T**2*N**2-E**2))/k)/(b**2+N**2*T**2),S=T*O+E;return{x:g-O,y:m-S}},getCirclePointBasic(s,o,e,t,n,i,a,r,d){const c=s+n/2,h=o+i/2,f=e+a/2,u=t+r/2,y=f-c,p=u-h,g=Math.sqrt(y*y+p*p),m=g-d,v=m*y/g*-1,x=m*p/g*-1;return{x:f+v,y:u+x}},getCirclePointPlus(s,o,e,t,n,i,a,r){const d=s+n/2,c=o+i/2,h=e+a/2,f=t+r/2,u=h-d,y=f-c,p=Math.sqrt(u*u+y*y),g=(p-n/2)*u/p*-1,m=(p-i/2)*y/p*-1;return{x:h+g,y:f+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),d=(s-e)*a-(o-t)*r+e,c=(s-e)*r+(o-t)*a+t;return{x:d,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)}},we=(s,o,e,t)=>{const n=s-e,i=o-t;return Math.sqrt(n**2+i**2)};function Yt(s,o,e,t,n=0,i=0){let a=1,r=n,d=i,c=0;for(let h of e){const f=h.width,u=h.height;u>c&&(c=u),t(h,r,d),r+=f+o,a>s?(d+=c+o,a=1,r=0,c=0):a++}}const J=gi;class mi{constructor(o){_(this,"graphInstance");_(this,"initialized",!1);_(this,"isFolderLayout",!1);this.graphInstance=o}analyzeNetwork(o,e,t=!1,n=!1){this.initialized||(this.initialized=!0),o.forEach(p=>{p.lot||(p.lot={}),p.lot.eached=!1,p.lot.index_of_level=0,p.lot.index_of_p_childs=0,p.lot.index_of_parent=0,p.lot.strength=0,p.lot.strengthWithChilds_from=0,p.lot.strengthWithChilds=0,p.lot.childrenSizeVisible=0,p.lot.childrenSize=0,p.lot.childs=[],p.lot.subling=void 0,p.lot.parent=void 0}),e.lot.parent=void 0;const i=this.markNodeParent(e);w("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},d={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,d),this.calcStrengthWithChildsValue(a),this.calcStrengthFromValue(e,1),t&&this.calcStrengthFromValue(e,-1);const h=a.filter(p=>p.lot.level===1),f=h.length===0?1:h.map(p=>p.lot.strengthWithChilds).reduce((p,g)=>p+g,0);r.max_strength=f;const u=a.filter(p=>p.lot.level>=0);w("groupNodes:tree-nodes:",u.length,r);const y={tree:{networkNodes:u,analyticResult:r},reverseTree:{networkNodes:[],analyticResult:d}};if(t){const p=a.filter(v=>v.lot.level===-1),g=p.length===0?1:p.map(v=>v.lot.strengthWithChilds).reduce((v,x)=>v+x,0);d.max_strength=g;const m=a.filter(v=>v.lot.level<=0);w("groupNodes:reverse-tree-nodes:",m.length,d),y.reverseTree.networkNodes=m}for(const p of o)this.graphInstance.updateNode(p,{rgChildrenSize:p.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 d=n&&t<0?r:a;w(`bothWay:${n}(deep:${i}) level ${t} size: ${e.length}`,d.direct),e.length>d.max_length&&(d.max_length=e.length),t>d.max_deep&&(d.max_deep=t),t<d.min_deep&&(d.min_deep=t),d.levels.has(t)||d.levels.set(t,{level:t,all_size:e.length,all_strength:0});const c=d.levels.get(t);e.forEach(p=>{p.lot.eached=!0,p.lot.subling=c,p.lot.level=t,o.push(p)});const h=[],f=[];let u=1,y=0;e.forEach(p=>{let g=[],m=[];n?i||t===0?(g=this.graphInstance.getNodeIncomingNodes(p),m=this.graphInstance.getNodeOutgoingNodes(p)):(t<0&&(u=-1),m=this.graphInstance.getNodeRelatedNodes(p)):m=this.graphInstance.getNodeRelatedNodes(p),this._appendNodeChildrenToNextLevelNodes(p,m,f,c,n,1),this._appendNodeChildrenToNextLevelNodes(p,g,h,c,n,-1),p.lot.index_of_level=y,y++}),c.all_strength>d.max_strength&&(d.max_strength=c.all_strength),f.length>0&&this.expandLevelNodesWithDirection(o,f,t+u,n,i,a,r),h.length>0&&this.expandLevelNodesWithDirection(o,h,t-1,n,i,a,r)}_appendNodeChildrenToNextLevelNodes(o,e,t,n,i,a){let r=0,d=0,c=0;if(e.forEach(h=>{h.lot||(h.lot={eached:!1,childs:[]}),h.lot.eached||(d++,h.lot.parent=o,z.isVisibleNode(h)&&(h.lot.eached=!0,h.lot.index_of_parent=c++,t.push(h),r++),o.lot.childs.push(h))}),a===1){const h=r>0?r:1;o.lot.strength=h,n.all_strength+=h,o.lot.strength_of_level=n.all_strength,o.lot.childrenSizeVisible=r,o.lot.childrenSize=d}}calcStrengthWithChildsValue(o){this.isFolderLayout?o.forEach(e=>{e.lot.strengthWithChilds=1,this.conductStrengthToParents(e)}):(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=>{if(a.lot.level===0||t===(a.lot.level<0?-1:1)){a.lot.childs.forEach(d=>{n.push(d)}),a.lot.parent&&i<a.lot.parent.lot.strengthWithChilds_from&&(i=a.lot.parent.lot.strengthWithChilds_from);const r=this.isFolderLayout?1:0;a.lot.strengthWithChilds_from=i+r,i+=a.lot.strengthWithChilds}}),n.length>0&&this._calcStrengthFromValue(n,e+(t<0?-1:1),t)}conductStrengthToParents(o){if(o.lot.parent){const e=Math.abs(o.lot.level)-1===Math.abs(o.lot.parent.lot.level);(this.isFolderLayout||e)&&(o.lot.parent.lot.strengthWithChilds+=1,this.conductStrengthToParents(o.lot.parent))}}}class yi{constructor(o,e,t){_(this,"graphOptions");_(this,"layoutOptions");_(this,"graphInstance");_(this,"networkAnalyzer");_(this,"allNodes",[]);_(this,"isMainLayouer",!0);_(this,"requireLinks",!1);_(this,"allLinks",[]);_(this,"rootNode");this.layoutOptions=o,this.graphOptions=e,this.graphInstance=t,this.networkAnalyzer=new mi(t)}setLinks(o){w("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.width||n.el_W||50,height:n.height||n.el_H||50};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 vi[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 vi={start:"end",end:"start",center:"center"},ge=yi;class xi extends ge{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");_(this,"fastStart",!1);_(this,"skipInitLayout",!1);_(this,"maxLayoutTimes",300);_(this,"byNode",!0);_(this,"byLine",!0);_(this,"lockX",!1);_(this,"lockY",!1);_(this,"force_node_repulsion",1);_(this,"force_line_elastic",1);_(this,"disableLiveChanges",!1);_(this,"force_x_coefficient",1);_(this,"force_y_coefficient",1);_(this,"instanceId","");_(this,"calcNodes",[]);_(this,"_graphEventHandler");_(this,"layoutTimes",0);_(this,"prev10",[]);_(this,"visibleNodes",[]);_(this,"_onFinishCallback");_(this,"_onTickCallback");_(this,"calcNodeMap",new WeakMap);_(this,"forCalcNodes",[]);_(this,"recentGraphVelocity",[]);_(this,"graphVelocityBalancedValue",.1);_(this,"prevLogTime",0);_(this,"animationFrameTimer",0);_(this,"prevNodeLevel1Index",0);_(this,"prevNodeLevel2Index",0);_(this,"stoped",!1);_(this,"maxTractionLength",400);_(this,"zeroForceLength",40);_(this,"maxRepulsionDistance",600);_(this,"nodeCollisionRadius",40);_(this,"maxMoveSpeed",100);_(this,"n2nMaxForce",50);this.layoutOptions=e,this.updateOptions(e),this.requireLinks=!0,this.instanceId=n?n.generateNewUUID(5):"error-id"}updateOptions(e){e.fastStart!==void 0&&(this.fastStart=e.fastStart),e.maxLayoutTimes!==void 0&&(this.maxLayoutTimes=e.maxLayoutTimes),e.byNode!==void 0&&(this.byNode=e.byNode),e.byLine!==void 0&&(this.byLine=e.byLine),e.force_node_repulsion!==void 0&&(this.force_node_repulsion=e.force_node_repulsion),e.force_line_elastic!==void 0&&(this.force_line_elastic=e.force_line_elastic),e.force_x_coefficient!==void 0&&(this.force_x_coefficient=e.force_x_coefficient),e.force_y_coefficient!==void 0&&(this.force_y_coefficient=e.force_y_coefficient),e.disableLiveChanges!==void 0&&(this.disableLiveChanges=e.disableLiveChanges),e.skipInitLayout!==void 0&&(this.skipInitLayout=e.skipInitLayout),e.maxTractionLength!==void 0&&(this.maxTractionLength=e.maxTractionLength),e.zeroForceLength!==void 0&&(this.zeroForceLength=e.zeroForceLength),e.maxRepulsionDistance!==void 0&&(this.maxRepulsionDistance=e.maxRepulsionDistance),e.nodeCollisionRadius!==void 0&&(this.nodeCollisionRadius=e.nodeCollisionRadius)}placeNodes(e,t){if(w("RGForceLayout["+this.instanceId+"].placeNodes"),this.calcNodes=e,this.allNodes.length===0&&(this.allNodes=e),this.rootNode=t,this.fastStart)w("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(w("!!!initNodesPosition....."),t){w("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,[]),w("!!!initNodesPosition fixedRootNode:2:",t.x,t.y),i.forEach(d=>{if(d.fixed===!0||!d.rgCalcedVisibility||d===t)return;const c=d.lot.x-z.getNodeWidth(d)/2,h=d.lot.y-z.getNodeHeight(d)/2;this.updateNodePosition(d,c,h)})}}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)}),w("["+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){w("analyticResult:",this.layoutOptions,n,i,a);const r={x:e.lot.x,y:e.lot.y},d=t.filter(c=>c.lot.level===1);this.placeNodesInFanRegion(d,0,360,r,1,n.max_strength,a,1,i,0)}calculateMinimumRadius(e,t=0){if(e.length===0||e.length===1)return 0;const n=e.map(h=>{const f=h.width||h.el_W,u=h.height||h.el_H;return Math.sqrt(f*f+u*u)/2+t/2}),i=[];for(let h=0;h<n.length;h++){const f=(h+1)%n.length;i.push(n[h]+n[f])}let a=Math.max(...i)/2,r=i.reduce((h,f)=>h+f,0);const d=100;let c=r;for(let h=0;h<d;h++){const f=(a+r)/2;let u=0;for(const y of i){const p=y/(2*f);if(p>1){u=10;break}u+=2*Math.asin(p)}u>2*Math.PI?a=f:(r=f,c=f)}return c}placeNodesInFanRegion(e,t,n,i,a,r,d,c,h,f){var m,v;let u=t;const y=n-t,p=200;let g=this.getLevelR(d,a)||f+p*h;a===1&&h===1&&(!this.layoutOptions.levelGaps||this.layoutOptions.levelGaps.length===0)&&(g=this.calculateMinimumRadius(e,10),g=Math.min(Math.max(g,200),500));for(const x of e){const L=((m=x.lot)==null?void 0:m.strengthWithChilds)/r,P=i.x+g,E=i.y,T=L*y,N=u+T/2,b=J.getRotatedPoint(P,E,i.x,i.y,N);x.lot.x=b.x,x.lot.y=b.y,x.lot.childs&&x.lot.childs.length>0&&this.placeNodesInFanRegion(x.lot.childs,u,u+T,i,a+1,(v=x.lot)==null?void 0:v.strengthWithChilds,d,c+1,h,g),u+=T}}graphEventHandle(e,...t){if(e===D.onNodeDragStart){const n=t[0],i=this.calcNodeMap.get(n);i&&(i.dragging=!0)}else if(e===D.onNodeDragging){const n=t[0],i=t[1],a=t[2],r=this.calcNodeMap.get(n);r&&(r.x=i,r.y=a)}else if(e===D.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||(w("node miss lot:",t.text),t.lot={x:t.x,y:t.y,childs:[]}),this.visibleNodes.push(t)}),this.resetCalcNodes(),w("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}})}w("Force Layout["+this.instanceId+"] finished"),this.applyFBuffToNodes(),this.applyPositionToNodes(),this.disConnectToGraphInstance();try{this._onFinishCallback&&this._onFinishCallback()}catch(e){console.error(e)}}resetCalcNodes(){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)}),this.allLinks=this.graphInstance.getLinksBetweenNodes(this.visibleNodes)}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){w("["+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.disableLiveChanges||this.layoutTimes%2===0&&this.applyPositionToNodes(),this.layoutTimes<=this.maxLayoutTimes?(Date.now()-this.prevLogTime>3e3&&(w("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()}syncNodePosition(e,t,n){const i=this.allNodes.find(r=>r.id===e),a=this.calcNodeMap.get(i);a&&(a.x=t,a.y=n)}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),w("[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,d=t.y;let c=Math.sqrt((a-d)**2+(i-r)**2);if(c<this.zeroForceLength)return;c>this.maxTractionLength&&(c=this.maxTractionLength);const h=(c-this.zeroForceLength)*.02*this.force_line_elastic*n,f=h,u=h,y=(i-r)/c,p=(a-d)/c;this.addFtoNode(e,y*f*-1,p*f*-1),this.addFtoNode(t,y*u,p*u)}addGravityByNode(e,t,n=1){const i=e.x,a=e.y,r=t.x,d=t.y;if(n===1&&(Math.abs(i-r)>this.maxRepulsionDistance||Math.abs(a-d)>this.maxRepulsionDistance))return;const c=Math.sqrt((a-d)**2+(i-r)**2);if(n===1&&c>this.maxRepulsionDistance)return;let h=(this.maxRepulsionDistance-c)*.02*this.force_node_repulsion*n;c<this.nodeCollisionRadius&&(h=h*2);const f=(i-r)/c,u=(a-d)/c;this.addFtoNode(e,f*h,u*h)}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.force_x_coefficient,e.y=e.y+n*this.force_y_coefficient,!this.disableLiveChanges){const i=e.rgNode;this.updateNodePosition(i,e.x,e.y)}e.Fx=0,e.Fy=0}}const Ee=xi;class Ci extends ge{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;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)),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(w("RGTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}w("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(w("groupNodes:2:",r.length,r.map(h=>h.text).join(",")),this.layoutOptions.simpleTree===!0){const{tree:h}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!1);this.placeNodesPosition(this.rootNode,h.networkNodes,h.analyticResult)}else{const{tree:h,reverseTree:f}=this.networkAnalyzer.analyzeNetwork(r,this.rootNode,!0);this.placeNodesPosition(this.rootNode,h.networkNodes,h.analyticResult),this.placeNodesPosition(this.rootNode,f.networkNodes,f.analyticResult)}const d=this.layoutOptions.rotate||0,c={x:t.x,y:t.y};this.allNodes.forEach(h=>{if(h.fixed!==!0&&!!z.isVisibleNode(h)&&(Number.isNaN(h.lot.x)&&(w("bad lot x:",h.text,h.lot.x),h.lot.x=0),Number.isNaN(h.lot.y)&&(w("bad lot y:",h.text,h.lot.y),h.lot.y=0),h!==t)){if(d){const p=J.getRotatedPoint(h.lot.x,h.lot.y,c.x,c.y,d);h.lot.x=p.x,h.lot.y=p.y}const f=h.lot.level<0?i:n,u=z.getNodeXByLotX(f,h),y=z.getNodeYByLotY(f,h);this.updateNodePosition(h,u,y)}}),w("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),d=n.max_strength;if(this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"){const c=this.layoutOptions.treeNodeGapH||20,h=this.layoutOptions.treeNodeGapV||20,f=new Map;for(const m of a){const v=r.get(m);f.set(m,Math.max(...v.map(x=>x.el_H)))}let u=0,y=0;for(const m of t){const v=m.el_W;u+=v,y++}const g=u/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,f,h+10):m.lot.y=e.lot.y+this.getLevelDistance(m.lot.level,f,h+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*(d/-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,h=this.layoutOptions.treeNodeGapV||20,f=new Map;for(const m of a){const v=r.get(m);f.set(m,Math.max(...v.map(x=>x.el_W||x.width||50)))}let u=0,y=0;for(const m of t){const v=m.el_H;u+=v,y++}if(y===0)return;const g=u/y+h;t.forEach(m=>{m.fixed!==!0&&m!==e&&(this.layoutOptions.from==="right"?m.lot.x=e.lot.x-this.getLevelDistance(m.lot.level,f,c+50):m.lot.x=e.lot.x+this.getLevelDistance(m.lot.level,f,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*(d/-2+m.lot.strengthWithChilds_from+m.lot.strengthWithChilds/2))}),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:d}=this.generateLevels(e),c=new Map;for(const u of r){const y=d.get(u);c.set(u,Math.max(...y.map(p=>p.el_W)))}const{calcNodes:h,calcNodeMap:f}=this.generateCalcNodes(e);h.forEach(u=>{const y=u.rgNode.lot.level<0?i:n;u.x=z.getNodeXByLotX(y,u.rgNode),u.y=z.getNodeYByLotY(y,u.rgNode),u.width=u.rgNode.el_W,u.height=u.rgNode.el_H,u.buffY=0});for(const u of r){const y=d.get(u)||[];if(t==="h")if(a==="end"){y.sort((g,m)=>g.lot.y-m.lot.y);const p=y.map(g=>f.get(g.id));this.adjustNodePositions(p,"bottom",this.layoutOptions.treeNodeGapV);for(const g of p){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 p=y.map(g=>f.get(g.id));this.adjustNodePositions(p,"top",this.layoutOptions.treeNodeGapV);for(const g of p){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 p=y.map(g=>f.get(g.id));this.adjustNodePositions(p,"right",this.layoutOptions.treeNodeGapH);for(const g of p){const m=g.rgNode.lot.level<0?i:n,v=z.getNodeLotXY(m,g);g.rgNode.lot.x=v.x}}else{y.sort((g,m)=>m.lot.x-g.lot.x);const p=y.map(g=>f.get(g.id));this.adjustNodePositions(p,"left",this.layoutOptions.treeNodeGapH);for(const g of p){const m=g.rgNode.lot.level<0?i:n;g.rgNode.lot.x=z.getNodeLotXY(m,g).x}}}if(t==="h"){const u=new Map,y=new Map;for(const L of r){const E=d.get(L).map(T=>f.get(T.id));u.set(L,Math.max(...E.map(T=>T.width))),y.set(L,Math.min(...E.map(T=>T.x)))}const p=this.layoutOptions.treeNodeGapH;let g=r.filter(L=>L>0).sort((L,P)=>L-P),m=r.filter(L=>L<0).sort((L,P)=>P-L),v=1;this.layoutOptions.from==="right"&&([m,g]=[g,m],v=-1);let x=0;for(const L of g){const P=L-v,E=y.get(P),T=u.get(P),N=y.get(L)+x;u.get(L);const b=E+T+p;if(b>N){const k=b-N;x=k;const O=d.get(L);for(const S of O)S.lot.x+=x;y.set(L,N+k)}else y.set(L,N)}x=0;for(const L of m){const P=L+v,E=y.get(P);u.get(P);const T=y.get(L)+x,N=u.get(L),b=E-p;if(T+N>b){const k=b-(T+N);x=k;const O=d.get(L);for(const S of O)S.lot.x+=x;y.set(L,T+k)}else y.set(L,T)}}else{const u=new Map,y=new Map;for(const L of r){const E=d.get(L).map(T=>f.get(T.id));u.set(L,Math.max(...E.map(T=>T.height))),y.set(L,Math.min(...E.map(T=>T.y)))}const p=this.layoutOptions.treeNodeGapV;let g=r.filter(L=>L>0).sort((L,P)=>L-P),m=r.filter(L=>L<0).sort((L,P)=>P-L),v=1;this.layoutOptions.from==="bottom"&&([m,g]=[g,m],v=-1);let x=0;for(const L of g){const P=L-v,E=y.get(P),T=u.get(P),N=y.get(L)+x;u.get(L);const b=E+T+p;if(b>N){const k=b-N;x=k;const O=d.get(L);for(const S of O)S.lot.y+=x;y.set(L,N+k)}else y.set(L,N)}x=0;for(const L of m){const P=L+v,E=y.get(P);u.get(P);const T=y.get(L)+x,N=u.get(L),b=E-p;if(T+N>b){const k=b-(T+N);x=k;const O=d.get(L);for(const S of O)S.lot.y+=x;y.set(L,T+k)}else y.set(L,T)}}}gatherNodes(e,t,n){if(!this.enableGatherNodes)return;const{calcNodes:i,calcNodeMap:a}=this.generateCalcNodes(e);i.forEach(d=>{d.movedNodeSizeBefore=1,d.movedNodeSizeAfter=1});const{levelNodesMap:r}=this.generateLevels(e);e.forEach(d=>{if(d.fixed!==!0&&d.lot.level!==0){const c=r.get(d.lot.level)||[];if(d.lot.strengthWithChilds===1&&d.lot.childrenSizeVisible<=1){const h=this.getBloomingNearByParent(d,d.lot.parent,c,t);if(h){const f=a.get(d.id);t==="h"?d.lot.y-h.lot.y>0?(d.lot.y=h.lot.y+n*f.movedNodeSizeAfter,f.movedNodeSizeAfter++):(d.lot.y=h.lot.y-n*f.movedNodeSizeBefore,f.movedNodeSizeBefore++):d.lot.x-h.lot.x>0?(d.lot.x=h.lot.x+n*f.movedNodeSizeAfter,f.movedNodeSizeAfter++):(d.lot.x=h.lot.x-n*f.movedNodeSizeBefore,f.movedNodeSizeBefore++)}}}})}getBloomingNearByParent(e,t,n,i){let a=9999,r;for(const d of n)if(d.lot.childrenSizeVisible>1&&d.lot.parent===t){const c=i==="h"?d.lot.y-t.lot.y:d.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=d)}if(r&&r!==e)return r}}const Wt=Ci;class wi extends Ee{constructor(e,t,n){super(e,t,n);_(this,"layoutOptions");this.layoutOptions=e,this.layoutOptions.distanceCoefficient||(this.layoutOptions.distanceCoefficient=1),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]),this.layoutOptions.levelDistance&&console.error("Error: levelDistance is not support\uFF0C Please use levelGaps option in layoutOptions")}placeNodes(e,t){if(w("RGCenterLayout:placeNodes"),!t){w("root is null:",t);return}w("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){w("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"},d=z.getNodeLotXY(r,t);t.lot.x=d.x,t.lot.y=d.y;const c=this.layoutOptions.rotate||0;w("root position:",t.lot.x,t.lot.y);const h=this.layoutOptions.distanceCoefficient||1,f=this.getLevelDistanceArr();this.placeRelativePosition(this.rootNode,i,a,h,f);const u={x:t.x,y:t.y};i.forEach(y=>{if(y.fixed!==!0&&!!y.rgCalcedVisibility&&y!==t){if(c){const v=J.getRotatedPoint(y.lot.x,y.lot.y,u.x,u.y,c);y.lot.x=v.x,y.lot.y=v.y}const p=r,g=z.getNodeXByLotX(p,y),m=z.getNodeYByLotY(p,y);this.updateNodePosition(y,g,m)}}),this.layoutEnd()}getLevelDistanceArr(){let e=[];if(this.layoutOptions.levelGaps){if(Array.isArray(this.layoutOptions.levelGaps))e=this.layoutOptions.levelGaps;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}}const Ut=wi;class Li extends Ee{constructor(o,e,t){super(o,e,t)}placeNodes(o,e){if(e)w("layout by root:",e);else{w("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=this.layoutOptions.rotate||0,i=z.getNodeLotXY(t,e);e.lot.x=i.x,e.lot.y=i.y;const a=this.allNodes.filter(c=>c.rgCalcedVisibility),r=a.length;let d=r*90/Math.PI/2;d<200&&(d=200),d>800&&(d=800),a.forEach((c,h)=>{const f=J.getOvalPoint(i.x,i.y,d,h,r);c.lot.x=f.x,c.lot.y=f.y}),a.forEach(c=>{if(c.fixed===!0||!c.rgCalcedVisibility)return;if(n){const y=J.getRotatedPoint(c.lot.x,c.lot.y,e.lot.x,e.lot.y,n);c.lot.x=y.x,c.lot.y=y.y}const h=t,f=z.getNodeXByLotX(h,c),u=z.getNodeYByLotY(h,c);this.updateNodePosition(c,f,u)}),this.layoutEnd()}}const jt=Li;class _i extends ge{constructor(e,t,n){super(e,t,n);_(this,"graphOptions");_(this,"layoutOptions");_(this,"allNodes",[]);this.layoutOptions=e,this.graphOptions=t}placeNodes(e,t){if(t)w("layout by root:",t);else{w("root is null:",t);return}w("allNodes:",e.length),this.networkAnalyzer.analyzeNetwork(e,t,!1,!1),w("[Fixed layout canvasOffset]",this.graphOptions.viewSize,this.graphOptions.canvasSize),this.layoutEnd()}}const Jt=_i;class bi extends ge{constructor(e,t,n){super(e,t,n);_(this,"graphInstance");_(this,"layoutOptions");_(this,"levelGaps",[]);this.layoutOptions=e,w("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)),this.requireLinks=!0,this.graphInstance=n}placeNodes(e,t){if(w("RGSmartTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e,w("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 d=z.getNodeLotXY(n,t);t.lot.x=d.x,t.lot.y=d.y,this.placeRelativePosition(t,[...a.networkNodes].concat(r.networkNodes),Math.max(a.analyticResult.max_strength,r.analyticResult.max_strength)),w("allNodes:",e.length);const c={left:0,top:90,right:180,bottom:270}[this.layoutOptions.from],h={x:t.x,y:t.y};this.allNodes.forEach(y=>{if(y.fixed===!0||!y.rgCalcedVisibility)return;if(Number.isNaN(y.lot.x)&&(w("bad lot x:",y.text,y.lot.x),y.lot.x=0),Number.isNaN(y.lot.y)&&(w("bad lot y:",y.text,y.lot.y),y.lot.y=0),c){const v=J.getRotatedPoint(y.lot.x,y.lot.y,h.x,h.y,c);y.lot.x=v.x,y.lot.y=v.y}const p=y.lot.level<0?i:n,g=z.getNodeXByLotX(p,y),m=z.getNodeYByLotY(p,y);this.updateNodePosition(y,g,m)}),w("create rootNode coordinates:1",t.x,t.y);const f=new Ee({layoutName:"force",maxLayoutTimes:30,force_node_repulsion:.1,force_line_elastic:1,fixedRootNode:!0,disableLiveChanges:!0},this.graphOptions,this.graphInstance);f.isMainLayouer=!1,f.requireLinks=!0,this.layoutOptions.from==="top"||this.layoutOptions.from==="bottom"?f.lockY=!0:f.lockX=!0;const u=t.fixed;t.fixed=!0,f.skipInitLayout=!0,f.resetCalcNodes(),setTimeout(()=>{t.fixed=u},800),f.onFinish(()=>{t.fixed=u,this.graphInstance&&(this.graphInstance.enableNodeXYAnimation(),this.graphInstance._dataUpdated()),this.applyNodesGap(this.allNodes),this.graphInstance&&(this.graphInstance._dataUpdated(),this.allNodes.forEach(y=>{this.graphInstance.updateNode(y,{x:y.x,y:y.y})}),setTimeout(()=>{this.graphInstance.disableNodeXYAnimation(),this.graphInstance._dataUpdated()},300))}),f.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:d,levelNodesMap:c}=this.generateLevels(t),h=new Map;for(const g of d){const m=c.get(g);h.set(g,Math.max(...m.map(v=>v.el_W)))}let f=0,u=0;for(const g of t){const m=g.el_H;f+=m,u++}if(u===0)return;const p=f/u+r;t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.x=e.lot.x+this.getLevelDistance(g.lot.level,h,a))}),t.forEach(g=>{g.fixed!==!0&&g!==e&&(g.lot.level===0?g.lot.y=e.lot.y+p*g.lot.index_of_level:g.lot.y=e.lot.y+p*(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 h=i.get(c);a.set(c,Math.max(...h.map(f=>f.el_W)))}const{calcNodes:r,calcNodeMap:d}=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 h=i.get(c)||[];if(t==="h"){const f=h.map(p=>d.get(p.id)),u=f.filter(p=>p.y<this.rootNode.y).sort((p,g)=>g.y-p.y),y=f.filter(p=>p.y>=this.rootNode.y).sort((p,g)=>p.y-g.y);this.adjustNodePositions(u,"top",5),this.adjustNodePositions(y,"bottom",5);for(const p of f)p.rgNode.y=p.y}else{const f=h.map(p=>d.get(p.id)),u=f.filter(p=>p.x<this.rootNode.x).sort((p,g)=>g.x-p.x),y=f.filter(p=>p.x>=this.rootNode.x).sort((p,g)=>p.x-g.x);this.adjustNodePositions(u,"left",5),this.adjustNodePositions(y,"right",5);for(const p of f)p.rgNode.x=p.x}}}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}}const Ni=bi;class Ti extends ge{constructor(e,t,n){super(e,t,n);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("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.bottomJunctionPointOffsetX===void 0&&(this.layoutOptions.bottomJunctionPointOffsetX=-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(w("RGFolderLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}this.rootNode=t,this.allNodes=e;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,w("allNodes:",e.length),this.networkAnalyzer.isFolderLayout=!0;const{tree:r}=this.networkAnalyzer.analyzeNetwork(e,t,!1,!1);this.placeRelativePosition(t,r.networkNodes,r.analyticResult),w("networkNodes:",r.networkNodes.length),this.allNodes.forEach(d=>{if(d.fixed!==!0&&(Number.isNaN(d.lot.x)&&(w("bad lot x:",d.text,d.lot.x),d.lot.x=0),Number.isNaN(d.lot.y)&&(w("bad lot y:",d.text,d.lot.y),d.lot.y=0),d!==t)){const c=d.lot.level<0?i:n,h=z.getNodeXByLotX(c,d),f=z.getNodeYByLotY(c,d);this.updateNodePosition(d,h,f)}}),w("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 d=0,c=0;for(const u of t){const y=u.lot.level,p=u.width||u.el_W||50,g=u.height||u.el_H||50;d+=g,c++;const m=r.get(y);m===void 0?r.set(y,p):p>m&&r.set(y,m)}if(c===0)return;const f=d/c+a;t.forEach(u=>{u.fixed!==!0&&u!==e&&(this.layoutOptions.from==="right"?u.lot.x=e.lot.x-this.getLevelDistance(u.lot.level,r,i+50):u.lot.x=e.lot.x+this.getLevelDistance(u.lot.level,r,i+50))}),t.forEach(u=>{u.fixed!==!0&&u!==e&&u.lot.level!==0&&(u.lot.y=e.lot.y+f*u.lot.strengthWithChilds_from)}),this.gatherNodes(t,"h",f)}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+"",d=i[r];if(a.lot.strengthWithChilds===1&&a.lot.childrenSizeVisible<=1){const c=this.getBloomingNearByParent(a,a.lot.parent,d,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 d of n)if(d.lot.childrenSizeVisible>1&&d.lot.parent===t){const c=i==="h"?d.lot.y-t.lot.y:d.lot.x-t.lot.x;Math.abs(c)<a&&(a=Math.abs(c),r=d)}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 qt=Ti,le=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(),Zt=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,d=0,c=0;const h={x:0,y:0},f={x:0,y:0},u=[];for(const y of o){const p=y.trim().split(/[ ,]+/),g=p[0].toUpperCase(),m=p[0]===p[0].toLowerCase();switch(g){case"M":e=U(n,p[1],m),t=U(i,p[2],m),n=e,i=t;break;case"L":e=U(n,p[1],m),t=U(i,p[2],m),u.push({x:e,y:t});break;case"C":a=U(n,p[1],m),r=U(i,p[2],m),d=U(n,p[3],m),c=U(i,p[4],m),e=U(n,p[5],m),t=U(i,p[6],m),n=e,i=t;break;case"Q":a=U(n,p[1],m),r=U(i,p[2],m),e=U(n,p[3],m),t=U(i,p[4],m),n=e,i=t;break;case"V":t=U(i,p[1],m),i=t;break;case"H":e=U(n,p[1],m),n=e;break;case"Z":break;default:console.log(`Unsupported command: ${g}`)}y===o[0]&&(h.x=e,h.y=t),y===o[o.length-1]&&(f.x=e,f.y=t)}return{startPoint:h,ctrl1:{x:a,y:r},ctrl2:{x:d,y:c},endPoint:f,lines:u}},U=(s,o,e)=>e?s+parseFloat(o):parseFloat(o),ki=(s,o,e,t,n,i,a)=>{const r=JSON.parse(JSON.stringify(s));let d=!1;if(e<0||e>=s.length-1)return{newPoints:r,pointsChanged:d};r[e-1];const c=r[e],h=r[e+1];o[e-1];const f=o[e];o[e+1];let u=i,y=a;if(t.direction==="v"){const p=o[e-2],g=o[e+2],m=f.x+u;let v=3e3;if(p){const x=Math.abs(p.x-m);x<10&&x<v&&(v=x,u=p.x-f.x)}if(g){const x=Math.abs(g.x-m);x<10&&x<v&&(v=x,u=g.x-f.x)}}else{const p=o[e-2],g=o[e+2],m=f.y+y;let v=3e3;if(p){const x=Math.abs(p.y-m);x<10&&x<v&&(v=x,y=p.y-f.y)}if(g){const x=Math.abs(g.y-m);x<10&&x<v&&(v=x,y=g.y-f.y)}}if(t.direction==="v")if(e===0){const p=c.y<h.y?1:-1,g={x:c.x,y:c.y},m={x:c.x,y:c.y+20*p};c.x=m.x+u,c.y=m.y,r.splice(e,0,g,m),n.indexOffset+=2,d=!0}else if(e===s.length-2){const p=c.y<h.y?1:-1,g={x:f.x+u,y:h.y-20*p},m={x:h.x,y:h.y-20*p};r.splice(e+1,0,g,m),d=!0}else c.x=f.x+u,h.x=f.x+u;else if(e===0){const p=c.x<h.x?1:-1,g={x:c.x,y:c.y},m={x:c.x+20*p,y:c.y};c.x=m.x,c.y=f.y+y,r.splice(e,0,g,m),n.indexOffset+=2,d=!0}else if(e===s.length-2){const p=c.x<h.x?1:-1,g={x:h.x-20*p,y:f.y+y},m={x:h.x-20*p,y:h.y};r.splice(e+1,0,g,m),d=!0}else c.y=f.y+y,h.y=f.y+y;return{newPoints:r,pointsChanged:d}},Pi=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=J.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,d=[{type:"M",x:e,y:t},{type:"l",dx:a,dy:r}],c=le(d);return{pathCommands:d,pathData:c,textPosition:o,points:[]}},Ei=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fx:n,fy:i,fcx:a,fcy:r,f_W:d,f_H:c,tx:h,ty:f,tcx:u,tcy:y,t_W:p,t_H:g}=s,m=h-n,v=f-i,x=n-a,L=i-r,P=h-u,E=f-y,T=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0;let N=Math.min(T,Math.abs(m))*(n<h?1:-1),b=Math.min(T,Math.abs(v))*(i<f?1:-1);const k=t.fromJunctionPoint||e.defaultJunctionPoint||Y.border,O=t.toJunctionPoint||e.defaultJunctionPoint||Y.border,S=t.lineDirection||(k===Y.tb||k===Y.top||k===Y.bottom?"v":"h")||(Math.abs(x)>=d/2?"h":"v"),R=t.lineDirection||(O===Y.tb||O===Y.top||O===Y.bottom?"v":"h")||(Math.abs(P)>=p/2?"h":"v"),C=[];let M=0,B=0;if(S==="v"){const A=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(f-i)/2),15),F=L>0?A:-A;if(t.placeText==="start"?(M=n,B=i+(L>0?20:-5)):t.placeText==="center"||t.placeText==="middle"?(M=n+(h-n)/2,B=i+F):(M=h,B=f-(L>0?20:-5)),C.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"v",dy:Math.round(F-b)},{type:"c",dx1:0,dy1:Math.round(b),dx2:Math.round(N),dy2:Math.round(b),dx:Math.round(N),dy:Math.round(b)}),R==="v")C.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(b),dx:Math.round(N),dy:Math.round(b)},{type:"v",dy:Math.round(f-i-F-b)});else{const H=Math.min(30,Math.abs(h-n)/2),j=P>0?-H:H;C.push({type:"h",dx:Math.round(h-n+j-N)},{type:"c",dx1:Math.round(N),dy1:0,dx2:Math.round(N),dy2:Math.round(b),dx:Math.round(N),dy:Math.round(b)},{type:"v",dy:Math.round(f-i-F-b)},{type:"h",dx:Math.round(j-N)})}}else{const A=t.polyLineStartDistance||Math.max(Math.min(30,Math.abs(h-n)/2),15),F=x>0?A:-A;if(t.placeText==="start"?(M=n+(x>0?10:-50),B=i):t.placeText==="center"||t.placeText==="middle"?(M=n+F,B=i+(f-i)/2):(M=h-(x>0?10:-50),B=f),N=Math.min(T,Math.abs(m))*(n>a?1:-1),b=Math.min(T,Math.abs(v))*(i<f?1:-1),C.push({type:"M",x:Math.round(n),y:Math.round(i)},{type:"h",dx:Math.round(F-N)},{type:"c",dx1:Math.round(N),dy1:0,dx2:Math.round(N),dy2:Math.round(b),dx:Math.round(N),dy:Math.round(b)}),R==="v"){N=Math.min(T,Math.abs(m))*(f<y?1:-1),b=Math.min(T,Math.abs(v))*(f<y?1:-1);const H=Math.min(30,Math.abs(f-i)/2),j=E>0?-H:H;C.push({type:"v",dy:Math.round(f-i+j-b)},{type:"h",dx:Math.round(h-n-F-N)},{type:"c",dx1:0,dy1:Math.round(b),dx2:Math.round(N),dy2:Math.round(b),dx:Math.round(N),dy:Math.round(b)},{type:"v",dy:Math.round(j-b)})}else N=Math.min(T,Math.abs(m))*(n+F<h?1:-1),b=Math.min(T,Math.abs(v))*(f>i?1:-1),C.push({type:"v",dy:Math.round(f-i-b*2)},{type:"c",dx1:0,dy1:Math.round(b),dx2:Math.round(N),dy2:Math.round(b),dx:Math.round(N),dy:Math.round(b)},{type:"h",dx:Math.round(h-n-F-N)})}o.x=M,o.y=B;const X=le(C);return{pathCommands:C,pathData:X,textPosition:o,points:[]}},Be={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},Si=({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},Kt=(s,o)=>Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));function Qe({source:s,sourcePosition:o="bottom",target:e,targetPosition:t="top",center:n,sourceOffset:i,targetOffset:a}){const r=Be[o],d=Be[t],c={x:s.x+r.x*i,y:s.y+r.y*i},h={x:e.x+d.x*a,y:e.y+d.y*a},f=Si({source:c,sourcePosition:o,target:h}),u=f.x!==0?"x":"y",y=f[u];let p=[],g,m;const v={x:0,y:0},x={x:0,y:0};let L=0;if(r[u]*d[u]===-1){g=n.x,m=n.y;const E=[{x:g,y:c.y},{x:g,y:h.y}],T=[{x:c.x,y:m},{x:h.x,y:m}];r[u]===y?(L=1.1,p=u==="x"?E:T):(L=1.2,p=u==="x"?T:E)}else{const E=[{x:c.x,y:h.y}],T=[{x:h.x,y:c.y}];if(u==="x"?p=r.x===y?T:E:p=r.y===y?E:T,o===t){L=2.1;const S=Math.abs(s[u]-e[u]),R=r[u]===y?i:a;if(S<=R){const C=Math.min(R-1,R-S);r[u]===y?v[u]=(c[u]>s[u]?-1:1)*C:x[u]=(h[u]>e[u]?-1:1)*C}}if(o!==t){L=2.2;const S=u==="x"?"y":"x",R=r[u]===d[S],C=c[S]>h[S],M=c[S]<h[S];(r[u]===1&&(!R&&C||R&&M)||r[u]!==1&&(!R&&M||R&&C))&&(p=u==="x"?E:T)}const N={x:c.x+v.x,y:c.y+v.y},b={x:h.x+x.x,y:h.y+x.y},k=Math.max(Math.abs(N.x-p[0].x),Math.abs(b.x-p[0].x)),O=Math.max(Math.abs(N.y-p[0].y),Math.abs(b.y-p[0].y));k>=O?(g=(N.x+b.x)/2,m=p[0].y):(g=p[0].x,m=(N.y+b.y)/2)}return[[s,{x:c.x+v.x,y:c.y+v.y},...p,{x:h.x+x.x,y:h.y+x.y},e],g,m,0,0,L]}const Ve=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 Oi(s,o,e,t){const n=Math.min(Kt(s,o)/2,Kt(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,h=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*h}]}const r=s.x<e.x?1:-1,d=s.y<e.y?-1:1;return[{type:"L",x:i,y:a+n*d},{type:"Q",x1:i,y1:a,x:i+n*r,y:a}]}const Qt=(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=Oi(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 Ae=(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",en=s=>s==="left"?"right":s==="right"?"left":s==="top"?"bottom":s==="bottom"?"top":"left",tn=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,d=Math.sqrt(a*a+r*r);e.push(d),o+=d}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],d=e[i],h=(t-(n-d))/d,f=a.x+(r.x-a.x)*h,u=a.y+(r.y-a.y)*h;return{x:f,y:u}}return{x:0,y:0}},Ri=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:d,fy:c,fcx:h,fcy:f,f_W:u,f_H:y,tx:p,ty:g,tcx:m,tcy:v,t_W:x,t_H:L}=s,P=d-h,E=c-f;let T=P>1?1:P<-1?-1:0,N=E>1?1:E<-1?-1:0;Math.abs(T)===1&&Math.abs(N)===1&&(Math.abs(P)>Math.abs(E)?N=0:T=0),T===0&&N===0&&(T=1);const b=p-m,k=g-v;let O=b>1?1:b<-1?-1:0,S=k>1?1:k<-1?-1:0;Math.abs(O)===1&&Math.abs(S)===1&&(Math.abs(b)>Math.abs(k)?S=0:O=0),O===0&&S===0&&(T=-1);const R=Ae(n,T,N,!1,d,c,p,g),C=Ae(i,O,S,!0,d,c,p,g),M=R,B=C,X=d+(p-d)/2,A=c+(g-c)/2;let F={x:0,y:0},H=20,j=20;t.ctrlOptionsFor44&&(F={x:t.ctrlOptionsFor44.cx,y:t.ctrlOptionsFor44.cy},H+=t.ctrlOptionsFor44.fd,j+=t.ctrlOptionsFor44.td);const se=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,[ne]=Qe({source:{x:d,y:c},sourcePosition:M,target:{x:p,y:g},targetPosition:B,center:{x:X+F.x,y:A+F.y},sourceOffset:H,targetOffset:j}),oe=Ve(ne),ee=Qt(oe,se),K=le(ee),ie=tn(ne);if(o.x=ie.x,o.y=ie.y,a==="v"){const Z=E>1?1:E<-1?-1:0,G=k>1?1:k<-1?-1:0;t.placeText==="start"?(o.x=d,o.y=c+Z*10):t.placeText==="end"&&(o.x=p,o.y=g+G*10)}else{const Z=P>1?1:P<-1?-1:0,G=b>1?1:b<-1?-1:0;t.placeText==="start"?(o.x=d+Z*10,o.y=c):t.placeText==="end"&&(o.x=p+G*10,o.y=g)}return{pathCommands:ee,pathData:K,textPosition:o,points:oe,startDirection:M,endDirection:B}},Mi=(s,o={x:0,y:0,rotate:0},e={})=>{const{line:t,fromJunctionPoint:n,toJunctionPoint:i,lineDirection:a,lineShape:r,fx:d,fy:c,fcx:h,fcy:f,f_W:u,f_H:y,tx:p,ty:g,tcx:m,tcy:v,t_W:x,t_H:L}=s,P=d-h,E=c-f;let T=P>3?1:P<-3?-1:0,N=E>3?1:E<-3?-1:0;Math.abs(T)===1&&Math.abs(N)===1&&(Math.abs(P)>Math.abs(E)?N=0:T=0),T===0&&N===0&&(T=1);const b=p-m,k=g-v;let O=b>3?1:b<-3?-1:0,S=k>3?1:k<-3?-1:0;Math.abs(O)===1&&Math.abs(S)===1&&(Math.abs(b)>Math.abs(k)?S=0:O=0),O===0&&S===0&&(T=-1);let R=Ae(n,T,N,!1,d,c,p,g),C=Ae(i,O,S,!0,d,c,p,g);const M=t.lineRadius!==void 0?t.lineRadius:e.lineRadius||0,B=t.ctrlPointsFor49;let X={x:Math.round(d),y:Math.round(c)},A={x:Math.round(p),y:Math.round(g)},F={x:Math.round(B[0].x),y:Math.round(B[0].y)},H={x:Math.round(B[B.length-1].x),y:Math.round(B[B.length-1].y)},j=[...B];if(t.isReverse&&([R,C]=[C,R]),Math.abs(X.x-F.x)>3||Math.abs(X.y-F.y)>3){const K=X.x+(F.x-X.x)/2,ie=X.y+(F.y-X.y)/2,Z=en(R),[G]=Qe({source:X,sourcePosition:R,target:F,targetPosition:Z,center:{x:K,y:ie},sourceOffset:20,targetOffset:5});j=Ve([...G,...j])}if(Math.abs(A.x-H.x)>3||Math.abs(A.y-H.y)>3){const K=H.x+(A.x-H.x)/2,ie=H.y+(A.y-H.y)/2,Z=en(C),[G]=Qe({source:H,sourcePosition:Z,target:A,targetPosition:C,center:{x:K,y:ie},sourceOffset:5,targetOffset:20});j=Ve([...j,...G])}const se=j,ne=Qt(se,M),oe=le(ne),ee=tn(B);return o.x=ee.x,o.y=ee.y,{pathCommands:[],pathData:oe,textPosition:o,points:se,startDirection:R,endDirection:C}},Ii=(s,o={x:0,y:0,rotate:0})=>{const{line:e,lineShape:t,fx:n,fy:i,fcx:a,fcy:r,tx:d,ty:c,tcx:h,tcy:f}=s,u=d-n,y=c-i;let p=n-a,g=i-r,m=d-h,v=c-f,{fromJunctionPoint:x,toJunctionPoint:L}=e;e.isReverse&&([x,L]=[L,x]),(x===Y.left||x===Y.right)&&(g=0),(x===Y.top||x===Y.bottom)&&(p=0),(L===Y.left||L===Y.right)&&(v=0),(L===Y.top||L===Y.bottom)&&(m=0);const P=Math.min(200,Math.max(100,Math.abs(u/2))),E=Math.min(200,Math.max(100,Math.abs(y/2))),T=p/(Math.abs(p)+Math.abs(g))*P,N=g/(Math.abs(p)+Math.abs(g))*E;let b={x:T,y:N};const k=m/(Math.abs(m)+Math.abs(v))*P+u,O=v/(Math.abs(m)+Math.abs(v))*E+y;let S={x:k,y:O};e.ctrlPoints&&e.ctrlPoints.length>0&&(e.isReverse?(b.x+=e.ctrlPoints[1].x,b.y+=e.ctrlPoints[1].y,S.x+=e.ctrlPoints[0].x,S.y+=e.ctrlPoints[0].y):(b.x+=e.ctrlPoints[0].x,b.y+=e.ctrlPoints[0].y,S.x+=e.ctrlPoints[1].x,S.y+=e.ctrlPoints[1].y));const R={x:n+b.x,y:i+b.y},C={x:n+S.x,y:i+S.y},M={x:n+u,y:i+y},B=[{type:"M",x:n,y:i},{type:"c",dx1:b.x,dy1:b.y,dx2:S.x,dy2:S.y,dx:u,dy:y}];t===8&&B.push({type:"Z"});const X=nn({x:n,y:i},R,C,M,t<6?.8:.5);o.x=X.x,o.y=X.y;const A=le(B);return{pathCommands:B,pathData:A,textPosition:o,points:[]}},nn=(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},d={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)*d.x+n*c.x,y:(1-n)*d.y+n*c.y}},Di=(s,o={x:0,y:0,rotate:0})=>{const{line:e,totalLinesBetweenNodes:t,currentLineIndex:n,lineDirection:i,lineShape:a,fx:r,fy:d,fcx:c,fcy:h,f_W:f,f_H:u,tx:y,ty:p,tcx:g,tcy:m,t_W:v,t_H:x}=s,L=y-r,P=p-d,E=y>r?1:-1,T=p>d?1:-1,N=i==="v"?T:E,b=r-c,k=d-h,O=y-g,S=p-m,R=1/(t+1)*(n+1);let C={x:0,y:0},M={x:0,y:0};if(a===W.Curve2)C=i==="v"?{x:0,y:N*30}:{x:N*30,y:0},M=i==="v"?{x:L*R,y:N*-10}:{x:N*-10,y:P*R};else if(a===W.Curve3)C=i==="v"?{x:0,y:P*R}:{x:N*30,y:0},M=i==="v"?{x:0,y:0}:{x:N*-10,y:P*R};else if(a===W.Curve5)C={x:0,y:0},M=i==="v"?{x:0,y:P*R}:{x:L*R,y:0};else if(a===W.Curve7||a===W.Curve8){const oe=b/(Math.abs(b)+Math.abs(k))*30,ee=k/(Math.abs(b)+Math.abs(k))*30;C={x:oe,y:ee};const K=O/(Math.abs(O)+Math.abs(S))*30+L,ie=S/(Math.abs(O)+Math.abs(S))*30+P;M={x:K,y:ie}}const B={x:r+C.x,y:d+C.y},X={x:r+M.x,y:d+M.y},A={x:r+L,y:d+P},F=[{type:"M",x:r,y:d},{type:"c",dx1:C.x,dy1:C.y,dx2:M.x,dy2:M.y,dx:L,dy:P}];a===8&&F.push({type:"Z"});const H=nn({x:r,y:d},B,X,A,a<6?.8:.5);o.x=H.x,o.y=H.y;const j=le(F);return{pathCommands:F,pathData:j,textPosition:o,points:[]}};class Bi{constructor(){_(this,"graphData",{rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]});_(this,"options",{});_(this,"runtimeDATA4NodeMap",new Map);_(this,"runtimeDATA4Links",[]);_(this,"runtimeDATA4LinkMap",new Map);_(this,"runtimeDATA4ConnectTargets",[]);_(this,"runtimeDATA4ElLineTargets",[]);_(this,"runtimeDATA4ShouldRenderItems",{nodes:[],lines:[],fakeLines:[]})}}class Vi extends Bi{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,d=n.el_H||n.height||50;if(o.x>i&&o.x<i+r&&o.y>a&&o.y<a+d)return n}return null}}class Ai{constructor(){_(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()}}const et=(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:"h",toolBarPositionH:"left",toolBarPositionV:"bottom",defaultNodeColor:"#ffffff",defaultNodeBorderColor:"#666666",defaultNodeBorderWidth:1,defaultNodeBorderRadius:4,defaultNodeShape:_e.rect,defaultNodeWidth:void 0,defaultNodeHeight:void 0,defaultLineColor:"#cccccc",defaultLineWidth:2,defaultLineShape:W.StandardStraight,defaultLineTextOffsetX:void 0,defaultLineTextOffsetY:void 0,defaultJunctionPoint:Y.border,defaultLineJunctionOffset:3,defaultPolyLineRadius:5,placeOtherGroup:!0,defaultLineTextOnPath:!1,lineTextMaxLength:66,multiLineDistance:30,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:Ne(JSON.parse(JSON.stringify(Fe)),{}),creatingLinePlot:!1,newLineTemplate:{from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},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=ue(o.newLineTemplate,o);const e=Object.keys(o);return s&&Object.keys(s).forEach(t=>{const n=s[t];if(!e.includes(t)){w("RGOptions: unknow option key:",t);return}if(typeof n=="object"){w("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},on=s=>{const o=s.layoutName||"";if(o==="center"){const e=s;e.layoutDirection=void 0}else if(o.includes("tree")){const e=s;e.from===void 0&&(e.from="left"),e.levelGaps===void 0&&(e.levelGaps=[]),(e.from==="top"||e.from==="bottom")&&(e.layoutDirection===void 0&&(e.layoutDirection="v"),w("set layoutDirection=v"),w("set defaultJunctionPoint=tb")),(e.from==="left"||e.from==="right")&&(e.layoutDirection===void 0&&(e.layoutDirection="h"),w("set defaultJunctionPoint=lr"))}else(o==="fixed"||o==="force")&&(s.layoutDirection=void 0)},zi=Object.freeze(Object.defineProperty({__proto__:null,createDefaultConfig:et,appendDefaultOptions4Layout:on,default:{createDefaultConfig:et}},Symbol.toStringTag,{value:"Module"}));class Se extends Vi{constructor(){super();_(this,"commits");_(this,"updateViewHook",e=>{});this.options=et({}),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.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,Object.assign(this.options,e),this.isPerformanceMode()&&!this.options.showEasyView){const t=Object.keys(e);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);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),n--,t++);for(const n of e)this.runtimeDATA4NodeMap.delete(n);w("Removed node\uFF1A",e,t),this.commits.nodesListChanged=!0}removeLineByIds(e){w("_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++)}w("_removeLineByIds:",t),this.removeLinkByLineIds(e),this.updateLinks(),this.commits.linesListChanged=!0}removeFakeLineByIds(e){w("_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,w("_removeFakeLineByIds:",t)}removeLinkByLineIds(e){w("_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,w("_removeLinkByLineIds:",t)}removeConnectTarget(e){const t=this.runtimeDATA4ConnectTargets.findIndex(n=>n.targetId===e);if(t!==-1){const n=this.runtimeDATA4ConnectTargets[t];(n.targetType===I.NodePoint||n.targetType===I.CanvasPoint)&&this.runtimeDATA4ConnectTargets.splice(t,1)}this.commits.connectTargetsListChanged=!0,this.commits.fakeLinesListChanged=!0}updateLinks(e=[]){const t=new Ai;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){for(let t=0;t<this.runtimeDATA4Links.length;t++){const n=this.runtimeDATA4Links[t];(e.includes(n.fromNode.id)||e.includes(n.toNode.id))&&(w("Removed Node-line\uFF1A",n.lineId),this.removeLineByIds([n.lineId]),t--)}for(let t=0;t<this.graphData.fakeLines.length;t++){const n=this.graphData.fakeLines[t];let i=!1;if(n.fromType===I.Node&&e.includes(n.from))i=!0;else if(n.fromType===I.CanvasPoint||n.fromType===I.NodePoint){const a=this.getConnectTargetById(n.from);a&&a.nodeId&&e.includes(a.nodeId)&&(i=!0)}else if(n.toType===I.CanvasPoint||n.toType===I.NodePoint){const a=this.getConnectTargetById(n.to);a&&a.nodeId&&e.includes(a.nodeId)&&(i=!0)}i&&(this.graphData.fakeLines.splice(t,1),w("Removed Node-fakeLine\uFF1A",n.id),t--,this.commits.fakeLinesListChanged=!0)}w("Removed Node connect-target\uFF1A");for(let t=0;t<this.runtimeDATA4ConnectTargets.length;t++){const n=this.runtimeDATA4ConnectTargets[t];n.nodeId&&e.includes(n.nodeId)&&(this.runtimeDATA4ConnectTargets.splice(t,1),w("Removed Node-connect-target\uFF1A",n.targetId),this.commitConnectTarget(n.targetId),t--)}}addFakeLines(e){for(const t of e)if(t.id||console.warn("[relation-graph]Must have id for fake line:",t),this.graphData.fakeLines.some(n=>n.id===t.id))console.log("[relation-graph]Ignore duplicate fake line id:",t.id);else{t.isFakeLine=!0;const n=ue(t,this.options);n.id||(n.id=Xe(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=be.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}Object.assign(n,t,{id:e}),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=be.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,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 d=!0;a||r.alwaysRender?d=!0:((r.x>i.x||r.y>i.y)&&(d=!1),(r.x+r.el_W<n.x||r.y+r.el_H<n.y)&&(d=!1)),r.rgShouldRender=d}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 Xi{constructor(){_(this,"listeners");_(this,"useReactiveDataToAutoUpdateView",!1);_(this,"instanceId");_(this,"dataProvider");_(this,"options");_(this,"_previousUpdateTime",0);_(this,"_dataUpdatedRequested",!1);_(this,"eventHandlers",[]);_(this,"_emitHook");this.dataProvider=new Se,this.options=this.dataProvider.getOptions(),this.listeners={},this.instanceId="RG-"+this.generateNewUUID(5)}generateNewUUID(o=5){return Xe(o)}enableDebugLog(o){this.dataProvider.updateOptions({debug:o}),typeof window<"u"&&window&&(window.relationGraphDebug=o)}_dataUpdated(){this._requestDataUpdate()}_beforeViewDataUpdated(){}_updateEditingControllerView(){}_updateEditingConnectControllerView(){}updateShouldRenderGraphData(o){}updateEasyView(){}updateMiniView(){}_requestDataUpdate(){typeof window>"u"||!window.requestAnimationFrame||this._dataUpdatedRequested||(this._dataUpdatedRequested=!0,requestAnimationFrame(this._doSomethingAfterDataUpdated.bind(this)))}_doSomethingAfterDataUpdated(){try{this._beforeViewDataUpdated(),!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}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 w("[custom event hook]Event:",o," => returnValue:",t),t}defaultEventHandler(o,...e){let t,n=!1;if(o===D.onReady)this.listeners.onReady&&(n=!0,this.listeners.onReady(this));else if(o===D.onNodeDragStart)this.listeners.onNodeDragStart&&(n=!0,this.listeners.onNodeDragStart(e[0],e[1]));else if(o===D.onNodeDragging){if(this.listeners.onNodeDragging){n=!0;const i=e[0],a=e[1],r=e[2],d=e[3],c=e[4],h=e[5];t=this.listeners.onNodeDragging(i,a,r,d,c,h)}}else if(o===D.onCanvasDragging){if(this.listeners.onCanvasDragging){n=!0;const i=e[0],a=e[1],r=e[2],d=e[3];t=this.listeners.onCanvasDragging(i,a,r,d)}}else if(o===D.onNodeDragEnd){const i=e[0],a=e[1],r=e[2],d=e[3];this.listeners.onNodeDragEnd&&(n=!0,this.listeners.onNodeDragEnd(i,a,r,d))}else if(o===D.onZoomEnd)this.listeners.onZoomEnd&&(n=!0,this.listeners.onZoomEnd());else if(o===D.onNodeClick){if(this.listeners.onNodeClick){n=!0;const i=e[0],a=e[1];this.listeners.onNodeClick(i,a)}}else if(o===D.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===D.onNodeExpand){if(this.listeners.onNodeExpand){n=!0;const i=e[0],a=e[1];this.listeners.onNodeExpand(i,a)}}else if(o===D.onNodeCollapse){if(this.listeners.onNodeCollapse){n=!0;const i=e[0],a=e[1];this.listeners.onNodeCollapse(i,a)}}else if(o===D.onCanvasDragEnd){if(this.listeners.onCanvasDragEnd){n=!0;const i=e[0];this.listeners.onCanvasDragEnd(i)}}else if(o===D.onCanvasClick){if(this.listeners.onCanvasClick){n=!0;const i=e[0];this.listeners.onCanvasClick(i)}}else if(o===D.onCanvasSelectionEnd){if(this.listeners.onCanvasSelectionEnd){n=!0;const i=e[0],a=e[1];this.listeners.onCanvasSelectionEnd(i,a)}}else if(o===D.onContextmenu){if(this.listeners.onContextmenu){n=!0;const i=e[0],a=e[1],r=e[2],d=e[3],c=e[4];this.listeners.onContextmenu(i,a,r,d,c)}}else if(o===D.onFullscreen){if(this.listeners.onFullscreen){n=!0;const i=e[0],a=e[1];t=this.listeners.onFullscreen(i,a)}}else if(o===D.beforeAddNodes){if(this.listeners.beforeAddNodes){n=!0;const i=e[0];t=this.listeners.beforeAddNodes(i)}}else if(o===D.beforeAddLines){if(this.listeners.beforeAddLines){n=!0;const i=e[0];t=this.listeners.beforeAddLines(i)}}else if(o===D.onKeyboardDown){if(this.listeners.onKeyboardDown){n=!0;const i=e[0];t=this.listeners.onKeyboardDown(i)}}else if(o===D.onKeyboardUp){if(this.listeners.onKeyboardUp){n=!0;const i=e[0];t=this.listeners.onKeyboardUp(i)}}else if(o===D.onLineBeCreated){if(this.listeners.onLineBeCreated){n=!0;const i=e[0];t=this.listeners.onLineBeCreated(i)}}else if(o===D.onCanvasDragStart){if(this.listeners.onCanvasDragStart){n=!0;const i=e[0],a=e[1],r=e[2];t=this.listeners.onCanvasDragStart(i,a,r)}}else if(o===D.onResizeEnd){if(this.listeners.onResizeEnd){n=!0;const i=e[0],a=e[1],r=e[2],d=e[3];t=this.listeners.onResizeEnd(i,a,r,d)}}else if(o===D.onResizeStart){if(this.listeners.onResizeStart){n=!0;const i=e[0],a=e[1];t=this.listeners.onResizeStart(i,a)}}else if(o===D.beforeNodeResize){if(this.listeners.beforeNodeResize){n=!0;const i=e[0],a=e[1],r=e[2],d=e[3],c=e[4];t=this.listeners.beforeNodeResize(i,a,r,d,c)}}else if(o===D.onViewResize&&this.listeners.onViewResize){n=!0;const i=e[0];t=this.listeners.onViewResize(i)}return{result:t,handled:n}}setEventListener(o){Object.assign(this.listeners,o)}}class Fi extends Xi{constructor(){super(...arguments);_(this,"$dom");_(this,"$canvasDom");_(this,"dataStores",{});_(this,"_rgAsConnectArea",!1);_(this,"$lineTextContainer4NormalLine");_(this,"$lineTextContainer4FakeLine");_(this,"viewBoundingClientRect",null)}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.dataStores.textContainer4NormalRef&&(this.dataStores.textContainer4NormalRef.value=this.$lineTextContainer4NormalLine)),this.$lineTextContainer4NormalLine):(this.$lineTextContainer4FakeLine||(this.$lineTextContainer4FakeLine=this.$canvasDom.querySelector(".rg-lines-container-normal-lines .rg-linetext-container"),this.dataStores.textContainer4FakeLineRef&&(this.dataStores.textContainer4FakeLineRef.value=this.$lineTextContainer4FakeLine)),this.$lineTextContainer4FakeLine)}getViewBoundingClientRect(){var t;if(!this.$dom)return this.viewBoundingClientRect||console.error("[getViewBoundingClientRect] RelationGraph DOM is not set yet!"),this.viewBoundingClientRect;const e=(t=this.$dom)==null?void 0:t.getBoundingClientRect();return this.viewBoundingClientRect=e,e}getBoundingClientRect(){return console.warn("Please use getViewBoundingClientRect instead of getBoundingClientRect, this method is compatible with older api versions."),this.getViewBoundingClientRect()}getCanvasSlotRectItems(){return[]}_getEventPoint(e){return this.getViewXyByEvent(e)}getViewXyByEvent(e){const t=ce(e),n={x:t.clientX,y:t.clientY};return this.getViewXyByClientXy(n)}getViewXyByClientXy(e){const t=this.getViewBoundingClientRect();return{x:e.x-t.x,y:e.y-t.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)}getEventTargetElement(e){return e.target instanceof Element?e.target:null}isNode(e){const t=ve(e,"rg-node-peel","rg-map");if(!!t)return this.dataProvider.getNodeById(t.dataset.id)}isLine(e){const t=ve(e,"rg-line-peel","relation-graph");if(!!t)return this.dataProvider.getLineById(t.dataset.id)}isLink(e){throw new Error("Please use isLine")}}class Gi extends Se{constructor(e,t,n,i){super();_(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(r.optionsChanged&&this.dataStores.store4Options.set(this.getOptions()),r.nodesListChanged&&this.dataStores.store4ShouldRenderNodes.set(this.getShouldRenderNodes()),r.linesListChanged){const d=this.getShouldRenderLines();this.dataStores.store4ShouldRenderLines.set(d)}if(r.fakeLinesListChanged){const d=this.getShouldRenderFakeLines();this.dataStores.store4ShouldRenderFakeLines.set(d)}}}}class $i extends Se{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 Hi extends Se{constructor(e,t){super();_(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()),(n.nodesListChanged||n.linesListChanged||n.changedLines.length>0)&&this.dataStores.store4ShouldRenderLines.set(this.getShouldRenderLines()),(n.fakeLinesListChanged||n.changedFakeLines.length>0)&&this.dataStores.store4ShouldRenderFakeLines.set([...this.getShouldRenderFakeLines()])}}}class Yi extends Se{constructor(o,e){super(),e(),this.updateViewHook=t=>{if(t.optionsChanged&&o.store4Options.set(this.getOptions()),t.linesListChanged||t.changedLines.length>0||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 Wi extends Fi{constructor(){super();_(this,"_initRawPropertyFn",(e,t,n)=>{});_(this,"dataStores")}setReactiveData4Vue2(e,t,n,i){this.useReactiveDataToAutoUpdateView=!0,this.dataProvider=new $i(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 Gi(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,textContainer4NormalRef:e.textContainer4NormalRef,textContainer4FakeLineRef:e.textContainer4FakeLineRef}}setReactiveData4React(e,t){this.dataProvider=new Yi(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 Hi(e,t),this.options=this.dataProvider.getOptions(),this.dataStores={optionsStore:e.store4Options,shouldRenderNodesStore:e.store4ShouldRenderNodes,shouldRenderLinesStore:e.store4ShouldRenderLines,shouldRenderFakeLinesStore:e.store4ShouldRenderFakeLines}}generateNewNodeId(e=5){const t=Xe(e);return this.dataProvider.getNodeById(t)?this.generateNewNodeId(e+1):t}}class Ui extends Wi{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()}_getAllLinks(){const o=this.getLinks();return this._getFakeLineLinks().concat(o)}getNodeByTargetId(o){const e=this.dataProvider.getConnectTargetById(o);if(e&&e.nodeId)return this.getNodeById(e.nodeId)}_getFakeLineLinks(){const o=[];for(const e of this.getFakeLines())if(!e.forDisplayOnly&&(e.fromType===I.Node||e.fromType===I.NodePoint||e.fromType===I.CanvasPoint)&&(e.toType===I.Node||e.toType===I.NodePoint||e.toType===I.CanvasPoint)){let t=null,n=null;e.fromType===I.Node?t=this.getNodeById(e.from):(e.fromType===I.NodePoint||e.fromType===I.CanvasPoint)&&(t=this.getNodeByTargetId(e.from)),e.toType===I.Node?n=this.getNodeById(e.to):(e.toType===I.NodePoint||e.toType===I.CanvasPoint)&&(n=this.getNodeByTargetId(e.to)),t&&n&&o.push({lineId:e.id,line:e,fromNode:t,toNode:n,totalLinesBetweenNodes:1,currentLineIndex:0,rgShouldRender:!0,rgCalcedVisibility:!0})}return o}getConnectTargets(){return this.dataProvider.getConnectTargets()}getConnectTargetById(o){return this.dataProvider.getConnectTargetById(o)}}class ji extends Ui{constructor(){super()}getRelatedLinesByNode(o){const e=[];for(const t of this._getAllLinks())(o===t.fromNode||o===t.toNode)&&e.push(t.line);return e}getLinksBetweenNodes(o){const e=[],t=this._getAllLinks();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,e={incoming:!0,outgoing:!0}){const t=[];for(const n of this.getLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}for(const n of this._getFakeLineLinks()){if(n.line.forDisplayOnly)continue;const{fromNode:i,toNode:a}=n;e.outgoing&&i===o&&(t.includes(a)||t.push(a)),e.incoming&&a===o&&(t.includes(i)||t.push(i))}return t}getNodeIncomingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!0,outgoing:!1})}getNodeOutgoingNodes(o){return this.getNodeRelatedNodes(o,{incoming:!1,outgoing:!0})}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(h=>h.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(h=>{h.x<n&&(n=h.x),h.x+(h.width||h.el_W)>a&&(a=h.x+(h.width||h.el_W)),h.y<i&&(i=h.y);const u=h.y+(h.height||h.el_H);u>r&&(r=u)});const d=a-n,c=r-i;return{width:d<0?0:d,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);w("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 be.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 Ji extends ji{constructor(){super();_(this,"_elLineUpdateTimer");_(this,"_canvasCurrentInfo",{x:0,y:0,scale:1});_(this,"_nodeResizeEffectTimer");_(this,"prevAddNodeTimestamp",0);_(this,"_nodesElSizeMap",new Map)}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){w("removeLineById:",e),this.dataProvider.removeFakeLineByIds([e]),this._dataUpdated()}removeLink(e){w("removeLink:",e),this.removeLinkByLineId(e.lineId)}removeLinkByLineId(e){this.dataProvider.removeLineByIds([e]),this._dataUpdated()}removeNodeById(e){this.dataProvider.removeNodeById([e]),this._dataUpdated()}removeNodesByIds(e){this.dataProvider.removeNodeById(e),this._dataUpdated()}removeNodes(e){this.removeNodesByIds(e.map(t=>t.id))}removeNode(e){this.removeNodes([e])}removeELementLineById(e){w("removeELementLineById:",e),this.removeFakeLineById(e)}addNode(e){if(w("addNode:",e),e&&Array.isArray(e)){console.error("addNode: node is array:",e);return}this._addNodes([e]),this._dataUpdated()}addNodes(e){if(w("addNodes:",e),e&&!Array.isArray(e)){console.error("addNodes: nodes is not array:",e);return}this._addNodes(e),this._dataUpdated()}addLine(e){if(w("addLine:",e),e&&Array.isArray(e)){console.error("addLine: line is array:",e);return}this.addLines([e])}addLines(e){if(w("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){w("addFakeLines:",e),this._addFakeLines(e),this._dataUpdated()}updateElementLines(){this.dataProvider.getElLineTargets().length!==0&&(w("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){w("addElementLines:",e),e.forEach(t=>{t.fromType=I.HTMLElementId,t.toType=I.HTMLElementId,t.isFakeLine=!0,t.id||(t.id=this.generateNewUUID(6)),t.forDisplayOnly=!0}),this.addFakeLines(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===I.HTMLElementId||t.toType===I.HTMLElementId)&&e.push(t.id);this.dataProvider.removeFakeLineByIds(e),this._dataUpdated()}_addNodes(e){this.emitEvent(D.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:d,id:c}=a;!d&&a.label&&(d=a.label,console.warn('Use "label" as "text":',a.label)),d===void 0&&c&&(d=c,console.warn('Use "id" as "text":',c)),r=Ne(Object.assign({},a,{text:d}),i,this._nodesElSizeMap),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(D.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(u=>u.id===n.id)){console.warn("Duplicate line id in new lines:",n.id);return}}else n.id="L-"+this.generateNewUUID(6);const h=ue(Object.assign({},n,{from:i,to:a,text:r}),this.getOptions());t.push(h)}),this.dataProvider.addLines(t)}updateNode(e,t){this.dataProvider.updateNode(typeof e=="string"?e:e.id,t),this._dataUpdated()}updateNodePosition(e,t,n){var a;const i=typeof e=="string"?e:e.id;this.dataProvider.updateNode(i,{x:t,y:n}),this.getOptions().layout.autoLayouting&&((a=this.layoutor)==null||a.syncNodePosition(i,t,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){be.flatNodeData(e,t,n,i)}backupNodesElSize(){for(const e of this.getNodes())this._nodesElSizeMap.set(e.id,[e.el_W,e.el_H])}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),w("Nodes is initialized"),this._addLines(a),this._dataUpdated(),e.fakeLines&&this.addFakeLines(e.fakeLines),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)),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.backupNodesElSize(),this.dataProvider.clearReactiveData(),this.dataProvider.clearChecked(),this.dataProvider.setEditingLine(null),this.dataProvider.setEditingNodes([])}_setJsonData(e,t=!1){this._clearGraph(),this.loadGraphJsonData(e)}}class qi extends Ji{constructor(){super();_(this,"canvasConnectTargetsMap",new Map);_(this,"nodeConnectTargetsMap",new Map);_(this,"connectTargetRuntimeMap",new Map);_(this,"connectTargetIdByHostElement",new WeakMap);_(this,"connectTargetIdByMeasureElement",new WeakMap);_(this,"connectTargetIdByTriggerElement",new WeakMap);_(this,"_connectTargetUpdateRequestedSet",new Map);_(this,"_updateTimer");_(this,"_removedConnectTargetMap",new Map)}_observeConnectTargetElement(e,t){}_unobserveConnectTargetElement(e,t){}updateConnectTargetsOnCanvas(e,t){if(!t)return;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(`.rg-node-peel[data-id="${e}"]`)}getConnectTargetRuntimeById(e){return this.connectTargetRuntimeMap.get(e)}getConnectTargetElementById(e){var t;return(t=this.connectTargetRuntimeMap.get(e))==null?void 0:t.measureEl}getConnectTargetHostElementById(e){var t;return(t=this.connectTargetRuntimeMap.get(e))==null?void 0:t.hostEl}updateConnectTargetsOnNode(e,t,n){const i=this.nodeConnectTargetsMap.get(t)||[];i.length!==0&&this.updateConnectTargetList(e,n,i)}updateConnectTargetList(e,t,n){for(const i of n){const a=this.getConnectTargetRuntimeById(i.targetId);if(!(a!=null&&a.measureEl)){console.error("Can not find measure element for connectTarget:",i.targetId,i);continue}this._requestUpdateConnectTargetOffset(e,i,t,a.measureEl)}}getRegisteredConnectTargetByElement(e){let t=e;for(;t;){const n=this.connectTargetIdByTriggerElement.get(t)||this.connectTargetIdByHostElement.get(t)||this.connectTargetIdByMeasureElement.get(t);if(n){const i=this.dataProvider.getConnectTargetById(n),a=this.connectTargetRuntimeMap.get(n);if(i&&a)return{matchedEl:t,connectTargetEl:a.measureEl,connectTarget:i,runtime:a}}t=t.parentElement}}getConnectTargetByElement(e){var t;return(t=this.getRegisteredConnectTargetByElement(e))==null?void 0:t.connectTarget}refreshConnectTargetRuntimeById(e,t,n){const i=this.getConnectTargetRuntimeById(t);if(!i)return;const a=this.resolveConnectTargetMeasureElement({hostEl:i.hostEl,targetId:i.targetId,targetType:I.NodePoint,domMode:i.domMode,measureSelector:i.measureSelector,strictMeasureTarget:i.strictMeasureTarget,measureEl:n})||i.measureEl,r={...i,measureEl:a};this.applyConnectTargetRuntime(r),this.updateConnectTargetById(e,t,a)}updateConnectTargetById(e,t,n){const i=this.dataProvider.getConnectTargetById(t);if(!i)return;const a=this.getConnectTargetRuntimeById(t),r=n||(a==null?void 0:a.measureEl),d=this.getConnectTargetRelativeElement(i,(a==null?void 0:a.hostEl)||r);!r||!d||this._requestUpdateConnectTargetOffset(e,i,d,r)}removeConnectTargetFromOwnerMaps(e){for(const[t,n]of this.nodeConnectTargetsMap.entries()){const i=n.findIndex(a=>a.targetId===e);i!==-1&&(n.splice(i,1),n.length===0&&this.nodeConnectTargetsMap.delete(t))}for(const t of["behind","above"]){const n=this.canvasConnectTargetsMap.get(t);if(!n)continue;const i=n.findIndex(a=>a.targetId===e);i!==-1&&(n.splice(i,1),n.length===0&&this.canvasConnectTargetsMap.delete(t))}}_requestUpdateConnectTargetOffset(e,t,n,i){this._connectTargetUpdateRequestedSet.set(t.targetId,{stableTimes:0,connectTarget:t,by:e,measureEl:i,relativeEl:n}),clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(this._connectTargetUpdateRequestedSet.size+10,50)),this._dataUpdated()}_updateAllRequestedConnectTargetOffsets(){let e=0;for(const t of this._connectTargetUpdateRequestedSet.values()){const{by:n,relativeEl:i,connectTarget:a}=t;if(this.dataProvider.isPerformanceMode()&&a.nodeId){const h=this.getNodeById(a.nodeId);if(!h||!h.rgShouldRender||!h.rgCalcedVisibility)continue}if(!this.dataProvider.getConnectTargetById(a.targetId))continue;const d=this.getConnectTargetElementById(a.targetId)||t.measureEl;if(!d)continue;this._updateConnectTargetOffset(n,a,d,i)?e++:t.stableTimes++,t.stableTimes>2&&this._connectTargetUpdateRequestedSet.delete(a.targetId)}e>0?(clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._updateAllRequestedConnectTargetOffsets()},Math.min(e/2+10,100)),this._dataUpdated()):(this._connectTargetUpdateRequestedSet.clear(),this._dataUpdated())}_updateConnectTargetOffset(e,t,n,i){const a=this.measureConnectTargetGeometry(t,n,i);if(!a)return!1;const{offsetX:r,offsetY:d,width:c,height:h}=a,f=t.offsetX!==r,u=t.offsetY!==d,y=c!==0&&t.width!==c,p=h!==0&&t.height!==h;return f||u||y||p?(this.dataProvider.updateConnectTarget(t.targetId,{offsetX:r,offsetY:d,width:c,height:h}),!0):!1}getConnectTargetRelativeElement(e,t){var i,a;if(t){const r=this.getNodeElByChildrenTarget(t);if(r)return r;const d=ve(t,"rg-canvas-slot","rg-map");if(d)return d}if(e.nodeId)return this.getNodeElByNodeId(e.nodeId);const n=e.targetType===I.CanvasPoint&&((i=this.canvasConnectTargetsMap.get("above"))==null?void 0:i.some(r=>r.targetId===e.targetId))?"above":"behind";return(a=this.$dom)==null?void 0:a.querySelector(`.rg-canvas-slot-${n}`)}measureConnectTargetGeometry(e,t,n){const i=t||this.getConnectTargetElementById(e.targetId),a=this.getConnectTargetHostElementById(e.targetId)||i,r=n||this.getConnectTargetRelativeElement(e,a);if(!i||!r)return;const d=r.getBoundingClientRect(),c=i.getBoundingClientRect(),h=this.dataProvider.getCanvasScale(),f=Math.round((c.x-d.x)/h),u=Math.round((c.y-d.y)/h),y=Math.round(c.width/h),p=Math.round(c.height/h);return{offsetX:f,offsetY:u,width:y,height:p}}createLineTargetFromConnectTarget(e,t){var d,c,h,f;const n=(d=t==null?void 0:t.offsetX)!=null?d:e.offsetX,i=(c=t==null?void 0:t.offsetY)!=null?c:e.offsetY,a=(h=t==null?void 0:t.width)!=null?h:e.width,r=(f=t==null?void 0:t.height)!=null?f:e.height;if(e.nodeId){const u=this.getNodeById(e.nodeId);if(!u){console.error("[createLineTargetFromConnectTarget]Can not find NodePoint-s Node:",`${e.targetId}@${e.nodeId}`);return}return{x:u.x+e.offsetPercentX*u.el_W+n,y:u.y+e.offsetPercentY*u.el_H+i,targetType:e.targetType||I.NodePoint,targetData:e.targetData,junctionPoint:e.junctionPoint,nodeShape:0,id:e.targetId,el_W:a,el_H:r,hidden:!1}}return{x:n,y:i,targetType:e.targetType||I.CanvasPoint,targetData:e.targetData,junctionPoint:e.junctionPoint,nodeShape:0,id:e.targetId,el_W:a,el_H:r,hidden:!1}}_onConnectTargetMounted(e,t,n){this._requestUpdateConnectTargetOffset(e,t,n)}getNodeElByChildrenTarget(e){const t=e instanceof Element?e:e.parentElement;return t?ve(t,"rg-node-peel","rg-map"):null}normalizeConnectTargetDomMode(e,t){return t==="contents"&&e instanceof HTMLElement?"contents":"wrap"}resolveConnectTargetMeasureElement(e){const t=this.normalizeConnectTargetDomMode(e.hostEl,e.domMode);if(e.measureEl)return e.measureEl;if(t!=="contents")return e.hostEl;let n=null;if(e.measureSelector)try{n=e.hostEl.querySelector(e.measureSelector)}catch(i){console.warn(`[registerConnectTarget]Invalid measureSelector for target: ${e.targetId}`,e.measureSelector,i)}if(n||(n=e.hostEl.firstElementChild),n||(n=e.hostEl.querySelector("*")),n)return n;if(e.strictMeasureTarget){console.warn(`[registerConnectTarget]Can not resolve measure element for target: ${e.targetId}`);return}return console.warn(`[registerConnectTarget]Can not resolve measure element for target: ${e.targetId}, fallback to host element.`),e.hostEl}removeRuntimeElementMappings(e){this.connectTargetIdByHostElement.delete(e.hostEl),this.connectTargetIdByMeasureElement.delete(e.measureEl),this.connectTargetIdByTriggerElement.delete(e.triggerEl)}addRuntimeElementMappings(e){this.connectTargetIdByHostElement.set(e.hostEl,e.targetId),this.connectTargetIdByMeasureElement.set(e.measureEl,e.targetId),this.connectTargetIdByTriggerElement.set(e.triggerEl,e.targetId)}isSameRuntime(e,t){return!!e&&e.hostEl===t.hostEl&&e.measureEl===t.measureEl&&e.triggerEl===t.triggerEl&&e.domMode===t.domMode&&e.measureSelector===t.measureSelector&&e.strictMeasureTarget===t.strictMeasureTarget}applyConnectTargetRuntime(e){const t=this.connectTargetRuntimeMap.get(e.targetId);if(this.isSameRuntime(t,e)){this.connectTargetRuntimeMap.set(e.targetId,e);return}t&&(this._unobserveConnectTargetElement(e.targetId,t),this.removeRuntimeElementMappings(t)),this.connectTargetRuntimeMap.set(e.targetId,e),this.addRuntimeElementMappings(e),this._observeConnectTargetElement(e.targetId,e)}registerConnectTarget(e,t,n,i,a={}){const r=e instanceof Element?{hostEl:e,targetId:t,targetType:n,junctionPoint:i,targetData:a}:e;if(r.targetType!==I.NodePoint&&r.targetType!==I.CanvasPoint)return;if(!r.hostEl){console.error(`[registerConnectTarget]Can not find CanvasPoint target DOM: ${r.targetId}`);return}const d=r.junctionPoint||Y.border,c=this.resolveConnectTargetMeasureElement(r);if(!c)return;const h={targetId:r.targetId,hostEl:r.hostEl,measureEl:c,triggerEl:r.triggerEl||r.hostEl,domMode:this.normalizeConnectTargetDomMode(r.hostEl,r.domMode),measureSelector:r.measureSelector,strictMeasureTarget:r.strictMeasureTarget},f=this.getNodeElByChildrenTarget(h.hostEl),u=f==null?void 0:f.dataset.id;if(u==="rg-newNodeTemplate")return;let y=this.dataProvider.getConnectTargetById(r.targetId);if(y)this.dataProvider.updateConnectTarget(r.targetId,{junctionPoint:d,targetType:r.targetType,targetData:r.targetData||{}});else{const g={targetId:r.targetId,targetType:r.targetType,junctionPoint:d,nodeId:"",width:20,height:20,offsetX:0,offsetY:0,offsetPercentX:0,offsetPercentY:0,targetData:r.targetData||{}};if(this.reuseConnectTarget(g),y=this.dataProvider.addConnectTarget(g),!y)return}return this.removeConnectTargetFromOwnerMaps(r.targetId),this.applyConnectTargetRuntime(h),(u?this.getNodeById(u):null)?this._addConnectTargetToNodeMap(u,y,h.hostEl,f):this._addConnectTargetToCanvasMap(y,h.hostEl),y}_addConnectTargetToNodeMap(e,t,n,i){this.dataProvider.updateConnectTarget(t.targetId,{junctionPoint:t.junctionPoint,targetType:I.NodePoint,nodeId:e,targetData:Object.assign({},t.targetData||{},{nodeId:e})});const a=this.nodeConnectTargetsMap.get(e);a?a.some(r=>r.targetId===t.targetId)||a.push(t):this.nodeConnectTargetsMap.set(e,[t]),this.refreshConnectTargetRuntimeById("NT-Runtime",t.targetId),this._onConnectTargetMounted("NT-Mounted",t,i||n)}_addConnectTargetToCanvasMap(e,t){const n=ve(t,"rg-canvas-slot","rg-map");if(!n)return;const i=n.classList.contains("rg-canvas-slot-above")?"above":"behind";this.dataProvider.updateConnectTarget(e.targetId,{junctionPoint:e.junctionPoint,targetType:I.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.refreshConnectTargetRuntimeById("CT-Runtime",e.targetId),this._onConnectTargetMounted("CT-Mounted",e,n)}unregisterConnectTarget(e){const t=this.dataProvider.getConnectTargetById(e),n=this.connectTargetRuntimeMap.get(e);n&&(this._unobserveConnectTargetElement(e,n),this.removeRuntimeElementMappings(n),this.connectTargetRuntimeMap.delete(e)),this._connectTargetUpdateRequestedSet.delete(e),t&&(this.removeConnectTargetFromOwnerMaps(e),this.dataProvider.removeConnectTarget(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 Zi extends qi{constructor(){super();_(this,"resolvedTargetCache",new Map);_(this,"fakeLineTargetRender")}_beforeViewDataUpdated(){this.resolvedTargetCache.clear(),super._beforeViewDataUpdated()}resolveTargetDescriptorByElement(e){const t=this.getRegisteredConnectTargetByElement(e);if(!t)return;const{connectTarget:n,connectTargetEl:i,runtime:a}=t;return{targetId:n.targetId,targetType:n.targetType,junctionPoint:n.junctionPoint,connectTargetEl:i,hostEl:a.hostEl,measureEl:a.measureEl,triggerEl:a.triggerEl}}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=this.resolveTargetRect(i.targetType,i.id,n,{preferLiveTarget:!0}),r=t.toNode;if(!r)return{line:Object.assign({},n,{isFakeLine:!1}),from:a,to:null,totalLinesBetweenNodes:1,currentLineIndex:0};const d=r.targetType===I.Node?t.toNode:this.resolveTargetRect(r.targetType,r.id,n,{preferLiveTarget:!0});return{line:Object.assign({},n,{isFakeLine:!1}),from:a,to:d,totalLinesBetweenNodes:1,currentLineIndex:0}}generateLineConfig(e){const t=this.getLinkByLine(e);return!t||!t.rgCalcedVisibility?!1:{line:t.line,from:t.fromNode,to:t.toNode,totalLinesBetweenNodes:t.totalLinesBetweenNodes,currentLineIndex:t.currentLineIndex}}generateFakeLineConfig(e){let t=1,n=0;if(e.fromType===I.HTMLElementId&&e.toType===I.HTMLElementId){const r=this.dataProvider.getFakeLines().filter(d=>d.from===e.from&&d.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,{preferLiveTarget:!1}),a=this.getFakeLineTarget(e.toType,e.to,e,{preferLiveTarget:!1});return!i&&e.fromType===I.Node?(console.error("[generateFakeLineConfig]error fakeLine from:",e.fromType,e.from,e),!1):!a&&e.toType===I.Node?(console.error("[generateFakeLineConfig]error fakeLine to:",e.toType,e.to,e),!1):!i||!a?!1:{line:e,from:i,to:a,totalLinesBetweenNodes:t,currentLineIndex:n}}setFakeLineTargetRender(e){this.fakeLineTargetRender=e}resolveTargetRect(e,t,n,i={}){if(e===I.HTMLElementId){let a=this.dataProvider.getElLineTargets().find(r=>r.id===t);return a||(a={x:300,y:300,targetType:I.HTMLElementId,nodeShape:1,id:t,el_W:40,el_H:40,hidden:!0},this.dataProvider.addElLineTarget(a),this.updateElementLines()),a.hidden?null:a}else{if(e===I.Node)return this.getNodeById(t);if(e===I.NodePoint||e===I.CanvasPoint){const a=this.dataProvider.getConnectTargetById(t);if(!a)return;const d=`${a.targetType||e}:${t}:${i.preferLiveTarget===!0?"live":"cached"}`;if(i.preferLiveTarget&&this.resolvedTargetCache.has(d))return this.resolvedTargetCache.get(d)||null;const c=i.preferLiveTarget?this.measureConnectTargetGeometry(a,i.connectTargetEl||this.getConnectTargetElementById(t)):void 0,h=this.createLineTargetFromConnectTarget(a,c);return i.preferLiveTarget&&this.resolvedTargetCache.set(d,h||null),h}}if(this.fakeLineTargetRender)return this.fakeLineTargetRender(e,t,n)}getFakeLineTarget(e,t,n,i={}){return this.resolveTargetRect(e,t,n,i)}}class Ki extends Zi{constructor(){super()}_updateOptions(o){!o.instanceId&&this.getOptions().instanceId!==o.instanceId&&(o.instanceId=this.instanceId);const e=Object.assign({},o);if(e.layouts)throw new Error('Graph options do not support setting "layouts" properties, Please use "layout"!');if(e.lineUseTextPath)throw new Error('Graph options do not support setting "lineUseTextPath" properties, Please use "defaultLineTextOnPath"!');if(e.debug!==void 0){const t=e.debug===!0;t&&w("RGOptions:user instance options:",e),typeof window<"u"&&window&&(window.relationGraphDebug=t)}e.layout?(this.dataProvider.updateOptions({...e,layout:{...this.getOptions().layout,...e.layout}}),this.layoutor&&this.layoutor.updateOptions&&this.layoutor.updateOptions(e.layout)):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),w("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){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 Qi extends Ki{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}}}const es=s=>{const o=Math.sin(s)*1e4;return o-Math.floor(o)},sn=(s,o,e,t,n,i)=>{const r=e-s,d=t-o,c=Math.sqrt(r*r+d*d),h=Math.max(2,Math.floor(c/12)),f=-d/c,u=r/c,y=[{type:"M",x:s,y:o}];let p=s,g=o;for(let m=1;m<=h;m++){let v=s+r*m/h,x=o+d*m/h;if(m<h){const L=es(n+m)-.5;v+=f*L*i,x+=u*L*i}y.push({type:"l",dx:v-p,dy:x-g}),p=v,g=x}return y},ts=(s,o={x:0,y:0,rotate:0})=>{const{fx:e,fy:t,tx:n,ty:i}=s;o.rotate=J.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=e+t+n+i,r=sn(e,t,n,i,a,2.5),d=sn(e,t,n,i,a+99,1.5),c=`${le(r)} ${le(d)}`;return{pathCommands:[...r,...d],pathData:c,textPosition:o,points:[]}};class ns extends Qi{constructor(){super()}_getJunctionPoint(o,e){return o===Y.border?J.getBorderPoint4MultiLine(e):o===Y.ltrb?J.getRectJoinPoint(e):o===Y.tb?J.getRectVJoinPoint(e):o===Y.lr?J.getRectHJoinPoint(e):o===Y.left?J.getRectLeftJoinPoint(e):o===Y.right?J.getRectRightJoinPoint(e):o===Y.top?J.getRectTopJoinPoint(e):o===Y.bottom?J.getRectBottomJoinPoint(e):o==="horizontalLine"?J.getRectHorizontalLineJoinPoint(e):o==="verticalLine"?J.getRectVerticalLineLineJoinPoint(e):J.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,{preferLiveTarget:!1}),n=this.getFakeLineTarget(r.toType,r.to,r,{preferLiveTarget:!1}),!t){console.warn("Invalid line configuration:error from:",e);return}if(!n){console.warn("Invalid line configuration:error to:",e);return}}return this.generateLinePath({line:e,from:t,to:n,totalLinesBetweenNodes:i,currentLineIndex:a})}_getLineDefaultOptions(){const o=this.getOptions();return{layoutDirection:o.layout.layoutDirection,multiLineDistance:o.multiLineDistance,defaultJunctionPoint:o.defaultJunctionPoint,lineRadius:o.defaultPolyLineRadius,defaultLineJunctionOffset:o.defaultLineJunctionOffset,defaultNodeShape:o.defaultNodeShape}}generateLinePath(o){o.totalLinesBetweenNodes===void 0&&(o.totalLinesBetweenNodes=1),o.currentLineIndex===void 0&&(o.currentLineIndex=0),o.defaultOptions===void 0&&(o.defaultOptions=this._getLineDefaultOptions());try{const e=this.withLineJunctionPoints(o);return this.createLinePathData(e)}catch(e){if(e.rgError)return this.createErrorLineValue(e.errorCode,e.x,e.y);throw e}}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:le(i),textPosition:n,points:[]}}withLineJunctionPoints({line:o,from:e,to:t,totalLinesBetweenNodes:n,currentLineIndex:i,defaultOptions:a}){if(!e||!t)throw w("error from-to:",e,t),this.throwLineError("F",-10,0);let r=o.lineShape||1;const d=o.lineDirection||a.layoutDirection||"h";let c=e.x||0,h=e.y||0,f=t.x||0,u=t.y||0;if(Number.isNaN(c)||Number.isNaN(h))throw w("error start node:",e.text,e.x,e.y),this.throwLineError("A",-10,-10);if(Number.isNaN(f)||Number.isNaN(u))throw w("error end point:",t.text,t.x,t.y),this.throwLineError("B",10,-10);let y=e.el_W||60,p=e.el_H||60;if(Number.isNaN(y)||Number.isNaN(p))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&&f===0&&h===0&&u===0)throw this.throwLineError("D",10,10);const v=f-c+(u-h)>0,x=o.isReverse?t:e,L=o.isReverse?e:t,P=Ce(x.nodeShape,a.defaultNodeShape),E=o.junctionOffset||a.defaultLineJunctionOffset||0;c-=E,h-=E,f-=E,u-=E,y+=E*2,p+=E*2,g+=E*2,m+=E*2;const T={from_x:c,from_y:h,to_x:f,to_y:u,f_W:y,f_H:p,t_W:g,t_H:m,nodeShape:P,isReverse:v,isEndPoint:!1,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||30},N=Ce(L.nodeShape,a.defaultNodeShape),b={from_x:f,from_y:u,to_x:c,to_y:h,f_W:g,f_H:m,t_W:y,t_H:p,nodeShape:N,isReverse:v,isEndPoint:!0,totalLinesBetweenNodes:n,currentLineIndex:i,lineDistance:a.multiLineDistance||50},k=a.defaultJunctionPoint||Y.border;let O=o.fromJunctionPoint||x.junctionPoint||k,S=o.toJunctionPoint||L.junctionPoint||k,R=o.fromJunctionPointOffsetX||0,C=o.fromJunctionPointOffsetY||0,M=o.toJunctionPointOffsetX||0,B=o.toJunctionPointOffsetY||0;o.isReverse&&([O,S]=[S,O],[R,C,M,B]=[M,B,R,C]),(e===t||c===0&&f===0&&h===0&&u===0)&&R===0&&C===0&&M===0&&B===0&&((r===W.StandardStraight||r===W.Curve2||r===W.Curve3||r===W.SimpleOrthogonal||r===W.Curve5)&&(r=W.StandardCurve),B=20);const X=this._getJunctionPoint(O,T);X.x+=R,X.y+=C;const A=this._getJunctionPoint(S,b);if(A.x+=M,A.y+=B,!X||!A)throw this.throwLineError("E",-20,-20);const F=c+y/2,H=h+p/2,j=f+g/2,se=u+m/2;O==="horizontalLine"?(X.x=A.x,(r===44||r===49)&&(X.x+=(A.x>j?1:-1)*30)):O==="verticalLine"&&(X.y=A.y,(r===44||r===49)&&(X.y+=(A.y>se?1:-1)*30)),S==="horizontalLine"?(A.x=X.x,(r===44||r===49)&&(A.x+=(X.x>F?1:-1)*30)):S==="verticalLine"&&(A.y=X.y,(r===44||r===49)&&(A.y+=(X.y>H?1:-1)*30));const ne=X.x,oe=X.y,ee=A.x,K=A.y;if(Number.isNaN(ne)||Number.isNaN(oe))throw w("error start point:",e.text),this.throwLineError("F",-10,0);if(Number.isNaN(ee)||Number.isNaN(K))throw w("error end point:",t.text),this.throwLineError("G",10,0);return{line:o,totalLinesBetweenNodes:n,currentLineIndex:i,lineDirection:d==="v"?"v":"h",lineShape:r,lineRadius:a.lineRadius||0,fromJunctionPoint:O,toJunctionPoint:S,fx:ne,fy:oe,fcx:F,fcy:H,f_W:y,f_H:p,tx:ee,ty:K,tcx:j,tcy:se,t_W:g,t_H:m}}createLinePathData(o){const{lineShape:e}=o;let t;return e===W.SimpleOrthogonal?t=Ei(o,void 0,this._getLineDefaultOptions()):e===W.StandardOrthogonal?t=Ri(o,void 0,this._getLineDefaultOptions()):e===W.HardOrthogonal?t=Mi(o,void 0,this._getLineDefaultOptions()):e===W.StandardCurve?t=Ii(o):e===W.Curve2||e===W.Curve3||e===W.Curve5||e===W.Curve7?t=Di(o):e===W.Curve8?t=ts(o):t=Pi(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.textOffsetX||a.defaultLineTextOffsetX||0,d=o.textOffsetY||a.defaultLineTextOffsetY||0,c=o.lineShape||1;return c===W.StandardStraight||c===W.SimpleOrthogonal?`translate(-50%, -50%) translate(${t+r}px,${n+d}px) rotate(${i||0}deg)`:`translate(-50%, -50%) translate(${t+r}px,${n+d}px)`}generateLineTextStyle(o,e){const t=this.getOptions(),n={transform:"",transformOrigin:"0 0"};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:d,y:c,rotate:h}=a;if(Number.isNaN(d)||Number.isNaN(c))return{text:r,cssStyles:n};const f=[],u=i.textAnchor||"center";u==="start"?f.push("translate(0%, -50%)"):u==="end"?f.push("translate(-100%, -50%)"):f.push("translate(-50%, -50%)"),f.push(`translate(${d}px,${c}px)`);const y=i.textOffsetX||t.defaultLineTextOffsetX||0,p=i.textOffsetY||t.defaultLineTextOffsetY||0,g=i.lineShape||1;return(i.useTextOnPath||t.defaultLineTextOnPath)&&g===1&&h&&f.push(`rotate(${h||0}deg)`),g===W.StandardStraight?(n.transformOrigin="50% 50%",f.push(`translate(${y}px,${p}px)`)):f.push(`translate(${y}px,${p}px)`),n.transform=f.join(" "),{text:r,cssStyles:n}}generateLineTextStyle4TextOnPath(o){const{line:e,from:t,to:n}=o;let i=e.text;if(!i||!n||!t)return null;let a=0;const r=this.getOptions();i.length>r.lineTextMaxLength&&(i=i.substring(0,r.lineTextMaxLength||15)+"...");const d=e.textOffsetX||r.defaultLineTextOffsetX||0,c=e.textOffsetY||r.defaultLineTextOffsetY||0,h={x:d,y:c-6};let f="50%";e.placeText==="start"?(f="0%",h.x+=20):e.placeText==="end"?(f="100%",h.x-=20):e.placeText==="center"?f="50%":e.placeText&&(f=e.placeText);let u="middle";return e.textAnchor&&(u=e.textAnchor),{text:i,textOffset:h,textAnchor:u,onPathStartOffset:f,textRotate:a}}}class os extends ns{constructor(){super()}getClampedZoom(o){const e=this.getOptions();return Math.max(e.minCanvasZoom,Math.min(e.maxCanvasZoom,o))}applyZoom(o,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions(),i=this.getClampedZoom(o),a=i-n.canvasZoom,r=e.x!==n.canvasOffset.x||e.y!==n.canvasOffset.y;if(!(a===0&&!r))try{const d=this.emitEvent(D.beforeZoomStart,n.canvasZoom,a,t);if(w("[zoom]","abortZoom:",d),d===!0)return;const c=n.canvasZoom;this._performanceModeLogicHook(c,i),this.dataProvider.updateOptions({canvasOffset:{x:e.x,y:e.y},canvasZoom:i}),this.emitEvent(D.onZoomEnd,i,c)}finally{this._updateEditingControllerView(),this._dataUpdated()}}zoom(o,e,t){if(this._rgAsConnectArea)return;const n=this.getOptions(),i=this.getViewBoundingClientRect(),a=this.getClampedZoom(n.canvasZoom+o);e||(e={x:i.x+i.width/2,y:i.y+i.height/2});const r=e.x-i.left,d=e.y-i.top,c=n.canvasZoom/100,h=a/100,f=r-(r-n.canvasOffset.x)*(h/c),u=d-(d-n.canvasOffset.y)*(h/c);this.applyZoom(a,{x:f,y:u},t)}setZoomAndOffset(o,e,t){this.applyZoom(o,e,t)}_performanceModeLogicHook(o,e){const t=this.getOptions();o<=40?e>40&&(t.performanceMode&&this.updateShouldRenderGraphData(!0),this.dataProvider.updateOptions({showEasyView:!1}),w("zoom:hide:showEasyView",o,e),this.updateElementLines()):o>40&&e<=40&&(w("zoom:show:showEasyView",o,e),t.performanceMode&&this.dataProvider.updateOptions({showEasyView:!0}))}setZoom(o,e){const t=this.getOptions(),n=o-t.canvasZoom;this.zoom(n,e)}}class is extends os{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,d=t.minY+t.height/2;this.dataProvider.setCanvasCenter(r,d);const c=Math.min(1,a/i),h=n*c+o*2;this.dataProvider.updateOptions({viewSize:{...e.viewSize,height:h},viewHeight:h+"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.getCanvasSlotRectItems(),n=t.length>0?[...t,...o||this.getNodes()]:o,i=this.getNodesRectBox(n),a=50,r=e.viewSize.width/(i.width+a*2),d=e.viewSize.height/(i.height+a*2),c=Math.min(r,d,1);w("zoomToFit:",{stuffSize:i,zoomPercent:c,zoomPercentX:r,zoomPercentY:d,viewSize:e.viewSize}),this._moveToCenter(n),this.setZoom(c*100),this._dataUpdated()}async zoomToFitWithAnimation(o){this.enableCanvasAnimation(),this.zoomToFit(o),await this.sleep(330),this.disableCanvasAnimation()}async moveToCenterWithAnimation(o){this.enableCanvasAnimation(),this.moveToCenter(o),await this.sleep(330),this.disableCanvasAnimation()}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){w("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 ss extends ge{constructor(e,t,n){super(e,t,n);_(this,"rotate",0);_(this,"enableGatherNodes",!1);_(this,"layoutOptions");this.layoutOptions=e,w("new RGTreeLayout:",this.layoutOptions),this.layoutOptions.from||(this.layoutOptions.from="left"),this.layoutOptions.levelGaps||(this.layoutOptions.levelGaps=[]);const i=this.layoutOptions.from;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)),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(w("RGTreeLayout:placeNodes"),t)w("layout by root:",t);else{console.error("root is null");return}w("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;w("groupNodes:2:",n.length,n.map(a=>a.text).join(",")),this.rotate,this.networkAnalyzer.analyzeNetwork(n,this.rootNode,!1),this.placeNodesPosition(t,n);const i={x:t.x,y:t.y};this.allNodes.forEach(a=>{if(a.fixed!==!0&&!!z.isVisibleNode(a)&&(Number.isNaN(a.lot.x)&&(w("bad lot x:",a.text,a.lot.x),a.lot.x=0),Number.isNaN(a.lot.y)&&(w("bad lot y:",a.text,a.lot.y),a.lot.y=0),a!==t)){this.layoutOptions.from==="right"&&(a.lot.x=J.getFlippedX(a.lot.x,i.x)),this.layoutOptions.from==="bottom"&&(a.lot.y=J.getFlippedY(a.lot.y,i.y));const r=this.layoutOptions.from==="right"?z.getNodeXByLotX({alignItemsX:"end"},a):a.lot.x,d=this.layoutOptions.from==="bottom"?z.getNodeYByLotY({alignItemsY:"end"},a):a.lot.y;this.updateNodePosition(a,r,d)}});for(const a of this.allNodes)this.graphInstance.updateNode(a,{rgChildrenSize:a.lot.childs.length});w("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,d=e.lot.y-e.y;this.layoutOptions.from==="right"&&(r+=e.lot.width),this.layoutOptions.from==="bottom"&&(d+=e.lot.height),n.forEach(c=>{c.fixed!==!0&&(c.lot.x-=r,c.lot.y-=d)})}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(f=>!t.includes(f));t.push(...c);const h=r.filter(f=>!t.includes(f));t.push(...h),a.lot.level=n,a.lot.toNodes=c,a.lot.fromNodes=h;for(const f of h.concat(c))f.lot.parent=a,i.includes(f)||i.push(f)}),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,d=a,c=e.filter(h=>h.lot.level===t);for(const h of c){if(!z.isVisibleNode(h))continue;let f=h.width||h.el_W||50,u=h.height||h.el_H||50;if(h.lot.width=f,h.lot.height=u,h.lot.toNodes.length===0&&h.lot.fromNodes.length===0)h.lot.width_with_childs=f,h.lot.height_with_childs=u;else if(n){let y=0,p=0;for(const v of h.lot.fromNodes)v.lot.height_with_childs>p&&(p=v.lot.height_with_childs),y+=v.lot.width_with_childs+d;let g=0,m=0;for(const v of h.lot.toNodes)v.lot.height_with_childs>m&&(m=v.lot.height_with_childs),g+=v.lot.width_with_childs+d;this.layoutOptions.changeNodeSizeDuringLayout&&(u=0),u=Math.max(p+r/2,u/2)+Math.max(m+r/2,u/2),h.lot.width_with_childs=f+Math.max(y,g)+d,h.lot.height_with_childs=u}else{let y=0,p=0;for(const v of h.lot.fromNodes)v.lot.width_with_childs>y&&(y=v.lot.width_with_childs),p+=v.lot.height_with_childs+d;let g=0,m=0;for(const v of h.lot.toNodes)v.lot.width_with_childs>g&&(g=v.lot.width_with_childs),m+=v.lot.height_with_childs+d;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),f=Math.max(y+r/2,f/2)+Math.max(g+r/2,f/2),h.lot.width_with_childs=f,h.lot.height_with_childs=u+Math.max(p,m)+d}}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 d=0;const c=e.filter(h=>h.lot.level===t);for(const h of c){d++;let f=h.lot.width;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),t===0&&(h.lot.groupStartX=h.lot.x+f/2-h.lot.width_with_childs/2);const u=h.lot.groupStartX,y=h.lot.y;let p=0,g=0;for(const v of h.lot.fromNodes)v.lot.width_with_childs>p&&(p=v.lot.width_with_childs);for(const v of h.lot.toNodes)v.lot.width_with_childs>g&&(g=v.lot.width_with_childs);const m=u+Math.max(p+a/2,f/2);if(h.lot.fromNodes.length>0){let v=h.lot.height+r;for(const x of h.lot.fromNodes)x.lot.groupStartX=m-x.lot.width_with_childs-a/2,x.lot.y=y+v+r,v+=x.lot.height_with_childs+r}if(h.lot.toNodes.length>0){let v=h.lot.height+r;for(const x of h.lot.toNodes)x.lot.groupStartX=m+a/2,x.lot.y=y+v+r,v+=x.lot.height_with_childs+r}p>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(h.lot.x=u,h.width=h.lot.width_with_childs):h.lot.x=m-h.lot.width/2:h.lot.x=u}d>0&&this.placeNodeChildrenV(e,t+1)}placeNodeChildrenH(e,t){const n=this.layoutOptions.treeNodeGapH,i=this.layoutOptions.treeNodeGapV,a=n,r=i;let d=0;const c=e.filter(h=>h.lot.level===t);for(const h of c){d++;let f=h.lot.height;this.layoutOptions.changeNodeSizeDuringLayout&&(f=0),t===0&&(h.lot.groupStartY=h.lot.y+f/2-h.lot.height_with_childs/2);const u=h.lot.groupStartY,y=h.lot.x;let p=0,g=0;for(const v of h.lot.fromNodes)v.lot.height_with_childs>p&&(p=v.lot.height_with_childs);for(const v of h.lot.toNodes)v.lot.height_with_childs>g&&(g=v.lot.height_with_childs);const m=u+Math.max(p+a/2,f/2);if(h.lot.fromNodes.length>0){let v=h.lot.width+r;for(const x of h.lot.fromNodes)x.lot.groupStartY=m-x.lot.height_with_childs-a/2,x.lot.x=y+v+r,v+=x.lot.width_with_childs+r}if(h.lot.toNodes.length>0){let v=h.lot.width+r;for(const x of h.lot.toNodes)x.lot.groupStartY=m+a/2,x.lot.x=y+v+r,v+=x.lot.width_with_childs+r}p>0||g>0?this.layoutOptions.changeNodeSizeDuringLayout?(h.lot.y=u,h.height=h.lot.height_with_childs):h.lot.y=m-h.lot.height/2:h.lot.y=u}d>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}}const as=ss;class rs extends is{constructor(){super();_(this,"_layoutTimer",null);_(this,"_layoutPromise",null);_(this,"_layoutResolve",null);_(this,"_layoutReject",null);_(this,"layoutor")}async doLayout(e){const t=Date.now()-this.prevAddNodeTimestamp;return t<300&&(this.dataProvider.updateOptions({canvasOpacity:.01}),this._dataUpdated(),await ze(300-t)),this._layoutPromise||(this._layoutPromise=new Promise((n,i)=>{this._layoutResolve=n,this._layoutReject=i})),clearTimeout(this._layoutTimer),this._layoutTimer=setTimeout(async()=>{var a,r;let n=!1,i;try{await this._doLayout(e)}catch(d){n=!0,i=d}finally{this.dataProvider.updateOptions({canvasOpacity:1}),this._dataUpdated(),n?(a=this._layoutReject)==null||a.call(this,i):(r=this._layoutResolve)==null||r.call(this),this._layoutResolve=null,this._layoutReject=null,this._layoutPromise=null}},50),this._layoutPromise}async _doLayout(e){this.updateNodesVisibleProperty();const t=this.getNodes();w("node size\uFF1A",t.length);let n=this.dataProvider.getRootNode();if(e&&(n=typeof e=="string"?this.getNodeById(e):e),n||(n=t[0],this._rgAsConnectArea||(w("[relation-graph]No root node, use first node as root:",n),w("[relation-graph]You can set rootNode call doLayout(rootNode | nodeId) with a node id"))),!n)throw new Error("custom rootNode not found, id:"+e);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(D.onForceLayoutFinish)}),await ze(100),w("doLayout:start force:",t.length),a.placeNodes(t,n);else{this.enableNodeXYAnimation();let r=[];n&&(r=this.getNetworkNodesByNode(n),a.placeNodes(r,n)),w("doLayout:placeOtherNodes:all:",t.length,"mainGroupNodes:",r.length),this.placeOtherNodes(r),setTimeout(()=>{this.disableNodeXYAnimation()},300),w("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)}),w("doLayout:allNodes:",r.length),w("doLayout:mainGroupNodes:",e.length),w("doLayout:notInMainGroupNodes:",i.length),w("doLayout:singleNodes:",a.length);const d=[{nodes:e}];this.placeNextNetwork(i,[...e],d),this.placeSingleNodes(a),d.push({nodes:a}),this.sortGroups(d),this._dataUpdated()}placeSingleNodes(e){if(e.length>0){const t=Math.ceil(Math.sqrt(e.length));Yt(t,30,e.map(i=>({width:i.el_W,height:i.el_H,node:i})),(i,a,r)=>{const d=i.node;d.x=a,d.y=r,d.lot||(d.lot={childs:[]})}),w("[placeSingleNodes]Single nodes:",e.length)}}sortGroups(e){w("[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;Yt(n,100,t,(a,r,d)=>{const c=r-a.orignX,h=d-a.orignY;w(`[placeNextNetwork]Move ${a.nodes.length} Nodes :`,c,h,a," > ");for(const f of a.nodes)this.updateNodePosition(f,f.x+c,f.y+h)},t[0].orignX,t[0].orignY)}placeNextNetwork(e,t,n){if(e.length>0){const i=this.getOptions();w("[placeNextNetwork]notPlacedNodes nodes:",e.length);const a=JSON.parse(JSON.stringify(i.layout)),r=e[0],d=this.createLayout(a);if(d.isMainLayouer=!1,w("[placeNextNetwork]layoutName:",d.layoutOptions.layoutName,"root:",r.text),d.layoutOptions.layoutName==="force"){const f=d;f.maxLayoutTimes=0}r.fixed?w("[placeNextNetwork]fixed root x,y:",r.x,r.y,r.text):(this.updateNodePosition(r,0,0),w("[placeNextNetwork]set root x,y:",r.x,r.y,r.text)),d.layoutOptions.fixedRootNode=!0;const c=this.getNetworkNodesByNode(r);w("[placeNextNetwork]thisNetworkNodes:",e.length),d.placeNodes(c,r),t.push(...c),n.push({nodes:c});const h=[];e.forEach(f=>{t.includes(f)||h.push(f)}),i.placeOtherGroup&&this.placeNextNetwork(h,t,n),this._dataUpdated()}else w("[placeOtherGroup]thisGroupNodes:all is OK!")}toggleAutoLayout(){const e=this.getOptions();w("toggleAutoLayout:to:",e.layout.autoLayouting),e.layout.autoLayouting?this.stopAutoLayout():this.startAutoLayout()}startAutoLayout(){var e;(e=this.layoutor)!=null&&e.start&&(w("Start force layout:"+this.layoutor.instanceId),this.layoutor.start())}stopAutoLayout(){var e;(e=this.layoutor)!=null&&e.stop&&(w("Stop force layout:"+this.layoutor.instanceId),this.layoutor.stop())}createLayout(e,t=!1){w("########createLayout:",e);const n=this.getOptions();on(e);let i=null;if(e.layoutName==="tree"?i=new Wt(e,n,this):e.layoutName==="center"?i=new Ut(e,n,this):e.layoutName==="circle"?i=new jt(e,n,this):e.layoutName==="force"?i=new Ee(e,n,this):e.layoutName==="fixed"?i=new Jt(e,n,this):e.layoutName==="smart-tree"?i=new Ni(e,n,this):e.layoutName==="io-tree"?i=new as(e,n,this):e.layoutName==="folder"&&(i=new qt(e,n,this)),!i)throw new Error("unknown layout: "+e.layoutName);return w("########supportAutoLayout:",i.autoLayout!==void 0,e.disableAsForceLayout),this.setLayoutor(i,t,i.autoLayout!==void 0&&e.disableAsForceLayout!==!0),i}setLayoutor(e,t,n=!1){e.isMainLayouer=t,e.layoutOptions.fixedRootNode=!0,t&&(this.layoutor=e,this._updateOptions({layout:{supportAutoLayout:n}}))}}const ls=async(s,o)=>{const e=s||document.documentElement;o?await ds(e):await cs()},ds=async s=>{s.requestFullscreen?await s.requestFullscreen():s.mozRequestFullScreen?await s.mozRequestFullScreen():s.webkitRequestFullscreen?await s.webkitRequestFullscreen():s.msRequestFullscreen&&await s.msRequestFullscreen()},cs=async()=>{document.exitFullscreen?await document.exitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.msExitFullscreen&&await document.msExitFullscreen()};class hs extends rs{constructor(){super();_(this,"_prevClickNodeTime",0);_(this,"_nodeXYMappingBeforeDrag",{});_(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 d=a!==0||r!==0;d&&(a=Math.max(Math.min(a/5,30),-30),r=Math.max(Math.min(r/5,30),-30));const c=t.canvasOffset.x+a,h=t.canvasOffset.y+r;return this.onCanvasDragging(c,h,a,r),d});_(this,"_canvasMovingTimer");_(this,"_relayoutTaskTimer");_(this,"_onMovingWhenCreatingLine");_(this,"_step1EventTime",0);_(this,"_onCreateLineCallback");_(this,"_mouseWheelTimer");_(this,"_mouseWheelEventPrevApplyTime",0);_(this,"_mouseWheelForce",{x:0,y:0});_(this,"_fullscreenchangeHandler")}draggingSelectedNodes(e,t,n,i,a){}onNodeClick(e,t){if("button"in t&&t.button===2)return;if(Date.now()-this._prevClickNodeTime<200){w("[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;w("[node]node click",e.text,n.creatingLinePlot,i),!t.shiftKey&&!i&&(n.checkedLineId="",this.dataProvider.updateOptions({checkedLineId:"",checkedNodeId:e.id})),this.emitEvent(D.onNodeClick,e,t),this._prevClickNodeTime=Date.now()}onNodeDragStart(e,t){var p;if(!e||xe(t))return;const n=this.getOptions();if((e.disableDrag||n.disableDragNode)&&!((p=this.getEventTargetElement(t))==null?void 0:p.closest(".rg-node-drag-handler"))){const m=v=>{this.onNodeClick(e,v),document.body.removeEventListener("mouseup",m)};document.body.addEventListener("mouseup",m);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=(g,m,v)=>{v.stopPropagation(),a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.dataProvider.updateOptions({draggingNodeId:"",editingReferenceLine:{...n.editingReferenceLine,show:!1}}),this._onNodeDragEnd(e,g,m,v),h?this.emitEvent(D.onNodeDragEnd,e,v,g,m):this.onNodeClick(e,t),this._dataUpdated()};this._nodeXYMappingBeforeDrag={},this._nodeXYMappingBeforeDrag[e.id]={x:e.x,y:e.y};for(const g of n.editingController.nodes)this._nodeXYMappingBeforeDrag[g.id]={x:g.x,y:g.y};const d=this.getCanvasXyByViewXy(this.getViewXyByEvent(t)),c={x:e.x,y:e.y};let h=!1;this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer);let f;const u=()=>{if(!f||a)return;const g=this.getViewXyByEvent(f),m=this.getCanvasXyByViewXy(g),v=m.x-d.x,x=m.y-d.y;let L=v+c.x,P=x+c.y,E=L-c.x,T=P-c.y;const N=this.emitEvent(D.onNodeDragging,e,L,P,E,T,f);N&&(typeof N.x=="number"&&(L=N.x,E=L-c.x),typeof N.y=="number"&&(P=N.y,T=P-c.y)),this.canvasAutoMoving(g),this.draggingSelectedNodes(e,L,P,E,T),this._dataUpdated()},y=()=>{u(),this._canvasMovingTimer=requestAnimationFrame(y)};he.startDrag(t,c,r,(g,m,v,x,L)=>{h?f=L:Math.abs(g)+Math.abs(m)>4&&(w("[node]onNodeDragStart...",fe(L),L),this.emitEvent(D.onNodeDragStart,e,L),h=!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){if("button"in t&&t.button===2)return;const n=this.getLinkByLineId(e.id);w("onLineClick:","line:",e,"link:",n);const i=this.getOptions();(e.disablePointEvent===void 0?i.disableLinePointEvent:e.disablePointEvent)||(this.setCheckedNode(""),this.setCheckedLine(e)),this.emitEvent(D.onLineClick,e,n,t),this._dataUpdated()}expandOrCollapseNode(e,t){t.stopPropagation(),e.expanded===!1?this.expandNode(e,t):this.collapseNode(e,t)}expandNode(e,t){w("onNodeExpand:",e),this.dataProvider.updateNode(e.id,{expanded:!0}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(D.onNodeExpand,e,t)}collapseNode(e,t){w("onNodeCollapse:",e),this.dataProvider.updateNode(e.id,{expanded:!1}),this._effectWhenExpandedOrCollapsed(e),this.emitEvent(D.onNodeCollapse,e,t)}_effectWhenExpandedOrCollapsed(e){const t=this.getDescendantNodes(e);this.updateNodesVisibleProperty([e].concat(t)),this._relayoutTaskTimer&&clearTimeout(this._relayoutTaskTimer),this._relayoutTaskTimer=setTimeout(()=>{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(D.onCanvasDragEnd,e)}onCanvasClick(e){if("button"in e&&e.button===2)return;if(this.getOptions().creatingLinePlot)this.onCanvasClickWhenCreatingLinePlot(e);else{if(this.dataProvider.isPerformanceMode()){const n=this.getNodeAtEvent(e);if(n){this.emitEvent(D.onNodeClick,n,e);return}}this.emitEvent(D.onCanvasClick,e)}}getNodeAtEvent(e){const t=ce(e),n=this.getCanvasXyByClientXy({x:t.clientX,y:t.clientY});return this.dataProvider.findNodeByXy(n)}onCanvasSelectionEnd(e,t){this.emitEvent(D.onCanvasSelectionEnd,e,t),w("[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=Ne(JSON.parse(JSON.stringify(Fe)),this.getOptions()),i=fe(e);this.dataProvider.updateOptions({newNodeTemplate:Object.assign({},n,t.templateNode),creatingNodePlot:!0,showTemplateNode:!i});let a=(m,v)=>{const x=this.getOptions().newNodeTemplate,L={width:x.width||50,height:x.height||50};this.dataProvider.updateOptions({newNodeTemplate:{...x,x:m-L.width/2,y:v-L.height/2}}),this._dataUpdated()};const r=this.getViewBoundingClientRect();w("[CreatingNodePlot]startCreatingNodePlot:");const d=ce(e),c=d.clientX-r.x+10,h=d.clientY-r.y+10;i||a(c,h);const f=m=>{w("[CreatingNodePlot]objectTemplateMove");const v=this.getViewXyByEvent(m);t.templateMove&&t.templateMove(v.x,v.y),a(v.x,v.y)},u=m=>{w("[CreatingNodePlot]user abort!"),g(),this.dataProvider.updateOptions({creatingNodePlot:!1})},y=Date.now(),p=m=>{if(Date.now()-y<300){window.removeEventListener("mouseup",p),window.addEventListener("click",p);return}let v=!1;if(this.getOptions().creatingNodePlot||(v=!0),g(),this.dataProvider.updateOptions({creatingNodePlot:!1}),v){w("[CreatingNodePlot]action be abort!");return}const x=ce(m),L=x.clientX-r.x+10,P=x.clientY-r.y+10;if(Math.abs(c-L)<30&&Math.abs(h-P)<30){w("[CreatingNodePlot]create node be abort!");return}const E=this.getCanvasXyByClientXy({x:x.clientX,y:x.clientY});w("[CreatingNodePlot]objectBePlaced:",E),t.onCreateNode(E.x,E.y,this.getOptions().newNodeTemplate),this._dataUpdated()},g=()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",p),window.removeEventListener("click",p),window.removeEventListener("contextmenu",u,{capture:!0})};i?window.addEventListener("click",p):(window.addEventListener("mousemove",f),window.addEventListener("mouseup",p),window.addEventListener("contextmenu",u,{capture:!0}))}startCreatingLinePlot(e,t){const n=fe(e);t&&t.onCreateLine&&(this._onCreateLineCallback=t.onCreateLine);const i=ue({id:"newRelationTemplate",from:"newRelationTemplate-from",to:"newRelationTemplate-to",color:"",text:""},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:I.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}),w("[CreatingLinePlot]startCreatingLinePlot:isTouchEvent:",n),n||(w("[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(){w("[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){w("[CreatingLinePlot]mousemove");const t=this.getCanvasXyByClientXy({x:e.clientX,y:e.clientY}),n=this.getOptions(),i=this.getEventTargetElement(e);if(!i)return;const a=i.dataset;let r="",d=I.Node;const c=this.isNode(i);let h=!1,f={x:0,y:0,el_W:5,el_H:5,nodeShape:0};c&&(r=c.id,c===this.getOptions().newLinkTemplate.fromNode?this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,show:!1}}):(this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:c,show:!0}}),this._updateEditingConnectControllerView()));const u=this.resolveTargetDescriptorByElement(i),y=u?null:i.closest(".rg-connect-ctl-handler");if(u||y){let p=this.getOptions().nodeConnectController.node;w("[CreatingLinePlot]content point:",(u==null?void 0:u.junctionPoint)||(y==null?void 0:y.dataset.point));let g=(u==null?void 0:u.junctionPoint)||(y==null?void 0:y.dataset.point)||Y.border;if(u){const m=this.resolveTargetRect(u.targetType,u.targetId,n.newLineTemplate,{preferLiveTarget:!0,connectTargetEl:u.measureEl});m&&(h=!0,f.x=m.x,f.y=m.y,f.el_W=m.el_W,f.el_H=m.el_H,f.nodeShape=m.nodeShape,this.dataProvider.updateOptions({nodeConnectController:{...this.getOptions().nodeConnectController,node:m,show:!1}}),g=m.junctionPoint||g,n.newLinkTemplate.toNode&&(r=u.targetId,d=m.targetType||u.targetType,this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,nodeShape:m.nodeShape}}})),this._updateEditingConnectControllerView())}else p&&(d=I.Node,h=!0,f.x=p.x,f.y=p.y,f.el_W=p.el_W,f.el_H=p.el_H,f.nodeShape=p.nodeShape,a.innode==="true"&&(f.x=t.x,f.y=t.y,f.el_W=2,f.el_H=2,f.nodeShape=1));n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:g}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:g}})}else w("[CreatingLinePlot]point:",a.point),n.newLineTemplate.isReverse?this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:Y.border}}):this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,toJunctionPoint:Y.border}}),n.newLinkTemplate.toNode&&(d=I.Node);n.newLinkTemplate.toNode&&(r&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,id:r}}}),this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,targetType:d}}})),n.newLinkTemplate.fromNode&&this.dataProvider.updateOptions({newLinkTemplate:{...this.getOptions().newLinkTemplate,toNode:{...this.getOptions().newLinkTemplate.toNode,x:h?f.x:t.x,y:h?f.y:t.y,el_W:f.el_W,el_H:f.el_H,nodeShape:f.nodeShape}}}),this._dataUpdated()}onCanvasClickWhenCreatingLinePlot(e){if(Date.now()-this._step1EventTime<500){w("[CreatingLinePlot]step1EventTime:",this._step1EventTime);return}const t=this.getOptions();if(!t.newLinkTemplate.fromNode){w("[CreatingLinePlot]CreatingLinePlot:fromNode not set!");return}let n=!1;if(!t.newLinkTemplate.toNodeObject){w("[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?(w("[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()):(w("[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){w("[CreatingLinePlot][fire-event]onCreateLine:",e,t);const n=this.getOptions(),i=ue(n.newLineTemplate,this.getOptions()),a=c=>c&&"id"in c&&c.id||"";n.newLineTemplate.isReverse?(i.from=a(t),i.to=a(e),i.isReverse=void 0,[e,t]=[t,e]):(i.from=a(e),i.to=a(t)),i.disablePointEvent=!1;const r=this.emitEvent(D.beforeCreateLine,{lineJson:i,fromNode:e,toNode:t});if(w("[CreatingLinePlot]onCreateLine:abort-flag:",r),r===!0){w("[CreatingLinePlot]onCreateLine:abort!");return}if(this._onCreateLineCallback){w("[CreatingLinePlot]onCreateLine:callback");try{this._onCreateLineCallback(e,t,i)}catch(c){return console.warn("[Custom Reject Connect By Throw Error:",c),!1}}return w("[CreatingLinePlot]onCreateLine:emitEvent"),this.emitEvent(D.onLineBeCreated,{lineJson:i,fromNode:e,toNode:t})}onContextmenu(e){e.stopPropagation(),e.preventDefault(),this.stopCreatingLinePlot();let t="canvas";const n=this.getEventTargetElement(e);let i=this.isNode(n);i?t="node":(i=this.isLine(n),i&&(t="line")),w("contextmenu:objectType",t,i);const a=ce(e),r=this.getCanvasXyByClientXy({x:a.clientX,y:a.clientY}),d=this.getViewXyByCanvasXy(r);this.emitEvent(D.onContextmenu,e,t,i,r,d)}async fullscreen(e){const t=this.getOptions();if(e!==void 0&&e===t.fullscreen)return;w("fullscreen:newValue:",e),e===void 0&&(e=!t.fullscreen);let n=this.$dom;w("options.fullscreenElementXPath:",t.fullscreenElementXPath),t.fullscreenElementXPath&&(n=document.querySelector(t.fullscreenElementXPath)||this.$dom),await ls(n,e),this.dataProvider.updateOptions({fullscreen:e}),this.emitEvent(D.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 d=t/r,c=n/r;r>200&&(r=200);const h=a.mouseWheelSpeed/10*-d*r,f=a.mouseWheelSpeed/10*-c*r,u=this.emitEvent(D.beforeScrollStart,h,f,e);if(w("[scroll]","abortScroll:",u),u===!0)return;this.scrollView(h,f)}else if(!(!i&&a.wheelEventAction==="none")){const r={x:e.clientX,y:e.clientY};let d=a.mouseWheelSpeed/20*-n;d=Math.max(Math.min(d,20),-20),this.zoom(d,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){w("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=(d,c,h,f,u)=>{const y=this.dataProvider.getCanvasScale();n.fromNode.x=i.x+d/y,n.fromNode.y=i.y+c/y,n.toNode.x=a.x+d/y,n.toNode.y=a.y+c/y,this._updateEditingControllerView(),this._dataUpdated()};he.startDrag(t,{x:0,y:0},(...d)=>{this.onLineDragEnd(...d)},r)}onLineDragEnd(e,t,n){w("onLineDragEnd"),this.updateElementLines()}onCanvasDragStart(e){var n;if(xe(e)||(n=this.getEventTargetElement(e))!=null&&n.closest(".rg-line-peel"))return;const t=this.getOptions();if(this.dataProvider.isPerformanceMode()&&t.editingController.nodes.length>0){const i=this.getNodeAtEvent(e);if(i){this.onNodeDragStart(i,e);return}}if(t.dragEventAction==="none"){this.onCanvasClick(e);return}if(t.dragEventAction==="selection"||e.shiftKey){this.startCreateSelection(e);return}if(!t.disableDragLine){const i=this.isLine(this.getEventTargetElement(e));if(i){this.onLineDragStart(i,e);return}}this.startMoveCanvas(e)}startMoveCanvas(e,t=!1){let n;if(fe(e)){let f,u,y,p,g,m=0,v=100;const x=b=>{if("touches"in b&&b.touches.length>0)return b.touches;if("targetTouches"in b&&b.targetTouches.length>0)return b.targetTouches},L=b=>({x:b.clientX,y:b.clientY}),P=(b,k)=>Math.hypot(k.x-b.x,k.y-b.y),E=(b,k)=>({x:(b.x+k.x)/2,y:(b.y+k.y)/2}),T=(b,k)=>{if(f="pan",k)u={x:k.touch.x,y:k.touch.y},y={x:k.offset.x,y:k.offset.y};else{u=L(b);const O=this.getOptions();y={x:O.canvasOffset.x,y:O.canvasOffset.y}}},N=(b,k)=>{f="pinch";const O=L(b),S=L(k),R=this.getOptions();m=P(O,S),v=R.canvasZoom,g={x:R.canvasOffset.x,y:R.canvasOffset.y},p=this.getViewXyByClientXy(E(O,S))};n=(b,k,O,S,R)=>{const C=x(R);if(!(!C||C.length===0))if(R.cancelable&&R.preventDefault(),C.length>1){const M=C[0],B=C[1];f!=="pinch"&&N(M,B);const X=L(M),A=L(B),F=P(X,A);if(!p||!g||m<=0||F<=0){N(M,B);return}const H=this.getViewXyByClientXy(E(X,A)),j=F-m,se=H.x-p.x,ne=H.y-p.y;if(Math.abs(j)<6&&Math.abs(se)<2&&Math.abs(ne)<2)return;const oe=F/m,ee=Math.pow(oe,.85),K=v*ee,ie=v/100,Z=this.getClampedZoom(K)/100,G=H.x-(p.x-g.x)*(Z/ie),Za=H.y-(p.y-g.y)*(Z/ie);this.setZoomAndOffset(K,{x:G,y:Za})}else{const M=C[0];if(f!=="pan"&&T(M,f===void 0?{touch:S,offset:O}:void 0),!u||!y){T(M);return}const B=L(M),X=B.x-u.x,A=B.y-u.y,F=y.x+X,H=y.y+A;this.onCanvasDragging(F,H,X,A),this._updateEditingControllerView(),this._dataUpdated()}}}else n=(d,c,h,f,u)=>{const y=h.x+d,p=h.y+c;this.onCanvasDragging(y,p,d,c),this._updateEditingControllerView(),this._dataUpdated()};const i=this.getOptions(),a={x:i.canvasOffset.x,y:i.canvasOffset.y};let r=t;he.startDrag(e,a,(d,c,h)=>{this.onCanvasDragStop(d,c,h)},(d,c,h,f,u)=>{const y="touches"in u&&u.touches?u.touches.length:0;r||(y>1||Math.abs(d)+Math.abs(c)>4)&&(this.emitEvent(D.onCanvasDragStart,h,f,u),r=!0),r&&n(d,c,h,f,u)})}onCanvasDragging(e,t,n,i){const a=this.emitEvent(D.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){w("[canvas]onDragEnd as click2"),this._dataUpdated(),this.onCanvasClick(n);return}else w("[canvas]onDragEnd"),this.onCanvasDragEnd(n)}startCreateSelection(e){const t=()=>{if(!n||a)return;const h=this.getViewXyByEvent(n);this.canvasAutoMoving(h)&&this._updateEditingControllerView();const u=this.getViewXyByCanvasXy(r),y=h.x-u.x,p=h.y-u.y;y<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:u.x+y,width:Math.abs(y)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,x:u.x,width:Math.abs(y)}}),p<0?this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:u.y+p,height:Math.abs(p)}}):this.dataProvider.updateOptions({selectionView:{...this.getOptions().selectionView,y:u.y,height:p}}),this._dataUpdated()};let n,i=!1,a=!0;const r=this.getCanvasXyByViewXy(this.getViewXyByEvent(e)),d=()=>{t(),this._canvasMovingTimer=requestAnimationFrame(d)},c=(h,f,u,y,p)=>{if(n=p,i)n=p;else if(Math.abs(h)+Math.abs(f)>6){i=!0,a=!1;const g=this.getOptions();this.dataProvider.updateOptions({creatingSelection:!0,selectionView:{...g.selectionView,width:5,height:5}}),this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this._canvasMovingTimer=requestAnimationFrame(d)}this._dataUpdated()};he.startDrag(e,{x:0,y:0},(...h)=>{a=!0,this._canvasMovingTimer&&cancelAnimationFrame(this._canvasMovingTimer),this.onCanvasDragStop(...h)},c)}addFullscreenListener(){this._fullscreenchangeHandler=()=>{let e=!1;document.fullscreenElement?(w("div entered fullscreen mode",document.fullscreenElement),this.$dom===document.fullscreenElement&&(w("relation-graph is fullscreen!"),e=!0)):w("div exited fullscreen mode"),e!==this.getOptions().fullscreen&&(this.dataProvider.updateOptions({fullscreen:e}),this._dataUpdated(),setTimeout(async()=>{this.resetViewSize(),this._moveToCenter(),this.zoomToFit(),w("relation-graph reset complete!")},500))},document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}removeFullscreenListener(){document.addEventListener("fullscreenchange",this._fullscreenchangeHandler)}defaultLineConnectEndHandler(e,t,n){w("defaultLineConnectEndHandler:",e,t,n)}defaultLineVertexBeChangedHandler(e,t,n){w("defaultLineVertexBeChangedHandler:",n==null?void 0:n.isReverse)}async sleep(e){await ze(e)}forceLayoutTickCallback(){this._updateEditingControllerView(),this.dataProvider.updateShouldRenderGraphData(),this._dataUpdated()}}class fs extends hs{constructor(){super();_(this,"$easyViewCanvas");_(this,"$rgWebglPainter");_(this,"_updateEasyViewRequested",!1);_(this,"_easyViewOffset",{x:0,y:0})}setEasyViewCanvas(e){this.$easyViewCanvas=e,this.$rgWebglPainter=new ui(e)}updateMiniView(){}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);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=Ce(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,d=e.borderColor||"#666666";this.$rgWebglPainter.evDrawNode4Rect(e.x,e.y,t,n,a,i,r,d)}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);if(!n)return;const i=t.opacity||1,a=this.getOptions(),r=t.color||a.defaultLineColor||"#888888",d=t.lineWidth||a.defaultLineWidth||1;this.$rgWebglPainter.evDrawLine(n.pathData,d,r,i)}}class us extends fs{constructor(){super();_(this,"_onResizing");_(this,"_onResizeEnd");_(this,"_startPoint",{x:0,y:0});_(this,"_startEventCanvasXy",{x:0,y:0});_(this,"_startSizeCanvasXy",{x:0,y:0});_(this,"_startSize",{x:0,y:0,width:0,height:0,widthOnCanvas:0,heightOnCanvas:0});_(this,"_resizeType","l");_(this,"_nodeStartSizeMap",new WeakMap);_(this,"resizeMinLimit",{width:10,height:10});_(this,"_resizeDraggingTimer");_(this,"_resizeDraggingEvent");_(this,"_resizeDraggingStoped",!0);_(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,d=this.dataProvider.getCanvasScale();let c=i-t,h=a-n;if(c<0&&(c=0),h<0&&(h=0),c>0&&h>0){const f=this.getViewXyByCanvasXy({x:t,y:n}),u=f.x-r*d,y=f.y-r*d,p=c*d+r*2*d,g=h*d+r*2*d;this.dataProvider.updateOptions({editingController:{...e.editingController,x:u,y,width:p,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 d of n.editingController.nodes)this._nodeStartSizeMap.set(d,{x:d.x,y:d.y,width:d.el_W,height:d.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(D.onResizeStart,n.editingController.nodes,t)}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 d=r.editingController.width,c=r.editingController.height,h=r.editingController.x,f=r.editingController.y;const u=this.dataProvider.getCanvasScale();this._resizeType==="tl"?(h=t.x+i,f=t.y+a,d=this._startSize.widthOnCanvas*u-i,c=this._startSize.heightOnCanvas*u-a):this._resizeType==="tr"?(f=t.y+a,h=n.x,d=this._startSize.widthOnCanvas*u+i,c=this._startSize.heightOnCanvas*u-a):this._resizeType==="bl"?(h=t.x+i,f=n.y,d=this._startSize.widthOnCanvas*u-i,c=this._startSize.heightOnCanvas*u+a):this._resizeType==="br"?(h=n.x,f=n.y,d=this._startSize.widthOnCanvas*u+i,c=this._startSize.heightOnCanvas*u+a):this._resizeType==="t"?(f=t.y+a,c=this._startSize.heightOnCanvas*u-a):this._resizeType==="r"?(h=n.x,d=this._startSize.widthOnCanvas*u+i):this._resizeType==="b"?(c=this._startSize.heightOnCanvas*u+a,f=n.y):this._resizeType==="l"&&(h=t.x+i,d=this._startSize.widthOnCanvas*u-i),d<this.resizeMinLimit.width&&(d=this.resizeMinLimit.width),c<this.resizeMinLimit.width&&(c=this.resizeMinLimit.height),this.dataProvider.updateOptions({editingController:{...r.editingController,x:h,y:f,width:d,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,d=this.getCanvasXyByViewXy({x:t.editingController.x,y:t.editingController.y});let c=!0,h=!0;this._resizeType==="t"||this._resizeType==="b"?c=!1:(this._resizeType==="r"||this._resizeType==="l")&&(h=!1);for(const f of t.editingController.nodes){const u=this._nodeStartSizeMap.get(f),y=u.width*i,p=u.height*a,g=d.x+i*(u.x-r.x),m=d.y+a*(u.y-r.y),v=y,x=p;this.emitEvent(D.beforeNodeResize,f,g,m,v,x)===!1||(c&&this.dataProvider.updateNode(f.id,{x:g,width:v,el_W:v}),h&&this.dataProvider.updateNode(f.id,{y:m,height:x,el_H:x}))}}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,w("onResizeEnd:",this.getOptions().editingController.nodes,n,i),this.emitEvent(D.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:h,showH:f,fixedY:u}=r;c&&(i+=h-t,t=h),f&&(a+=u-n,n=u)}const d=this.getOptions();if(!d.editingController.nodes.includes(e))this.dataProvider.updateNode(e.id,{x:t,y:n}),this._updateEditingLineView();else{for(const c of d.editingController.nodes){const h=this._nodeXYMappingBeforeDrag[c.id];h&&this.dataProvider.updateNode(c.id,{x:h.x+i,y:h.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,d=0,c=this.dataProvider.getCanvasScale(),h=n,f=i,u=a-n,y=r-i,p=this.getViewXyByCanvasXy({x:h,y:f});this.dataProvider.updateOptions({nodeConnectController:{...e.nodeConnectController,x:p.x-d*c,y:p.y-d*c,width:u*c+d*2*c,height:y*c+d*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 R=Math.abs(i),C=Math.abs(a);R+C>2&&this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,show:!0}})}if(!r.editingReferenceLine.show)return;const d=t,c=e.el_W,h=e.el_H,f=t+c/2,u=t+c,y=n,p=n+h/2,g=n+h,m=this.getViewXyByCanvasXy({x:f,y:p});let v=!1,x=!1,L=0,P=0;const E=this.getNodes().filter(R=>this._nodeXYMappingBeforeDrag[R.id]?!1:Math.abs(R.x-f)<600&&Math.abs(R.y-p)<600);E.sort((R,C)=>{const M=we(f,p,R.x+R.el_W/2,R.y+R.el_H/2),B=we(f,p,C.x+C.el_W/2,C.y+C.el_H/2);return M<B?-1:1});let{v_x:T,v_y:N,v_height:b,h_x:k,h_y:O,h_width:S}=r.editingReferenceLine;for(const R of E){const C=R.x,M=R.el_W,B=R.el_H,X=R.x+M/2,A=R.x+M,F=R.y,H=R.y+B/2,j=R.y+B,se=Math.abs(d-C),ne=Math.abs(f-X),oe=Math.abs(u-A),ee=Math.abs(y-F),K=Math.abs(p-H),ie=Math.abs(g-j),Z=5;if(ne<800&&K<800){if(!x&&ne<Z){const G=this.getViewXyByCanvasXy({x:X,y:H});T=G.x,N=m.y>G.y?G.y:m.y,b=Math.round(Math.abs(m.y-G.y)),x=!0,L=X-c/2}if(!x&&se<Z){const G=this.getViewXyByCanvasXy({x:C,y:H});T=G.x,N=m.y>G.y?G.y:m.y,b=Math.round(Math.abs(m.y-G.y)),x=!0,L=C}if(!x&&oe<Z){const G=this.getViewXyByCanvasXy({x:A,y:H});T=G.x,N=m.y>G.y?G.y:m.y,b=Math.round(Math.abs(m.y-G.y)),x=!0,L=A-c}if(!v&&K<Z){const G=this.getViewXyByCanvasXy({x:X,y:H});O=G.y,k=m.x>G.x?G.x:m.x,S=Math.round(Math.abs(m.x-G.x)),v=!0,P=H-h/2}if(!v&&ee<Z){const G=this.getViewXyByCanvasXy({x:X,y:F});O=G.y,k=m.x>G.x?G.x:m.x,S=Math.round(Math.abs(m.x-G.x)),v=!0,P=F}if(!v&&ie<Z){const G=this.getViewXyByCanvasXy({x:X,y:j});O=G.y,k=m.x>G.x?G.x:m.x,S=Math.abs(m.x-G.x),v=!0,P=j-h}if(v&&x)break}}if(this.dataProvider.updateOptions({editingReferenceLine:{...r.editingReferenceLine,v_x:T,v_y:N,v_height:b,h_x:k,h_y:O,h_width:S,directionH:v,directionV:x}}),r.referenceLineAdsorption)return{showV:x,fixedX:L,showH:v,fixedY:P}}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 d=this.createLineDrawInfo(n,t);if(!d){this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,show:!1}});return}if(t.lineShape===W.StandardOrthogonal){let{textPosition:P,pathData:E,points:T,startDirection:N,endDirection:b}=d;r=P,i=T[0],a=T[T.length-1];const k=[];for(let O=0;O<T.length-1;O++){const S=T[O],R=T[O+1],C={pIndex:O,optionName:"cp-"+O,x:0,y:0,direction:"v",startDirection:N,endDirection:b};S.x!==R.x&&(C.direction="h");const M=this.getViewXyByCanvasXy({x:(S.x+R.x)/2,y:(S.y+R.y)/2});C.x=M.x,C.y=M.y,k.push(C)}if(k.length!==1){if(k.length!==2)if(k.length===3){const O=T[0],S=T[1],R=T[3];if(k[1].direction==="v"){const C=O.x,M=S.x,B=R.x;if(Math.max(C,M,B)!==M&&Math.min(C,M,B)!==M)k[1].optionName="cx";else{const A=Math.abs(M-C),F=Math.abs(M-B);A>=F?k[1].optionName="td":A<F&&(k[1].optionName="fd")}}else{const C=O.y,M=S.y,B=R.y;if(Math.max(C,M,B)!==M&&Math.min(C,M,B)!==M)k[1].optionName="cy";else{const A=Math.abs(M-C),F=Math.abs(M-B);A>=F?k[1].optionName="td":A<F&&(k[1].optionName="fd")}}}else k.length===4?(k[1].optionName="fd",k[2].optionName="td"):k.length===5&&(k[1].optionName="fd",k[2].direction==="v"?k[2].optionName="cx":k[2].optionName="cy",k[3].optionName="td")}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:k,line49Points:T}})}else if(t.lineShape===W.HardOrthogonal){let{textPosition:P,pathData:E,points:T,startDirection:N,endDirection:b}=d;r=P;const k=[];T=t.ctrlPointsFor49,i=T[0],a=T[T.length-1];const O=T;for(let S=0;S<O.length-1;S++){const R=O[S],C=O[S+1],M={pIndex:S,optionName:"cp-"+S,x:0,y:0,direction:"v",startDirection:N,endDirection:b};R.x!==C.x?(M.direction="h",Math.abs(R.x-C.x)<15&&(M.hide=!0)):Math.abs(R.y-C.y)<15&&(M.hide=!0);const B=this.getViewXyByCanvasXy({x:(R.x+C.x)/2,y:(R.y+C.y)/2});M.x=B.x,M.y=B.y,k.push(M)}for(let S=0;S<k.length;S++){const R=k[S-1],C=k[S],M=k[S+1];S===0&&C.direction===M.direction&&(C.hide=!0),S===k.length-1&&C.direction===R.direction&&(C.hide=!0)}this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,line44Splits:k,line49Points:O}})}else if(t.lineShape!==1){r=d.textPosition;const P=Zt(d.pathData);let E,T;t.isReverse?(i=P.endPoint,a=P.startPoint,E=this.getViewXyByCanvasXy(P.ctrl1),T=this.getViewXyByCanvasXy(P.ctrl2)):(i=P.startPoint,a=P.endPoint,E=this.getViewXyByCanvasXy(P.ctrl1),T=this.getViewXyByCanvasXy(P.ctrl2)),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,ctrlPoint1:E,ctrlPoint2:T}})}else{r=d.textPosition;const P=d.pathData,E=Zt(P);i=E.startPoint,a=E.endPoint}const c=this.getViewXyByCanvasXy(t.isReverse?a:i),h=this.getViewXyByCanvasXy(t.isReverse?i:a);this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,startPoint:c,endPoint:h}});const f=this.getViewXyByCanvasXy(r),u=this.$canvasDom.querySelector(`g[data-id='${t.id}']`);let y=0,p=0,g=t.textOffsetX||0,m=t.textOffsetY||0;const v=this.dataProvider.getCanvasScale();let x=20,L=20;if(u){const P=u.querySelector("text.rg-line-text");if(P){g=Math.floor(parseFloat(P.getAttribute("x")||"0")),m=Math.floor(parseFloat(P.getAttribute("y")||"0"));const E=P.clientWidth,T=P.clientHeight;x=E,L=T}}x+=40,L+=10,x>120&&(x=120),L>20&&(L=20),this.dataProvider.updateOptions({editingLineController:{...this.getOptions().editingLineController,text:{...this.getOptions().editingLineController.text,width:x,height:L,x:f.x+y+g*v,y:f.y+p+m*v}}})}startMoveLineVertex(e,t,n){t.stopPropagation();const i=this.getOptions().editingLineController.line,a=this.getLinkByLine(i);let r,d;if(a)r=a.fromNode,d=a.toNode;else{const f=this.generateFakeLineConfig(i);if(!f){console.warn("[startDragLine]Can not resolve fake line targets:",i);return}const{from:u,to:y}=f;r=u,d=y}let c=r;this.dataProvider.setEditingLine(null),a?this.removeLine(i):this.removeFakeLine(i);let h=!1;i.lineShape===W.HardOrthogonal&&(i.lineShape=W.StandardOrthogonal),e==="start"?(i.fromJunctionPointOffsetX=0,i.fromJunctionPointOffsetY=0,c=d,h=!0):(i.toJunctionPointOffsetX=0,i.toJunctionPointOffsetY=0),this.startCreatingLinePlot(t,{template:i,fromNode:c,isReverse:h,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 d=this.getOptions().editingController.nodes;d.length===1&&(e=d[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.resolveTargetRect(a.fromType,a.from,a,{preferLiveTarget:!0});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;const r=a.nodeConnectController.node;let{toJunctionPoint:d,toJunctionPointOffsetX:c,toJunctionPointOffsetY:h,fromJunctionPoint:f,fromJunctionPointOffsetX:u,fromJunctionPointOffsetY:y}=a.newLineTemplate;if(!a.newLinkTemplate.fromNode)a.newLineTemplate.isReverse?(d=e,c=n.x,h=n.y):(f=e,u=n.x,y=n.y),this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:f,fromJunctionPointOffsetX:u,fromJunctionPointOffsetY:y,toJunctionPoint:d,toJunctionPointOffsetX:c,toJunctionPointOffsetY:h},newLinkTemplate:{...this.getOptions().newLinkTemplate,fromNode:r}});else{a.newLineTemplate.isReverse?(f=e,u=n.x,y=n.y):(d=e,c=n.x,h=n.y);const p=this.getOptions().newLinkTemplate.fromNode;this.dataProvider.updateOptions({newLineTemplate:{...this.getOptions().newLineTemplate,fromJunctionPoint:f,fromJunctionPointOffsetX:u,fromJunctionPointOffsetY:y,toJunctionPoint:d,toJunctionPointOffsetX:c,toJunctionPointOffsetY:h},newLinkTemplate:{...this.getOptions().newLinkTemplate,toNodeObject:r}});const g=r;try{const m={newLineTemplate:this.getOptions().newLineTemplate,fromNode:p,toNode:g};this.emitEvent(D.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(xe(e))return;const n=this.getViewXyByEvent(e),a=this.getOptions().editingLineController.line,r=a.textOffsetX||0,d=a.textOffsetY||0;let c=!1;const h=u=>{const y=this.dataProvider.getCanvasScale(),p=this.getViewXyByEvent(u),g=p.x-n.x,m=p.y-n.y;(g>0||m>0)&&(c=!0);const v=Math.round(r+g/y),x=Math.round(d+m/y);this.dataProvider.updateLine(a.id,{textOffsetX:v,textOffsetY:x}),this._updateEditingLineView(),this._dataUpdated()},f=u=>{this.$dom.removeEventListener("mousemove",h),this.$dom.removeEventListener("mouseup",f),c&&t&&t(),this._dataUpdated()};this.$dom.addEventListener("mousemove",h),this.$dom.addEventListener("mouseup",f)}startMoveLine6CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const r=this.getOptions().editingLineController.line;let d=r.ctrlPoints||[];d.length===0&&(d.push({x:0,y:0}),d.push({x:0,y:0})),this.dataProvider.updateLine(r.id,{ctrlPoints:d}),d=r.ctrlPoints,r.isReverse&&(e=d.length-1-e);const c=this.dataProvider.getCanvasScale(),h=d[e],{x:f,y:u}=h,y=()=>{n(r),this._dataUpdated()};he.startDrag(t,{x:0,y:0},y,(p,g)=>{h.x=f+p/c,h.y=u+g/c,this.dataProvider.updateLine(r.id,{ctrlPoints:d}),this._updateEditingLineView(),this._dataUpdated()})}startMoveLine44CtrlPoint(e,t,n){t.stopPropagation(),t.preventDefault();const a=this.getOptions().editingLineController,r=a.line;let d=r.ctrlOptionsFor44;d||(d={cx:0,cy:0,fd:0,td:0},this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:d}),d=r.ctrlOptionsFor44);const c=d[e.optionName],h={indexOffset:0};let f=r.ctrlPointsFor49?JSON.parse(JSON.stringify(r.ctrlPointsFor49)):null;const u=(p,g)=>{const m=this.dataProvider.getCanvasScale();if(r.lineShape===W.StandardOrthogonal){if(e.optionName==="cx"){const x=c+p/m*1;d.cx=x,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:d})}else if(e.optionName==="cy"){const x=c+g/m*1;d.cy=x,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:d})}else if(e.optionName==="fd"){const v=Be[e.startDirection],x=e.direction==="v"?p*v.x:g*v.y;d.fd=c+x/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:d})}else if(e.optionName==="td"){const v=Be[e.endDirection],x=e.direction==="v"?p*v.x:g*v.y;d.td=c+x/m,this.dataProvider.updateLine(r.id,{ctrlOptionsFor44:d})}else if(e.direction==="v"&&Math.abs(p)>5||e.direction==="h"&&Math.abs(g)>5){const v=a.line49Points;f=JSON.parse(JSON.stringify(v)),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:f}),this.dataProvider.updateLine(r.id,{lineShape:W.HardOrthogonal})}}else if(r.lineShape===W.HardOrthogonal){const{newPoints:v,pointsChanged:x}=ki(r.ctrlPointsFor49,f,e.pIndex+h.indexOffset,e,h,p/m,g/m);x&&(f=JSON.parse(JSON.stringify(v))),this.dataProvider.updateLine(r.id,{ctrlPointsFor49:v})}},y=()=>{if(r.lineShape===W.HardOrthogonal){const p=Ve(r.ctrlPointsFor49);this.dataProvider.updateLine(r.id,{ctrlPointsFor49:p})}this._updateEditingLineView(),n&&n(r),this._dataUpdated()};he.startDrag(t,{x:0,y:0},y,(p,g)=>{u(p,g),this._updateEditingLineView(),this._dataUpdated()})}onLineVertexBeDroppedOnConnectController(e,t,n,i){if(w("onLineVertexBeDroppedOnConnectController",e,t,n),t.stopPropagation(),!n){this.onLineVertexBeDropped(e,t,void 0,i);return}const a=ce(t),r=n.getBoundingClientRect(),d={x:r.left,y:r.top+r.height/2},c={x:r.left+r.width/2,y:r.top},h={x:r.left+r.width,y:r.top+r.height/2},f={x:r.left+r.width/2,y:r.top+r.height};let u=de.left;const y={x:0,y:0};if(e)u=e,u===de.top||u===de.bottom?y.x=a.clientX-f.x:u===de.right?y.y=a.clientY-h.y:y.y=a.clientY-d.y;else{const g=we(a.clientX,a.clientY,d.x,d.y),m=we(a.clientX,a.clientY,c.x,c.y),v=we(a.clientX,a.clientY,h.x,h.y),x=we(a.clientX,a.clientY,f.x,f.y),L=Math.min(g,m,v,x);L===g?(u=de.left,y.x=a.clientX-d.x,y.y=a.clientY-d.y):L===m?(u=de.top,y.x=a.clientX-c.x,y.y=a.clientY-c.y):L===v?(u=de.right,y.x=a.clientX-h.x,y.y=a.clientY-h.y):L===x&&(u=de.bottom,y.x=a.clientX-f.x,y.y=a.clientY-f.y)}const p=this.dataProvider.getCanvasScale();y.x=y.x/p,y.y=y.y/p,w("onMouseUpWithOffset:",e,y),this.onLineVertexBeDropped(u,t,y,i)}}class ps extends us{constructor(){super();_(this,"$miniViewCanvas");_(this,"$mvCanvasCtx");_(this,"_canvasDomScale",1);_(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});_(this,"visibleArea",{x:0,y:0});_(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 x of this.getNodes())if(x.rgCalcedVisibility&&x.opacity!==0){x.x<e&&(e=x.x),x.y<t&&(t=x.y);const L=x.x+x.el_W,P=x.y+x.el_H;L>n&&(n=L),P>i&&(i=P),a++}const r=1,d=50,c=50;a===0?(this.miniViewBox.canvas_start_x=-100-d,this.miniViewBox.canvas_start_y=-100-c,this.miniViewBox.canvas_end_x=100+d,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-d,this.miniViewBox.canvas_start_y=t-c,this.miniViewBox.canvas_end_x=n+d,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 h=this.$miniViewCanvas.parentElement.getBoundingClientRect(),f=h.width,u=h.height;let y=0,p=0,g=1;f/this.miniViewBox.canvas_width<u/this.miniViewBox.canvas_height?(g=f/this.miniViewBox.canvas_width*r,y=f,p=f/this.miniViewBox.canvas_width*this.miniViewBox.canvas_height):(g=u/this.miniViewBox.canvas_height*r,y=u/this.miniViewBox.canvas_height*this.miniViewBox.canvas_width,p=u),this.miniViewBox.miniview_width=f,this.miniViewBox.miniview_height=u,this.$miniViewCanvas.width=f,this.$miniViewCanvas.height=u,this.$mvCanvasCtx.canvas.width=f*window.devicePixelRatio,this.$mvCanvasCtx.canvas.height=u*window.devicePixelRatio,this.$mvCanvasCtx.canvas.style.width=`${f}px`,this.$mvCanvasCtx.canvas.style.height=`${u}px`;const m=(u-p)/2,v=(f-y)/2;this.miniViewBox.canvas_start_x-=v/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 d=i*a,c=i*r,h=e.x-this.miniViewBox.canvas_start_x,f=e.y-this.miniViewBox.canvas_start_y,u=i*h,y=i*f;let p=!1;(u+d<0||y+c<0||y>this.miniViewBox.miniview_height||u>this.miniViewBox.miniview_width)&&(p=!0);const g=this.getOptions().miniViewVisibleHandle;(g.emptyContent!==p||g.width!==d||g.height!==c||g.x!==d||g.y!==c)&&this.dataProvider.updateOptions({miniViewVisibleHandle:{emptyContent:p,width:d,height:c,x:u,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=Ce(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);if(!i)return;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,d=0,c=0,h=0,f=0,u=0,y=!1;n.forEach(p=>{const g=p.trim().split(/[ ,]+/),m=g[0].toUpperCase(),v=g[0]===g[0].toLowerCase();switch(m){case"M":i=U(r,g[1],v)-this.miniViewBox.canvas_start_x,a=U(d,g[2],v)-this.miniViewBox.canvas_start_y,r=i,d=a,y&&(e.closePath(),y=!1),e.moveTo(i,a);break;case"L":i=U(r,g[1],v)-this.miniViewBox.canvas_start_x,a=U(d,g[2],v)-this.miniViewBox.canvas_start_y,e.lineTo(i,a);break;case"C":c=U(r,g[1],v),h=U(d,g[2],v),f=U(r,g[3],v),u=U(d,g[4],v),i=U(r,g[5],v),a=U(d,g[6],v),r=i,d=a,e.bezierCurveTo(c,h,f,u,i,a);break;case"Q":c=U(r,g[1],v),h=U(d,g[2],v),i=U(r,g[3],v),a=U(d,g[4],v),r=i,d=a;break;case"V":a=U(d,g[1],v),d=a,e.lineTo(i,a);break;case"H":i=U(r,g[1],v),r=i,e.lineTo(i,a);break;case"Z":e.closePath(),y=!1;break;default:w(`Unsupported command: ${m}`)}})}onVisibleViewHandleDragStart(e){e.preventDefault(),e.stopPropagation();const t=this.getOptions(),n=t.canvasOffset.x,i=t.canvasOffset.y,a=this.miniViewBox.canvas_width,r=this.miniViewBox.canvas_height,d=()=>{const p=u/this.miniViewBox.miniview_width,g=y/this.miniViewBox.miniview_height,m=this.dataProvider.getCanvasScale(),v=a*p*m,x=r*g*m;this.dataProvider.setCanvasOffset(n-v,i-x),this._updateEditingControllerView(),this.updateMiniViewVisibleArea(),this.updateShouldRenderGraphData(),this.dataProvider.dataUpdated()};let c;const h=(p,g,m)=>{c&&clearInterval(c),this.onCanvasDragEnd(m)};let f=!1,u=0,y=0;he.startDrag(e,{x:0,y:0},h,(p,g)=>{u=p,y=g,!f&&Math.abs(p)+Math.abs(g)>3&&(f=!0,c=setInterval(()=>{d()},50))})}resetByVisiableView(e){!this.getOptions().miniViewVisibleHandle.emptyContent||(this.setZoom(100),this._moveToCenter(),this.zoomToFit())}}class gs extends ps{constructor(){super();_(this,"$watermarkDom",null);_(this,"$watermarkPosition","br");_(this,"$backgroundDom",null);_(this,"_originBackgroundColor","");_(this,"graphStatusBeforeImageGeneration",{orignCanvasOffsetX:0,orignCanvasOffsetY:0,orignZoom:0,forceLayouting:!1})}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.updateShouldRenderGraphData(),this.updateElementLines(),await this.moveItemsAndFitContent(),this._dataUpdated(),this.$canvasDom.parentElement}async restoreAfterImageGeneration(){const{orignCanvasOffsetX:e,orignCanvasOffsetY:t,orignZoom:n,forceLayouting:i}=this.graphStatusBeforeImageGeneration;this.$canvasDom.parentElement.style.width="100%",this.$canvasDom.parentElement.style.height="100%",this.setZoom(n),this.dataProvider.updateOptions({canvasOffset:{x:e,y:t}}),this._dataUpdated(),i&&this.startAutoLayout(),this.clearLoading()}async moveItemsAndFitContent(){const e=this.getOptions(),t=e.canvasZoom,n=e.canvasOffset.x,i=e.canvasOffset.y,a=e.layout.autoLayouting===!0;a&&(this.stopAutoLayout(),await this.sleep(200)),this.loading("Generating..."),this.dataProvider.updateOptions({snapshotting:!0}),this.dataProvider.clearChecked(),this.setZoom(100),this.updateShouldRenderGraphData(!0),this._dataUpdated(),await this.sleep(200);const r=this.getNodesRectBox(),d=this.getCanvasSlotRectItems(),c=this.getNodesRectBox(d),h=100,f=Math.min(r.minX,c.minX)-h,u=Math.min(r.minY,c.minY)-h,y=Math.max(r.maxX,c.maxX)+h,p=Math.max(r.maxY,c.maxY)+h,g=f,m=u,v=y-f,x=p-u;this.graphStatusBeforeImageGeneration={orignCanvasOffsetX:n,orignCanvasOffsetY:i,orignZoom:t,forceLayouting:a},this.dataProvider.updateOptions({canvasOffset:{x:-g,y:-m}}),this._dataUpdated(),this.setZoom(100),this.$canvasDom.parentElement.style.width=v+"px",this.$canvasDom.parentElement.style.height=x+"px",w("export image:",{imageWidth:v,imageHeight:x,minX:f,minY:u,maxX:y,maxY:p,devicePixelRatio:window.devicePixelRatio}),await this.sleep(200)}}class ms extends gs{constructor(){super();_(this,"resizeObserver");_(this,"resizeListenerMap",new WeakMap);_(this,"domToNodeIdMap",new WeakMap);_(this,"connectTargetHostMutationObserverMap",new Map);_(this,"_trackpadGestureActive",!1);_(this,"_trackpadGestureStartZoom",100);_(this,"_trackpadGestureAnchorView");_(this,"_trackpadGestureStartOffset");_(this,"_mouseMoveHandler");_(this,"_gestureStartHandler");_(this,"_gestureChangeHandler");_(this,"_gestureEndHandler");_(this,"_lastMouseClientXy");_(this,"mutationObserver4Nodes");_(this,"mutationObserver4CanvasSlotBehind");_(this,"mutationObserver4CanvasSlotAbove");_(this,"_updateCanvasConnectTargetsTask");_(this,"onKeyDownHanlder");_(this,"onKeyUpHanlder")}setDom(e){w("relation-graph mounted on:",this.instanceId,e),this.$dom=e}setCanvasDom(e){w("relation-graph canvas dom mounted!"),this.$canvasDom=e,this.$lineTextContainer4NormalLine=null,this.$lineTextContainer4FakeLine=null,this.reinitMutationObservers(),this.getLineTextContainer({isFakeLine:!0}),this.getLineTextContainer({isFakeLine:!1})}async analyzeRenderedGraph(e={}){return _o({dom:this.$dom,canvasDom:this.$canvasDom,instanceId:this.instanceId,graphOptions:this.getOptions(),performanceMode:this.dataProvider.isPerformanceMode(),showEasyView:this.getOptions().showEasyView,sleep:t=>this.sleep(t),getNodeById:t=>this.getNodeById(t),getLineById:t=>this.getLineById(t),getLinkByLineId:t=>this.getLinkByLineId(t),getFakeLineById:t=>this.getFakeLineById(t)},e)}async getClassAndRender(e={}){return this.analyzeRenderedGraph(e)}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)=>{w("resizeListener:this.$dom"),this.resetViewSize(),this.updateEasyView(),this._rgAsConnectArea&&this.updateCanvasConnectTargetsPosition("View Resize"),this._updateEditingLineView(),this._updateEditingControllerView(),this._dataUpdated(),setTimeout(()=>{w("resizeListener:updateShouldRenderGraphData"),this.emitEvent(D.onViewResize,{width:e,height:t}),this._dataUpdated()},500)}),this._rgAsConnectArea||(this.removeKeyboardListener(),this.addKeyboardListener(),this.removeTrackpadGestureListeners(),this.addTrackpadGestureListeners())}updateCanvasConnectTargetsPosition(e="api"){this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-behind")),this.updateConnectTargetsOnCanvas(e,this.$dom.querySelector(".rg-canvas-slot-above"))}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),d=this.domToNodeIdMap.get(r);d&&this.updateConnectTargetsOnNode("Mutation",d,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=>{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);for(const e of this.connectTargetHostMutationObserverMap.values())e.disconnect();this.connectTargetHostMutationObserverMap.clear()}getTrackpadGestureAnchorView(){const e=this.getViewBoundingClientRect();return e?this._lastMouseClientXy?this.getViewXyByClientXy({x:this._lastMouseClientXy.x,y:this._lastMouseClientXy.y}):{x:e.width/2,y:e.height/2}:{x:0,y:0}}addTrackpadGestureListeners(){this._mouseMoveHandler=e=>{this._lastMouseClientXy={x:e.clientX,y:e.clientY}},this._gestureStartHandler=e=>{const t=e;xe(t)||(t.cancelable&&t.preventDefault(),t.stopPropagation(),this._trackpadGestureActive=!0,this._trackpadGestureStartZoom=this.getOptions().canvasZoom,this._trackpadGestureStartOffset={x:this.getOptions().canvasOffset.x,y:this.getOptions().canvasOffset.y},this._trackpadGestureAnchorView=this.getTrackpadGestureAnchorView())},this._gestureChangeHandler=e=>{const t=e;if(!this._trackpadGestureActive||!this._trackpadGestureAnchorView||!this._trackpadGestureStartOffset)return;t.cancelable&&t.preventDefault(),t.stopPropagation();const n=t.scale;if(!n||!Number.isFinite(n)||n<=0)return;const i=.01;if(Math.abs(n-1)<i)return;const a=this._trackpadGestureStartZoom*n,r=this._trackpadGestureStartZoom/100,d=this.getClampedZoom(a)/100,c=this._trackpadGestureAnchorView.x-(this._trackpadGestureAnchorView.x-this._trackpadGestureStartOffset.x)*(d/r),h=this._trackpadGestureAnchorView.y-(this._trackpadGestureAnchorView.y-this._trackpadGestureStartOffset.y)*(d/r);this.setZoomAndOffset(a,{x:c,y:h})},this._gestureEndHandler=e=>{const t=e;t.cancelable&&t.preventDefault(),t.stopPropagation(),this._trackpadGestureActive=!1,this._trackpadGestureAnchorView=void 0,this._trackpadGestureStartOffset=void 0},this.$dom.addEventListener("mousemove",this._mouseMoveHandler),this.$dom.addEventListener("gesturestart",this._gestureStartHandler),this.$dom.addEventListener("gesturechange",this._gestureChangeHandler),this.$dom.addEventListener("gestureend",this._gestureEndHandler)}removeTrackpadGestureListeners(){this._mouseMoveHandler&&this.$dom.removeEventListener("mousemove",this._mouseMoveHandler),this._gestureStartHandler&&this.$dom.removeEventListener("gesturestart",this._gestureStartHandler),this._gestureChangeHandler&&this.$dom.removeEventListener("gesturechange",this._gestureChangeHandler),this._gestureEndHandler&&this.$dom.removeEventListener("gestureend",this._gestureEndHandler),this._trackpadGestureActive=!1,this._trackpadGestureAnchorView=void 0,this._trackpadGestureStartOffset=void 0,this._mouseMoveHandler=void 0,this._gestureStartHandler=void 0,this._gestureChangeHandler=void 0,this._gestureEndHandler=void 0}addKeyboardListener(){this.onKeyDownHanlder=e=>{xe(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!1&&this.setCanvasMoveMode(!0)),this.emitEvent(D.onKeyboardDown,e))},this.onKeyUpHanlder=e=>{xe(e)||(e.code==="Space"&&(e.preventDefault(),this.getOptions().canvasMoveMode===!0&&this.setCanvasMoveMode(!1)),this.emitEvent(D.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)}_observeConnectTargetElement(e,t){if(this.addResizeListener(t.measureEl,()=>{const i=this.getConnectTargetRuntimeById(e);!i||this.updateConnectTargetById("Target-Resize",e,i.measureEl)}),this.connectTargetHostMutationObserverMap.has(t.hostEl))return;const n=new MutationObserver(()=>{this.refreshConnectTargetRuntimeById("Target-HostMutation",e)});n.observe(t.hostEl,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),this.connectTargetHostMutationObserverMap.set(t.hostEl,n)}_unobserveConnectTargetElement(e,t){this.removeResizeListener(t.measureEl);const n=this.connectTargetHostMutationObserverMap.get(t.hostEl);n&&(n.disconnect(),this.connectTargetHostMutationObserverMap.delete(t.hostEl))}_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):w("removeNodeResizeListener: dom is null or undefined!")}removeResizeListener(e){this.resizeListenerMap.delete(e),this.resizeObserver&&this.resizeObserver.unobserve(e)}destroyResizeObserver(){this.resizeObserver&&this.resizeObserver.disconnect()}getCanvasSlotList(){return this.$dom.querySelectorAll(".rg-map > .rg-map-canvas > .rg-canvas-slot")}getCanvasSlotRectItems(){if(!this.$dom)return[];const e=this.getCanvasSlotList(),t=[];for(const n of Array.from(e))for(const i of Array.from(n.children)){const a=i,r={x:a.offsetLeft||0,y:a.offsetTop||0,nodeShape:1,el_W:a.scrollWidth,el_H:a.scrollHeight};t.push(r)}return t}}class ys extends ms{constructor(){super()}dataUpdated(){this._requestDataUpdate()}setOptions(o){w("setOptions:",o),this._updateOptions(o),this._dataUpdated()}updateOptions(o){w("updateOptions:",o),this._updateOptions(o),this._dataUpdated()}moveToCenter(o){this._moveToCenter(o),this._dataUpdated()}transToLinker(o=!0){this._rgAsConnectArea=o,this.resetViewSize(),this.updateCanvasConnectTargetsPosition("Linker"),this.removeKeyboardListener(),this._rgAsConnectArea||this.addKeyboardListener(),this._dataUpdated()}setRootNodeId(o){w("setRootNodeId:",o),this.dataProvider.setRootNodeId(o)}getRootNode(){return this.dataProvider.getRootNode()}getCheckedNode(){return this.getNodeById(this.getOptions().checkedNodeId)}getCheckedLine(){const o=this.getLineById(this.getOptions().checkedLineId);return o||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){w("appendData:",o),this.loadGraphJsonData(o),e&&await this.doLayout()}async applyInitialData(o){w("applyInitialData:",o),await this.setJsonData(o),this.moveToCenter(),this.zoomToFit()}getGraphJsonData(){var i;const o=[],e=[],t=[];this.getNodes().forEach(a=>{const r=Te(a);r&&o.push(r)}),this.getLines().forEach(a=>{const r=pe(a);r&&e.push(r)}),this.getFakeLines().forEach(a=>{const r=pe(a);r&&t.push(r)});const n={rootId:((i=this.dataProvider.getRootNode())==null?void 0:i.id)||"",nodes:o,lines:e};return t.length>0&&(n.fakeLines=t),n}transRGNodeToJsonObject(o,e={}){const t=e.mode==="effective"&&!e.graphOptions?{...e,graphOptions:this.getOptions()}:e;return Te(o,t)}transRGLinkToJsonObject(o,e={}){const t=e.mode==="effective"&&!e.graphOptions?{...e,graphOptions:this.getOptions()}:e;return Re(o,t)}transRGLineToJsonObject(o,e={}){const t=e.mode==="effective"&&!e.graphOptions?{...e,graphOptions:this.getOptions()}:e;return pe(o,t)}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(){this.getGraphJsonOptions()}printData(){this.getGraphJsonData()}printGraphJsonData(){this.printOptions(),this.printData()}}class an extends ys{constructor(){super();_(this,"viewComponentUnmounted",!1)}setListeners(e){this.listeners=e}ready(){this.initDom(),this.resetViewSize(),this.addFullscreenListener(),this.emitEvent(D.onReady,this),this.viewComponentUnmounted=!1}beforeUnmount(){this.viewComponentUnmounted=!0,this.removeFullscreenListener(),this.removeKeyboardListener(),this.removeTrackpadGestureListeners(),this.destroyMutationObserver(),this.destroyResizeObserver()}}function rn(s,o=!1){const e=l.markRaw(s?Reflect.construct(s,[]):new an);return e._rgAsConnectArea=o,e}function ln(s,o=!1){const e=l.inject(Le,null);return e?e.graphInstance:rn(s,o)}const tt=s=>({get value(){return s()}});function nt(s){return l.defineComponent({name:"RGDataProvider",props:{options:{required:!1,type:Object}},setup(o,{slots:e}){if(!l.inject(Le,null)){const n=l.ref({rootNode:void 0,nodes:[],normalLines:[],fakeLines:[]}),i=l.ref({}),a=l.ref({nodes:[],lines:[],fakeLines:[]}),r=l.ref(null),d=l.ref(null),c=l.ref([]),h=l.ref([]),f=l.ref([]),u=l.ref(new Map),y=l.ref(new Map),p=tt(()=>a.value.nodes),g=tt(()=>a.value.lines),m=tt(()=>a.value.fakeLines),E={store4Options:{set:T=>{}},store4ShouldRenderNodes:{set:T=>{}},store4ShouldRenderLines:{set:T=>{}},store4ShouldRenderFakeLines:{set:T=>{}},optionsRef:i,shouldRenderNodesRef:p,shouldRenderLinesRef:g,shouldRenderFakeLinesRef:m,textContainer4FakeLineRef:r,textContainer4NormalRef:d};s.setReactiveData4Vue3(E,n.value,i.value,{runtimeDATA4Links:f.value,runtimeDATA4ElLineTargets:c.value,runtimeDATA4ConnectTargets:h.value,runtimeDATA4NodeMap:u.value,runtimeDATA4LinkMap:y.value,runtimeDATA4ShouldRenderItems:a.value},(T,N,b)=>{T[N]=l.markRaw(b)}),s.setOptions(o.options||{}),l.provide(Le,{graphInstance:s})}return l.onMounted(()=>{}),()=>e.default?e.default():null}})}const ot={onReady:s=>!0,onNodeClick:(s,o)=>!0,onNodeExpand:(s,o)=>!0,onNodeCollapse:(s,o)=>!0,onLineClick:(s,o,e)=>!0,onNodeDragStart:(s,o)=>!0,onNodeDragEnd:(s,o,e,t)=>!0,onNodeDragging:(s,o,e,t,n,i)=>!0,onCanvasDragEnd:s=>!0,onCanvasDragging:(s,o,e,t)=>!0,onContextmenu:(s,o,e,t,n)=>!0,onFullscreen:(s,o)=>!0,onCanvasClick:s=>!0,onCanvasSelectionEnd:(s,o)=>!0,beforeZoomStart:()=>!0,onZoomEnd:()=>!0,onViewResize:()=>!0,onResizeStart:(s,o)=>!0,beforeNodeResize:(s,o,e,t,n)=>!0,onResizeEnd:(s,o,e,t)=>!0,onLineVertexDropped:s=>!0,beforeCreateLine:s=>!0,onLineBeCreated:s=>!0,beforeAddNodes:s=>!0,beforeAddLines:s=>!0,onKeyboardDown:s=>!0,onKeyboardUp:s=>!0,onCanvasDragStart:(s,o,e)=>!0,onForceLayoutFinish:()=>!0,beforeScrollStart:(s,o,e)=>!0};function dn({relationGraphCore:s}={}){const o=ln(s),e=nt(o);return{RelationGraph:l.defineComponent({name:"RelationGraph",props:{options:{required:!1,type:Object},initialData:{required:!1,type:Object},emitProxy:{required:!1,type:Function}},emits:ot,setup(t,{slots:n,emit:i}){return l.onMounted(()=>{const a=t.emitProxy||i;o.setEventEmitHook((r,...d)=>{a(r,...d)}),rt("Vue3"),t.options&&o.setOptions(t.options||{}),o.ready(),t.initialData&&o.applyInitialData(t.initialData)}),l.onBeforeUnmount(()=>{o.beforeUnmount()}),()=>l.h(e,{options:t.options},{default:()=>l.h(co,t,n)})}}),graphInstance:o}}const Oe=s=>s,vs=`graphRef.value.getInstance() will be deprecated
|
|
43
43
|
|
|
44
44
|
It is recommended to use the graphInstance:
|
|
45
45
|
###### Method 1: ######
|
|
@@ -79,45 +79,11 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
79
79
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
80
80
|
|
|
81
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
|
-
`,
|
|
82
|
+
`,xs=`graphRef.value.getInstance() will be deprecated
|
|
83
83
|
|
|
84
84
|
It is recommended to use the graphInstance:
|
|
85
85
|
###### Method 1: ######
|
|
86
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
87
|
import { RGProvider } from 'relation-graph-vue3';
|
|
122
88
|
|
|
123
89
|
<RGProvider>
|
|
@@ -152,46 +118,11 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
152
118
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
153
119
|
|
|
154
120
|
Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
|
|
155
|
-
`,
|
|
121
|
+
`,Cs=`graphRef.current.getInstance() will be deprecated
|
|
156
122
|
|
|
157
123
|
It is recommended to use the graphInstance:
|
|
158
124
|
###### Method 1: ######
|
|
159
125
|
|
|
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
126
|
import { RGProvider } from 'relation-graph-react';
|
|
196
127
|
|
|
197
128
|
<RGProvider>
|
|
@@ -226,7 +157,7 @@ And method graphRef.value.getInstance() will be deprecated in future versions.
|
|
|
226
157
|
More details: https://www.relation-graph.com/docs/better-integration#vue3
|
|
227
158
|
|
|
228
159
|
Set option "definitelyNoDataProviderNeeded": true to disable the data provider warning if you are sure that no data provider is needed in your case.
|
|
229
|
-
`,
|
|
160
|
+
`,ws=`Please Initialize the graph using the new method:
|
|
230
161
|
|
|
231
162
|
###### Method 1: ######
|
|
232
163
|
// Use graphInstance to set the data.
|
|
@@ -253,7 +184,7 @@ Initialize using the onReady event of the RelationGraph component. then use grap
|
|
|
253
184
|
|
|
254
185
|
###### More Method: ######
|
|
255
186
|
https://www.relation-graph.com/docs.'
|
|
256
|
-
`,
|
|
187
|
+
`,Ls=`Please Initialize the graph using the new method:
|
|
257
188
|
|
|
258
189
|
###### Method 1: ######
|
|
259
190
|
// Use graphInstance to set the data.
|
|
@@ -281,4 +212,4 @@ Initialize using the onReady event of the RelationGraph component. then use grap
|
|
|
281
212
|
|
|
282
213
|
###### More Method: ######
|
|
283
214
|
https://www.relation-graph.com/docs.'
|
|
284
|
-
`,bt={Vue3GetInstance:Pe(Bo),ReactGetInstance:Pe(Ao),Vue2GetInstance:Pe(Vo),setJsonData:Pe(zo),setJsonData4Vue2:Pe(Xo)},Ye=r.defineComponent({name:"RelationGraph",props:{options:{required:!1,type:Object},initialData:{required:!1,type:Object},relationGraphCore:{required:!1,type:Function}},emits:$e,setup(l,{slots:i,emit:e,expose:t,attrs:n}){const{RelationGraph:o,graphInstance:s}=Nt({relationGraphCore:l.relationGraphCore});if(i["graph-plug"])throw new Error('Slot name "#graph-plug" has been renamed to "#view". Please update your code accordingly.');if(i["canvas-plug"])throw new Error('Slot name "#canvas-plug" has been renamed to "#canvas". Please update your code accordingly.');if(i["canvas-plug-above"])throw new Error('Slot name "#canvas-plug-above" has been renamed to "#canvas-above". Please update your code accordingly.');if(i["node-expand-holder"])throw new Error('Slot name "#node-expand-holder" has been renamed to "#node-expand-button". Please update your code accordingly.');return t({getInstance(){var a;return(a=l.options)!=null&&a.definitelyNoDataProviderNeeded||console.warn("[relation-graph]",bt.Vue3GetInstance),s},async setJsonData(){throw new Error(bt.setJsonData)}}),()=>r.h(o,{options:l.options,initialData:l.initialData,emitProxy:e},{...i})}}),Go={class:"rg-canvas-slot rg-canvas-slot-behind",style:{position:"relative","pointer-events":"all","user-select":"text"}},Fo=r.defineComponent({__name:"RelationLinkerCanvas",setup(l){const i=r.ref(),e=H(),t=r.computed(()=>e.dataStores.optionsRef.value),n=r.computed(()=>({"background-color":"transparent","text-wrap":"unset",position:"relative",width:"100%",height:"fit-content"}));return r.onMounted(()=>{L("[RGCanvas mounted]"),e.setCanvasDom(i.value)}),(o,s)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-map",[t.value.canvasOpacity===1&&"rg-map-ready"]])},[r.createElementVNode("div",{style:r.normalizeStyle(n.value),class:"rg-map-canvas rg-canvas-behind"},[r.createElementVNode("div",Go,[r.renderSlot(o.$slots,"canvas-behind")])],4),r.createElementVNode("div",{ref_key:"rgCanvasRef",ref:i,style:r.normalizeStyle([n.value,{position:"absolute",left:"0px",top:"0px","z-index":"9"}]),class:"rg-map-canvas"},[r.createVNode(ot,{"show-easy-view":t.value.showEasyView,"creating-line":!!(t.value.creatingLinePlot&&t.value.newLinkTemplate.fromNode),"default-expand-holder-position":t.value.defaultExpandHolderPosition,draggingNodeId:t.value.draggingNodeId,checkedNodeId:t.value.checkedNodeId,defaultLineTextOnPath:t.value.defaultLineTextOnPath,"checked-line-id":t.value.checkedLineId,"graph-instance-id":t.value.instanceId},{line:r.withCtx(a=>[r.renderSlot(o.$slots,"line",r.normalizeProps(r.guardReactiveProps(a)))]),_:3},8,["show-easy-view","creating-line","default-expand-holder-position","draggingNodeId","checkedNodeId","defaultLineTextOnPath","checked-line-id","graph-instance-id"])],4)],2))}}),Ho=["id"],$o={class:"rg-graph-plugs"},Yo={class:"rg-view-slot"},Wo=r.defineComponent({__name:"RelationLinkerUI",setup(l){const i=H(),e=r.ref(),t=r.computed(()=>i.dataStores.optionsRef.value),n=r.ref(!1);return r.onMounted(()=>{i.setDom(e.value),n.value=!0}),r.onBeforeUnmount(()=>{i.beforeUnmount()}),(o,s)=>{var a,d,h,c,f,p,m,u,g;return r.openBlock(),r.createElementBlock("div",{ref_key:"relationGraphRef$",ref:e,id:"relation-graph-ins-"+((a=t.value)==null?void 0:a.instanceId),tabindex:"1",class:r.normalizeClass(["relation-graph",t.value&&t.value.creatingLinePlot?"rg-creating-line":""]),style:r.normalizeStyle({width:"100%",height:"fit-content",opacity:n.value?1:0,"--rg-checked-item-bg-color":(d=t.value)==null?void 0:d.checkedItemBackgroundColor,"--rg-background-color":(h=t.value)==null?void 0:h.backgroundColor,"--rg-node-color":(c=t.value)==null?void 0:c.defaultNodeColor,"--rg-node-border-color":(f=t.value)==null?void 0:f.defaultNodeBorderColor,"--rg-node-border-width":((p=t.value)==null?void 0:p.defaultNodeBorderWidth)+"px","--rg-node-border-radius":((m=t.value)==null?void 0:m.defaultNodeBorderRadius)+"px","--rg-line-color":(u=t.value)==null?void 0:u.defaultLineColor,"--rg-line-width":((g=t.value)==null?void 0:g.defaultLineWidth)+"px"})},[t.value&&n.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[r.createVNode(Fo,null,{line:r.withCtx(y=>[r.renderSlot(o.$slots,"line",r.normalizeProps(r.guardReactiveProps(y)))]),"canvas-behind":r.withCtx(()=>[r.renderSlot(o.$slots,"default")]),_:3}),r.createVNode(it),r.createElementVNode("div",$o,[r.createElementVNode("div",Yo,[r.renderSlot(o.$slots,"view")])])],64)):r.createCommentVNode("",!0)],14,Ho)}}});function Uo(l,{options:i,emitProxy:e}){return r.defineComponent({name:"RelationLinkerUIFrame",props:{lines:{type:Array,required:!0}},setup(t,{slots:n}){const o=e!=null?e:r.defineEmits();l.setEventEmitHook((a,...d)=>{o(a,...d)});const s=async a=>{a&&(l.clearGraph(),l.addFakeLines(a))};return r.watch(()=>t.lines,async a=>{await s(a)},{deep:!0}),r.onMounted(()=>{Je("Vue-Linker"),l.ready(),t.lines&&s(t.lines)}),r.onBeforeUnmount(()=>{l.beforeUnmount()}),()=>r.h(Wo,{},n)}})}function Jo({relationGraphCore:l,options:i,emitProxy:e}={}){const t=_t(l,!0),n=He(t),o=Uo(t,{options:i,emitProxy:e}),s=r.defineComponent({name:"RelationLinker",props:{lines:{type:Array,required:!0}},setup(a,{attrs:d,slots:h}){return r.onMounted(()=>{}),()=>r.h(n,{},{default:()=>r.h(o,a,h)})}});return{RGProvider:n,RelationLinker:s,VueLinker:s,graphInstance:t}}const jo=r.defineComponent({__name:"RelationLinker",props:{options:{},lines:{},relationGraphCore:{}},emits:["onReady","onNodeClick","onNodeExpand","onNodeCollapse","onLineClick","onNodeDragStart","onNodeDragEnd","onNodeDragging","onCanvasDragEnd","onCanvasDragging","onContextmenu","onFullscreen","onCanvasClick","onCanvasSelectionEnd","beforeZoomStart","onZoomEnd","onViewResize","onResizeStart","beforeNodeResize","onResizeEnd","onLineVertexDropped","beforeCreateLine","onLineBeCreated","beforeAddNodes","beforeAddLines","onKeyboardDown","onKeyboardUp","onCanvasDragStart","onForceLayoutFinish","beforeScrollStart"],setup(l,{emit:i}){const e=l,t=i,{RelationLinker:n}=Jo({options:e.options,relationGraphCore:e.relationGraphCore,emitProxy:t});return(o,s)=>(r.openBlock(),r.createBlock(r.unref(n),{lines:e.lines},{view:r.withCtx(()=>[r.renderSlot(o.$slots,"view")]),line:r.withCtx(a=>[r.renderSlot(o.$slots,"line",r.normalizeProps(r.guardReactiveProps(a)))]),default:r.withCtx(()=>[r.renderSlot(o.$slots,"default")]),_:3},8,["lines"]))}}),qo=r.defineComponent({__name:"RGProvider",props:{relationGraphCore:{},forLinker:{type:Boolean}},setup(l){const i=l,e=wt(i.relationGraphCore,i.forLinker),t=He(e);return(n,o)=>(r.openBlock(),r.createBlock(r.unref(t),null,{default:r.withCtx(()=>[r.renderSlot(n.$slots,"default")]),_:3}))}}),Zo=["data-id"],Ko={class:"rg-node-text"},Qo=r.defineComponent({__name:"RGFakeNode",props:{node:{}},setup(l){const i=l,e=r.ref(),t=H(),n=r.computed(()=>t.dataStores.optionsRef.value),o=r.computed(()=>i.node.borderColor),s=r.computed(()=>n.value.draggingNodeId===i.node.id),a=r.computed(()=>i.node.borderWidth===void 0?void 0:i.node.borderWidth+"px"),d=r.computed(()=>i.node.width?i.node.width+"px":void 0),h=r.computed(()=>i.node.height?i.node.height+"px":void 0),c=f=>{t.onNodeDragStart(i.node,f)};return r.onMounted(()=>{t.addNodeResizeListener(e.value,i.node)}),r.onBeforeUnmount(()=>{t.removeNodeResizeListener(e.value)}),(f,p)=>(r.openBlock(),r.createElementBlock("div",{ref_key:"nodePeelRef",ref:e,style:r.normalizeStyle({left:f.node.x+"px",top:f.node.y+"px","--rg-node-z-index":f.node.zIndex?f.node.zIndex:void 0,"--rg-node-opacity":f.node.opacity>1?f.node.opacity/100:f.node.opacity,"pointer-events":f.node.opacity===0?"none":void 0,"--rg-node-color":f.node.color||n.value.defaultNodeColor,"--rg-node-font-color":f.node.fontColor,"--rg-node-font-size":f.node.fontSize?f.node.fontSize+"px":void 0,"--rg-node-border-width":a.value,"--rg-node-width":d.value,"--rg-node-height":h.value,"--rg-node-border-radius":f.node.borderRadius&&f.node.borderRadius+"px","--rg-node-border-color":o.value}),class:r.normalizeClass(["rg-node-peel",[f.node.selected&&"rg-node-selected",s.value&&"rg-node-dragging",f.node.id===n.value.checkedNodeId&&"rg-node-checked","rg-node-shape-"+(f.node.nodeShape===void 0?1:f.node.nodeShape),"rg-node-type-"+f.node.type,f.node.className]]),"data-id":f.node.id},[r.createElementVNode("div",{class:"rg-node",onMousedown:p[0]||(p[0]=r.withModifiers(m=>c(m),["left","stop"])),onTouchstart:p[1]||(p[1]=r.withModifiers(m=>c(m),["stop"]))},[r.renderSlot(f.$slots,"default",{},()=>[r.createElementVNode("div",Ko,[r.createElementVNode("span",null,r.toDisplayString(f.node.text),1)])])],32)],14,Zo))}}),ei={class:"c-debug-tools-row"},ti=r.defineComponent({__name:"RGDebugView",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=r.ref(!1),n=()=>{t.value=!t.value},o=()=>{i.printOptions()},s=()=>{i.printData()},a=()=>{i.enableDebugLog(!i.options.debug),L("debugLog:",i.options.debug)};return(d,h)=>(r.openBlock(),r.createElementBlock("div",null,[r.createElementVNode("div",{class:r.normalizeClass([[],"rg-setting-panel-button"]),onClick:n}," Debug "),t.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:r.normalizeClass([[],"rg-setting-panel"])},[r.createElementVNode("div",{class:"c-debug-tools-row"},[r.createElementVNode("button",{onClick:o},"print options in console")]),r.createElementVNode("div",{class:"c-debug-tools-row"},[r.createElementVNode("button",{onClick:s},"print json data in console")]),r.createElementVNode("div",ei,[r.createTextVNode("debug log status: "+r.toDisplayString(e.value.debug)+" ",1),r.createElementVNode("button",{onClick:a},r.toDisplayString(e.value.debug?"disable":"enable")+" debug log",1)]),r.renderSlot(d.$slots,"default")])):r.createCommentVNode("",!0)]))}}),ni=["title"],oi=r.defineComponent({__name:"GraphToolBar",props:{direction:{},positionH:{},positionV:{}},setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value);r.onMounted(()=>{});const t=()=>{i.refresh()},n=()=>{i.toggleAutoLayout()},o=async()=>{i.setZoom(100),i.moveToCenter(),i.enableCanvasAnimation(),i.zoomToFit(),setTimeout(()=>{i.disableCanvasAnimation()},300)},s=d=>{i.zoom(d)},a=()=>{i.fullscreen()};return(d,h)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-toolbar",["rg-toolbar-h-"+(d.positionH||e.value.toolBarPositionH),"rg-toolbar-v-"+(d.positionV||e.value.toolBarPositionV),"rg-toolbar-"+(d.direction||e.value.toolBarDirection)]])},[r.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:h[0]||(h[0]=c=>a())},[r.createVNode(K,{"icon-name":"icon-quanping"})]),r.createElementVNode("div",{class:"rg-mb-button",onClick:h[1]||(h[1]=c=>s(20))},[r.createVNode(K,{"icon-name":"icon-fangda"})]),r.createElementVNode("div",{class:"rg-current-zoom",onClick:o},r.toDisplayString(Math.round(e.value.canvasZoom))+"%",1),r.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:h[2]||(h[2]=c=>s(-20))},[r.createVNode(K,{"icon-name":"icon-suoxiao"})]),e.value.layout.supportAutoLayout?(r.openBlock(),r.createElementBlock("div",{key:0,title:e.value.layout.autoLayouting?"\u70B9\u51FB\u505C\u6B62\u81EA\u52A8\u5E03\u5C40":"\u70B9\u51FB\u5F00\u59CB\u81EA\u52A8\u8C03\u6574\u5E03\u5C40",class:r.normalizeClass([{"rg-mb-button-on":e.value.layout.autoLayouting},"rg-mb-button"]),onClick:n},[e.value.layout.autoLayouting?(r.openBlock(),r.createBlock(K,{key:1,"icon-name":"icon-lianjiezhong","class-name":"rg-loading-icon"})):(r.openBlock(),r.createBlock(K,{key:0,"icon-name":"icon-zidong"}))],10,ni)):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"rg-mb-button",onClick:t},[r.createVNode(K,{"icon-name":"icon-ico_reset"})]),r.renderSlot(d.$slots,"default"),h[3]||(h[3]=r.createElementVNode("div",{style:{clear:"both"}},null,-1))],2))}}),ii=r.defineComponent({__name:"GraphBackground",props:{forImage:{type:Boolean,default:!0},forDisplay:{type:Boolean,default:!0}},setup(l){const i=H(),e=l;r.computed(()=>i.dataStores.optionsRef.value);const t=r.ref();return r.onMounted(()=>{i.setBackgroundDom(t.value,e.forImage,e.forDisplay)}),r.onUnmounted(()=>{i.setBackgroundDom(null,e.forImage,e.forDisplay)}),(n,o)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",{class:"rg-background",ref_key:"$backgroundRef",ref:t},[r.renderSlot(n.$slots,"default")],512)),[[r.vShow,n.forDisplay!==!1]])}}),si=r.defineComponent({__name:"GraphWatermark",props:{forImage:{type:Boolean,default:!0},forDisplay:{type:Boolean,default:!1},position:{default:"br"},width:{},height:{}},setup(l){const i=H(),e=l,t=r.computed(()=>i.dataStores.optionsRef.value),n=r.computed(()=>{let s=!1;return t.value.snapshotting?e.forImage===!1?s=!1:s=!0:e.forDisplay===!0?s=!0:s=!1,s}),o=r.ref();return r.onMounted(()=>{i.setWatermarkDom(o.value,e.forImage,e.forDisplay,e.position)}),r.onUnmounted(()=>{i.setWatermarkDom(null,e.forImage,e.forDisplay)}),(s,a)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-watermark",["rg-watermark-"+(s.position||"br")]]),ref_key:"$watermarkRef",ref:o,style:r.normalizeStyle({"--watermark-width":s.width,"--watermark-height":s.height})},[r.renderSlot(s.$slots,"default")],6)),[[r.vShow,n.value]])}}),ai=r.defineComponent({__name:"RGEditingNodeController",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value);return(t,n)=>e.value.editingController.show?(r.openBlock(),r.createElementBlock("div",{key:0,class:"rg-editing-ctrl",style:r.normalizeStyle({width:e.value.editingController.width+"px",height:e.value.editingController.height+"px",transform:`translate(${e.value.editingController.x}px, ${e.value.editingController.y}px)`})},[r.renderSlot(t.$slots,"default")],4)):r.createCommentVNode("",!0)}}),ri={class:"rg-resize-ctl"},li=r.defineComponent({__name:"RGEditingResize",props:{disableResizeWidth:{type:Boolean},disableResizeHeight:{type:Boolean}},emits:["beforeResizeStart"],setup(l,{emit:i}){const e=H(),t=i,n=r.computed(()=>e.dataStores.optionsRef.value),o=(s,a)=>{a.stopPropagation(),t("beforeResizeStart"),e.onResizeStart(s,a)};return(s,a)=>(r.openBlock(),r.createElementBlock("div",ri,[n.value.editingController.width>30&&!s.disableResizeWidth&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:0,class:"rg-resize-ctl-handler rg-resize-ctl-tl",onMousedown:a[0]||(a[0]=d=>o("tl",d))},null,32)):r.createCommentVNode("",!0),n.value.editingController.width>30&&!s.disableResizeWidth&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:1,class:"rg-resize-ctl-handler rg-resize-ctl-tr",onMousedown:a[1]||(a[1]=d=>o("tr",d))},null,32)):r.createCommentVNode("",!0),n.value.editingController.width>30&&!s.disableResizeWidth&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:2,class:"rg-resize-ctl-handler rg-resize-ctl-bl",onMousedown:a[2]||(a[2]=d=>o("bl",d))},null,32)):r.createCommentVNode("",!0),!s.disableResizeWidth&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:3,class:"rg-resize-ctl-handler rg-resize-ctl-br",onMousedown:a[3]||(a[3]=d=>o("br",d))},null,32)):r.createCommentVNode("",!0),(n.value.editingController.width>60||s.disableResizeWidth)&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:4,class:"rg-resize-ctl-handler rg-resize-ctl-t",onMousedown:a[4]||(a[4]=d=>o("t",d))},null,32)):r.createCommentVNode("",!0),(n.value.editingController.width>60||s.disableResizeWidth)&&!s.disableResizeHeight?(r.openBlock(),r.createElementBlock("div",{key:5,class:"rg-resize-ctl-handler rg-resize-ctl-b",onMousedown:a[5]||(a[5]=d=>o("b",d))},null,32)):r.createCommentVNode("",!0),(n.value.editingController.height>60||s.disableResizeHeight)&&!s.disableResizeWidth?(r.openBlock(),r.createElementBlock("div",{key:6,class:"rg-resize-ctl-handler rg-resize-ctl-l",onMousedown:a[6]||(a[6]=d=>o("l",d))},null,32)):r.createCommentVNode("",!0),(n.value.editingController.height>60||s.disableResizeHeight)&&!s.disableResizeWidth?(r.openBlock(),r.createElementBlock("div",{key:7,class:"rg-resize-ctl-handler rg-resize-ctl-r",onMousedown:a[7]||(a[7]=d=>o("r",d))},null,32)):r.createCommentVNode("",!0)]))}}),di={class:"rg-miniview-container"},ci=r.defineComponent({__name:"RGMiniView",props:{position:{},width:{},height:{},className:{}},setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=r.ref(),n=r.ref();r.onMounted(()=>{i.onMiniViewMounted(),i.setMiniViewCanvas(n.value)}),r.onUnmounted(()=>{i.onMiniViewUnMounted()});const o=a=>{i.onVisibleViewHandleDragStart(a)},s=a=>{i.resetByVisiableView(a)};return(a,d)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-miniview",["rg-miniview-"+(a.position||"br"),a.$attrs.className]]),ref_key:"$rgMiniView",ref:t,style:r.normalizeStyle({...a.$attrs.style,"--miniview-width":a.width,"--miniview-height":a.height})},[r.createElementVNode("div",di,[r.createElementVNode("canvas",{ref_key:"$rgMiniViewCanvas",ref:n,class:r.normalizeClass({"rg-mv-canvas-reset":e.value.miniViewVisibleHandle.emptyContent}),onClick:s},null,2),r.createElementVNode("div",{class:"rg-mv-visible-area",onMousedown:o,style:r.normalizeStyle({transform:`translate(${e.value.miniViewVisibleHandle.x}px, ${e.value.miniViewVisibleHandle.y}px)`,width:e.value.miniViewVisibleHandle.width+"px",height:e.value.miniViewVisibleHandle.height+"px"})},null,36)])],6))}}),hi=r.defineComponent({__name:"RGEditingNearNodeWidget",props:{position:{}},setup(l){return(i,e)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-editing-bar",["rg-editing-bar-"+(i.position||"top")]])},[r.renderSlot(i.$slots,"default")],2))}}),fi={key:0,class:"rg-editing-line-ctrl"},pi={key:0,class:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg"},ui=["d"],gi=["d"],mi=["onMousedown","onTouchstart"],yi={key:0},vi={key:1,class:"empty-text"},xi=["value"],Ci=r.defineComponent({__name:"RGEditingLineController",props:{textEditable:{type:Boolean,default:!0},pathEditable:{type:Boolean,default:!0}},emits:["onMoveLineVertexStart","onMoveLineVertexEnd","onLinePathChanged","onLineTextDragEnd","onLineTextChanged"],setup(l,{emit:i}){const e=H(),t=r.computed(()=>e.dataStores.optionsRef.value),n=r.computed(()=>t.value.editingLineController),o=r.computed(()=>n.value.line),s=r.computed(()=>{var b;return(b=n.value.line)==null?void 0:b.lineShape}),a=r.computed(()=>n.value.ctrlPoint1),d=r.computed(()=>n.value.ctrlPoint2),h=r.computed(()=>`M ${n.value.startPoint.x} ${n.value.startPoint.y} L ${a.value.x} ${a.value.y}`),c=r.computed(()=>`M ${n.value.endPoint.x} ${n.value.endPoint.y} L ${d.value.x} ${d.value.y}`),f=r.computed(()=>n.value.line44Splits),p=r.computed(()=>o.value&&o.value.text),m=r.ref(""),u=r.ref(!1);let g=r.ref(0);const y=i;r.watch(p,b=>{b!==m.value&&(m.value=b,r.nextTick(()=>{e.updateEditingLineView()}))}),r.watch(s,b=>{r.nextTick(()=>{e.updateEditingLineView()})});const v=(b,N)=>{e.startMoveLine6CtrlPoint(b,N,P=>{y("onLinePathChanged",P,b)})},x=(b,N)=>{e.startMoveLine44CtrlPoint(b,N,P=>{y("onLinePathChanged",P,b)})},w=(b,N)=>{const P=t.value.editingLineController.line;y("onMoveLineVertexStart",b,P),e.startMoveLineVertex(b,N,(R,S,M)=>{y("onMoveLineVertexEnd",R,S,M),e.defaultLineVertexBeChangedHandler(R,S,M)})},k=b=>{e.startMoveLineText(b,()=>{const N=t.value.editingLineController.line;y("onLineTextDragEnd",N)})},T=b=>{g.value&&Date.now()-g.value<500&&(u.value=!0,r.nextTick(()=>{b.target.focus()})),g.value=Date.now()},O=b=>{const N=o.value;N&&N.text!==b.target.value&&(e.updateLine(N.id,{text:b.target.value}),y("onLineTextChanged",N)),u.value=!1};return(b,N)=>n.value.show?(r.openBlock(),r.createElementBlock("div",fi,[r.renderSlot(b.$slots,"default"),b.pathEditable?(r.openBlock(),r.createElementBlock("svg",pi,[r.createElementVNode("g",null,[o.value.lineShape===6&&a.value?(r.openBlock(),r.createElementBlock("path",{key:0,d:h.value},null,8,ui)):r.createCommentVNode("",!0),o.value.lineShape===6&&d.value?(r.openBlock(),r.createElementBlock("path",{key:1,d:c.value},null,8,gi)):r.createCommentVNode("",!0)])])):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"rg-line-ctrl-dot start-dot",style:r.normalizeStyle({"--rg-ctl-x":n.value.startPoint.x+"px","--rg-ctl-y":n.value.startPoint.y+"px"}),onMousedown:N[0]||(N[0]=r.withModifiers(P=>w("start",P),["left"])),onTouchstart:N[1]||(N[1]=P=>w("start",P))},null,36),r.createElementVNode("div",{class:"rg-line-ctrl-dot end-dot",style:r.normalizeStyle({"--rg-ctl-x":n.value.endPoint.x+"px","--rg-ctl-y":n.value.endPoint.y+"px"}),onMousedown:N[2]||(N[2]=r.withModifiers(P=>w("end",P),["left"])),onTouchstart:N[3]||(N[3]=P=>w("end",P))},null,36),b.pathEditable&&o.value.lineShape===6&&a.value?(r.openBlock(),r.createElementBlock("div",{key:1,class:"rg-line-ctrl-dot ctrl-dot",style:r.normalizeStyle({"--rg-ctl-x":a.value.x+"px","--rg-ctl-y":a.value.y+"px"}),onMousedown:N[4]||(N[4]=r.withModifiers(P=>v(0,P),["left"])),onTouchstart:N[5]||(N[5]=P=>v(0,P))},null,36)):r.createCommentVNode("",!0),b.pathEditable&&o.value.lineShape===6&&d.value?(r.openBlock(),r.createElementBlock("div",{key:2,class:"rg-line-ctrl-dot ctrl-dot",style:r.normalizeStyle({"--rg-ctl-x":d.value.x+"px","--rg-ctl-y":d.value.y+"px"}),onMousedown:N[6]||(N[6]=r.withModifiers(P=>v(1,P),["left"])),onTouchstart:N[7]||(N[7]=P=>v(1,P))},null,36)):r.createCommentVNode("",!0),b.pathEditable&&(o.value.lineShape===44||o.value.lineShape===49)?(r.openBlock(!0),r.createElementBlock(r.Fragment,{key:3},r.renderList(f.value,P=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[P.hide?r.createCommentVNode("",!0):(r.openBlock(),r.createElementBlock("div",{key:P.optionName,class:r.normalizeClass(["rg-line-ctrl-dot ctrl-split",{"ctrl-split-core":!P.optionName.startsWith("cp-"),"ctrl-split-v":P.direction==="v","ctrl-split-h":P.direction==="h"}]),style:r.normalizeStyle({"--rg-ctl-x":P.x+"px","--rg-ctl-y":P.y+"px"}),onMousedown:r.withModifiers(R=>x(P,R),["left"]),onTouchstart:R=>x(P,R)},null,46,mi))],64))),256)):r.createCommentVNode("",!0),b.textEditable&&o.value?(r.openBlock(),r.createElementBlock("div",{key:4,class:r.normalizeClass(["rg-line-ctrl-text",u.value&&"rg-line-ctrl-text-editing"]),style:r.normalizeStyle({"--rg-ctl-x":n.value.text.x+"px","--rg-ctl-y":n.value.text.y+"px"}),onClick:T,onMousedown:N[8]||(N[8]=P=>k(P)),onTouchstart:N[9]||(N[9]=P=>k(P))},[u.value?(r.openBlock(),r.createElementBlock("input",{key:1,ref:"inputRef",class:"rg-line-text-input",value:m.value,onBlur:O},null,40,xi)):(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[m.value?(r.openBlock(),r.createElementBlock("p",yi,r.toDisplayString(m.value),1)):(r.openBlock(),r.createElementBlock("p",vi,"Add Text..."))],64))],38)):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0)}}),kt=r.defineComponent({__name:"RGEditingConnectPoints",props:{mouseUpOnJunctionPoint:{type:Function},mouseUpOnJunctionPointWithOffset:{type:Function}},setup(l){return(i,e)=>(r.openBlock(),r.createElementBlock("div",{class:"rg-connect-ctl",onMouseup:e[15]||(e[15]=t=>i.mouseUpOnJunctionPointWithOffset("",t)),onTouchend:e[16]||(e[16]=t=>i.mouseUpOnJunctionPointWithOffset("",t))},[r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseup:e[0]||(e[0]=t=>i.mouseUpOnJunctionPoint("top",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseup:e[1]||(e[1]=t=>i.mouseUpOnJunctionPoint("bottom",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseup:e[2]||(e[2]=t=>i.mouseUpOnJunctionPoint("border",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseup:e[3]||(e[3]=t=>i.mouseUpOnJunctionPoint("left",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseup:e[4]||(e[4]=t=>i.mouseUpOnJunctionPoint("right",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseup:e[5]||(e[5]=t=>i.mouseUpOnJunctionPoint("lr",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseup:e[6]||(e[6]=t=>i.mouseUpOnJunctionPoint("tb",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseup:e[7]||(e[7]=t=>i.mouseUpOnJunctionPointWithOffset("bottom",t)),onTouchend:e[8]||(e[8]=t=>i.onMouseUpWithOffset("bottom",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseup:e[9]||(e[9]=t=>i.mouseUpOnJunctionPointWithOffset("top",t)),onTouchend:e[10]||(e[10]=t=>i.onMouseUpWithOffset("top",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseup:e[11]||(e[11]=t=>i.mouseUpOnJunctionPointWithOffset("left",t)),onTouchend:e[12]||(e[12]=t=>i.onMouseUpWithOffset("left",t))},null,32),r.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseup:e[13]||(e[13]=t=>i.mouseUpOnJunctionPointWithOffset("right",t)),onTouchend:e[14]||(e[14]=t=>i.onMouseUpWithOffset("right",t))},null,32)],32))}}),Li=r.defineComponent({__name:"RGEditingConnectController",setup(l){const i=H(),e=r.computed(()=>i.dataStores.optionsRef.value),t=r.ref(),n=(s,a)=>{i.onLineVertexBeDroppedOnConnectController(s,a,void 0,(d,h,c)=>{L("onLineVertexBeDropped:callback:",c)})},o=(s,a)=>{i.onLineVertexBeDroppedOnConnectController(s,a,t.value,(d,h,c)=>{L("onLineVertexBeDropped:callback:",c)})};return(s,a)=>e.value.nodeConnectController.show?(r.openBlock(),r.createElementBlock("div",{key:0,class:"rg-editing-connect-ctrl",ref_key:"connectBoxRef",ref:t,style:r.normalizeStyle({transform:`translate(${e.value.nodeConnectController.x}px, ${e.value.nodeConnectController.y}px)`,width:e.value.nodeConnectController.width+"px",height:e.value.nodeConnectController.height+"px"})},[r.renderSlot(s.$slots,"default",{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:o},()=>[r.createVNode(kt,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:o})])],4)):r.createCommentVNode("",!0)}}),wi=r.defineComponent({__name:"RGConnectSource",props:{lineTemplate:{}},emits:["onConnectStart","onLineConnectEnd"],setup(l,{emit:i}){const e=H(),t=l,n=i,o=a=>{a.stopPropagation()},s=a=>{a.stopPropagation(),n("onConnectStart",t.lineTemplate,a),e.startCreateLineFromNode(null,t.lineTemplate||{},a,(d,h,c)=>{n("onLineConnectEnd",d,h,c),e.defaultLineConnectEndHandler(d,h,c)})};return(a,d)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["rg-connect-source-handle",["rg-connect-ctl-handler","rg-connect-target",a.$attrs.className]]),style:r.normalizeStyle(a.$attrs.style),onMousedown:d[0]||(d[0]=h=>s(h)),onClick:o},[r.renderSlot(a.$slots,"default")],38))}}),_i=["data-point","data-target-id","data-target-type","data-target-data"],Ni=["data-point","data-target-id","data-target-type","data-target-data"],bi=r.defineComponent({__name:"RGConnectTarget",props:{junctionPoint:{},targetId:{},targetType:{},targetData:{},lineTemplate:{},disableDrop:{type:Boolean},disableDrag:{type:Boolean},forSvg:{type:Boolean}},emits:["onLineVertexBeDropped","onDragConnectStart","onDragConnectEnd"],setup(l,{emit:i}){const e=H(),t=l,n=i,o=r.ref();r.onMounted(()=>{e.registerConnectTarget(o.value,t.targetId,t.targetType||D.NodePoint,t.junctionPoint,t.targetData)}),r.onUnmounted(()=>{e.unregisterConnectTarget(t.targetId)});const s=h=>{h.stopPropagation()},a=(h,c)=>{c.stopPropagation(),!t.disableDrop&&e.onLineVertexBeDropped(h,c,void 0,(f,p,m)=>{n("onLineVertexBeDropped",f,p,m)})},d=h=>{if(h.stopPropagation(),t.disableDrag||e.options.creatingLinePlot)return;const c=Object.assign({},t.lineTemplate||{});c.from||(c.from=t.targetId),c.fromType||(c.fromType=t.targetType||D.NodePoint),c.fromJunctionPoint||(c.fromJunctionPoint=t.junctionPoint),n("onDragConnectStart",c,h),e.startCreateLineFromNode(null,c,h,(f,p,m)=>{n("onDragConnectEnd",f,p,m)})};return(h,c)=>h.forSvg?(r.openBlock(),r.createElementBlock("g",{key:0,ref_key:"targetRef",ref:o,class:r.normalizeClass(["rg-connect-ctl-handler","rg-connect-target",h.$attrs.className]),style:r.normalizeStyle(h.$attrs.style),"data-point":h.junctionPoint||r.unref(W).border,"data-target-id":h.targetId,"data-target-type":h.targetType||r.unref(D).NodePoint,"data-target-data":JSON.stringify(h.targetData||{}),onMousedown:d,onMouseup:c[0]||(c[0]=f=>a(h.junctionPoint,f)),onClick:s},[r.renderSlot(h.$slots,"default")],46,_i)):(r.openBlock(),r.createElementBlock("div",{key:1,ref_key:"targetRef",ref:o,class:r.normalizeClass(["rg-connect-ctl-handler","rg-connect-target",h.$attrs.className]),style:r.normalizeStyle(h.$attrs.style),"data-point":h.junctionPoint||r.unref(W).border,"data-target-id":h.targetId,"data-target-type":h.targetType||r.unref(D).NodePoint,"data-target-data":JSON.stringify(h.targetData||{}),onMousedown:d,onMouseup:c[1]||(c[1]=f=>a(h.junctionPoint,f)),onClick:s},[r.renderSlot(h.$slots,"default")],46,Ni))}}),ki={class:"rg-editing-referline"},Oi={class:"referline"},Pi={key:0},Ti={class:"referline"},Si={key:0},Ri=r.defineComponent({__name:"RGEditingReferenceLine",props:{showText:{type:Boolean},adsorption:{type:Boolean}},setup(l){const i=H(),e=l,t=r.computed(()=>i.dataStores.optionsRef.value);return r.onMounted(()=>{i.onReferenceLineMounted(e.adsorption)}),r.onUnmounted(()=>{i.onReferenceLineUnMounted()}),(n,o)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",ki,[r.withDirectives(r.createElementVNode("div",{class:"rg-referline rg-referline-v",style:r.normalizeStyle({transform:`translate(var(--rg-refer-offset), 0px) translate(${t.value.editingReferenceLine.v_x}px, ${t.value.editingReferenceLine.v_y}px)`,height:t.value.editingReferenceLine.v_height+"px"})},[r.createElementVNode("div",Oi,[n.showText!==!1?(r.openBlock(),r.createElementBlock("div",Pi,r.toDisplayString(Math.round(t.value.editingReferenceLine.v_height))+"px",1)):r.createCommentVNode("",!0)])],4),[[r.vShow,t.value.editingReferenceLine.directionV]]),r.withDirectives(r.createElementVNode("div",{class:"rg-referline rg-referline-h",style:r.normalizeStyle({transform:`translate(0px, var(--rg-refer-offset)) translate(${t.value.editingReferenceLine.h_x}px, ${t.value.editingReferenceLine.h_y}px)`,width:t.value.editingReferenceLine.h_width+"px"})},[r.createElementVNode("div",Ti,[n.showText!==!1?(r.openBlock(),r.createElementBlock("div",Si,r.toDisplayString(Math.round(t.value.editingReferenceLine.h_width))+"px",1)):r.createCommentVNode("",!0)])],4),[[r.vShow,t.value.editingReferenceLine.directionH]])],512)),[[r.vShow,t.value.editingReferenceLine.show]])}});function Mi(){const l=H();if(!l)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return{optionsRef:l.dataStores.optionsRef}}function pe(){const l=H();if(!l)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return l.dataStores.optionsRef}function Ei(){const l=H();if(!l)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");const i=l.dataStores.optionsRef;return r.computed(()=>l.getCreatingLine(i.value))}function Ii(){const l=H();if(!l)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");const i=l.dataStores.optionsRef;return r.computed(()=>l.getCreatingNode(i.value))}function Di(){const l=pe();return r.computed(()=>l.value.editingController)}function Vi(){const l=pe();return r.computed(()=>l.value.editingLineController)}function Bi(){const l=pe();return r.computed(()=>l.value.nodeConnectController)}function Ai(){const l=pe();return r.computed(()=>({viewSize:l.value.viewSize,canvasSize:l.value.canvasSize,canvasOffset:l.value.canvasOffset,canvasZoom:l.value.canvasZoom,fullscreen:l.value.fullscreen,showEasyView:l.value.showEasyView}))}function zi(){const l=pe();return r.computed(()=>({...l.value.selectionView,show:l.value.creatingSelection}))}function Xi(){const l=pe();return r.computed(()=>({checkedLineId:l.value.checkedLineId,checkedNodeId:l.value.checkedNodeId,draggingNodeId:l.value.draggingNodeId}))}function Gi(){const l=H();if(!l)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return{optionsRef:l.dataStores.optionsRef,shouldRenderNodesRef:l.dataStores.shouldRenderNodesRef,shouldRenderLinesRef:l.dataStores.shouldRenderLinesRef,shouldRenderFakeLinesRef:l.dataStores.shouldRenderFakeLinesRef}}const Ot={useGraphInstance:H,useRelationGraph:Nt,useGraphStore:Mi,useGraphData:Gi,useGraphOptions:pe,useCreatingLine:Ei,useCreatingNode:Ii,useEditingNodes:Di,useEditingLine:Vi,useViewInformation:Ai,useSelection:zi,useConnectingNode:Bi,useCheckedItem:Xi},Fi=We,Hi={BaseLayout:fe,BidirectionalTreeLayout:lt,CenterLayout:dt,CircleLayout:ct,FixedLayout:ht,ForceLayout:ke,RGFolderLayout:ft},$i={RGOptionsDataUtils:no,RGLineDataUtils:Sn,RGNodeDataUtils:Pn,RGGraphMath:j,RGNodesAnalyticUtils:Le,RGEffectUtils:le},Yi=Qo,Wi=et,Ui=Qe,Ji=ti,ji=oi,qi=je,Zi=st,Ki=ci,Qi=ii,es=si,ts=ai,ns=li,os=hi,is=Ci,ss=Li,as=wi,rs=bi,ls=kt,ds=Ri,cs=Ot,hs=Ot.useRelationGraph,fs=qo,ps=jo;Ye.install=l=>{l.component("RelationGraph",Ye)};const Pt=Ye,us=Pt;B.INSTALLED_KEY=Tt,B.RGBackground=Qi,B.RGConnectSource=as,B.RGConnectTarget=rs,B.RGDebugView=Ji,B.RGDirection=Ke,B.RGEditingConnectController=ss,B.RGEditingConnectPoints=ls,B.RGEditingLineController=is,B.RGEditingNearNodeWidget=os,B.RGEditingNodeController=ts,B.RGEditingReferenceLine=ds,B.RGEditingResize=ns,B.RGEventNames=I,B.RGEventsDefine4Vue3=$e,B.RGFakeNode=Yi,B.RGHooks=cs,B.RGInnerConnectTargetType=D,B.RGJunctionPoint=W,B.RGLayouts=Hi,B.RGLinePath=Wi,B.RGLineShape=Y,B.RGLineText=Ui,B.RGMiniToolBar=Zi,B.RGMiniView=Ki,B.RGNodeExpandHolder=qi,B.RGNodeShape=xe,B.RGProvider=fs,B.RGToolBar=ji,B.RGUtils=$i,B.RGWatermark=es,B.RelationGraph=Pt,B.RelationGraphCore=Lt,B.RelationGraphProvideKey=ye,B.RelationLinker=ps,B.default=us,B.useRelationGraph=hs,B.version=Fi,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
215
|
+
`,cn={Vue3GetInstance:Oe(xs),ReactGetInstance:Oe(Cs),Vue2GetInstance:Oe(vs),setJsonData:Oe(ws),setJsonData4Vue2:Oe(Ls)},it=l.defineComponent({name:"RelationGraph",props:{options:{required:!1,type:Object},initialData:{required:!1,type:Object},relationGraphCore:{required:!1,type:Function}},emits:ot,setup(s,{slots:o,emit:e,expose:t,attrs:n}){const{RelationGraph:i,graphInstance:a}=dn({relationGraphCore:s.relationGraphCore});if(o["graph-plug"])throw new Error('Slot name "#graph-plug" has been renamed to "#view". Please update your code accordingly.');if(o["canvas-plug"])throw new Error('Slot name "#canvas-plug" has been renamed to "#canvas". Please update your code accordingly.');if(o["canvas-plug-above"])throw new Error('Slot name "#canvas-plug-above" has been renamed to "#canvas-above". Please update your code accordingly.');if(o["node-expand-holder"])throw new Error('Slot name "#node-expand-holder" has been renamed to "#node-expand-button". Please update your code accordingly.');return t({getInstance(){var r;return(r=s.options)!=null&&r.definitelyNoDataProviderNeeded||console.warn("[relation-graph]",cn.Vue3GetInstance),a},async setJsonData(){throw new Error(cn.setJsonData)}}),()=>l.h(i,{options:s.options,initialData:s.initialData,emitProxy:e},{...o})}}),_s={class:"rg-canvas-slot rg-canvas-slot-behind",style:{position:"relative","pointer-events":"all","user-select":"text"}},bs=l.defineComponent({__name:"RelationLinkerCanvas",setup(s){const o=l.ref(),e=$(),t=l.computed(()=>e.dataStores.optionsRef.value),n=l.computed(()=>({"background-color":"transparent","text-wrap":"unset",position:"relative",width:"100%",height:"fit-content"}));return l.onMounted(()=>{w("[RGCanvas mounted]"),e.setCanvasDom(o.value)}),(i,a)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-map",[t.value.canvasOpacity===1&&"rg-map-ready"]])},[l.createElementVNode("div",{style:l.normalizeStyle(n.value),class:"rg-map-canvas rg-canvas-behind"},[l.createElementVNode("div",_s,[l.renderSlot(i.$slots,"canvas-behind")])],4),l.createElementVNode("div",{ref_key:"rgCanvasRef",ref:o,style:l.normalizeStyle([n.value,{position:"absolute",left:"0px",top:"0px","z-index":"9"}]),class:"rg-map-canvas"},[l.createVNode(mt,{"show-easy-view":t.value.showEasyView,"creating-line":!!(t.value.creatingLinePlot&&t.value.newLinkTemplate.fromNode),"default-expand-holder-position":t.value.defaultExpandHolderPosition,draggingNodeId:t.value.draggingNodeId,checkedNodeId:t.value.checkedNodeId,defaultLineTextOnPath:t.value.defaultLineTextOnPath,"checked-line-id":t.value.checkedLineId,"graph-instance-id":t.value.instanceId},{line:l.withCtx(r=>[l.renderSlot(i.$slots,"line",l.normalizeProps(l.guardReactiveProps(r)))]),_:3},8,["show-easy-view","creating-line","default-expand-holder-position","draggingNodeId","checkedNodeId","defaultLineTextOnPath","checked-line-id","graph-instance-id"])],4)],2))}}),Ns=["id"],Ts={class:"rg-graph-plugs"},ks={class:"rg-view-slot"},Ps=l.defineComponent({__name:"RelationLinkerUI",setup(s){const o=$(),e=l.ref(),t=l.computed(()=>o.dataStores.optionsRef.value),n=l.ref(!1);return l.onMounted(()=>{o.setDom(e.value),n.value=!0}),l.onBeforeUnmount(()=>{o.beforeUnmount()}),(i,a)=>{var r,d,c,h,f,u,y,p,g;return l.openBlock(),l.createElementBlock("div",{ref_key:"relationGraphRef$",ref:e,id:"relation-graph-ins-"+((r=t.value)==null?void 0:r.instanceId),tabindex:"1",class:l.normalizeClass(["relation-graph",t.value&&t.value.creatingLinePlot?"rg-creating-line":""]),style:l.normalizeStyle({width:"100%",height:"fit-content",opacity:n.value?1:0,"--rg-checked-item-bg-color":(d=t.value)==null?void 0:d.checkedItemBackgroundColor,"--rg-background-color":(c=t.value)==null?void 0:c.backgroundColor,"--rg-node-color":(h=t.value)==null?void 0:h.defaultNodeColor,"--rg-node-border-color":(f=t.value)==null?void 0:f.defaultNodeBorderColor,"--rg-node-border-width":((u=t.value)==null?void 0:u.defaultNodeBorderWidth)+"px","--rg-node-border-radius":((y=t.value)==null?void 0:y.defaultNodeBorderRadius)+"px","--rg-line-color":(p=t.value)==null?void 0:p.defaultLineColor,"--rg-line-width":((g=t.value)==null?void 0:g.defaultLineWidth)+"px"})},[t.value&&n.value?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[l.createVNode(bs,null,{line:l.withCtx(m=>[l.renderSlot(i.$slots,"line",l.normalizeProps(l.guardReactiveProps(m)))]),"canvas-behind":l.withCtx(()=>[l.renderSlot(i.$slots,"default")]),_:3}),l.createVNode(yt),l.createElementVNode("div",Ts,[l.createElementVNode("div",ks,[l.renderSlot(i.$slots,"view")])])],64)):l.createCommentVNode("",!0)],14,Ns)}}});function Es(s,{options:o,emitProxy:e}){return l.defineComponent({name:"RelationLinkerUIFrame",props:{lines:{type:Array,required:!0}},setup(t,{slots:n}){const i=e!=null?e:l.defineEmits();s.setEventEmitHook((r,...d)=>{i(r,...d)});const a=async r=>{r&&(s.clearGraph(),s.addFakeLines(r))};return l.watch(()=>t.lines,async r=>{await a(r)},{deep:!0}),l.onMounted(()=>{rt("Vue-Linker"),s.ready(),t.lines&&a(t.lines)}),l.onBeforeUnmount(()=>{s.beforeUnmount()}),()=>l.h(Ps,{},n)}})}function Ss({relationGraphCore:s,options:o,emitProxy:e}={}){const t=ln(s,!0),n=nt(t),i=Es(t,{options:o,emitProxy:e}),a=l.defineComponent({name:"RelationLinker",props:{lines:{type:Array,required:!0}},setup(r,{attrs:d,slots:c}){return l.onMounted(()=>{}),()=>l.h(n,{},{default:()=>l.h(i,r,c)})}});return{RGProvider:n,RelationLinker:a,VueLinker:a,graphInstance:t}}const Os=l.defineComponent({__name:"RelationLinker",props:{options:{},lines:{},relationGraphCore:{}},emits:["onReady","onNodeClick","onNodeExpand","onNodeCollapse","onLineClick","onNodeDragStart","onNodeDragEnd","onNodeDragging","onCanvasDragEnd","onCanvasDragging","onContextmenu","onFullscreen","onCanvasClick","onCanvasSelectionEnd","beforeZoomStart","onZoomEnd","onViewResize","onResizeStart","beforeNodeResize","onResizeEnd","onLineVertexDropped","beforeCreateLine","onLineBeCreated","beforeAddNodes","beforeAddLines","onKeyboardDown","onKeyboardUp","onCanvasDragStart","onForceLayoutFinish","beforeScrollStart"],setup(s,{emit:o}){const e=s,t=o,{RelationLinker:n}=Ss({options:e.options,relationGraphCore:e.relationGraphCore,emitProxy:t});return(i,a)=>(l.openBlock(),l.createBlock(l.unref(n),{lines:e.lines},{view:l.withCtx(()=>[l.renderSlot(i.$slots,"view")]),line:l.withCtx(r=>[l.renderSlot(i.$slots,"line",l.normalizeProps(l.guardReactiveProps(r)))]),default:l.withCtx(()=>[l.renderSlot(i.$slots,"default")]),_:3},8,["lines"]))}}),Rs=l.defineComponent({__name:"RGProvider",props:{relationGraphCore:{},forLinker:{type:Boolean}},setup(s){const o=s,e=rn(o.relationGraphCore,o.forLinker),t=nt(e);return(n,i)=>(l.openBlock(),l.createBlock(l.unref(t),null,{default:l.withCtx(()=>[l.renderSlot(n.$slots,"default")]),_:3}))}}),Ms=["data-id"],Is={class:"rg-node-text"},Ds=l.defineComponent({__name:"RGFakeNode",props:{node:{}},setup(s){const o=s,e=l.ref(),t=$(),n=l.computed(()=>t.dataStores.optionsRef.value),i=l.computed(()=>o.node.borderColor),a=l.computed(()=>n.value.draggingNodeId===o.node.id),r=l.computed(()=>o.node.borderWidth===void 0?void 0:o.node.borderWidth+"px"),d=l.computed(()=>o.node.width?o.node.width+"px":void 0),c=l.computed(()=>o.node.height?o.node.height+"px":void 0),h=f=>{t.onNodeDragStart(o.node,f)};return l.onMounted(()=>{t.addNodeResizeListener(e.value,o.node)}),l.onBeforeUnmount(()=>{t.removeNodeResizeListener(e.value)}),(f,u)=>(l.openBlock(),l.createElementBlock("div",{ref_key:"nodePeelRef",ref:e,style:l.normalizeStyle({left:f.node.x+"px",top:f.node.y+"px","--rg-node-z-index":f.node.zIndex?f.node.zIndex:void 0,"--rg-node-opacity":f.node.opacity>1?f.node.opacity/100:f.node.opacity,"pointer-events":f.node.opacity===0?"none":void 0,"--rg-node-color":f.node.color||n.value.defaultNodeColor,"--rg-node-font-color":f.node.fontColor,"--rg-node-font-size":f.node.fontSize?f.node.fontSize+"px":void 0,"--rg-node-border-width":r.value,"--rg-node-width":d.value,"--rg-node-height":c.value,"--rg-node-border-radius":f.node.borderRadius&&f.node.borderRadius+"px","--rg-node-border-color":i.value}),class:l.normalizeClass(["rg-node-peel",[f.node.selected&&"rg-node-selected",a.value&&"rg-node-dragging",f.node.id===n.value.checkedNodeId&&"rg-node-checked","rg-node-shape-"+(f.node.nodeShape===void 0?1:f.node.nodeShape),"rg-node-type-"+f.node.type,f.node.className]]),"data-id":f.node.id},[l.createElementVNode("div",{class:"rg-node",onMousedown:u[0]||(u[0]=l.withModifiers(y=>h(y),["left","stop"])),onTouchstart:u[1]||(u[1]=l.withModifiers(y=>h(y),["stop"]))},[l.renderSlot(f.$slots,"default",{},()=>[l.createElementVNode("div",Is,[l.createElementVNode("span",null,l.toDisplayString(f.node.text),1)])])],32)],14,Ms))}}),Bs={class:"c-debug-tools-row"},Vs=l.defineComponent({__name:"RGDebugView",setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=l.ref(!1),n=()=>{t.value=!t.value},i=()=>{o.printOptions()},a=()=>{o.printData()},r=()=>{o.enableDebugLog(!o.options.debug),w("debugLog:",o.options.debug)};return(d,c)=>(l.openBlock(),l.createElementBlock("div",null,[l.createElementVNode("div",{class:l.normalizeClass([[],"rg-setting-panel-button"]),onClick:n}," Debug "),t.value?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass([[],"rg-setting-panel"])},[l.createElementVNode("div",{class:"c-debug-tools-row"},[l.createElementVNode("button",{onClick:i},"print options in console")]),l.createElementVNode("div",{class:"c-debug-tools-row"},[l.createElementVNode("button",{onClick:a},"print json data in console")]),l.createElementVNode("div",Bs,[l.createTextVNode("debug log status: "+l.toDisplayString(e.value.debug)+" ",1),l.createElementVNode("button",{onClick:r},l.toDisplayString(e.value.debug?"disable":"enable")+" debug log",1)]),l.renderSlot(d.$slots,"default")])):l.createCommentVNode("",!0)]))}}),As=["title"],zs=l.defineComponent({__name:"GraphToolBar",props:{direction:{},positionH:{},positionV:{}},setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value);l.onMounted(()=>{});const t=()=>{o.refresh()},n=()=>{o.toggleAutoLayout()},i=async()=>{o.setZoom(100),o.moveToCenter(),o.enableCanvasAnimation(),o.zoomToFit(),setTimeout(()=>{o.disableCanvasAnimation()},300)},a=d=>{o.zoom(d)},r=()=>{o.fullscreen()};return(d,c)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-toolbar",["rg-toolbar-h-"+(d.positionH||e.value.toolBarPositionH),"rg-toolbar-v-"+(d.positionV||e.value.toolBarPositionV),"rg-toolbar-"+(d.direction||e.value.toolBarDirection)]])},[l.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:c[0]||(c[0]=h=>r())},[l.createVNode(Q,{"icon-name":"icon-quanping"})]),l.createElementVNode("div",{class:"rg-mb-button",onClick:c[1]||(c[1]=h=>a(20))},[l.createVNode(Q,{"icon-name":"icon-fangda"})]),l.createElementVNode("div",{class:"rg-current-zoom",onClick:i},l.toDisplayString(Math.round(e.value.canvasZoom))+"%",1),l.createElementVNode("div",{class:"rg-mb-button",style:{"margin-top":"0px"},onClick:c[2]||(c[2]=h=>a(-20))},[l.createVNode(Q,{"icon-name":"icon-suoxiao"})]),e.value.layout.supportAutoLayout?(l.openBlock(),l.createElementBlock("div",{key:0,title:e.value.layout.autoLayouting?"\u70B9\u51FB\u505C\u6B62\u81EA\u52A8\u5E03\u5C40":"\u70B9\u51FB\u5F00\u59CB\u81EA\u52A8\u8C03\u6574\u5E03\u5C40",class:l.normalizeClass([{"rg-mb-button-on":e.value.layout.autoLayouting},"rg-mb-button"]),onClick:n},[e.value.layout.autoLayouting?(l.openBlock(),l.createBlock(Q,{key:1,"icon-name":"icon-lianjiezhong","class-name":"rg-loading-icon"})):(l.openBlock(),l.createBlock(Q,{key:0,"icon-name":"icon-zidong"}))],10,As)):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"rg-mb-button",onClick:t},[l.createVNode(Q,{"icon-name":"icon-ico_reset"})]),l.renderSlot(d.$slots,"default"),c[3]||(c[3]=l.createElementVNode("div",{style:{clear:"both"}},null,-1))],2))}}),Xs=l.defineComponent({__name:"GraphBackground",props:{forImage:{type:Boolean,default:!0},forDisplay:{type:Boolean,default:!0}},setup(s){const o=$(),e=s;l.computed(()=>o.dataStores.optionsRef.value);const t=l.ref();return l.onMounted(()=>{o.setBackgroundDom(t.value,e.forImage,e.forDisplay)}),l.onUnmounted(()=>{o.setBackgroundDom(null,e.forImage,e.forDisplay)}),(n,i)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:"rg-background",ref_key:"$backgroundRef",ref:t},[l.renderSlot(n.$slots,"default")],512)),[[l.vShow,n.forDisplay!==!1]])}}),Fs=l.defineComponent({__name:"GraphWatermark",props:{forImage:{type:Boolean,default:!0},forDisplay:{type:Boolean,default:!1},position:{default:"br"},width:{},height:{}},setup(s){const o=$(),e=s,t=l.computed(()=>o.dataStores.optionsRef.value),n=l.computed(()=>{let a=!1;return t.value.snapshotting?e.forImage===!1?a=!1:a=!0:e.forDisplay===!0?a=!0:a=!1,a}),i=l.ref();return l.onMounted(()=>{o.setWatermarkDom(i.value,e.forImage,e.forDisplay,e.position)}),l.onUnmounted(()=>{o.setWatermarkDom(null,e.forImage,e.forDisplay)}),(a,r)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-watermark",["rg-watermark-"+(a.position||"br")]]),ref_key:"$watermarkRef",ref:i,style:l.normalizeStyle({"--watermark-width":a.width,"--watermark-height":a.height})},[l.renderSlot(a.$slots,"default")],6)),[[l.vShow,n.value]])}}),Gs=l.defineComponent({__name:"RGEditingNodeController",props:{hideBorderForSingleNode:{type:Boolean,default:!1}},setup(s){const o=s,e=$(),t=l.computed(()=>e.dataStores.optionsRef.value);return(n,i)=>t.value.editingController.show?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["rg-editing-ctrl",{"rg-ctrl-hide-border":o.hideBorderForSingleNode&&t.value.editingController.nodes.length===1}]),style:l.normalizeStyle({width:t.value.editingController.width+"px",height:t.value.editingController.height+"px",transform:`translate(${t.value.editingController.x}px, ${t.value.editingController.y}px)`})},[l.renderSlot(n.$slots,"default")],6)):l.createCommentVNode("",!0)}}),$s={class:"rg-resize-ctl"},Hs=l.defineComponent({__name:"RGEditingResize",props:{disableResizeWidth:{type:Boolean},disableResizeHeight:{type:Boolean}},emits:["beforeResizeStart"],setup(s,{emit:o}){const e=$(),t=o,n=l.computed(()=>e.dataStores.optionsRef.value),i=(a,r)=>{r.stopPropagation(),t("beforeResizeStart"),e.onResizeStart(a,r)};return(a,r)=>(l.openBlock(),l.createElementBlock("div",$s,[n.value.editingController.width>30&&!a.disableResizeWidth&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:0,class:"rg-resize-ctl-handler rg-resize-ctl-tl",onMousedown:r[0]||(r[0]=d=>i("tl",d))},null,32)):l.createCommentVNode("",!0),n.value.editingController.width>30&&!a.disableResizeWidth&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:1,class:"rg-resize-ctl-handler rg-resize-ctl-tr",onMousedown:r[1]||(r[1]=d=>i("tr",d))},null,32)):l.createCommentVNode("",!0),n.value.editingController.width>30&&!a.disableResizeWidth&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:2,class:"rg-resize-ctl-handler rg-resize-ctl-bl",onMousedown:r[2]||(r[2]=d=>i("bl",d))},null,32)):l.createCommentVNode("",!0),!a.disableResizeWidth&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:3,class:"rg-resize-ctl-handler rg-resize-ctl-br",onMousedown:r[3]||(r[3]=d=>i("br",d))},null,32)):l.createCommentVNode("",!0),(n.value.editingController.width>60||a.disableResizeWidth)&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:4,class:"rg-resize-ctl-handler rg-resize-ctl-t",onMousedown:r[4]||(r[4]=d=>i("t",d))},null,32)):l.createCommentVNode("",!0),(n.value.editingController.width>60||a.disableResizeWidth)&&!a.disableResizeHeight?(l.openBlock(),l.createElementBlock("div",{key:5,class:"rg-resize-ctl-handler rg-resize-ctl-b",onMousedown:r[5]||(r[5]=d=>i("b",d))},null,32)):l.createCommentVNode("",!0),(n.value.editingController.height>60||a.disableResizeHeight)&&!a.disableResizeWidth?(l.openBlock(),l.createElementBlock("div",{key:6,class:"rg-resize-ctl-handler rg-resize-ctl-l",onMousedown:r[6]||(r[6]=d=>i("l",d))},null,32)):l.createCommentVNode("",!0),(n.value.editingController.height>60||a.disableResizeHeight)&&!a.disableResizeWidth?(l.openBlock(),l.createElementBlock("div",{key:7,class:"rg-resize-ctl-handler rg-resize-ctl-r",onMousedown:r[7]||(r[7]=d=>i("r",d))},null,32)):l.createCommentVNode("",!0)]))}}),Ys={class:"rg-miniview-container"},Ws=l.defineComponent({__name:"RGMiniView",props:{position:{},width:{},height:{},className:{}},setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=l.ref(),n=l.ref();l.onMounted(()=>{o.onMiniViewMounted(),o.setMiniViewCanvas(n.value)}),l.onUnmounted(()=>{o.onMiniViewUnMounted()});const i=r=>{o.onVisibleViewHandleDragStart(r)},a=r=>{o.resetByVisiableView(r)};return(r,d)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-miniview",["rg-miniview-"+(r.position||"br"),r.$attrs.className]]),ref_key:"$rgMiniView",ref:t,style:l.normalizeStyle({...r.$attrs.style,"--miniview-width":r.width,"--miniview-height":r.height})},[l.createElementVNode("div",Ys,[l.createElementVNode("canvas",{ref_key:"$rgMiniViewCanvas",ref:n,class:l.normalizeClass({"rg-mv-canvas-reset":e.value.miniViewVisibleHandle.emptyContent}),onClick:a},null,2),l.createElementVNode("div",{class:"rg-mv-visible-area",onMousedown:i,style:l.normalizeStyle({transform:`translate(${e.value.miniViewVisibleHandle.x}px, ${e.value.miniViewVisibleHandle.y}px)`,width:e.value.miniViewVisibleHandle.width+"px",height:e.value.miniViewVisibleHandle.height+"px"})},null,36)])],6))}}),Us=l.defineComponent({__name:"RGEditingNearNodeWidget",props:{position:{}},setup(s){return(o,e)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-editing-bar",["rg-editing-bar-"+(o.position||"top")]])},[l.renderSlot(o.$slots,"default")],2))}}),js={key:0,class:"rg-editing-line-ctrl"},Js={key:0,class:"rg-edt-ctrl-svg",xmlns:"http://www.w3.org/2000/svg"},qs=["d"],Zs=["d"],Ks=["onMousedown","onTouchstart"],Qs={key:0},ea={key:1,class:"empty-text"},ta=["value"],na=l.defineComponent({__name:"RGEditingLineController",props:{textEditable:{type:Boolean,default:!0},pathEditable:{type:Boolean,default:!0}},emits:["onMoveLineVertexStart","onMoveLineVertexEnd","onLinePathChanged","onLineTextDragEnd","onLineTextChanged"],setup(s,{emit:o}){const e=$(),t=l.computed(()=>e.dataStores.optionsRef.value),n=l.computed(()=>t.value.editingLineController),i=l.computed(()=>n.value.line),a=l.computed(()=>{var N;return(N=n.value.line)==null?void 0:N.lineShape}),r=l.computed(()=>n.value.ctrlPoint1),d=l.computed(()=>n.value.ctrlPoint2),c=l.computed(()=>`M ${n.value.startPoint.x} ${n.value.startPoint.y} L ${r.value.x} ${r.value.y}`),h=l.computed(()=>`M ${n.value.endPoint.x} ${n.value.endPoint.y} L ${d.value.x} ${d.value.y}`),f=l.computed(()=>n.value.line44Splits),u=l.computed(()=>i.value&&i.value.text),y=l.ref(""),p=l.ref(!1);let g=l.ref(0);const m=o;l.watch(u,N=>{N!==y.value&&(y.value=N,l.nextTick(()=>{e.updateEditingLineView()}))}),l.watch(a,N=>{l.nextTick(()=>{e.updateEditingLineView()})});const v=(N,b)=>{e.startMoveLine6CtrlPoint(N,b,k=>{m("onLinePathChanged",k,N)})},x=(N,b)=>{e.startMoveLine44CtrlPoint(N,b,k=>{m("onLinePathChanged",k,N)})},L=(N,b)=>{const k=t.value.editingLineController.line;m("onMoveLineVertexStart",N,k),e.startMoveLineVertex(N,b,(O,S,R)=>{m("onMoveLineVertexEnd",O,S,R),e.defaultLineVertexBeChangedHandler(O,S,R)})},P=N=>{e.startMoveLineText(N,()=>{const b=t.value.editingLineController.line;m("onLineTextDragEnd",b)})},E=N=>{g.value&&Date.now()-g.value<500&&(p.value=!0,l.nextTick(()=>{N.target.focus()})),g.value=Date.now()},T=N=>{const b=i.value;b&&b.text!==N.target.value&&(e.updateLine(b.id,{text:N.target.value}),m("onLineTextChanged",b)),p.value=!1};return(N,b)=>n.value.show?(l.openBlock(),l.createElementBlock("div",js,[l.renderSlot(N.$slots,"default"),N.pathEditable?(l.openBlock(),l.createElementBlock("svg",Js,[l.createElementVNode("g",null,[i.value.lineShape===6&&r.value?(l.openBlock(),l.createElementBlock("path",{key:0,d:c.value},null,8,qs)):l.createCommentVNode("",!0),i.value.lineShape===6&&d.value?(l.openBlock(),l.createElementBlock("path",{key:1,d:h.value},null,8,Zs)):l.createCommentVNode("",!0)])])):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"rg-line-ctrl-dot start-dot",style:l.normalizeStyle({"--rg-ctl-x":n.value.startPoint.x+"px","--rg-ctl-y":n.value.startPoint.y+"px"}),onMousedown:b[0]||(b[0]=l.withModifiers(k=>L("start",k),["left"])),onTouchstart:b[1]||(b[1]=k=>L("start",k))},null,36),l.createElementVNode("div",{class:"rg-line-ctrl-dot end-dot",style:l.normalizeStyle({"--rg-ctl-x":n.value.endPoint.x+"px","--rg-ctl-y":n.value.endPoint.y+"px"}),onMousedown:b[2]||(b[2]=l.withModifiers(k=>L("end",k),["left"])),onTouchstart:b[3]||(b[3]=k=>L("end",k))},null,36),N.pathEditable&&i.value.lineShape===6&&r.value?(l.openBlock(),l.createElementBlock("div",{key:1,class:"rg-line-ctrl-dot ctrl-dot",style:l.normalizeStyle({"--rg-ctl-x":r.value.x+"px","--rg-ctl-y":r.value.y+"px"}),onMousedown:b[4]||(b[4]=l.withModifiers(k=>v(0,k),["left"])),onTouchstart:b[5]||(b[5]=k=>v(0,k))},null,36)):l.createCommentVNode("",!0),N.pathEditable&&i.value.lineShape===6&&d.value?(l.openBlock(),l.createElementBlock("div",{key:2,class:"rg-line-ctrl-dot ctrl-dot",style:l.normalizeStyle({"--rg-ctl-x":d.value.x+"px","--rg-ctl-y":d.value.y+"px"}),onMousedown:b[6]||(b[6]=l.withModifiers(k=>v(1,k),["left"])),onTouchstart:b[7]||(b[7]=k=>v(1,k))},null,36)):l.createCommentVNode("",!0),N.pathEditable&&(i.value.lineShape===44||i.value.lineShape===49)?(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:3},l.renderList(f.value,k=>(l.openBlock(),l.createElementBlock(l.Fragment,null,[k.hide?l.createCommentVNode("",!0):(l.openBlock(),l.createElementBlock("div",{key:k.optionName,class:l.normalizeClass(["rg-line-ctrl-dot ctrl-split",{"ctrl-split-core":!k.optionName.startsWith("cp-"),"ctrl-split-v":k.direction==="v","ctrl-split-h":k.direction==="h"}]),style:l.normalizeStyle({"--rg-ctl-x":k.x+"px","--rg-ctl-y":k.y+"px"}),onMousedown:l.withModifiers(O=>x(k,O),["left"]),onTouchstart:O=>x(k,O)},null,46,Ks))],64))),256)):l.createCommentVNode("",!0),N.textEditable&&i.value?(l.openBlock(),l.createElementBlock("div",{key:4,class:l.normalizeClass(["rg-line-ctrl-text",p.value&&"rg-line-ctrl-text-editing"]),style:l.normalizeStyle({"--rg-ctl-x":n.value.text.x+"px","--rg-ctl-y":n.value.text.y+"px"}),onClick:E,onMousedown:b[8]||(b[8]=k=>P(k)),onTouchstart:b[9]||(b[9]=k=>P(k))},[p.value?(l.openBlock(),l.createElementBlock("input",{key:1,ref:"inputRef",class:"rg-line-text-input",value:y.value,onBlur:T},null,40,ta)):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[y.value?(l.openBlock(),l.createElementBlock("p",Qs,l.toDisplayString(y.value),1)):(l.openBlock(),l.createElementBlock("p",ea,"Add Text..."))],64))],38)):l.createCommentVNode("",!0)])):l.createCommentVNode("",!0)}}),hn=l.defineComponent({__name:"RGEditingConnectPoints",props:{mouseUpOnJunctionPoint:{type:Function},mouseUpOnJunctionPointWithOffset:{type:Function}},setup(s){return(o,e)=>(l.openBlock(),l.createElementBlock("div",{class:"rg-connect-ctl",onMouseup:e[15]||(e[15]=t=>o.mouseUpOnJunctionPointWithOffset("",t)),onTouchend:e[16]||(e[16]=t=>o.mouseUpOnJunctionPointWithOffset("",t))},[l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-t","data-point":"top",onMouseup:e[0]||(e[0]=t=>o.mouseUpOnJunctionPoint("top",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-b","data-point":"bottom",onMouseup:e[1]||(e[1]=t=>o.mouseUpOnJunctionPoint("bottom",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-center","data-point":"border",onMouseup:e[2]||(e[2]=t=>o.mouseUpOnJunctionPoint("border",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-l","data-point":"left",onMouseup:e[3]||(e[3]=t=>o.mouseUpOnJunctionPoint("left",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-r","data-point":"right",onMouseup:e[4]||(e[4]=t=>o.mouseUpOnJunctionPoint("right",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-lr","data-point":"lr",onMouseup:e[5]||(e[5]=t=>o.mouseUpOnJunctionPoint("lr",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-tb","data-point":"tb",onMouseup:e[6]||(e[6]=t=>o.mouseUpOnJunctionPoint("tb",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-bottom-bar","data-point":"bottom","data-innode":"true",onMouseup:e[7]||(e[7]=t=>o.mouseUpOnJunctionPointWithOffset("bottom",t)),onTouchend:e[8]||(e[8]=t=>o.onMouseUpWithOffset("bottom",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-top-bar","data-point":"top","data-innode":"true",onMouseup:e[9]||(e[9]=t=>o.mouseUpOnJunctionPointWithOffset("top",t)),onTouchend:e[10]||(e[10]=t=>o.onMouseUpWithOffset("top",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-left-bar","data-point":"left","data-innode":"true",onMouseup:e[11]||(e[11]=t=>o.mouseUpOnJunctionPointWithOffset("left",t)),onTouchend:e[12]||(e[12]=t=>o.onMouseUpWithOffset("left",t))},null,32),l.createElementVNode("div",{class:"rg-connect-ctl-handler rg-connect-ctl-handler-style rg-connect-ctl-right-bar","data-point":"right","data-innode":"true",onMouseup:e[13]||(e[13]=t=>o.mouseUpOnJunctionPointWithOffset("right",t)),onTouchend:e[14]||(e[14]=t=>o.onMouseUpWithOffset("right",t))},null,32)],32))}}),oa=l.defineComponent({__name:"RGEditingConnectController",setup(s){const o=$(),e=l.computed(()=>o.dataStores.optionsRef.value),t=l.ref(),n=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,void 0,(d,c,h)=>{w("onLineVertexBeDropped:callback:",h)})},i=(a,r)=>{o.onLineVertexBeDroppedOnConnectController(a,r,t.value,(d,c,h)=>{w("onLineVertexBeDropped:callback:",h)})};return(a,r)=>e.value.nodeConnectController.show?(l.openBlock(),l.createElementBlock("div",{key:0,class:"rg-editing-connect-ctrl",ref_key:"connectBoxRef",ref:t,style:l.normalizeStyle({transform:`translate(${e.value.nodeConnectController.x}px, ${e.value.nodeConnectController.y}px)`,width:e.value.nodeConnectController.width+"px",height:e.value.nodeConnectController.height+"px"})},[l.renderSlot(a.$slots,"default",{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:i},()=>[l.createVNode(hn,{mouseUpOnJunctionPoint:n,mouseUpOnJunctionPointWithOffset:i})])],4)):l.createCommentVNode("",!0)}}),ia=l.defineComponent({__name:"RGConnectSource",props:{lineTemplate:{}},emits:["onConnectStart","onLineConnectEnd"],setup(s,{emit:o}){const e=$(),t=s,n=o,i=r=>{r.stopPropagation()},a=r=>{r.stopPropagation(),n("onConnectStart",t.lineTemplate,r),e.startCreateLineFromNode(null,t.lineTemplate||{},r,(d,c,h)=>{n("onLineConnectEnd",d,c,h),e.defaultLineConnectEndHandler(d,c,h)})};return(r,d)=>(l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(["rg-connect-source-handle",["rg-connect-ctl-handler","rg-connect-target",r.$attrs.className]]),style:l.normalizeStyle(r.$attrs.style),onMousedown:d[0]||(d[0]=c=>a(c)),onClick:i},[l.renderSlot(r.$slots,"default")],38))}}),sa=["data-point"],aa=["data-point"],ra=l.defineComponent({__name:"RGConnectTarget",props:{junctionPoint:{},targetId:{},targetType:{},targetData:{},lineTemplate:{},disableDrop:{type:Boolean},disableDrag:{type:Boolean},forSvg:{type:Boolean},domMode:{},measureSelector:{},strictMeasureTarget:{type:Boolean}},emits:["onLineVertexBeDropped","onDragConnectStart","onDragConnectEnd"],setup(s,{emit:o}){const e=$(),t=l.useAttrs(),n=s,i=o,a=l.ref(),r=l.computed(()=>n.junctionPoint||Y.border),d=l.computed(()=>!n.forSvg&&n.domMode==="contents"?"contents":"wrap"),c=l.computed(()=>d.value==="contents"?[t.style,{display:"contents"}]:t.style),h=()=>{!a.value||e.registerConnectTarget({hostEl:a.value,targetId:n.targetId,targetType:n.targetType||I.NodePoint,junctionPoint:r.value,targetData:n.targetData,domMode:d.value,measureSelector:n.measureSelector,strictMeasureTarget:n.strictMeasureTarget})};l.onMounted(()=>{h()}),l.watch(()=>[n.targetId,n.targetType,n.junctionPoint,n.targetData,n.domMode,n.measureSelector,n.strictMeasureTarget,n.forSvg],([p],g)=>{const m=g==null?void 0:g[0];m&&m!==p&&e.unregisterConnectTarget(m),h()},{deep:!0}),l.onUnmounted(()=>{e.unregisterConnectTarget(n.targetId)});const f=p=>{p.stopPropagation()},u=(p,g)=>{g.stopPropagation(),!n.disableDrop&&e.onLineVertexBeDropped(p,g,void 0,(m,v,x)=>{i("onLineVertexBeDropped",m,v,x)})},y=p=>{var v;if(p.stopPropagation(),n.disableDrag||e.options.creatingLinePlot)return;const g=Object.assign({},n.lineTemplate||{}),m=((v=e.getConnectTargetById(n.targetId))==null?void 0:v.targetType)||n.targetType||I.NodePoint;g.from||(g.from=n.targetId),g.fromType||(g.fromType=m),g.fromJunctionPoint||(g.fromJunctionPoint=r.value),i("onDragConnectStart",g,p),e.startCreateLineFromNode(null,g,p,(x,L,P)=>{i("onDragConnectEnd",x,L,P)})};return(p,g)=>p.forSvg?(l.openBlock(),l.createElementBlock("g",{key:0,ref_key:"targetRef",ref:a,class:l.normalizeClass(["rg-connect-ctl-handler","rg-connect-target",l.unref(t).className]),style:l.normalizeStyle(l.unref(t).style),"data-point":r.value,onMousedown:y,onMouseup:g[0]||(g[0]=m=>u(r.value,m)),onClick:f},[l.renderSlot(p.$slots,"default")],46,sa)):(l.openBlock(),l.createElementBlock("div",{key:1,ref_key:"targetRef",ref:a,class:l.normalizeClass(["rg-connect-ctl-handler","rg-connect-target",l.unref(t).className]),style:l.normalizeStyle(c.value),"data-point":r.value,onMousedown:y,onMouseup:g[1]||(g[1]=m=>u(r.value,m)),onClick:f},[l.renderSlot(p.$slots,"default")],46,aa))}}),la={class:"rg-editing-referline"},da={class:"referline"},ca={key:0},ha={class:"referline"},fa={key:0},ua=l.defineComponent({__name:"RGEditingReferenceLine",props:{showText:{type:Boolean},adsorption:{type:Boolean}},setup(s){const o=$(),e=s,t=l.computed(()=>o.dataStores.optionsRef.value);return l.onMounted(()=>{o.onReferenceLineMounted(e.adsorption)}),l.onUnmounted(()=>{o.onReferenceLineUnMounted()}),(n,i)=>l.withDirectives((l.openBlock(),l.createElementBlock("div",la,[l.withDirectives(l.createElementVNode("div",{class:"rg-referline rg-referline-v",style:l.normalizeStyle({transform:`translate(var(--rg-refer-offset), 0px) translate(${t.value.editingReferenceLine.v_x}px, ${t.value.editingReferenceLine.v_y}px)`,height:t.value.editingReferenceLine.v_height+"px"})},[l.createElementVNode("div",da,[n.showText!==!1?(l.openBlock(),l.createElementBlock("div",ca,l.toDisplayString(Math.round(t.value.editingReferenceLine.v_height))+"px",1)):l.createCommentVNode("",!0)])],4),[[l.vShow,t.value.editingReferenceLine.directionV]]),l.withDirectives(l.createElementVNode("div",{class:"rg-referline rg-referline-h",style:l.normalizeStyle({transform:`translate(0px, var(--rg-refer-offset)) translate(${t.value.editingReferenceLine.h_x}px, ${t.value.editingReferenceLine.h_y}px)`,width:t.value.editingReferenceLine.h_width+"px"})},[l.createElementVNode("div",ha,[n.showText!==!1?(l.openBlock(),l.createElementBlock("div",fa,l.toDisplayString(Math.round(t.value.editingReferenceLine.h_width))+"px",1)):l.createCommentVNode("",!0)])],4),[[l.vShow,t.value.editingReferenceLine.directionH]])],512)),[[l.vShow,t.value.editingReferenceLine.show]])}});function pa(){const s=$();if(!s)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return{optionsRef:s.dataStores.optionsRef}}function me(){const s=$();if(!s)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return s.dataStores.optionsRef}function ga(){const s=$();if(!s)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");const o=s.dataStores.optionsRef;return l.computed(()=>s.getCreatingLine(o.value))}function ma(){const s=$();if(!s)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");const o=s.dataStores.optionsRef;return l.computed(()=>s.getCreatingNode(o.value))}function ya(){const s=me();return l.computed(()=>s.value.editingController)}function va(){const s=me();return l.computed(()=>s.value.editingLineController)}function xa(){const s=me();return l.computed(()=>s.value.nodeConnectController)}function Ca(){const s=me();return l.computed(()=>({viewSize:s.value.viewSize,canvasSize:s.value.canvasSize,canvasOffset:s.value.canvasOffset,canvasZoom:s.value.canvasZoom,fullscreen:s.value.fullscreen,showEasyView:s.value.showEasyView}))}function wa(){const s=me();return l.computed(()=>({...s.value.selectionView,show:s.value.creatingSelection}))}function La(){const s=me();return l.computed(()=>({checkedLineId:s.value.checkedLineId,checkedNodeId:s.value.checkedNodeId,draggingNodeId:s.value.draggingNodeId}))}function _a(){const s=$();if(!s)throw new Error("RGHooks.useGraphStore must be used inside RGProvider or RelationGraph tag.");return{optionsRef:s.dataStores.optionsRef,shouldRenderNodesRef:s.dataStores.shouldRenderNodesRef,shouldRenderLinesRef:s.dataStores.shouldRenderLinesRef,shouldRenderFakeLinesRef:s.dataStores.shouldRenderFakeLinesRef}}const fn={useGraphInstance:$,useRelationGraph:dn,useGraphStore:pa,useGraphData:_a,useGraphOptions:me,useCreatingLine:ga,useCreatingNode:ma,useEditingNodes:ya,useEditingLine:va,useViewInformation:Ca,useSelection:wa,useConnectingNode:xa,useCheckedItem:La},ba=st,Na={BaseLayout:ge,BidirectionalTreeLayout:Wt,CenterLayout:Ut,CircleLayout:jt,FixedLayout:Jt,ForceLayout:Ee,RGFolderLayout:qt},Ta={RGOptionsDataUtils:zi,RGLineDataUtils:mo,RGNodeDataUtils:uo,RGGraphMath:J,RGNodesAnalyticUtils:be,RGEffectUtils:he},ka=Ds,Pa=ut,Ea=ft,Sa=Vs,Oa=zs,Ra=lt,Ma=vt,Ia=Ws,Da=Xs,Ba=Fs,Va=Gs,Aa=Hs,za=Us,Xa=na,Fa=oa,Ga=ia,$a=ra,Ha=hn,Ya=ua,Wa=fn,Ua=fn.useRelationGraph,ja=Rs,Ja=Os;it.install=s=>{s.component("RelationGraph",it)};const un=it,qa=un;V.INSTALLED_KEY=pn,V.RGBackground=Da,V.RGConnectSource=Ga,V.RGConnectTarget=$a,V.RGDebugView=Sa,V.RGDirection=ht,V.RGEditingConnectController=Fa,V.RGEditingConnectPoints=Ha,V.RGEditingLineController=Xa,V.RGEditingNearNodeWidget=za,V.RGEditingNodeController=Va,V.RGEditingReferenceLine=Ya,V.RGEditingResize=Aa,V.RGEventNames=D,V.RGEventsDefine4Vue3=ot,V.RGFakeNode=ka,V.RGHooks=Wa,V.RGInnerConnectTargetType=I,V.RGJunctionPoint=Y,V.RGLayouts=Na,V.RGLinePath=Pa,V.RGLineShape=W,V.RGLineText=Ea,V.RGMiniToolBar=Ma,V.RGMiniView=Ia,V.RGNodeExpandHolder=Ra,V.RGNodeShape=_e,V.RGProvider=ja,V.RGToolBar=Oa,V.RGUtils=Ta,V.RGWatermark=Ba,V.RelationGraph=un,V.RelationGraphCore=an,V.RelationGraphProvideKey=Le,V.RelationLinker=Ja,V.default=qa,V.useRelationGraph=Ua,V.version=ba,Object.defineProperties(V,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|