(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7917],{99790:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/graph",function(){return l(77574)}])},77574:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return f}});var a=l(85893),n=l(76212),r=l(71965),i=l(47020),o=l(99397),d=l(74330),u=l(14726),s=l(96486),c=l(11163),b=l(67294);let g=["#5F95FF","#61DDAA","#F6BD16","#7262FD","#78D3F8","#9661BC","#F6903D","#008685","#F08BB4"];var f=function(){let e=(0,c.useRouter)(),[t,l]=(0,b.useState)(null),f=(0,b.useRef)(),[h,p]=(0,b.useState)(!1),v=async()=>{let[e,t]=await (0,n.Vx)((0,n.FT)(y,{limit:500}));l(t)},m=e=>{if(!e)return{nodes:[],edges:[]};let t=e.nodes.map(e=>({id:e.id,data:e})),l=e.edges.map(e=>({source:e.source,target:e.target,data:e}));return{nodes:t,edges:l}},{query:{spaceName:y}}=(0,c.useRouter)();(0,b.useEffect)(()=>{y&&v()},[y]);let k=(0,b.useMemo)(()=>m(t),[t]);(0,b.useEffect)(()=>{if(h&&f.current){let e=(0,s.groupBy)(k.nodes,e=>e.data.communityId),t=[];Object.entries(e).forEach(e=>{var l;let[a,n]=e;if(!a||n.length<2)return;let r=null===(l=f.current)||void 0===l?void 0:l.getElementRenderStyle((0,i.jD)(n[0])).fill;t.push({key:a,type:"bubble-sets",members:n.map(i.jD),stroke:r,fill:r,fillOpacity:.1})}),f.current.setPlugins(e=>[...e,...t])}},[h]);let F=e=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:24,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10;return t+(Math.max(a,Math.min(n,e))-a)/(n-a)*(l-t)})(W(e)),W=e=>e?k.edges.filter(t=>t.source===e||t.target===e).length:0;return t?(0,a.jsx)("div",{className:"p-4 h-full overflow-y-scroll relative px-2",children:(0,a.jsx)(o.P3,{ref:e=>{f.current=e},style:{height:"100%",width:"100%"},options:{data:k,autoFit:"center",node:{style:e=>{var t;let l={size:F((0,i.jD)(e)),label:!0,labelLineWidth:2,labelText:null===(t=e.data)||void 0===t?void 0:t.name,labelFontSize:10,labelBackground:!0,labelBackgroundFill:"#e5e7eb",labelPadding:[0,6],labelBackgroundRadius:4,labelMaxWidth:"400%",labelWordWrap:!0};return!function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,a=(0,s.groupBy)(e.nodes,e=>e.data.communityId),n=Object.values(a).find(e=>e.map(i.jD).includes(t));return n.length>l}(k,(0,i.jD)(e))&&Object.assign(l,{fill:"#b0b0b0"}),l},state:{active:{lineWidth:2,labelWordWrap:!1,labelFontSize:12,labelFontWeight:"bold"},inactive:{label:!1}},palette:{type:"group",field:"communityId",color:g}},edge:{style:{lineWidth:1,stroke:"#e2e2e2",endArrow:!0,endArrowType:"vee",label:!0,labelFontSize:8,labelBackground:!0,labelText:e=>e.data.name,labelBackgroundFill:"#e5e7eb",labelPadding:[0,6],labelBackgroundRadius:4,labelMaxWidth:"60%",labelWordWrap:!0},state:{active:{stroke:"#b0b0b0",labelWordWrap:!1,labelFontSize:10,labelFontWeight:"bold"},inactive:{label:!1}}},behaviors:["drag-canvas","zoom-canvas","drag-element",{type:"hover-activate",degree:1,state:"active",enable:e=>["node"].includes(e.targetType)}],animation:!1,layout:{type:"force",preventOverlap:!0,nodeSize:e=>F(null==e?void 0:e.id),linkDistance:e=>{let{source:t,target:l}=e,a=Math.min(F(t),F(l)),n=Math.min(W(t),W(l));return 1===n?2*a:Math.min(n*a*1.5,700)}},transforms:["process-parallel-edges"]},onReady:()=>{p(!0)},children:(0,a.jsx)(u.ZP,{style:{background:"#fff"},onClick:()=>{e.push("/construct/knowledge")},icon:(0,a.jsx)(r.Z,{}),children:"Back"})})}):(0,a.jsx)(d.Z,{className:"h-full justify-center content-center"})}}},function(e){e.O(0,[3662,3817,4330,215,2973,4744,1741,9774,2888,179],function(){return e(e.s=99790)}),_N_E=e.O()}]);