UNPKG

force-graph-vis

Version:

基于D3.js的知识图谱可视化解决方案

1 lines 90 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ForceGraphVis={})}(this,(function(t){"use strict";var e;let i=null===(e=window)||void 0===e?void 0:e.d3;function n(t){t?(i=t,window&&!window.d3&&(window.d3=t)):i||console.error("setGlobalD3:全局未定义d3,options未配置d3,请检查环境&配置是否正确!")}function s(){if(i)return i;console.error("getD3:获取d3失败,请检查环境&配置是否正确!")}const o=()=>({install(t){t.inject({setGlobalD3:n,getD3:s})}});var r={graph:{created:"graph:created",beforeRender:"graph:beforeRender",render:"graph:render",start:"graph:start",destroy:"graph:destroy"},svg:{contextmenu:"svg:contextmenu"},node:{mouseenter:"node:mouseenter",mouseleave:"node:mouseleave",click:"node:click",dblclick:"node:dblclick",contextmenu:"node:contextmenu",highlight:"highlight",dragStart:"dragStart",drag:"drag",dragEnd:"dragEnd"},link:{mouseenter:"link:mouseenter",mouseleave:"link:mouseleave",click:"link:click",highlight:"highlight"},render:{createNode:"render:createNode",drawNode:"render:drawNode"},zoom:{start:"zoom:start",zooming:"zoom:zooming",end:"zoom:end"},simulation:{tick:"simulation:tick",end:"simulation:end"},dynamicLoadData:{change:"dynamicLoadData:change",afterChange:"dynamicLoadData:afterChange",clear:"dynamicLoadData:clear"},rectSelection:{contextmenu:"rectSelection:contextmenu",start:"rectSelection:start",brushing:"rectSelection:brushing",end:"rectSelection:end"},layoutLayer:{data:"layoutLayer:data"},lockNode:{lock:"lockNode:lock",unlock:"lockNode:unlock"}};const a={Red:["#FFEBEE","#FFCDD2","#EF9A9A","#E57373","#EF5350","#F44336","#E53935","#D32F2F","#C62828","#B71C1C","#FF8A80","#FF5252","#FF1744","#D50000"],Pink:["#FCE4EC","#F8BBD0","#F48FB1","#F06292","#EC407A","#E91E63","#D81B60","#C2185B","#AD1457","#880E4F","#FF80AB","#FF4081","#F50057","#C51162"],Purple:["#F3E5F5","#E1BEE7","#CE93D8","#BA68C8","#AB47BC","#9C27B0","#8E24AA","#7B1FA2","#6A1B9A","#4A148C","#EA80FC","#E040FB","#D500F9","#AA00FF"],DeepPurple:["#EDE7F6","#D1C4E9","#B39DDB","#9575CD","#7E57C2","#673AB7","#5E35B1","#512DA8","#4527A0","#311B92","#B388FF","#7C4DFF","#651FFF","#6200EA"],Indigo:["#E8EAF6","#C5CAE9","#9FA8DA","#7986CB","#5C6BC0","#3F51B5","#3949AB","#303F9F","#283593","#1A237E","#8C9EFF","#536DFE","#3D5AFE","#304FFE"],Blue:["#E3F2FD","#BBDEFB","#90CAF9","#64B5F6","#42A5F5","#2196F3","#1E88E5","#1976D2","#1565C0","#0D47A1","#82B1FF","#448AFF","#2979FF","#2962FF"],LightBlue:["#E1F5FE","#B3E5FC","#81D4FA","#4FC3F7","#29B6F6","#03A9F4","#039BE5","#0288D1","#0277BD","#01579B","#80D8FF","#40C4FF","#00B0FF","#0091EA"],Cyan:["#E0F7FA","#B2EBF2","#80DEEA","#4DD0E1","#26C6DA","#00BCD4","#00ACC1","#0097A7","#00838F","#006064","#84FFFF","#18FFFF","#00E5FF","#00B8D4"],Teal:["#E0F2F1","#B2DFDB","#80CBC4","#4DB6AC","#26A69A","#009688","#00897B","#00796B","#00695C","#004D40","#A7FFEB","#64FFDA","#1DE9B6","#00BFA5"],Green:["#E8F5E9","#C8E6C9","#A5D6A7","#81C784","#66BB6A","#4CAF50","#43A047","#388E3C","#2E7D32","#1B5E20","#B9F6CA","#69F0AE","#00E676","#00C853"],LightGreen:["#F1F8E9","#DCEDC8","#C5E1A5","#AED581","#9CCC65","#8BC34A","#7CB342","#689F38","#558B2F","#33691E","#CCFF90","#B2FF59","#76FF03","#64DD17"],Lime:["#F9FBE7","#F0F4C3","#E6EE9C","#DCE775","#D4E157","#CDDC39","#C0CA33","#AFB42B","#9E9D24","#827717","#F4FF81","#EEFF41","#C6FF00","#AEEA00"],Yellow:["#FFFDE7","#FFF9C4","#FFF59D","#FFF176","#FFEE58","#FFEB3B","#FDD835","#FBC02D","#F9A825","#F57F17","#FFFF8D","#FFFF00","#FFEA00","#FFD600"],Amber:["#FFF8E1","#FFECB3","#FFE082","#FFD54F","#FFCA28","#FFC107","#FFB300","#FFA000","#FF8F00","#FF6F00","#FFE57F","#FFD740","#FFC400","#FFAB00"],Orange:["#FFF3E0","#FFE0B2","#FFCC80","#FFB74D","#FFA726","#FF9800","#FB8C00","#F57C00","#EF6C00","#E65100","#FFD180","#FFAB40","#FF9100","#FF6D00"],DeepOrange:["#FBE9E7","#FFCCBC","#FFAB91","#FF8A65","#FF7043","#FF5722","#F4511E","#E64A19","#D84315","#BF360C","#FF9E80","#FF6E40","#FF3D00","#DD2C00"]},l=["50","100","200","300","400","500","600","700","800","900","A100","A200","A400","A700"],c={Brown:["#EFEBE9","#D7CCC8","#BCAAA4","#A1887F","#8D6E63","#795548","#6D4C41","#5D4037","#4E342E","#3E2723"],Gray:["#FAFAFA","#F5F5F5","#EEEEEE","#E0E0E0","#BDBDBD","#9E9E9E","#757575","#616161","#424242","#212121"],BlueGray:["#ECEFF1","#CFD8DC","#B0BEC5","#90A4AE","#78909C","#607D8B","#546E7A","#455A64","#37474F","#263238"]},d=["50","100","200","300","400","500","600","700","800","900"],h={red:["#fff1f0","#ffccc7","#ffa39e","#ff7875","#ff4d4f","#f5222d","#cf1322","#a8071a","#820014","#5c0011"],volcano:["#fff2e8","#ffd8bf","#ffbb96","#ff9c6e","#ff7a45","#fa541c","#d4380d","#ad2102","#871400","#610b00"],orange:["#fff7e6","#ffe7ba","#ffd591","#ffc069","#ffa940","#fa8c16","#d46b08","#ad4e00","#873800","#612500"],green:["#f6ffed","#d9f7be","#b7eb8f","#95de64","#73d13d","#52c41a","#389e0d","#237804","#135200","#092b00"],cyan:["#e6fffb","#b5f5ec","#87e8de","#5cdbd3","#36cfc9","#13c2c2","#08979c","#006d75","#00474f","#002329"],blue:["#e6f7ff","#bae7ff","#91d5ff","#69c0ff","#40a9ff","#1890ff","#096dd9","#0050b3","#003a8c","#002766"],geekblue:["#f0f5ff","#d6e4ff","#adc6ff","#85a5ff","#597ef7","#2f54eb","#1d39c4","#10239e","#061178","#030852"],purple:["#f9f0ff","#efdbff","#d3adf7","#b37feb","#9254de","#722ed1","#531dab","#391085","#22075e","#120338"],magenta:["#fff0f6","#ffd6e7","#ffadd2","#ff85c0","#f759ab","#eb2f96","#c41d7f","#9e1068","#780650","#520339"]},f=[1,2,3,4,5,6,7,8,9,10],u={GeekBlue:["#b8e1ff","#9ac5ff","#7daaff","#5b8ff9","#3d76dd","#085ec0","#0047a5","#00318a","#001d70"],Cyan:["#9df5ca","#61ddaa","#42c090","#19a576","#008a5d","#006f45","#00562f","#003e19","#002800"],Grey:["#d0e4ff","#b4c8ed","#99add1","#7e92b5","#65789b","#4c6080","#334867","#1b324f","#021d38"],SunriseYellow:["#ffd83b","#f6bd16","#d7a100","#b98700","#9c6e00","#7f5600","#633f00","#482900","#2f1400"],DeepPurple:["#ebccff","#ccb0ff","#ae95ff","#907bff","#7262fd","#5349e0","#2f32c3","#001ba7","#00068c"],DaybreakBlue:["#95f0ff","#78d3f8","#5ab8db","#3a9dbf","#0a82a4","#00698a","#005170","#003958","#002440"],GoldenPurple:["#ffccff","#ebb0ff","#ce95f5","#b27ad8","#9661bc","#7b48a1","#613086","#48186c","#2e0054"],SunsetOrange:["#ffc771","#ffab57","#f6903d","#d77622","#b85c00","#9b4300","#7d2a00","#601000","#450000"],DarkGreen:["#8cf4f2","#6fd8d6","#52bcba","#31a09f","#008685","#006c6c","#005354","#003b3d","#002627"],Magenta:["#ffc2ec","#ffa6d0","#f08bb4","#d37099","#b65680","#9a3c67","#7e214f","#630038","#490022"],DustRed:["#ffbb95","#ff9e7b","#ff8362","#e8684a","#c84d32","#aa311c","#8c1104","#6f0000","#510000"],Dark:["#e2e2e2","#c6c6c6","#ababab","#919191","#777777","#5e5e5e","#474747","#303030","#1b1b1b"]},p={SunsetOrange:["#fdedbe","#ffdf80","#ffcb33","#ffb200","#ff8c00","#ff6500","#e6450f","#b22c00","#661900"],LeafYellow:["#ffebb0","#ffdf80","#faca3e","#e6b80b","#b5ac23","#6a9a48","#20876b","#06746b","#044e48"],GeekBlue:["#d2edc8","#a9dacc","#75c6d1","#42b3d5","#3993c2","#3073ae","#27539b","#1e3388","#171e6d"],GoldenPurple:["#facdaa","#f4a49e","#ee7b91","#e85285","#be408c","#942d93","#6a1b9a","#56167d","#42105f"]},g={CyanYellow:["#215b77","#227ba2","#1b9cd0","#22baed","#61c9ff","#8ad4ff","#abdfff","#c9e9ff","#eff3de","#ffe9b8","#ffde94","#ffd470","#ffc741","#edb40a","#d09c10","#a37b16","#795b16"],GreenRed:["#014c63","#10686c","#168575","#16a37e","#0bc286","#65cf9b","#96dcb0","#c1e8c5","#f2eaea","#ffc5ac","#ffa884","#ff895d","#ff6836","#f3470d","#d13808","#a4300c","#7a270e"],GreenYellow:["#003f7f","#004c99","#0059b2","#0072e5","#1a8cff","#4da6ff","#80bfff","#b3d9ff","#eae9eb","#ffd5b1","#ffc08c","#ffab66","#ff963e","#f17f0b","#d16a0c","#a45411","#794012"],Grow:["#014c63","#10686c","#168575","#16a37e","#0bc286","#65cf9b","#96dcb0","#c1e8c5","#eaf3db","#f1e3af","#f3d282","#f2c354","#eeb311","#de9111","#cd6e10","#bb490f","#a8190d"],Magic:["#661900","#b22c00","#e6450f","#ff6500","#ff8c00","#ffb200","#ffcb33","#ffdf80","#ffe2dc","#eaacff","#dd78ff","#c53fff","#a700ff","#8500ff","#620be1","#3607c2","#27029a"],Classic:["#661900","#b22c00","#e6450f","#ff6500","#ff8c00","#ffb200","#ffcb33","#ffdf80","#e0f2eb","#66d8ff","#1ac5ff","#00a5ff","#007fff","#0059ff","#0040ff","#002cb2","#001f7f"]},y={MYG:["#b5950e","#637e08","#115a04","#dfca62","#7aac3c","#167b1c","#dfe9c1","#7ac675","#168d38"],MPC:["#8b59ff","#6752ff","#1444ed","#b78dff","#8881ff","#1b6bed","#d7d1ff","#a0bfff","#209fed"],MBG:["#1685e1","#0c7189","#025142","#6fb6e1","#3d9b89","#0b6e42","#bbdfe1","#66bd89","#128742"],MOB:["#d6893e","#80703e","#1a523e","#d6b08c","#808f8c","#1a698c","#d6d6d8","#80afd8","#1a80d8"]},m=["#347BED","#F08605","#3DC29D","#FAD000","#6FCEF7","#8D67F5"],b=(t,e,i)=>(i="number"==typeof i?i:e.findIndex((t=>t===i)),Object.values(t).map((t=>t[i]))),k={_colorMaterialDesign14Map:a,_colorMaterialDesign14IndexName:l,colorMaterialDesign14Get:t=>b(a,l,t),_colorMaterialDesign10Map:c,_colorMaterialDesign10IndexName:d,colorMaterialDesign10Get:t=>b(c,d,t),_colorMaterialDesign1Map:{Black:["#000000"],White:["#FFFFFF"]},_colorAppleIndexName:["Blue","Brown","Cyan","Green","Indigo","Mint","Orange","Pink","Purple","Red","Teal","Yellow"],colorApplemacOSDefaultAqua:["#007aff","#a2845e","#55bef0","#8e8e93","#28cd41","#5856d6","#00c7be","#ff9500","#ff2d55","#af52de","#ff3b30","#59adc4","#ffcc00"],colorApplemacOSDefaultDark:["#0a84ff","#ac8e68","#5ac8f5","#98989d","#32d74b","#5e5ce6","#66d4cf","#ff9f0a","#ff375f","#bf5af2","#ff453a","#6ac4dc","#ffd60a"],colorApplemacOSVibrantAqua:["#0070f5","#987a54","#41afdc","#848489","#1ec337","#5452cc","#00bdb4","#f58b00","#f5234b","#9f4bc9","#ff3126","#2ea7bd","#f5c200"],colorApplemacOSVibrantDark:["#148eff","#b69872","#5acdfa","#a2a2a7","#3ce155","#6361f2","#6ce0db","#ffa914","#ff4169","#cc65ff","#ff4f44","#44d4ed","#ffe014"],colorApplemacOSAccessibleAqua:["#0040dd","#7f6545","#0071a4","#69696e","#007d1b","#3634a3","#0c817b","#c93400","#d30f45","#ad44ab","#d70015","#008299","#a05a00"],colorApplemacOSAccessibleDark:["#409cff","#b59469","#70d7ff","#98989d","#31de4b","#7d7aff","#66d4cf","#ffb340","#ff6482","#da8fff","#ff6961","#5de6ff","#ffd426"],colorApplemacOSAccessibleAndVibrantAqua:["#0040dd","#775d3b","#006796","#616165","#007018","#3634a3","#0b7570","#ad3a00","#c11032","#ad44ab","#c20618","#00778c","#925100"],colorApplemacOSAccessibleAndVibrantDark:["#409cff","#b59469","#70d7ff","#98989d","#31de4b","#7d7aff","#66d4cf","#ffb340","#ff3a5f","#da8fff","#ff4136","#5de6ff","#ffd426"],colorAppleiOSDefaultLight:["#007aff","#a2845e","#32ade6","#34c759","#5856d6","#00c7be","#ff9500","#ff2d55","#af52de","#ff3b30","#30b0c7","#ffcc00"],colorAppleiOSDefaultDark:["#0a84ff","#ac8e68","#64d2ff","#30d158","#5e5ce6","#66d4cf","#ff9f0a","#ff375f","#bf5af2","#ff453a","#40c8e0","#ffd60a"],colorAppleiOSAccessibleLight:["#0040dd","#7f6545","#0071a4","#248a3d","#3634a3","#0c817b","#c93400","#d30f45","#8944ab","#d70015","#008299","#b25000"],colorAppleiOSAccessibleDark:["#409cff","#b59469","#70d7ff","#30db5b","#7d7aff","#66d4cf","#ffb340","#ff6482","#da8fff","#ff6961","#5de6ff","#ffd426"],colorApplewatchOS:["#2094fa","#ac8e68","#5ac8fa","#9ba0aa","#04de71","#787aff","#66d4cf","#ff9500","#fa114f","#bf5af2","#ff3b30","#6ac4dc","#ffe620"],colorFluentUI:["#FFB900","#E74856","#0078D7","#0099BC","#7A7574","#767676","#FF8C00","#E81123","#0063B1","#2D7D9A","#5D5A58","#4C4A48","#F7630C","#EA005E","#8E8CD8","#00B7C3","#68768A","#69797E","#CA5010","#C30052","#6B69D6","#038387","#515C6B","#4A5459","#DA3B01","#E3008C","#8764B8","#00B294","#567C73","#647C64","#EF6950","#BF0077","#744DA9","#018574","#486860","#525E54","#D13438","#C239B3","#B146C2","#00CC6A","#498205","#847545","#FF4343","#9A0089","#881798","#10893E","#107C10","#7E735F"],_colorAntdMap:h,_colorAntdIndexName:f,colorAntdGet:t=>b(h,f,t),colorAntVBase10:["#5b8ff9","#61ddaa","#65789b","#f6bd16","#7262fd","#78d3f8","#9661bc","#f6903d","#008685","#f08bb4"],colorAntVBase10IndexName:["Geek Blue","Cyan","Grey","Sunrise Yellow","Deep Purple","Daybreak Blue","Golden Purple","Sunset Orange","Dark Green","Magenta"],colorAntVBase20:["#5b8ff9","#cdddfd","#61ddaa","#cdf3e4","#65789b","#ced4de","#f6bd16","#fcebb9","#7262fd","#d3cefd","#78d3f8","#d3eef9","#9661bc","#decfea","#f6903d","#ffe0c7","#008685","#bbdede","#f08bb4","#ffe0ed"],colorAntVAutumn:["#ff6b3b","#626681","#ffc100","#9fb40f","#76523b","#dad5b5","#0e8e89","#e19348","#f383a2","#247fea","#2bcb95","#b1abf4","#1d42c2","#1d9ed1","#d64bc0","#255634","#8c8c47","#8cdae5","#8e283b","#791dc9"],colorAntVMacaron:["#025df4","#db6bcf","#2498d1","#bbbde6","#4045b2","#21a97a","#ff745a","#007e99","#ffa8a8","#2391ff","#ffc328","#a0dc2c","#946dff","#626681","#eb4185","#cd8150","#36bccb","#327039","#803488","#83bc99"],colorAntVContrastingOrange:["#ff4500","#1aaf8b","#406c85","#f6bd16","#b40f0f","#2fb8fc","#4435ff","#ff5ca2","#bbe800","#fe8a26","#946dff","#6c3e00","#6193ff","#ff988e","#36bccb","#004988","#ffcf9d","#ccdc8a","#8d00a1","#1cc25e"],_colorAntVSingleMap:u,colorAntVSingleGet:t=>b(u,[],t),_colorAntVNearMap:p,colorAntVNearGet:t=>b(p,[],t),_colorAntVDivergentMap:g,colorAntVDivergentGet:t=>b(g,[],t),_colorAntVOverlayMap:y,colorAntVOverlayGet:t=>b(y,[],t),colorAntVStrong9:["#5b8ff9","#e8684a","#9270ca","#269a99","#beded1","#efe0b5","#b5d7e5","#f4dbc6","#f2cada"],colorAntVStrong19:["#5b8ff9","#e8684a","#9270ca","#269a99","#5ad8a6","#f6bd16","#6dc8ec","#ff9d4d","#ff99c3","#bdd2fd","#beded1","#c2c8d5","#efe0b5","#f6c3b7","#b5d7e5","#d3c6ea","#f4dbc6","#aad8d8","#f2cada"],colorAntVSemantic:["#f4664a","#30bf78","#faad14"],colorAntVSemanticIndexName:["Red","Green","Yellow"],colorEChartsVintage:["#d87c7c","#919e8b","#d7ab82","#6e7074","#61a0a8","#efa18d","#787464","#cc7e63","#724e58","#4b565b"],_colorEChartsVintageBackground:"rgba(254,248,239,1)",colorEChartsDark:["#dd6b66","#759aa0","#e69d87","#8dc1a9","#ea7e53","#eedd78","#73a373","#73b9bc","#7289ab","#91ca8c","#f49f42"],_colorEChartsDarkBackground:"rgba(51,51,51,1)",colorEChartsWesteros:["#516b91","#59c4e6","#edafda","#93b7e3","#a5e7f0","#cbb0e3"],_colorEChartsWesterosBackground:"rgba(0,0,0,0)",colorEChartsEssos:["#893448","#d95850","#eb8146","#ffb248","#f2d643","#ebdba4"],_colorEChartsEssosBackground:"rgba(242,234,191,0.15)",colorEChartsWonderland:["#4ea397","#22c3aa","#7bd9a5","#d0648a","#f58db2","#f2b3c9"],_colorEChartsWonderlandBackground:"rgba(255,255,255,0)",colorEChartsWalden:["#3fb1e3","#6be6c1","#626c91","#a0a7e6","#c4ebad","#96dee8"],_colorEChartsWaldenBackground:"rgba(255,255,255,0)",colorEChartsChalk:["#fc97af","#87f7cf","#f7f494","#72ccff","#f7c5a0","#d4a4eb","#d2f5a6","#76f2f2"],_colorEChartsChalkBackground:"rgba(41,52,65,1)",colorEChartsInfographic:["#c1232b","#27727b","#fcce10","#e87c25","#b5c334","#fe8463","#9bca63","#fad860","#f3a43b","#60c0dd","#d7504b","#c6e579","#f4e001","#f0805a","#26c0c0"],_colorEChartsInfographicBackground:"rgba(0,0,0,0)",colorEChartsMacarons:["#2ec7c9","#b6a2de","#5ab1ef","#ffb980","#d87a80","#8d98b3","#e5cf0d","#97b552","#95706d","#dc69aa","#07a2a4","#9a7fd1","#588dd5","#f5994e","#c05050","#59678c","#c9ab00","#7eb00a","#6f5553","#c14089"],_colorEChartsMacaronsBackground:"rgba(0,0,0,0)",colorEChartsRoma:["#e01f54","#001852","#f5e8c8","#b8d2c7","#c6b38e","#a4d8c2","#f3d999","#d3758f","#dcc392","#2e4783","#82b6e9","#ff6347","#a092f1","#0a915d","#eaf889","#6699ff","#ff6666","#3cb371","#d5b158","#38b6b6"],_colorEChartsRomaBackground:"rgba(0,0,0,0)",colorEChartsShine:["#c12e34","#e6b600","#0098d9","#2b821d","#005eaa","#339ca8","#cda819","#32a487"],_colorEChartsShineBackground:"rgba(0,0,0,0)",colorEChartsPurplePassion:["#9b8bba","#e098c7","#8fd3e8","#71669e","#cc70af","#7cb4cc"],_colorEChartsPurplePassionBackground:"rgba(91,92,110,1)",colorMTDV:m};let v=()=>({hooks:{[r.graph.created](){this.color()}},colorPalette:k,color(t=k.current||["#0EB0ED"],e=!0){return t=e?i.shuffle([...t]):t,this.colorStatic=i.scaleOrdinal(t),this.colorStatic},name:"colorPalette",install(t){let e=t.getPluginOptions(this.name);e.randomNodeColor&&(this.nodeColor=function(t){const e=t.group||t.id||t.index||this.random();return B(t)||this.colorStatic(e)}),e.randomLinkColor&&(this.linkColor=function(t){const e=t.group||t.id||t.index||this.random();return W(t)||this.colorStatic(e)}),k.d3=i.schemeCategory20||i.schemeCategory10,k.current||(k.current=m),t.inject(this),t.injectHooks(this.hooks)}});const E="kg-force-render-layer",x="kg-force-nodes-group",F="kg-force-nodes-layer",C="kg-force-node-wrap",D=t=>t.radius||10,L=t=>D(t)+6,A=t=>t.name,w=t=>t.fontSize||8,B=t=>t.color,S="background",P="center",I=t=>!!t.centerNode,G=t=>{var e;const i=t.textPlacement||"bottom-right";return null!==(e={bottom:{dx:0,dy:D(t)+12,textAnchor:"middle",dominantBaseline:"middle"},"bottom-right":{dx:D(t)+4,dy:D(t),textAnchor:"start",dominantBaseline:"initial"},center:{dx:0,dy:0,textAnchor:"middle",dominantBaseline:"middle"}}[i])&&void 0!==e?e:{}},M={primary:"#347BED",success:"#28A859",warning:"#FF9D00",danger:"#FA4B48",secondary:"#A9AFB8"},N=t=>{const e=D(t),i=e/Math.SQRT2,n={top:[0,-e],"top-left":[-i,-i],"top-right":[i,-i],bottom:[0,e],"bottom-left":[-i,i],"bottom-right":[i,i],left:[-e,0],right:[e,0]};return n[t.placement]||n["top-right"]},T=t=>{const e=t.nodeTag;if("string"==typeof e)return[{color:M[e]||M.secondary,icon:"",position:N(t)}];return(Array.isArray(e)?e:[e]).map((t=>{if("string"==typeof t)return{color:M[t]||M.secondary,icon:"",position:N(t)};const{type:e,icon:i}=t||{};return e||i?{color:M[e]||M.secondary,icon:i,position:N(t)}:null}))},$="kg-force-links-group",O="kg-force-links-layer",j="kg-force-link-wrap",z=t=>t.linkWidth,R=t=>(parseInt(t.linkWidth)||1)+2,_=t=>t.labelBorderWidth||1,H=t=>t.name,W=t=>t.color||"rgba(0, 0, 0, 0.3)",V=(t,e)=>t.labelWidth||e||47,Z=20,Y="background",U="labelBorder";var K=Object.freeze({__proto__:null,colorPalette:k,RenderLayerName:E,NodesGroupClassName:x,NodesRenderLayerName:F,NodeWrapClassName:C,NodeRadiusDefault:D,NodeHaloRadiusDefault:L,NodeStateRadiusDefault:t=>D(t)+4,NodeTextDefault:A,NodeTextDxDefault:t=>D(t)+8,NodeTextPlacementProps:G,NodeColorDefault:B,NodeBgSuffix:S,NodeCenterSuffix:P,NodeTextSizeDefault:w,isCenterNode:I,NodeTagIconSizeDefault:8,NodeTagProps:T,LinksGroupClassName:$,LinksRenderLayerName:O,LinkWrapClassName:j,LinkWidthDefault:z,LinkTextDefault:H,LinkTextDyDefault:4,LinkColorDefault:W,LinkLabelWidthDefault:47,getLinkLabelWidth:V,LinkLabelHeightDefault:Z,LinkWidthBackground:R,LinkLabelSuffix:"label",LinkBgSuffix:Y,linkLabelBorderSuffix:U,LinkDashArray:"2,2",LinkArrowIdDefault:"arrowhead",LinkArrowStartIdDefault:"startArrowhead",LinkArrowSvgSizeDefault:10,LinkArrowSizeDefault:10,LinkArrowPositionDefault:0,linkRectDefault:_});var q={bezierCurveCoord:t=>{let e=Math.abs(t.source.x-t.target.x),i=Math.abs(t.source.y-t.target.y),n=t.source.x,s=t.source.y,o={x:.33,y:.1},r={x:.66,y:.9};t.source.x>t.target.x&&(o.x=-o.x,r.x=-r.x),t.source.y>t.target.y&&(r.y=-1.1),t.controlPointProportion&&t.controlPointProportion.length&&(t.controlPointProportion[0]&&(o=t.controlPointProportion[0]),t.controlPointProportion[1]&&(r=t.controlPointProportion[1]));let a={x:n+.88*e,y:s-.3*i};return{controlPoint1:{x:n+e*o.x,y:s+i*o.y},controlPoint2:{x:n+e*r.x,y:s+i*r.y},pointStart:{x:t.source.x,y:t.source.y},pointEnd:{x:t.target.x,y:t.target.y},sPoint:a}},getProportion:(t,{x:e,y:i})=>{let n=Math.abs(t.source.x-t.target.x),s=Math.abs(t.source.y-t.target.y);return{x:(e-t.source.x)/n,y:(i-t.source.y)/s}}};let J={onlyModifyClass(t,e,i){t.classed(e,((t,n,s)=>{let o=s[n],r=i(t);return!0===r||!1===r?r:o.classList.contains(e)}))}};const{sin:X,cos:Q,PI:tt}=Math;function et(t,e){let i=d3.select(t),n=i.node().getComputedTextLength(),s=i.text();for(;n>e&&s.length>0;)s=s.slice(0,-1),i.text(s+"..."),n=i.node().getComputedTextLength()}let it={couldBeClass:function(t){if("function"!=typeof t)return!1;if(void 0===t.prototype)return!1;if(t.prototype.constructor!==t)return!1;if(Object.getOwnPropertyNames(t.prototype).length>=2)return!0;let e=String(t);if("class"==e.slice(0,5))return!0;if(/^function\s*\(|^function anonymous\(/.test(e))return!1;let i=/(call|apply|_classCallCheck)\(this(, arguments)?\)|\bthis(.\S+|\[.+?\])\s*(=|\()|=\s*this[,;]/.test(e);return!(!/^function\s+[A-Z]/.test(e)||!(i||/\[native code\]/.test(e)&&"BigInt"!==t.name&&"Symbol"!==t.name))||!(!i||"default_1"!==t.name)},classUtil:J,linkCoord:(t,e={},i)=>{let n={x:t.source.x,y:t.source.y,radius:D(t.source)},s={x:t.target.x,y:t.target.y,radius:D(t.target)},o=s.x-n.x,r=s.y-n.y,a=180*Math.atan2(Math.abs(r),Math.abs(o))/Math.PI*Math.PI/180,l=Math.cos(a)*n.radius,c=Math.sin(a)*n.radius,d=Math.cos(a)*s.radius,h=Math.sin(a)*s.radius,f=e.multipleSource||e.multiple||1,u=e.multipleTarget||e.multiple||1,p=e.gapSource||e.gap||0,g=e.gapTarget||e.gap||0,y=(l+p)*f,m=(c+p)*f,b=(d+g)*u,k=(h+g)*u;n.x<s.x?(n.x+=y,s.x-=b):(n.x-=y,s.x+=b),n.y<s.y?(n.y+=m,s.y-=k):(n.y-=m,s.y+=k);let v=null;return v=e.source?Object.assign({},t,{source:n}):e.target?Object.assign({},t,{target:s}):Object.assign({},t,{source:n,target:s}),i&&i(v),v},bezierCurveCoord:q.bezierCurveCoord,getProportion:q.getProportion,getStraightPath:t=>`M${t.source.x} ${t.source.y} L${t.target.x} ${t.target.y}`,getArcPath:(t,e="upper")=>{let{source:i,target:n}=t,s=n.x-i.x,o=n.y-i.y,r=Math.sqrt(s*s+o*o),a=`M${i.x},${i.y} A${r},${r} 0 0,1 ${n.x},${n.y}`,l=`M${i.x},${i.y} A${r},${r} 0 0,0 ${n.x},${n.y}`;if("upper"===e)return a;if("lower"===e)return l;throw new Error("arc direction is must be upper or lower")},getBezierPath:(t,e={})=>{let i=q.bezierCurveCoord(t,e),{controlPoint1:n,controlPoint2:s,sPoint:o}=i,{source:r,target:a}=t;return`M${r.x} ${r.y} C${n.x} ${n.y} ${s.x} ${s.y} ${a.x} ${a.y}`},getSelfPath:t=>{const{source:e}=t,i=D(e),n=(t.angle||0)/180*tt,s=n-.5*tt,o=e.x-i*X(n),r=e.y-i*Q(n),a=e.x-i*X(s),l=e.y-i*Q(s),c=100+parseInt(i),d=n-.02777*tt,h=n-.472*tt;return`M${o} ${r} C${e.x-c*X(d)} ${e.y-c*Q(d)} ${e.x-c*X(h)} ${e.y-c*Q(h)} ${a},${l}`},getAngleFromPoint:function(t,e){let i=t.y-e.y,n=t.x-e.x;return(90-180*Math.atan2(i,n)/Math.PI)%360},ellipsis:et},nt=()=>({random(t=10,e=.3){let n=t*e;return i.randomUniform(t-n,t+n)()},$sleep:(t=0)=>new Promise((e=>setTimeout(e,t))),install(t){t.inject(this)}});const{bezierCurveCoord:st}=it,ot=()=>({createBezierCurve(){let t=it.getProportion;this.polylinesGroup||(this.polylinesGroup=this.svg.append("g").attr("class","kg-control-polyline").selectAll("polyline"));const e=this.polylinesGroup.data(this.data.links.filter((t=>"bezier"===t.linkType)),this.linkIdentity);e.exit().remove(),this.polylinesGroup=e.enter().append("polyline").attr("class","debug-kg-polyline").attr("style","display: none").merge(e),this.circle2sGroup||(this.circle2sGroup=this.svg.append("g").attr("class","kg-control-1").selectAll("circle"));const n=this.circle2sGroup.data(this.data.links.filter((t=>"bezier"===t.linkType)),this.linkIdentity);n.exit().remove(),this.circle2sGroup=n.enter().append("circle").attr("class","debug-kg-circle debug-kg-circle2").attr("style","display: none").merge(n),this.circle3sGroup||(this.circle3sGroup=this.svg.append("g").attr("class","kg-control-2").selectAll("circle"));const s=this.circle3sGroup.data(this.data.links.filter((t=>"bezier"===t.linkType)),this.linkIdentity);s.exit().remove(),this.circle3sGroup=s.enter().append("circle").attr("class","debug-kg-circle debug-kg-circle3").attr("style","display: none").merge(s);let o=this;this.circle2sGroup.call(i.drag().on("start",(function(t){i.select(this).classed("debug-circle-active",!0)})).on("drag",(function(e,n){let s=e.sourceEvent||e instanceof MouseEvent?n:e,r=i.event||e;i.select(this).attr("cx",r.x).attr("cy",r.y);let a=t(s,{x:r.x,y:r.y});s.controlPointProportion?s.controlPointProportion[0]=a:s.controlPointProportion=[].concat(a),o.updateBezierPath(s)})).on("end",(function(e,n){let s=e.sourceEvent||e instanceof MouseEvent?n:e,r=i.event||e;i.select(this).classed("debug-circle-active",!1),s.controlPointProportion[0]=t(s,{x:r.x,y:r.y}),o.updateBezierPath(s)}))),this.circle3sGroup.call(i.drag().on("start",(function(t){i.select(this).classed("debug-circle-active",!0)})).on("drag",(function(e,n){let s=e.sourceEvent||e instanceof MouseEvent?n:e,r=i.event||e;i.select(this).attr("cx",r.x).attr("cy",r.y);let a=t(s,{x:r.x,y:r.y});s.controlPointProportion?s.controlPointProportion[1]=a:s.controlPointProportion=[].concat(null,a),o.updateBezierPath(s)})).on("end",(function(e,n){let s=e.sourceEvent||e instanceof MouseEvent?n:e,r=i.event||e;i.select(this).classed("debug-circle-active",!1);let a=t(s,{x:r.x,y:r.y});s.controlPointProportion?s.controlPointProportion[1]=a:s.controlPointProportion=[].concat(null,a),o.updateBezierPath(s)})))},dragBezierControlPoints(t){this.circle2sGroup.filter(`[control_target_id='c1_${t.id}']`).attr("style","display: block"),this.circle3sGroup.filter(`[control_target_id='c2_${t.id}']`).attr("style","display: block"),this.polylinesGroup.filter(`[polyline_target_id='pl_${t.id}']`).attr("style","display: block")},hiddenControlPoints(t){this.circle2sGroup.filter(`[control_target_id='c1_${t.id}']`).attr("style","display: none"),this.circle3sGroup.filter(`[control_target_id='c2_${t.id}']`).attr("style","display: none"),this.polylinesGroup.filter(`[polyline_target_id='pl_${t.id}']`).attr("style","display: none")},onClickBezierControl({item:t,index:e,array:i,event:n}){this.dragBezierControlPoints(t),t.controlPoints=!t.controlPoints,t.controlPoints||this.hiddenControlPoints(t)},tickedBezierControl(){this.polylinesGroup.attr("points",(t=>{t=this.fixLinkCoordination(t);let e=st(t),{pointStart:i,pointEnd:n,controlPoint1:s,controlPoint2:o}=e;return`${i.x},${i.y} ${s.x},${s.y} ${o.x},${o.y} ${n.x},${n.y}`})).attr("polyline_id",(t=>`pl_${t.source.id}_${t.target.id}`)).attr("polyline_target_id",(t=>`pl_${t.target.id}`)).attr("polyline_source_id",(t=>`pl_${t.source.id}`)),this.circle2sGroup.attr("cx",(t=>st(this.fixLinkCoordination(t)).controlPoint1.x)).attr("control_id",(t=>`c1_${t.source.id}_${t.target.id}`)).attr("control_target_id",(t=>`c1_${t.target.id}`)).attr("control_source_id",(t=>`c1_${t.source.id}`)).attr("cy",(t=>st(this.fixLinkCoordination(t)).controlPoint1.y)),this.circle3sGroup.attr("cx",(t=>st(this.fixLinkCoordination(t)).controlPoint2.x)).attr("control_id",(t=>`c2_${t.source.id}_${t.target.id}`)).attr("control_target_id",(t=>`c2_${t.target.id}`)).attr("control_source_id",(t=>`c2_${t.source.id}`)).attr("cy",(t=>st(this.fixLinkCoordination(t)).controlPoint2.y))},updateBezierPath(t){this.updateLinkPath(t),this.polylinesGroup.attr("points",(t=>{t=this.fixLinkCoordination(t);let e=st(t),{pointStart:i,pointEnd:n,controlPoint1:s,controlPoint2:o}=e;return`${i.x},${i.y} ${s.x},${s.y} ${o.x},${o.y} ${n.x},${n.y}`}))},hooks:{[r.graph.render](){this.createBezierCurve()},[r.simulation.tick](){this.tickedBezierControl()},[r.node.click](...t){this.onClickBezierControl(...t)}},name:"bezierCurveController",install(t){!1!==t.getPluginOptions(this.name).enable&&(t.injectHooks(this.hooks),t.inject({createBezierCurve:this.createBezierCurve,tickedBezierControl:this.tickedBezierControl,onClickBezierControl:this.onClickBezierControl,dragBezierControlPoints:this.dragBezierControlPoints,hiddenControlPoints:this.hiddenControlPoints,updateBezierPath:this.updateBezierPath}))}});let rt=()=>({graphSelector(t,e){if(this.isStop)return;if(!0===this.isDestroy)return;let i=(t,e)=>{for(let i in e)if(e[i]!==t[i])return!1;return!0},n=e=>{let n=!1;return e===t?n=!0:"function"==typeof t?t(e)&&(n=!0):"object"==typeof t&&(n=i(e,t)),n},s=null;t&&(s=this.nodesGroup.filter((function(t){if(n(t))return!0})));let o=null;return e&&(o=this.linksGroup.filter((function(s){if((s=>{let{source:o,target:r}=s,a=!1;if("function"==typeof e)a=!!e(s);else if("object"==typeof e){let{source:t,target:n}=e;if(!t&&!n)throw new Error("lightSelector 传参错误: linkSelector");let s=!1,l=!1;s=!t||i(o,t),l=!n||i(r,n),s&&l&&(a=!0)}else if("string"==typeof e){if(!t)throw new Error("lightSelector 传参错误: nodeSelector不能为空");if("source"===e)a=n(o);else if("target"===e)a=n(r);else{if("all"!==e)throw new Error("lightSelector 传参错误: linkSelector");a=n(o)||n(r)}}return a})(s))return!0}))),{nodeSelection:s,linkSelection:o}},findLinkedRoute(t,e="source",i=1,n,s){n||(n=[]),s||(s=[]);let o={source:"target",target:"source"};if(i<=0)return{nodes:n,links:s};let r=[];return this.data.links.forEach((i=>{let a=i[e],l=i[o[e]];a||console.log(a),t||console.log(t),a.id===t.id&&(n.includes(l)?s.includes(i)||s.push(i):(r.push(l),n.push(l),s.push(i)))})),r.length&&r.forEach((t=>this.findLinkedRoute(t,e,i-1,n,s))),{nodes:n,links:s}},install(t){t.inject(this)}}),at=()=>({hooks:{[r.graph.render](){this.nodesRenderLayer.createLayer("highlight",1),this.linksRenderLayer.createLayer("highlight",1)},[r.graph.destroy](){this.highlightDebounceTimer&&clearTimeout(this.highlightDebounceTimer),this.highlightDebounceTimer=null}},setHighlightStep(t){let e=[t],i=[];this.findLinkedRoute(t,"target",1/0,e,i),e=e.reverse(),i=i.reverse(),async function(){for(let t=0;t<e.length;t++){let n=e.slice(0,t+1),s=i.slice(0,t);if(this.pureHighlight(n,s),await this.$sleep(1e3),this.isStop)return}}.bind(this)()},getRelatedNodesAndLinks(t,e){let i,n;return"link"===e?(i=[t],n=[t.target,t.source]):(n=[t],i=[],this.findLinkedRoute(t,"source",1,n,i),this.findLinkedRoute(t,"target",1,n,i)),{linkArr:i,nodeArr:n}},setHighlight(t,e){if(this.isDrag)return;const{linkArr:i,nodeArr:n}=this.getRelatedNodesAndLinks(t,e),s=this.linksStatusMap.get("highlight"),o=this.nodesStatusMap.get("highlight");i.forEach((t=>{let e=s.get(t);e?s.set(t,++e):s.set(t,1)})),n.forEach((t=>{let e=o.get(t);e?o.set(t,++e):o.set(t,1)})),this.highlightDebounce(o,s)},resetHighlight(t,e){if(this.isDrag)return;const i=this.linksStatusMap.get("highlight"),n=this.nodesStatusMap.get("highlight"),{linkArr:s,nodeArr:o}=this.getRelatedNodesAndLinks(t,e);s.forEach((t=>{let e=i.get(t);e&&i.set(t,--e)})),o.forEach((t=>{let e=n.get(t);e&&n.set(t,--e)})),this.highlightDebounce(n,i)},clearHighlight(){const t=this.linksStatusMap.get("highlight"),e=this.nodesStatusMap.get("highlight");this.highlightDebounce(e,t)},highlightDebounce(t,e){this.highlightDebounceTimer&&clearTimeout(this.highlightDebounceTimer),this.highlightDebounceTimer=setTimeout((()=>{this.highlightDebounceTimer2&&clearTimeout(this.highlightDebounceTimer2);const[i,n]=this.getHighlightNodesAndLinks(t,e);this.pureHighlight(i,n),this.eventEmitter.emit(r.node.highlight,{nodes:i,links:n}),this.highlightDebounceTimer=null}),150)},getHighlightNodesAndLinks(t,e){const i=Array.from(t.entries()).reduce(((t,[e,i])=>(i>0&&t.push(e),t)),[]),n=Array.from(e.entries()).reduce(((t,[e,i])=>(i>0&&t.push(e),t)),[]);return[0===i.length?null:i,0===n.length?null:n]},pureHighlight(t,e){if(t||e){if(t){const e=[],i=[];this.nodesGroup.each(((n,s,o)=>t.includes(n)?i.push(o[s]):e.push(o[s]))),this.nodesRenderLayer.appendToLayer("highlight",i),this.nodesRenderLayer.appendToLayer("base",e).classed("layer-opacity",!0)}if(e){const t=[],i=[];this.linksGroup.each(((n,s,o)=>e.includes(n)?i.push(o[s]):t.push(o[s]))),this.linksRenderLayer.appendToLayer("highlight",i),this.linksRenderLayer.appendToLayer("base",t).classed("layer-opacity",!0)}}else this.nodesRenderLayer.baseLayer.classed("layer-opacity",!1),this.linksRenderLayer.baseLayer.classed("layer-opacity",!1),this.highlightDebounceTimer2=setTimeout((()=>{this.nodesRenderLayer.mergeLayer("base","highlight"),this.linksRenderLayer.mergeLayer("base","highlight"),this.highlightDebounceTimer2=null}),300)},isConnected(t,e){let i={};return this.data.links.forEach((function(t){i[t.source+","+t.target]=!0})),i[t.id+","+e.id]||i[e.id+","+t.id]||t.id===e.id},light(){this.nodesRenderLayer.baseLayer.classed("layer-opacity",!1),this.linksRenderLayer.baseLayer.classed("layer-opacity",!1)},dark(){this.nodesRenderLayer.baseLayer.classed("layer-opacity",!0),this.linksRenderLayer.baseLayer.classed("layer-opacity",!0)},flyLine(t=this.pathsGroup,e=1e3,n=i.easeQuadOut){return new Promise((function(s,o){t.style("stroke-dasharray",(function(t){return i.select(this).node().getTotalLength()})).style("stroke-dashoffset",(function(t){return i.select(this).node().getTotalLength()})).transition().style("stroke-dashoffset",0).duration(e).ease(n).on("end",(()=>{s()}))}))},install(t){t.inject(this),t.injectHooks(this.hooks)}}),lt=()=>({printPoint(){let t={};this.nodesGroup.each((e=>{t[e.id]={x:e.x,y:e.y}})),this.pathsGroup.each((function(e){let n=i.select(this);t[n.attr("id")]=e.controlPointProportion}));let e=JSON.stringify(t);return console.log(e),e},printPointAndCopy(){copy(window.printPoint())},fixedGraph(){this.data.nodes.forEach((t=>{t.fx=t.x,t.fy=t.y}))},getLinkId(){let t=$0,e=t=>t.classList.contains("kg-force-node-wrap");for(;!e(t);)t=t.parentNode;let n=i.select(t).attr("id");n=n.replace("node_",""),this.data.links.forEach((t=>{let{target:e,source:i}=t;e.id===n&&(i.id,e.id,console.log(`${i.id} ${e.id}`),copy(`${i.id} ${e.id}`))}))},install(t){(t=>{let e=[];for(let t in this)"install"!==t&&e.push(t);e.forEach((e=>{window[e]=this[e].bind(t)}))})(t)}}),ct=()=>{},dt=()=>({startOD(){this.OD=new class{constructor({rootElement:t=document.body,detectionElement:e="*",xGridCnt:i=10,yGridCnt:n=10}){return this.detectionElement=e,this.rootElement=this.getDOM(t),this.rootRect=this.getRect(this.rootElement),this.xGridCnt=i,this.yGridCnt=n,this.xGridWidth=this.rootRect.width/i,this.yGridHeight=this.rootRect.height/n,this.gridSizeMap={},this.gridPointsMap={},this.detectionElements=[...this.rootElement.querySelectorAll(e)],this.detectionRectList=[],this._tick=ct,this}detect(){return performance.now(),this.divideGrid(),this.detectionElements=[...this.rootElement.querySelectorAll(this.detectionElement)],this.makeDetectionRect(),this.findDetection(),this}makeDetectionRect(){this.detectionRectList=this.detectionElements.map(((t,e)=>{let i=this.getRect(t);return Object.assign(i,{text:t.innerHTML,element:t,index:e,gridList:[]}),this.fillGrid(i),i}))}fillGrid(t){t.text;let e=(t,e)=>(t<0&&(t=0),"x"===e&&t>this.xGridCnt-1&&(t=this.xGridCnt-1),"y"===e&&t>this.yGridCnt-1&&(t=this.yGridCnt-1),t),i=parseInt(""+(t.left-this.rootRect.left)/this.xGridWidth);i=e(i,"x");let n=parseInt(""+(t.right-this.rootRect.left)/this.xGridWidth);n=e(n,"x");let s=parseInt(""+(t.top-this.rootRect.top)/this.yGridHeight);s=e(s,"y");let o=parseInt(""+(t.bottom-this.rootRect.top)/this.yGridHeight);o=e(o,"y");for(let e=i;e<=n;e++)for(let i=s;i<=o;i++){let n=e+"-"+i;this.gridPointsMap[n].push(t),t.gridList.push(n)}}findDetection(){let t=[];this.detectionRectList.forEach((e=>{let i=[];e.gridList.map((t=>i=i.concat(this.gridPointsMap[t]))),i=i.filter((t=>t!==e));let n=!1;i.forEach((t=>{n||e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top||e.index<t.index&&(n=!0)})),!0===n&&t.push(e)})),this._tick(t,this.detectionRectList)}divideGrid(){for(let t=0;t<this.xGridCnt;t++)for(let e=0;e<this.yGridCnt;e++){let i=t+"-"+e;this.gridSizeMap[i]={width:this.xGridWidth,height:this.yGridHeight,x:this.rootRect.x+this.xGridWidth*t,y:this.rootRect.y+this.yGridHeight*e},this.gridPointsMap[i]=[]}}tick(t=ct){return this._tick=t,this}getRect(t){let e=t.getBoundingClientRect();return{DOMRect:e,width:e.width,height:e.height,left:e.left,right:e.right,top:e.top,bottom:e.bottom,tl:{x:e.left,y:e.top},tr:{x:e.right,y:e.top},bl:{x:e.left,y:e.bottom},br:{x:e.right,y:e.bottom}}}getDOM(t){return"string"==typeof t?document.querySelector(t):t}}({rootElement:this.dom,detectionElement:".kg-force-text"}).tick(((t,e)=>{e.forEach((t=>t.element.classList.remove("kg-force-text-opacity"))),t.forEach((t=>t.element.classList.add("kg-force-text-opacity")))})),this.occIntervalTime=setInterval((()=>{this.OD.detect()}),2e3)},stopOD(){clearInterval(this.occIntervalTime),this.OD=null},hooks:{[r.simulation.end](){this.startOD()},[r.graph.destroy](){this.stopOD()}},name:"occlusionDetection",install(t){t.getPluginOptions(this.name).enable&&(t.injectHooks(this.hooks),t.inject(this))}}),ht=()=>({isolate(t,e){let i=this.data.nodes.filter(e),n=t.initialize;return t.initialize=function(){n.call(t,i)},t},mergeData(t){let e=t.nodes||[],i=t.links||[];return this.data.nodes=this.updateAdd(this.data.nodes,e),this.data.links=this.updateAdd(this.data.links,i),this.data},updateAdd(t,e){const i=e.slice(0);return t.forEach((t=>{i.find(((e,n)=>{if(t.id===e.id)return Object.assign(t,e),i.splice(n,1)}))})),t.concat(i)},findSideNode(t="left"){let e=[];switch(this.nodesGroup.datum((function(t){return t.rect=this.getBoundingClientRect(),e.push(t),t})),t){case"left":case"top":e.sort(((e,i)=>e.rect[t]-i.rect[t]));break;case"right":case"bottom":e.sort(((e,i)=>i.rect[t]-e.rect[t]))}return e},setData(t){this.updateData(t,!1,"setData")},updateData(t,e=!0,i="updateData"){this.clearHighlight(),e?this.mergeData(t):(this.data.nodes=t.nodes||[],this.data.links=t.links||[]),this.eventEmitter.emit(r.dynamicLoadData.change,{data:this.data,action:i}),this.createNodes(this.nodesGroup.data(this.data.nodes,this.nodeIdentity),!e),this.simulation.nodes(this.data.nodes),this.simulation.force("link").links(this.data.links),this.createLinks(this.linksGroup.data(this.data.links,this.linkIdentity),!e),this.eventEmitter.emit(r.dynamicLoadData.afterChange,{action:i})},clear(){this.clearHighlight(),0!==Object.keys(this.simulation).length&&(this.simulation.stop(),this.simulation.nodes([]),this.simulation.force("link").links([])),this.data.nodes=[],this.data.links=[],this.nodesGroup=this.linksGroup=this.pathsGroup=null,this.svg.selectAll("*").remove(),this.render(),this.start(),this.transformTo(),this.eventEmitter.emit(r.dynamicLoadData.clear)},getNodeById(t){return this.data.nodes.find((e=>t===this.nodeIdentity(e)))},getLinkById(t){return this.data.links.find((e=>t===this.linkIdentity(e)))},deleteNodeById(t){const e="deleteNode";this.clearHighlight();const n=this.nodeIdentity;t=Array.isArray(t)?t:[t],this.nodesGroup=this.nodesGroup.filter((function(e){return!t.includes(n(e))||(i.select(this).remove(),!1)})),this.data.nodes=this.nodesGroup.data(),this.linksGroup=this.linksGroup.filter((function(e){return!t.includes(n(e.source))&&!t.includes(n(e.target))||(i.select(this).remove(),!1)})),this.pathsGroup=this.pathsGroup.filter((function(e){return!t.includes(n(e.source))&&!t.includes(n(e.target))||(i.select(this).remove(),!1)})),this.data.links=this.linksGroup.data(),this.eventEmitter.emit(r.dynamicLoadData.change,{data:this.data,action:e}),this.simulation.nodes(this.data.nodes),this.simulation.force("link").links(this.data.links),this.eventEmitter.emit(r.dynamicLoadData.afterChange,{action:e})},deleteLinkById(t){const e="deleteLink";this.clearHighlight();const n=this.linkIdentity;t=Array.isArray(t)?t:[t],this.linksGroup=this.linksGroup.filter((function(e){return!t.includes(n(e))||(i.select(this).remove(),!1)})),this.pathsGroup=this.pathsGroup.filter((function(e){return!t.includes(n(e))||(i.select(this).remove(),!1)})),this.data.links=this.linksGroup.data(),this.eventEmitter.emit(r.dynamicLoadData.change,{data:this.data,action:e}),this.simulation.force("link").links(this.data.links),this.eventEmitter.emit(r.dynamicLoadData.afterChange,{action:e})},nodeIdentity:t=>t.id||t,nodeBgIdentity(t){return this.nodeIdentity(t)+"-"+S},nodeCenterIdentity(t){return this.nodeIdentity(t)+"-"+P},linkIdentity(t){if(t.id)return t.id;const e=typeof t.source,i=typeof t.target;return"string"===e&&"string"===i?(t.id=t.source+"-"+t.target,t.id):"object"===e&&"object"===i?(t.id=this.nodeIdentity(t.source)+"-"+this.nodeIdentity(t.target),t.id):void 0},linkBgIdentity(t){return this.linkIdentity(t)+"-"+Y},linkLabelBorderIdentity(t){return this.linkBgIdentity(t)+"-"+U},linkLabelBorderBackgroundIdentity(t){return this.linkBgIdentity(t)+"-"+"labelBorderbackground"},linkArrowStartIdentity(t){return this.linkBgIdentity(t)+"-arrow-start"},linkArrowEndIdentity(t){return this.linkBgIdentity(t)+"-arrow-end"},linkArrowPathIdentity:t=>t+"link",linkStrokeDasharray:t=>t.isDashed?t.dashArray?t.dashArray:"2,2":"",name:"dynamicLoadData",hooks:{[r.dynamicLoadData.afterChange](){this.simulation.alpha(1).restart()}},install(t){t.inject(this),t.injectHooks(this.hooks)}}),ft=null;let ut=(t,e)=>((e=Array.isArray(e)?e:[e]).forEach(((e,i)=>{let n=t.findIndex((t=>t.id===e.id));-1!==n&&t.splice(n,1)})),t),pt=(t,e)=>{e=Array.isArray(e)?e:[e];let{nodes:i,links:n}=t,s=[],o=[],r=[],a=[],l=[];return e.forEach(((t,e)=>{n.forEach((e=>{let n="object"==typeof e.source?e.source.id:e.source,s="object"==typeof e.target?e.target.id:e.target;if(t.id===n){let t=i.find((t=>t.id===s));t&&o.push(t)}if(t.id===s){let t=i.find((t=>t.id===n));t&&a.push(t)}}))})),o=Array.from(new Set(o)),a=Array.from(new Set(a)),s=o.filter((t=>a.includes(t))),r=o.filter((t=>!s.includes(t))),l=a.filter((t=>!s.includes(t))),{bothNodes:s,nextNodes:o,nextNodesOnly:r,prevNodes:a,prevNodesOnly:l}};const gt=(t,e)=>t.nodes.filter((t=>t.level===e));let yt=(t,e={})=>{e.expandFirst=e.expandFirst?e.expandFirst:"next";let{nextFarFirst:i=!1,root:n}=e;n=Array.isArray(n)?n:[n];let s=[...t.nodes];t.links;let o=[],r=[],a=[...s],l=[],c=a.filter((t=>n.includes(t.id)));0===c.length&&console.error("未找到根节点"),l=[...l,...c],ut(a,l);let d=()=>{let e=!1,n=1,s=c;for(;!e;){let r={nodes:a,links:t.links},c=gt(r,n);if(c&&0!==c.length||(c=pt(r,s).nextNodes),0===c.length){e=!0;break}o.push(c),n++,s=c,!0!==i&&(l=[...l,...c],ut(a,l))}(()=>{if(!0===i){let t=[];for(let e=o.length-1;e>=0;e--){let i=o[e];t=[...t,...i];for(let i=0;i<e;i++){let e=o[i];ut(e,t)}}ut(a,t)}})()},h=()=>{let e=!1,i=-1,n=c;for(;!e;){let s={nodes:a,links:t.links},o=gt(s,i);if(o&&0!==o.length||(o=pt(s,n).prevNodes),0===o.length){e=!0;break}r.push(o),i--,n=o,l=[...l,...o],ut(a,l)}};return"next"===e.expandFirst?(d(),h()):"prev"===e.expandFirst&&(h(),d()),{rootNodes:c,nextNodesLevel:[c,...o],nextNodesLevelOnly:o,prevNodesLevel:[c,...r],prevNodesLevelOnly:r,remainNodes:a}},mt=()=>({layoutLayer(t){let e={expandFirst:"next",width:this.width,height:this.height,levelGap:350,nodeGap:2,maxLevel:1/0,padding:{top:30,bottom:30,left:30,right:30},initDuration:1500};t=Object.assign(e,t);let i=yt(this.data,t);this.eventEmitter.emit(r.layoutLayer.data,{levelNodes:i});let n=i.nextNodesLevel;i.prevNodesLevelOnly.length&&(n=[...[...i.prevNodesLevelOnly].reverse(),i.rootNodes,...i.nextNodesLevelOnly]);const{layoutWidth:s,layoutHeight:o}=(({layerNodes:t,remainNodes:e},i)=>{let{padding:n,nodeGap:s,levelGap:o,width:r,height:a,maxLevel:l}=i,c=r,d=a;n.width=n.left+n.right,n.height=n.top+n.bottom;let h=t.length-1;h<=0&&(h=1),"auto"!==r?(c=r-n.width,o=c/h):void 0!==o&&(c=h*o);let f=0;const u=t.concat([e]).map((t=>{const e=t.reduce(((t,e)=>t+2*(e.radius||10)+s),0);return f=e>f?e:f,e}));"auto"!==a?d=a-n.height:void 0!==s&&(d=f);let p=(t,e,i,o)=>{o.reduce(((e,n)=>(n.fx=t,n.fy=(e+(n.radius||10))*i,e+(2*(n.radius||10)+s))),n.top/i)};return t.forEach(((t,e)=>{let i=o*(e+0)+n.left;const s=d/u[e];p(i,u[e],s,t)})),p(c+(n.width||o),u[u.length-1],d/u[u.length-1],e),{layoutWidth:c+n.width,layoutHeight:d+n.height}})({layerNodes:n,remainNodes:i.remainNodes},t);this.simulation.alpha(0).restart();const a=Math.max(Math.min(this.width/s,this.height/o,1),.6);return this.transformTo(this.getD3().zoomIdentity.translate(this.width/2-s/2*a,this.height/2-o/2*a).scale(a),t.initDuration),{layoutWidth:s,layoutHeight:o}},install(t){t.inject(this)}}),bt=()=>({layoutRing(t){let e=yt(this.data,t),i=this.dom.getBoundingClientRect(),{radiusArr:n,nodes:s}=(({rectObj:t,layerNodes:e,remainNodes:i},n)=>{let{width:s,height:o}=t,r={top:30,bottom:30,left:30,right:30};r.width=r.left+r.right,r.height=r.top+r.bottom,s-=r.width,o-=r.height;let a=e,l=a[0][0];l.fx=s/2+r.top,l.fy=o/2+r.left;let c=Math.min(s,o)/2/(a.length-1),d=[];a.forEach(((t,e)=>{d.push(e*c)}));let h=t=>t*(Math.PI/180);return a.forEach(((t,e)=>{if(e>0){let i=(t=>{let e=[],i=360/t;for(let n=0;n<t;n++)e.push(i*n);return e})(t.length);t.forEach(((t,n)=>{let s=i[n],o=d[e],r=l.fx+o*Math.cos(h(s)),a=l.fy+o*Math.sin(h(s));t.fx=r,t.fy=a}))}})),{nodes:a,radiusArr:d}})({rectObj:i,layerNodes:e.nextNodesLevel,remainNodes:e.remainNodes});return this.simulation.alpha(1).restart(),{radiusArr:n,nodes:s}},install(t){t.inject(this)}}),kt=()=>({layoutForce(){let{nodes:t,links:e}=this.data;t.forEach((t=>{t.fx=void 0,t.fy=void 0})),this.simulation.alpha(.1).restart()},install(t){t.inject(this)}}),vt=()=>({canClose:!0,popupInstanceIndex:0,popupInstances:[],openPopup(t=0,e=0,i,n=200){this.popupInstanceIndex=this.popupInstanceIndex+1;const s=["position: fixed",`top: ${e+=10}px`,`left: ${t+=10}px`,"padding: 12px",`width: ${n}px`,"background: #FFFFFF","z-index: 2","box-shadow: 0 -2px 4px 0 rgba(0,0,0,0.02), 0 2px 6px 6px rgba(0,0,0,0.02), 0 2px 6px 0 rgba(0,0,0,0.06)","border-radius: 4px","opacity: 0","transition: opacity 0.4s 0.2s"],o=this.popupInstances[this.popupInstanceIndex]=document.createElement("div");o.className="popup-container",o.id=`popup-${this.popupInstanceIndex}`,o.style=s.join(";"),o.innerHTML=i,document.body.appendChild(o),setTimeout((()=>{o.style.opacity=1}),10),this.initPopupEvent(o)},mouseEnterEvent(t){this.canClose=!1},mouseLeaveEvent(t){this.canClose=!0,this.closePopup.call(this,0)},initPopupEvent(t){t.addEventListener("mouseenter",this.mouseEnterEvent),t.addEventListener("mouseleave",this.mouseLeaveEvent)},removePopupEvent(t){t&&t.removeEventListener("mouseenter",this.mouseEnterEvent),t&&t.removeEventListener("mouseleave",this.mouseLeaveEvent)},openLinkPopup(t,e,i,n=""){if(!1===i.showPopup)return;if(!this.options.showLinkPopup&&!i.showPopup)return;const{generateLinkPopupTemplate:s}=this.options;n=n||"function"==typeof s&&s(i)||this.generateLinkPopupTemplate(i),this.openPopup(t,e,n)},openNodePopup(t,e,i,n=""){if(!1===i.showPopup)return;if(!this.options.showNodePopup&&!i.showPopup)return;const{generateNodePopupTemplate:s}=this.options;n=n||"function"==typeof s&&s(i)||this.generateNodePopupTemplate(i),this.openPopup(t,e,n)},generateNodePopupTemplate:t=>`<div class="popup-content">\n <div class="header">\n <span style="vertical-align: top; color: rgba(0, 0, 0, 0.6); margin-right: 10px">节点id:</span>\n <span style="display: inline-block; width: 115px; word-break: break-all; white-space: pre-line;">${t.id}</span>\n </div>\n ${t.description?`<div class="content" style="color: rgba(0, 0, 0, 0.6); margin-top: 12px">\n\t\t\t\t ${t.description||""}\n </div>`:""}\n </div>`,generateLinkPopupTemplate:t=>`<div class="popup-content">\n <div class="header" style="display: flex; justify-content: space-between; align-items: center">\n <span style="width: 60px; overflow: hidden; text-overflow: ellipsis;flex-shrink: 0;">${t.source.id}</span>\n <span style="font-size: 0">\n <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="60" height="32">\n <path d="M555.853 62l406.147 450-406.147 450z" p-id="9727" fill="#DEE8FA"></path>\n <path d="M62 292.625h624.015v438.75h-624.015v-438.75z" p-id="9728" fill="#DEE8FA"></path>\n </svg>\n </span>\n <span style="width: 60px; overflow: hidden; text-overflow: ellipsis;flex-shrink: 0;">${t.target.id}</span>\n </div>\n <div class="content" style="color: rgba(0, 0, 0, 0.6); margin-top: 12px">\n\t\t\t\t${t.description||""}\n </div>\n </div>`,closePopup(t=50){const e=this.popupInstanceIndex;setTimeout((()=>{if(!this.canClose)return;const t=this.popupInstances[e];this.removePopupEvent(t),t&&document.body.removeChild(t),this.popupInstances[e]=null,this.popupInstances.forEach(((t,e)=>{t&&e!==this.popupInstances.length-1&&this.removeDom(t)}))}),t)},removeDom(t){const{id:e}=t,i=document.getElementById(e);i&&(this.removePopupEvent(i),document.body.removeChild(i))},closeAllPopups(){this.popupInstances=this.popupInstances.map((t=>(t&&this.removeDom(t),null)))},install(t){t.inject(this)}});function Et(t){return t&&t.classList?Array.prototype.includes.call(t.classList,"menu-item")?t.id:Et(t=t.parentNode):""}let xt=()=>({nodeMenu:[{icon:"mtdicon-hierarchy-o",name:"拓展节点",callback:(t,e)=>{}},{icon:"mtdicon-visibility-off-o",name:"隐藏节点",callback:(t,e)=>{}}],contextMenuId:"force-graph-vis-context-menu",menuInstance:null,openMenu(t,e,i,{width:n=200}){this.menuInstance&&this.closeMenu();const s=["position: fixed",`top: ${e+=10}px`,`left: ${t+=10}px`,"padding: 12px",`width: ${n}px`,"background: #FFFFFF","z-index: 2","box-shadow: 0 -2px 4px 0 rgba(0,0,0,0.02), 0 2px 6px 6px rgba(0,0,0,0.02), 0 2px 6px 0 rgba(0,0,0,0.06)","border-radius: 4px","opacity: 0","transition: opacity 0.4s 0.2s"],o=this.menuInstance=document.createElement("div");o.className="context-menu-container",o.id=this.contextMenuId,o.style=s.join(";"),o.innerHTML=i,document.body.appendChild(o),setTimeout((()=>{o.style.opacity=1}),10),this.initMenuEvent(o)},menuEventHandler(t){const e=this.menuInstance,i=t.target;if(i===e||e.contains(i)){const t=Et(i),e=this.nodeMenu.find((e=>e.id===t)),n=e&&e.callback,s=e&&e.data;"function"==typeof n&&n(s,this)}else this.closeMenu()},initMenuEvent(t){window.addEventListener("click",this.menuEventHandler)},removeMenuEvent(){window.removeEventListener("click",this.menuEventHandler)},closeMenu(){this.removeMenuEvent(),document.body.removeChild(this.menuInstance),this.menuInstance=null},generateMenuItem(t){const{icon:e,name:i}=t,n=`menu-${i}`;t.id=n;return`\n <div class="menu-item" id="${n}" style="font-size: 14px; color: rgba(0, 0, 0, 0.84); margin: 7px 0; cursor: pointer;">\n <i class='mtdicon ${e}'></i>\n <span>${i}</span> \n </div>`},generateNodeMenu(t){return this.nodeMenu.map((e=>(e.data=t,this.generateMenuItem(e)))).join("")},openNodePopupByRightClick(t,e,{data:i,template:n="",width:s}){this.closeAllPopups(),n=n||this.generateNodeMenu(i),this.openMenu(t,e,n,s)},install(t){t.inject(this)}}),Ft=()=>({drawLock(t=this.nodesGroup){this.lockGroup=t.append("g").attr("class","kg-force-node-ctrl-area-group"),this.lockGroup.append("circle").on("click",((t,e)=>{let{event:i,d:n}=this.compatMouseEvent(t,e);this.optio