1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1165],{1165:(e,t,a)=>{a.r(t),a.d(t,{FlowObserver:()=>x});var s=a(95155),n=a(12115),o=a(22539),i=a(76122),r=a(50546),l=a(91480),d=a(69170),c=a.n(d),p=a(30627),u=a(65212),g=a(3412),h=a(72827);a(8301);let f={custom:e=>{let{data:t}=e,a=t.messageCount>5?"#10b981":"#ffffff",n=t.selected;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.h7,{type:"target",position:i.yX.Left}),(0,s.jsxs)("div",{style:{padding:"10px",background:"#191919",border:n?"0.5px solid #10b981":"0.5px solid hsl(0, 0%, 16%)",borderRadius:"6px",color:a,fontSize:"12px",flexDirection:"row",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s ease"},children:[(0,s.jsx)(l.A,{size:14,color:a}),(0,s.jsx)("span",{children:t.appName}),(0,s.jsxs)("span",{style:{color:"#525252"},children:[t.sendsCount," | ",t.receivesCount]})]}),(0,s.jsx)(o.h7,{type:"source",position:i.yX.Right})]})}},m=e=>"fusioncat-flow-state-".concat(e),y=(e,t,a)=>{try{let s={nodes:e.map(e=>({id:e.id,position:e.position})),viewport:t,timestamp:Date.now()};sessionStorage.setItem(m(a),JSON.stringify(s))}catch(e){}},w=e=>{try{let t=sessionStorage.getItem(m(e));if(!t)return null;let a=JSON.parse(t);return{nodes:new Map(a.nodes.map(e=>[e.id,e.position])),viewport:a.viewport}}catch(e){return null}},v=new(c()),k=async(e,t)=>{let a={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.spacing.nodeNode":"80","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.edgeNode":"50","elk.spacing.edgeEdge":"30","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.cycleBreaking.strategy":"GREEDY","elk.layered.layering.strategy":"NETWORK_SIMPLEX","elk.edgeRouting":"ORTHOGONAL","elk.padding":"[top=100,left=100,bottom=100,right=100]"},children:e.map(e=>({id:e.id,width:200,height:60})),edges:t.map(e=>({id:e.id,sources:[e.source],targets:[e.target]}))};try{let t=await v.layout(a);return e.map(e=>{var a,s,n;let o=null==(a=t.children)?void 0:a.find(t=>t.id===e.id);return{...e,position:{x:null!=(s=null==o?void 0:o.x)?s:0,y:null!=(n=null==o?void 0:o.y)?n:0}}})}catch(t){return console.error("ELK layout failed:",t),e}},E=(0,r.PA)(function(e){let{projectYamlData:t,appData:a,schemaData:r,messagesData:l,serversData:d,channelsData:c}=e,[v,E]=(0,n.useState)([]),{setViewport:x,getViewport:N}=(0,o.VH)(),b=(0,n.useRef)(!0),I=(0,u.y)(t),{flowMessagesStore:C,selectionStore:S,highlightStore:A,layoutStore:M,propsStore:T}=(0,p.E)(),j=(0,g.M)(I),O=(0,h.F)(I),R=T.projectIdValue||"default";(0,n.useEffect)(()=>{sessionStorage.removeItem("fusioncat-flow-state")},[]);let z=(0,n.useCallback)((e,t)=>{let s=t.data;if(C.activeNodeId===t.id)C.clearFlowMessages(),C.setActiveNode(null,null);else{M.closeCreatePanel();let e=a.find(e=>e.id===t.id);if(e&&e.name){let t=O(e.name,"app");S.setSelectedElement(e,t,e.name,"application"),A.highlightElement(e.name,"application")}let{sends:n,receives:o}=j(s.appName);C.setFlowMessages(s.appName,n,o),C.setActiveNode(t.id,"application")}},[j,C,a,O,S,A,M]),_=(0,n.useCallback)(e=>{E(t=>{let a=(0,o._0)(e,t);return y(a,N(),R),a})},[N,R]),{nodes:D,edges:G}=(0,n.useMemo)(()=>{let e=[],t=[],s=(null==I?void 0:I.apps)||[];
1if(0===a.length)return{nodes:[],edges:[]};let n=new Map,o=new Map,r=w(R),l=(null==r?void 0:r.nodes)||new Map;a.forEach((t,a)=>{var i,r;if(!t.id||!t.name)return;n.set(t.id,t.name),o.set(t.name,t.id);let d=s.find(e=>e.name===t.name),c=(null==d||null==(i=d.sends)?void 0:i.length)||0,p=(null==d||null==(r=d.receives)?void 0:r.length)||0,u=l.get(t.id)||{x:200+a%3*300,y:100+200*Math.floor(a/3)};e.push({id:t.id,type:"custom",position:u,data:{appName:t.name,appId:t.id,messageCount:c+p,connectionCount:0,sendsCount:0,receivesCount:0,entityType:"app",entityName:t.name},zIndex:2})});let d=new Map,c=new Map;s.forEach(e=>{e.receives&&e.receives.forEach(t=>{let a="".concat(t.message,"::").concat(t.resource);c.has(a)||c.set(a,{receivers:new Set,resource:t.resource,message:t.message}),c.get(a).receivers.add(e.name)})}),c.forEach(e=>{let t=Array.from(e.receivers);if(t.length>1)for(let a=0;a<t.length;a++)for(let s=a+1;s<t.length;s++){let n=o.get(t[a]),i=o.get(t[s]);if(!n||!i)continue;let[r,l]=[n,i].sort(),c="".concat(r,"<->").concat(l);d.has(c)||d.set(c,{app1:r,app2:l,flows:[],bidirectional:!0});let p=d.get(c);p.flows.some(t=>t.message===e.message)||p.flows.push({message:e.message,resource:e.resource})}});let p=new Map;return d.forEach(e=>{p.has(e.app1)||p.set(e.app1,new Set),p.has(e.app2)||p.set(e.app2,new Set),p.get(e.app1).add(e.app2),p.get(e.app2).add(e.app1)}),e.forEach(e=>{var t,a;let o=n.get(e.id),i=s.find(e=>e.name===o),r=p.get(e.id);e.data.connectionCount=r?r.size:0,e.data.sendsCount=(null==i||null==(t=i.sends)?void 0:t.length)||0,e.data.receivesCount=(null==i||null==(a=i.receives)?void 0:a.length)||0}),d.forEach((e,a)=>{t.push({id:a,source:e.app1,target:e.app2,type:"smoothstep",animated:!1,style:{stroke:"#525252",strokeWidth:1},markerEnd:{type:i.TG.Arrow,color:"#525252",width:16,height:16},markerStart:{type:i.TG.Arrow,color:"#525252",width:16,height:16},data:{flows:e.flows,bidirectional:e.bidirectional}})}),{nodes:e,edges:t,needsLayout:0===l.size}},[I,a,R]);(0,n.useEffect)(()=>{D.length&&G.length&&(async()=>{let e=w(R);if(0===((null==e?void 0:e.nodes)||new Map).size){let e=[],t=[];D.forEach(a=>{a.data.connectionCount>0?e.push(a):t.push(a)});let a=0;if(e.length>0){let s=G.filter(t=>e.some(e=>e.id===t.source)&&e.some(e=>e.id===t.target)),n=await k(e,s);n.forEach(e=>{let t=e.position.x+200;t>a&&(a=t)}),E(e=>{let s=e.map(e=>{let t=n.find(t=>t.id===e.id);return t?{...e,position:t.position}:e});if(t.length>0){let e=a>0?a+400:100;t.forEach((t,a)=>{let n=s.find(e=>e.id===t.id);n&&(n.position={x:e,y:100+100*a})})}return s})}else t.length>0&&E(e=>e.map((e,t)=>({...e,position:{x:100,y:100+100*t}})))}})()},[D,G,R]),(0,n.useEffect)(()=>{E(D)},[D]),(0,n.useEffect)(()=>{if(b.current){let e=w(R);(null==e?void 0:e.viewport)&&setTimeout(()=>{x(e.viewport,{duration:0})},0),b.current=!1}},[x,R]),(0,n.useEffect)(()=>{let e=setTimeout(()=>{b.current||y(v,N(),R)},300);return()=>clearTimeout(e)},[v,N,R]);let L=(0,n.useMemo)(()=>v.map(e=>({...e,data:{...e.data,selected:C.activeNodeId===e.id}})),[v,C.activeNodeId]),P=(0,n.useMemo)(()=>{let e=G.map(e=>{let t=C.activeNodeId===e.source||C.activeNodeId===e.target,a="#292929";if(t){let e=C.receives.length>0,t=C.sends.length>0;e?a="#10b981":t&&(a="var(--edge-color)")}return{...e,style:t?{stroke:a,strokeWidth:1}:{stroke:"#525252",strokeWidth:1},markerEnd:{type:i.TG.Arrow,color:t?a:"#525252",width:16,height:16},markerStart:{type:i.TG.Arrow,color:t?a:"#525252",width:16,height:16},...t&&{zIndex:1}}}),t=C.draftConnection;if(t&&t.sourceAppId&&t.targetAppId){let a={id:"draft-connection",source:"sends"===t.direction?t.sourceAppId:t.targetAppId,target:"sends"===t.direction?t.targetAppId:t.sourceAppId,type:"smoothstep",animated:!0,style:{stroke:"#6b7280",strokeWidth:2,strokeDasharray:"5,5"},markerEnd:{type:i.TG.ArrowClosed,color:"#6b7280",width:16,height:16},label:t.messageName||"New connection",labelStyle:{fill:"#9ca3af",fontSize:10,fontWeight:500},labelBgStyle:{fill:"#1f2937",fillOpacity:.9},labelBgPadding:[4,8],labelBgBorderRadius:4,zIndex:10};e.push(a)}return e},[G,C.activeNodeId,C.receives,C.sends,C.draftConnection]),W=(0,n.useCallback)(e=>{2===e.detail&&(sessionStorage.removeItem(m(R)),E([]),setTimeout(()=>{E(D)},0))},[D,R]);return(0,s.jsx)("div",{style:{width:"100%",height:"100%",background:"hsl(0, 0%, 8%)"},onClickCapture:W,children:(0,s.jsx)(o.Gc,{nodes:L,edges:P,nodeTypes:f,onNodeClick:z,onNodesChange:_,nodesDraggable:!0,fitView:b.current&&!w(R),fitViewOptions:{padding:.2},children:(0,s.jsx)(o.VS,{color:"#525252",gap:16})})})}),x=(0,r.PA)(function(e){return(0,s.jsx)(o.Ln,{children:(0,s.jsx)(E,{...e})})})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.