UNPKG

@asyncapi/studio

Version:

One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.

1 lines 69.4 kB
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5405],{53940:function(e,t,n){n.d(t,{AC:function(){return k},HH:function(){return eI},Ly:function(){return g},Mi:function(){return nw},Rr:function(){return nE},SM:function(){return nb},UG:function(){return em},_K:function(){return tC},ll:function(){return nM},oR:function(){return C},s_:function(){return _},x$:function(){return ny}});var o,r,l,a,i,s,d,c,u,g,p=n(28148),h=n(95970),f=n(67822),m=n(13582),y=n(7086),x=n(27338),b=n(3302),S=n(67933),w=n(82440),v=n(73686);n(44294);let E=(0,h.createContext)(null),M=E.Provider,N="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#100";function C(e,t){let n=(0,h.useContext)(E);if(null===n)throw Error(N);return(0,m.oR)(n,e,t)}let k=()=>{let e=(0,h.useContext)(E);if(null===e)throw Error(N);return(0,h.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},A=e=>e.userSelectionActive?"none":"all";function _({position:e,children:t,className:n,style:o,...r}){let l=C(A),a=`${e}`.split("-");return(0,p.jsx)("div",{className:(0,f.Z)(["react-flow__panel",n,...a]),style:{...o,pointerEvents:l},...r,children:t})}function I({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:(0,p.jsx)(_,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:(0,p.jsx)("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}var $=(0,h.memo)(({x:e,y:t,label:n,labelStyle:o={},labelShowBg:r=!0,labelBgStyle:l={},labelBgPadding:a=[2,4],labelBgBorderRadius:i=2,children:s,className:d,...c})=>{let u=(0,h.useRef)(null),[g,m]=(0,h.useState)({x:0,y:0,width:0,height:0}),y=(0,f.Z)(["react-flow__edge-textwrapper",d]);return((0,h.useEffect)(()=>{if(u.current){let e=u.current.getBBox();m({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),void 0!==n&&n)?(0,p.jsxs)("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:y,visibility:g.width?"visible":"hidden",...c,children:[r&&(0,p.jsx)("rect",{width:g.width+2*a[0],x:-a[0],y:-a[1],height:g.height+2*a[1],className:"react-flow__edge-textbg",style:l,rx:i,ry:i}),(0,p.jsx)("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:u,style:o,children:n}),s]}):null});let j=({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:l,labelBgStyle:a,labelBgPadding:i,labelBgBorderRadius:s,style:d,markerEnd:c,markerStart:u,interactionWidth:g=20})=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("path",{style:d,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:c,markerStart:u}),g&&(0,p.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:g,className:"react-flow__edge-interaction"}),o?(0,p.jsx)($,{x:t,y:n,label:o,labelStyle:r,labelShowBg:l,labelBgStyle:a,labelBgPadding:i,labelBgBorderRadius:s}):null]});function P(e,t,n){return void 0===n?n:o=>{let r=t().edges.find(t=>t.id===e);r&&n(o,{...r})}}function O({sourceX:e,sourceY:t,targetX:n,targetY:o}){let r=Math.abs(n-e)/2,l=Math.abs(o-t)/2;return[n<e?n+r:n-r,o<t?o+l:o-l,r,l]}function B({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:l,targetControlX:a,targetControlY:i}){let s=.125*e+.375*r+.375*a+.125*n,d=.125*t+.375*l+.375*i+.125*o;return[s,d,Math.abs(s-e),Math.abs(d-t)]}j.displayName="BaseEdge",(o=s||(s={})).Strict="strict",o.Loose="loose",(r=d||(d={})).Free="free",r.Vertical="vertical",r.Horizontal="horizontal";let z=e=>({width:e.offsetWidth,height:e.offsetHeight}),R=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),L=(e={x:0,y:0},t)=>({x:R(e.x,t[0][0],t[1][0]),y:R(e.y,t[0][1],t[1][1])}),D=e=>e.getRootNode?.()||window?.document,H=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),T=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Z=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),F=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Y=(e,t)=>Math.ceil(Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))),V=e=>!!e.width&&!!e.height&&!!e.x&&!!e.y,X=e=>!isNaN(e)&&isFinite(e),U=Symbol.for("internals"),K=["Enter"," ","Escape"],W=e=>{};function G({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===g.Left||e===g.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function q({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:l=g.Top}){let[a,i]=G({pos:n,x1:e,y1:t,x2:o,y2:r}),[s,d]=G({pos:l,x1:o,y1:r,x2:e,y2:t}),[c,u,p,h]=B({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:i,targetControlX:s,targetControlY:d});return[`M${e},${t} C${a},${i} ${s},${d} ${o},${r}`,c,u,p,h]}(l=c||(c={})).Bezier="default",l.Straight="straight",l.Step="step",l.SmoothStep="smoothstep",l.SimpleBezier="simplebezier",(a=u||(u={})).Arrow="arrow",a.ArrowClosed="arrowclosed",(i=g||(g={})).Left="left",i.Top="top",i.Right="right",i.Bottom="bottom";let Q=(0,h.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=g.Bottom,targetPosition:l=g.Top,label:a,labelStyle:i,labelShowBg:s,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:y})=>{let[x,b,S]=q({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:l});return(0,p.jsx)(j,{path:x,labelX:b,labelY:S,label:a,labelStyle:i,labelShowBg:s,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:y})});Q.displayName="SimpleBezierEdge";let J={[g.Left]:{x:-1,y:0},[g.Right]:{x:1,y:0},[g.Top]:{x:0,y:-1},[g.Bottom]:{x:0,y:1}},ee=({source:e,sourcePosition:t=g.Bottom,target:n})=>t===g.Left||t===g.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},et=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function en({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:l=g.Top,borderRadius:a=5,centerX:i,centerY:s,offset:d=20}){let[c,u,p,h,f]=function({source:e,sourcePosition:t=g.Bottom,target:n,targetPosition:o=g.Top,center:r,offset:l}){let a,i;let s=J[t],d=J[o],c={x:e.x+s.x*l,y:e.y+s.y*l},u={x:n.x+d.x*l,y:n.y+d.y*l},p=ee({source:c,sourcePosition:t,target:u}),h=0!==p.x?"x":"y",f=p[h],m=[],[y,x,b,S]=O({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[h]*d[h]==-1){a=r.x||y,i=r.y||x;let e=[{x:a,y:c.y},{x:a,y:u.y}],t=[{x:c.x,y:i},{x:u.x,y:i}];m=s[h]===f?"x"===h?e:t:"x"===h?t:e}else{let e=[{x:c.x,y:u.y}],n=[{x:u.x,y:c.y}];if(m="x"===h?s.x===f?n:e:s.y===f?e:n,t!==o){let t="x"===h?"y":"x",o=s[h]===d[t],r=c[t]>u[t],l=c[t]<u[t];(1===s[h]&&(!o&&r||o&&l)||1!==s[h]&&(!o&&l||o&&r))&&(m="x"===h?e:n)}a=m[0].x,i=m[0].y}return[[e,c,...m,u,n],a,i,b,S]}({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:l,center:{x:i,y:s},offset:d});return[c.reduce((e,t,n)=>e+(n>0&&n<c.length-1?function(e,t,n,o){let r=Math.min(et(e,t)/2,et(t,n)/2,o),{x:l,y:a}=t;if(e.x===l&&l===n.x||e.y===a&&a===n.y)return`L${l} ${a}`;if(e.y===a){let t=e.x<n.x?-1:1,o=e.y<n.y?1:-1;return`L ${l+r*t},${a}Q ${l},${a} ${l},${a+r*o}`}let i=e.x<n.x?1:-1,s=e.y<n.y?-1:1;return`L ${l},${a+r*s}Q ${l},${a} ${l+r*i},${a}`}(c[n-1],t,c[n+1],a):`${0===n?"M":"L"}${t.x} ${t.y}`),""),u,p,h,f]}let eo=(0,h.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:l,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:d,style:c,sourcePosition:u=g.Bottom,targetPosition:h=g.Top,markerEnd:f,markerStart:m,pathOptions:y,interactionWidth:x})=>{let[b,S,w]=en({sourceX:e,sourceY:t,sourcePosition:u,targetX:n,targetY:o,targetPosition:h,borderRadius:y?.borderRadius,offset:y?.offset});return(0,p.jsx)(j,{path:b,labelX:S,labelY:w,label:r,labelStyle:l,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:d,style:c,markerEnd:f,markerStart:m,interactionWidth:x})});eo.displayName="SmoothStepEdge";let er=(0,h.memo)(e=>(0,p.jsx)(eo,{...e,pathOptions:(0,h.useMemo)(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));er.displayName="StepEdge";let el=(0,h.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:l,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:d,style:c,markerEnd:u,markerStart:g,interactionWidth:h})=>{let[f,m,y]=function({sourceX:e,sourceY:t,targetX:n,targetY:o}){let[r,l,a,i]=O({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,l,a,i]}({sourceX:e,sourceY:t,targetX:n,targetY:o});return(0,p.jsx)(j,{path:f,labelX:m,labelY:y,label:r,labelStyle:l,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:d,style:c,markerEnd:u,markerStart:g,interactionWidth:h})});function ea(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function ei({pos:e,x1:t,y1:n,x2:o,y2:r,c:l}){switch(e){case g.Left:return[t-ea(t-o,l),n];case g.Right:return[t+ea(o-t,l),n];case g.Top:return[t,n-ea(n-r,l)];case g.Bottom:return[t,n+ea(r-n,l)]}}function es({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:l=g.Top,curvature:a=.25}){let[i,s]=ei({pos:n,x1:e,y1:t,x2:o,y2:r,c:a}),[d,c]=ei({pos:l,x1:o,y1:r,x2:e,y2:t,c:a}),[u,p,h,f]=B({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:d,targetControlY:c});return[`M${e},${t} C${i},${s} ${d},${c} ${o},${r}`,u,p,h,f]}el.displayName="StraightEdge";let ed=(0,h.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=g.Bottom,targetPosition:l=g.Top,label:a,labelStyle:i,labelShowBg:s,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,pathOptions:y,interactionWidth:x})=>{let[b,S,w]=es({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:l,curvature:y?.curvature});return(0,p.jsx)(j,{path:b,labelX:S,labelY:w,label:a,labelStyle:i,labelShowBg:s,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:x})});ed.displayName="BezierEdge";let ec=(0,h.createContext)(null),eu=ec.Provider;function eg(e,t,n,o,r,l,a){let i=a.elementFromPoint(e.clientX,e.clientY),d=i?.classList.contains("target")||!1,c=i?.classList.contains("source")||!1,u={elementBelow:i,isValid:!1,connection:{source:null,target:null,sourceHandle:null,targetHandle:null},isHoveringHandle:!1};if(i&&(d||c)){u.isHoveringHandle=!0;let e=i.getAttribute("data-nodeid"),a=i.getAttribute("data-handleid"),g=n?{source:e,sourceHandle:a,target:o,targetHandle:r}:{source:o,sourceHandle:r,target:e,targetHandle:a};u.connection=g,(t!==s.Strict||n&&c||!n&&d)&&(u.isValid=l(g))}return u}function ep(e){e?.classList.remove("react-flow__handle-valid"),e?.classList.remove("react-flow__handle-connecting")}function eh({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:r,getState:l,setState:a,isValidConnection:i,elementEdgeUpdaterType:s,onEdgeUpdateEnd:d}){let c;let u=e.target.closest(".react-flow"),g=D(e.target);if(!g)return;let p=g.elementFromPoint(e.clientX,e.clientY),h=p?.classList.contains("target"),f=p?.classList.contains("source");if(!u||!h&&!f&&!s)return;let{onConnectStart:m,connectionMode:y}=l(),x=s||(h?"target":"source"),b=u.getBoundingClientRect();function S(e){a({connectionPosition:{x:e.clientX-b.left,y:e.clientY-b.top}});let{connection:o,elementBelow:l,isValid:s,isHoveringHandle:d}=eg(e,y,r,n,t,i,g);if(!d)return ep(c);o.source!==o.target&&l&&(ep(c),c=l,l.classList.add("react-flow__handle-connecting"),l.classList.toggle("react-flow__handle-valid",s))}a({connectionPosition:{x:e.clientX-b.left,y:e.clientY-b.top},connectionNodeId:n,connectionHandleId:t,connectionHandleType:x}),m?.(e,{nodeId:n,handleId:t,handleType:x}),g.addEventListener("mousemove",S),g.addEventListener("mouseup",function e(u){let{connection:p,isValid:h}=eg(u,y,r,n,t,i,g);h&&o?.(p),l().onConnectEnd?.(u),s&&d&&d(u),ep(c),a({connectionNodeId:null,connectionHandleId:null,connectionHandleType:null}),g.removeEventListener("mousemove",S),g.removeEventListener("mouseup",e)})}ec.Consumer;let ef=e=>"id"in e&&"source"in e&&"target"in e,em=e=>"id"in e&&!("source"in e)&&!("target"in e),ey=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,ex=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;let n=t?`${t}__`:"";return`${n}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("&")}`},eb=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),eS=(e,t)=>{let n;return e.source&&e.target?eb(n=ef(e)?{...e}:{...e,id:ey(e)},t)?t:t.concat(n):(W("Can't create edge. An edge needs a source and a target. Help: https://reactflow.dev/error#600"),t)},ew=({x:e,y:t},[n,o,r],l,[a,i])=>{let s={x:(e-n)/r,y:(t-o)/r};return l?{x:a*Math.round(s.x/a),y:i*Math.round(s.y/i)}:s},ev=e=>0===e.length?{x:0,y:0,width:0,height:0}:Z(e.reduce((e,{positionAbsolute:t,position:n,width:o,height:r})=>H(e,T({x:t?t.x:n.x,y:t?t.y:n.y,width:o||0,height:r||0})),{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),eE=(e,t,[n,o,r]=[0,0,1],l=!1,a=!1)=>{let i={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},s=[];return e.forEach(e=>{let{positionAbsolute:t={x:0,y:0},width:n,height:o,selectable:r=!0}=e;if(a&&!r)return!1;let d=Y(i,{...t,width:n||0,height:o||0}),c=void 0===n||void 0===o||null===n||null===o,u=(n||0)*(o||0);(c||l&&d>0||d>=u||e.dragging)&&s.push(e)}),s},eM=(e,t)=>{let n=e.map(e=>e.id);return t.filter(e=>n.includes(e.source)||n.includes(e.target))},eN=(e,t,n,o,r,l=.1)=>{let a=R(Math.min(t/(e.width*(1+l)),n/(e.height*(1+l))),o,r);return[t/2-(e.x+e.width/2)*a,n/2-(e.y+e.height/2)*a,a]},eC=(e,t=0)=>e.transition().duration(t),ek=()=>!0,eA=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),e_=(0,h.forwardRef)(({type:e="source",position:t=g.Top,isValidConnection:n=ek,isConnectable:o=!0,id:r,onConnect:l,children:a,className:i,onMouseDown:s,...d},c)=>{let u=k(),m=(0,h.useContext)(ec),{connectionStartHandle:y,connectOnClick:b,noPanClassName:S}=C(eA,x.Z),w=r||null,v="target"===e,E=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=u.getState(),r={...t,...e};if(o){let{edges:e}=u.getState();u.setState({edges:eS(r,e)})}n?.(r),l?.(r)};return(0,p.jsx)("div",{"data-handleid":w,"data-nodeid":m,"data-handlepos":t,className:(0,f.Z)(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,i,{source:!v,target:v,connectable:o,connecting:y?.nodeId===m&&y?.handleId===w&&y?.type===e}]),onMouseDown:e=>{0===e.button&&eh({event:e,handleId:w,nodeId:m,onConnect:E,isTarget:v,getState:u.getState,setState:u.setState,isValidConnection:n}),s?.(e)},onClick:b?t=>{let{onClickConnectStart:o,onClickConnectEnd:r,connectionMode:l}=u.getState();if(!y){o?.(t,{nodeId:m,handleId:w,handleType:e}),u.setState({connectionStartHandle:{nodeId:m,type:e,handleId:w}});return}let a=D(t.target),{connection:i,isValid:s}=eg(t,l,"target"===y.type,y.nodeId,y.handleId||null,n,a);s&&E(i),r?.(t),u.setState({connectionStartHandle:null})}:void 0,ref:c,...d,children:a})});e_.displayName="Handle";var eI=(0,h.memo)(e_);let e$=({data:e,isConnectable:t,targetPosition:n=g.Top,sourcePosition:o=g.Bottom})=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(eI,{type:"target",position:n,isConnectable:t}),e?.label,(0,p.jsx)(eI,{type:"source",position:o,isConnectable:t})]});e$.displayName="DefaultNode";var ej=(0,h.memo)(e$);let eP=({data:e,isConnectable:t,sourcePosition:n=g.Bottom})=>(0,p.jsxs)(p.Fragment,{children:[e?.label,(0,p.jsx)(eI,{type:"source",position:n,isConnectable:t})]});eP.displayName="InputNode";var eO=(0,h.memo)(eP);let eB=({data:e,isConnectable:t,targetPosition:n=g.Top})=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(eI,{type:"target",position:n,isConnectable:t}),e?.label]});eB.displayName="OutputNode";var ez=(0,h.memo)(eB);let eR=()=>null;eR.displayName="GroupNode";let eL=e=>({selectedNodes:Array.from(e.nodeInternals.values()).filter(e=>e.selected),selectedEdges:e.edges.filter(e=>e.selected)}),eD=e=>e.id;function eH(e,t){return(0,x.Z)(e.selectedNodes.map(eD),t.selectedNodes.map(eD))&&(0,x.Z)(e.selectedEdges.map(eD),t.selectedEdges.map(eD))}let eT=(0,h.memo)(({onSelectionChange:e})=>{let t=k(),{selectedNodes:n,selectedEdges:o}=C(eL,eH);return(0,h.useEffect)(()=>{let r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChange?.(r)},[n,o,e]),null});eT.displayName="SelectionListener";let eZ=e=>!!e.onSelectionChange;function eF({onSelectionChange:e}){let t=C(eZ);return e||t?(0,p.jsx)(eT,{onSelectionChange:e}):null}let eY=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function eV(e,t){(0,h.useEffect)(()=>{void 0!==e&&t(e)},[e])}function eX(e,t,n){(0,h.useEffect)(()=>{void 0!==t&&n({[e]:t})},[t])}let eU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:r,onConnectStart:l,onConnectEnd:a,onClickConnectStart:i,onClickConnectEnd:s,nodesDraggable:d,nodesConnectable:c,nodesFocusable:u,edgesFocusable:g,minZoom:p,maxZoom:f,nodeExtent:m,onNodesChange:y,onEdgesChange:b,elementsSelectable:S,connectionMode:w,snapGrid:v,snapToGrid:E,translateExtent:M,connectOnClick:N,defaultEdgeOptions:A,fitView:_,fitViewOptions:I,onNodesDelete:$,onEdgesDelete:j,onNodeDrag:P,onNodeDragStart:O,onNodeDragStop:B,onSelectionDrag:z,onSelectionDragStart:R,onSelectionDragStop:L,noPanClassName:D,nodeOrigin:H,rfId:T})=>{let{setNodes:Z,setEdges:F,setDefaultNodesAndEdges:Y,setMinZoom:V,setMaxZoom:X,setTranslateExtent:U,setNodeExtent:K,reset:W}=C(eY,x.Z),G=k();return(0,h.useEffect)(()=>(Y(n,o?.map(e=>({...e,...A}))),()=>{W()}),[]),eX("defaultEdgeOptions",A,G.setState),eX("connectionMode",w,G.setState),eX("onConnect",r,G.setState),eX("onConnectStart",l,G.setState),eX("onConnectEnd",a,G.setState),eX("onClickConnectStart",i,G.setState),eX("onClickConnectEnd",s,G.setState),eX("nodesDraggable",d,G.setState),eX("nodesConnectable",c,G.setState),eX("nodesFocusable",u,G.setState),eX("edgesFocusable",g,G.setState),eX("elementsSelectable",S,G.setState),eX("snapToGrid",E,G.setState),eX("snapGrid",v,G.setState),eX("onNodesChange",y,G.setState),eX("onEdgesChange",b,G.setState),eX("connectOnClick",N,G.setState),eX("fitViewOnInit",_,G.setState),eX("fitViewOnInitOptions",I,G.setState),eX("onNodesDelete",$,G.setState),eX("onEdgesDelete",j,G.setState),eX("onNodeDrag",P,G.setState),eX("onNodeDragStart",O,G.setState),eX("onNodeDragStop",B,G.setState),eX("onSelectionDrag",z,G.setState),eX("onSelectionDragStart",R,G.setState),eX("onSelectionDragStop",L,G.setState),eX("noPanClassName",D,G.setState),eX("nodeOrigin",H,G.setState),eX("rfId",T,G.setState),eV(e,Z),eV(t,F),eV(p,V),eV(f,X),eV(M,U),eV(m,K),null},eK={display:"none"},eW={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},eG="react-flow__node-desc",eq="react-flow__edge-desc",eQ=e=>e.ariaLiveMessage;function eJ({rfId:e}){let t=C(eQ);return(0,p.jsx)("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:eW,children:t})}function e0({rfId:e,disableKeyboardA11y:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{id:`${eG}-${e}`,style:eK,children:["Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),(0,p.jsx)("div",{id:`${eq}-${e}`,style:eK,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&(0,p.jsx)(eJ,{rfId:e})]})}let e1=(e,t,n)=>n===g.Left?e-t:n===g.Right?e+t:e,e2=(e,t,n)=>n===g.Top?e-t:n===g.Bottom?e+t:e,e5="react-flow__edgeupdater",e3=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:l,onMouseOut:a,type:i})=>(0,p.jsx)("circle",{onMouseDown:r,onMouseEnter:l,onMouseOut:a,className:(0,f.Z)([e5,`${e5}-${i}`]),cx:e1(t,o,e),cy:e2(n,o,e),r:o,stroke:"transparent",fill:"transparent"});var e4=e=>{let t=({id:t,className:n,type:o,data:r,onClick:l,onEdgeDoubleClick:a,selected:i,animated:s,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:g,labelBgPadding:m,labelBgBorderRadius:y,style:x,source:b,target:S,sourceX:w,sourceY:v,targetX:E,targetY:M,sourcePosition:N,targetPosition:C,elementsSelectable:A,hidden:_,sourceHandleId:I,targetHandleId:$,onContextMenu:j,onMouseEnter:O,onMouseMove:B,onMouseLeave:z,edgeUpdaterRadius:R,onEdgeUpdate:L,onEdgeUpdateStart:D,onEdgeUpdateEnd:H,markerEnd:T,markerStart:Z,rfId:F,ariaLabel:Y,isFocusable:V,pathOptions:X,interactionWidth:U})=>{let W=(0,h.useRef)(null),[G,q]=(0,h.useState)(!1),[Q,J]=(0,h.useState)(!1),ee=k(),et=(0,h.useMemo)(()=>`url(#${ex(Z,F)})`,[Z,F]),en=(0,h.useMemo)(()=>`url(#${ex(T,F)})`,[T,F]);if(_)return null;let eo=P(t,ee.getState,a),er=P(t,ee.getState,j),el=P(t,ee.getState,O),ea=P(t,ee.getState,B),ei=P(t,ee.getState,z),es=(e,n)=>{let o=n?S:b,r=(n?$:I)||null,l=n?"target":"source",a=ee.getState().edges.find(e=>e.id===t);J(!0),D?.(e,a,l),eh({event:e,handleId:r,nodeId:o,onConnect:e=>L?.(a,e),isTarget:n,getState:ee.getState,setState:ee.setState,isValidConnection:()=>!0,elementEdgeUpdaterType:l,onEdgeUpdateEnd:e=>{J(!1),H?.(e,a,l)}})},ed=()=>q(!0),ec=()=>q(!1);return(0,p.jsxs)("g",{className:(0,f.Z)(["react-flow__edge",`react-flow__edge-${o}`,n,{selected:i,animated:s,inactive:!A&&!l,updating:G}]),onClick:e=>{let{edges:n,addSelectedEdges:o}=ee.getState();A&&(ee.setState({nodesSelectionActive:!1}),o([t])),l&&l(e,n.find(e=>e.id===t))},onDoubleClick:eo,onContextMenu:er,onMouseEnter:el,onMouseMove:ea,onMouseLeave:ei,onKeyDown:V?e=>{if(K.includes(e.key)&&A){let{unselectNodesAndEdges:n,addSelectedEdges:o,edges:r}=ee.getState();"Escape"===e.key?(W.current?.blur(),n({edges:[r.find(e=>e.id===t)]})):o([t])}}:void 0,tabIndex:V?0:void 0,role:V?"button":void 0,"data-testid":`rf__edge-${t}`,"aria-label":null===Y?void 0:Y||`Edge from ${b} to ${S}`,"aria-describedby":V?`${eq}-${F}`:void 0,ref:W,children:[!Q&&(0,p.jsx)(e,{id:t,source:b,target:S,selected:i,animated:s,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:g,labelBgPadding:m,labelBgBorderRadius:y,data:r,style:x,sourceX:w,sourceY:v,targetX:E,targetY:M,sourcePosition:N,targetPosition:C,sourceHandleId:I,targetHandleId:$,markerStart:et,markerEnd:en,pathOptions:X,interactionWidth:U}),void 0!==L&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(e3,{position:N,centerX:w,centerY:v,radius:R,onMouseDown:e=>es(e,!0),onMouseEnter:ed,onMouseOut:ec,type:"source"}),(0,p.jsx)(e3,{position:C,centerX:E,centerY:M,radius:R,onMouseDown:e=>es(e,!1),onMouseEnter:ed,onMouseOut:ec,type:"target"})]})]})};return t.displayName="EdgeWrapper",(0,h.memo)(t)};function e7(e){let t={default:e4(e.default||ed),straight:e4(e.bezier||el),step:e4(e.step||er),smoothstep:e4(e.step||eo),simplebezier:e4(e.simplebezier||Q)},n=Object.keys(e).filter(e=>!["default","bezier"].includes(e)).reduce((t,n)=>(t[n]=e4(e[n]||ed),t),{});return{...t,...n}}function e8(e,t,n=null){let o=(n?.x||0)+t.x,r=(n?.y||0)+t.y,l=n?.width||t.width,a=n?.height||t.height;switch(e){case g.Top:return{x:o+l/2,y:r};case g.Right:return{x:o+l,y:r+a/2};case g.Bottom:return{x:o+l/2,y:r+a};case g.Left:return{x:o,y:r+a/2}}}function e6(e,t){if(!e)return null;let n=null;return 1!==e.length&&t?t&&(n=e.find(e=>e.id===t)):n=e[0],void 0===n?null:n}let e9=(e,t,n,o,r,l)=>{let a=e8(n,e,t),i=e8(l,o,r);return{sourceX:a.x,sourceY:a.y,targetX:i.x,targetY:i.y}};function te(e){let t=e?.[U]?.handleBounds||null,n=!e||!t||!e.width||!e.height||void 0===e.positionAbsolute?.x||void 0===e.positionAbsolute?.y;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!n]}function tt(e,t,n){let o=e;do{if(o?.matches(t))return!0;if(o===n.current)break;o=o.parentElement}while(o);return!1}function tn(e,t,n,o){let r=e.extent||o;if("parent"===e.extent){if(e.parentNode&&e.width&&e.height){let t=n.get(e.parentNode);r=t?.positionAbsolute&&t?.width&&t?.height?[[t.positionAbsolute.x,t.positionAbsolute.y],[t.positionAbsolute.x+t.width-e.width,t.positionAbsolute.y+t.height-e.height]]:r}else W("Only child nodes can use a parent extent. Help: https://reactflow.dev/error#500"),r=o}else if(e.extent&&e.parentNode){let t=n.get(e.parentNode),o=t?.positionAbsolute?.x??0,l=t?.positionAbsolute?.y??0;r=[[e.extent[0][0]+o,e.extent[0][1]+l],[e.extent[1][0]+o,e.extent[1][1]+l]]}let l={x:0,y:0};if(e.parentNode){let t=n.get(e.parentNode);l={x:t?.positionAbsolute?.x??0,y:t?.positionAbsolute?.y??0}}let a=r?L(t,r):t;return{position:{x:a.x-l.x,y:a.y-l.y},positionAbsolute:a}}function to({nodeId:e,dragItems:t,nodeInternals:n}){let o=t.map(e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute}));return[e?o.find(t=>t.id===e):o[0],o]}let tr=(e,t,n,o)=>{let r=t.querySelectorAll(e);if(!r||!r.length)return null;let l=Array.from(r),a=t.getBoundingClientRect(),i={x:a.width*o[0],y:a.height*o[1]};return l.map(e=>{let t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-a.left-i.x)/n,y:(t.top-a.top-i.y)/n,...z(e)}})};function tl(e,t,n){return void 0===n?n:o=>{n(o,{...t().nodeInternals.get(e)})}}function ta({id:e,store:t,unselect:n=!1}){let{addSelectedNodes:o,unselectNodesAndEdges:r,multiSelectionActive:l,nodeInternals:a}=t.getState(),i=a.get(e);t.setState({nodesSelectionActive:!1}),i.selected?(n||i.selected&&l)&&r({nodes:[i]}):o([e])}function ti(e){return(t,n,o)=>e?.(t,o)}function ts({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:l,selectNodesOnDrag:a}){let[i,s]=(0,h.useState)(!1),d=k(),c=(0,h.useRef)(),u=(0,h.useRef)({x:null,y:null}),g=(0,h.useCallback)(({sourceEvent:e})=>{let{transform:t,snapGrid:n,snapToGrid:o}=d.getState(),r=e.touches?e.touches[0].clientX:e.clientX,l=e.touches?e.touches[0].clientY:e.clientY,a={x:(r-t[0])/t[2],y:(l-t[1])/t[2]};return{xSnapped:o?n[0]*Math.round(a.x/n[0]):a.x,ySnapped:o?n[1]*Math.round(a.y/n[1]):a.y,...a}},[]);return(0,h.useEffect)(()=>{if(e?.current){let i=(0,S.Z)(e.current);if(t)i.on(".drag",null);else{let t=(0,b.Z)().on("start",e=>{let{nodeInternals:t,multiSelectionActive:n,unselectNodesAndEdges:o,onNodeDragStart:i,onSelectionDragStart:s}=d.getState(),p=r?i:ti(s);a||n||!r||t.get(r)?.selected||o(),r&&l&&a&&ta({id:r,store:d});let h=g(e);if(u.current=h,c.current=Array.from(t.values()).filter(e=>(e.selected||e.id===r)&&(!e.parentNode||!function e(t,n){if(!t.parentNode)return!1;let o=n.get(t.parentNode);return!!o&&(!!o.selected||e(o,n))}(e,t))).map(e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:h.x-(e.positionAbsolute?.x??0),y:h.y-(e.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode,width:e.width,height:e.height})),p&&c.current){let[n,o]=to({nodeId:r,dragItems:c.current,nodeInternals:t});p(e.sourceEvent,n,o)}}).on("drag",e=>{let{updateNodePositions:t,nodeInternals:n,nodeExtent:o,onNodeDrag:l,onSelectionDrag:a,snapGrid:i,snapToGrid:p}=d.getState(),h=g(e);if((u.current.x!==h.xSnapped||u.current.y!==h.ySnapped)&&c.current){u.current={x:h.xSnapped,y:h.ySnapped},c.current=c.current.map(e=>{let t={x:h.x-e.distance.x,y:h.y-e.distance.y};p&&(t.x=i[0]*Math.round(t.x/i[0]),t.y=i[1]*Math.round(t.y/i[1]));let r=tn(e,t,n,o);return e.position=r.position,e.positionAbsolute=r.positionAbsolute,e});let d=r?l:ti(a);if(t(c.current,!0,!0),s(!0),d){let[t,o]=to({nodeId:r,dragItems:c.current,nodeInternals:n});d(e.sourceEvent,t,o)}}}).on("end",e=>{if(s(!1),c.current){let{updateNodePositions:t,nodeInternals:n,onNodeDragStop:o,onSelectionDragStop:l}=d.getState(),a=r?o:ti(l);if(t(c.current,!1,!1),a){let[t,o]=to({nodeId:r,dragItems:c.current,nodeInternals:n});a(e.sourceEvent,t,o)}}}).filter(t=>{let r=t.target;return!t.button&&(!n||!tt(r,`.${n}`,e))&&(!o||tt(r,o,e))});return i.call(t),()=>{i.on(".drag",null)}}}},[e,t,n,o,l,d,r,a,g]),i}function td(){let e=k();return(0,h.useCallback)(t=>{let{nodeInternals:n,nodeExtent:o,updateNodePositions:r,snapToGrid:l,snapGrid:a}=e.getState();r(Array.from(n.values()).filter(e=>e.selected).map(e=>{if(e.positionAbsolute){let r={x:e.positionAbsolute.x+t.x,y:e.positionAbsolute.y+t.y};l&&(r.x=a[0]*Math.round(r.x/a[0]),r.y=a[1]*Math.round(r.y/a[1]));let i=tn(e,r,n,o);e.position=i.position,e.positionAbsolute=i.positionAbsolute}return e}),!0,!0)},[])}let tc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var tu=e=>{let t=({id:t,type:n,data:o,xPos:r,yPos:l,xPosOrigin:a,yPosOrigin:i,selected:s,onClick:d,onMouseEnter:c,onMouseMove:u,onMouseLeave:g,onContextMenu:m,onDoubleClick:y,style:x,className:b,isDraggable:S,isSelectable:w,isConnectable:v,isFocusable:E,selectNodesOnDrag:M,sourcePosition:N,targetPosition:C,hidden:A,resizeObserver:_,dragHandle:I,zIndex:$,isParent:j,noDragClassName:P,noPanClassName:O,initialized:B,disableKeyboardA11y:z,ariaLabel:R,rfId:L})=>{let D=k(),H=(0,h.useRef)(null),T=(0,h.useRef)(N),Z=(0,h.useRef)(C),F=(0,h.useRef)(n),Y=w||S||d||c||u||g,V=td(),X=tl(t,D.getState,c),U=tl(t,D.getState,u),W=tl(t,D.getState,g),G=tl(t,D.getState,m),q=tl(t,D.getState,y);(0,h.useEffect)(()=>{if(H.current&&!A){let e=H.current;return _?.observe(e),()=>_?.unobserve(e)}},[A]),(0,h.useEffect)(()=>{let e=F.current!==n,o=T.current!==N,r=Z.current!==C;H.current&&(e||o||r)&&(e&&(F.current=n),o&&(T.current=N),r&&(Z.current=C),D.getState().updateNodeDimensions([{id:t,nodeElement:H.current,forceUpdate:!0}]))},[t,n,N,C]);let Q=ts({nodeRef:H,disabled:A||!S,noDragClassName:P,handleSelector:I,nodeId:t,isSelectable:w,selectNodesOnDrag:M});return A?null:(0,p.jsx)("div",{className:(0,f.Z)(["react-flow__node",`react-flow__node-${n}`,{[O]:S},b,{selected:s,selectable:w,parent:j,dragging:Q}]),ref:H,style:{zIndex:$,transform:`translate(${a}px,${i}px)`,pointerEvents:Y?"all":"none",visibility:B?"visible":"hidden",...x},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:X,onMouseMove:U,onMouseLeave:W,onContextMenu:G,onClick:e=>{!w||M&&S||ta({id:t,store:D}),d&&d(e,{...D.getState().nodeInternals.get(t)})},onDoubleClick:q,onKeyDown:E?e=>{let{snapGrid:n,snapToGrid:o}=D.getState();if(K.includes(e.key)&&w){let n="Escape"===e.key;n&&H.current?.blur(),ta({id:t,store:D,unselect:n})}else if(!z&&S&&s&&Object.prototype.hasOwnProperty.call(tc,e.key)){D.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~r}, y: ${~~l}`});let t=o?n[0]:5,a=o?n[1]:5,i=e.shiftKey?4:1;V({x:tc[e.key].x*t*i,y:tc[e.key].y*a*i})}}:void 0,tabIndex:E?0:void 0,role:E?"button":void 0,"aria-describedby":z?void 0:`${eG}-${L}`,"aria-label":R,children:(0,p.jsx)(eu,{value:t,children:(0,p.jsx)(e,{id:t,data:o,type:n,xPos:r,yPos:l,selected:s,isConnectable:v,sourcePosition:N,targetPosition:C,dragging:Q,dragHandle:I,zIndex:$})})})};return t.displayName="NodeWrapper",(0,h.memo)(t)};function tg(e){let t={input:tu(e.input||eO),default:tu(e.default||ej),output:tu(e.output||ez),group:tu(e.group||eR)},n=Object.keys(e).filter(e=>!["input","default","output","group"].includes(e)).reduce((t,n)=>(t[n]=tu(e[n]||ej),t),{});return{...t,...n}}let tp=({x:e,y:t,width:n,height:o,origin:r})=>n&&o?r[0]<0||r[1]<0||r[0]>1||r[1]>1?(W("nodeOrigin must be between 0 and 1"),{x:e,y:t}):{x:e-n*r[0],y:t-o*r[1]}:{x:e,y:t},th="undefined"!=typeof document?document:null;var tf=(e=null,t={target:th})=>{let[n,o]=(0,h.useState)(!1),r=(0,h.useRef)(new Set([])),[l,a]=(0,h.useMemo)(()=>{if(null!==e){let t=(Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).map(e=>e.split("+")),n=t.reduce((e,t)=>e.concat(...t),[]);return[t,n]}return[[],[]]},[e]);return(0,h.useEffect)(()=>{if(null!==e){let e=e=>{if(tx(e))return!1;let t=ty(e.code,a);r.current.add(e[t]),tm(l,r.current,!1)&&(e.preventDefault(),o(!0))},n=e=>{if(tx(e))return!1;let t=ty(e.code,a);tm(l,r.current,!0)?(o(!1),r.current.clear()):r.current.delete(e[t])},i=()=>{r.current.clear(),o(!1)};return t?.target?.addEventListener("keydown",e),t?.target?.addEventListener("keyup",n),window.addEventListener("blur",i),()=>{t?.target?.removeEventListener("keydown",e),t?.target?.removeEventListener("keyup",n),window.removeEventListener("blur",i)}}},[e,o]),n};function tm(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function ty(e,t){return t.includes(e)?"code":"key"}function tx(e){let t=e.composedPath?.()[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}function tb(e,t){let n=new Map,o={};return e.forEach(e=>{let r=X(e.zIndex)?e.zIndex:e.selected?1e3:0,l=t.get(e.id),a={width:l?.width,height:l?.height,...e,positionAbsolute:{x:e.position.x,y:e.position.y}};e.parentNode&&(a.parentNode=e.parentNode,o[e.parentNode]=!0),Object.defineProperty(a,U,{enumerable:!1,value:{handleBounds:l?.[U]?.handleBounds,z:r}}),n.set(e.id,a)}),n.forEach(e=>{if(e.parentNode&&!n.has(e.parentNode))throw Error(`Parent node ${e.parentNode} not found`);if(e.parentNode||o[e.id]){let{x:t,y:r,z:l}=function e(t,n,o,r){if(!t.parentNode)return r;let l=n.get(t.parentNode);return e(l,n,o,{x:(r.x??0)+(l.position?.x??0),y:(r.y??0)+(l.position?.y??0),z:(l[U]?.z??0)>(r.z??0)?l[U]?.z??0:r.z??0})}(e,n,o,{...e.position,z:e[U]?.z??0});e.positionAbsolute={x:t,y:r},e[U].z=l,o[e.id]&&(e[U].isParent=!0)}}),n}function tS(e,t={}){let{nodeInternals:n,width:o,height:r,minZoom:l,maxZoom:a,d3Zoom:i,d3Selection:s,fitViewOnInitDone:d,fitViewOnInit:c}=e();if((t.initial&&!d&&c||!t.initial)&&i&&s){let e=Array.from(n.values()).filter(e=>t.includeHiddenNodes?e.width&&e.height:!e.hidden),d=e.every(e=>e.width&&e.height);if(e.length>0&&d){let[n,d,c]=eN(ev(e),o,r,t.minZoom??l,t.maxZoom??a,t.padding??.1),u=v.CR.translate(n,d).scale(c);return"number"==typeof t.duration&&t.duration>0?i.transform(eC(s,t.duration),u):i.transform(s,u),!0}}return!1}function tw({changedNodes:e,changedEdges:t,get:n,set:o}){let{nodeInternals:r,edges:l,onNodesChange:a,onEdgesChange:i,hasDefaultNodes:s,hasDefaultEdges:d}=n();e?.length&&(s&&o({nodeInternals:(e.forEach(e=>{let t=r.get(e.id);t&&r.set(t.id,{...t,[U]:t[U],selected:e.selected})}),new Map(r))}),a?.(e)),t?.length&&(d&&o({edges:l.map(e=>{let n=t.find(t=>t.id===e.id);return n&&(e.selected=n.selected),e})}),i?.(t))}let tv=()=>{},tE={zoomIn:tv,zoomOut:tv,zoomTo:tv,getZoom:()=>1,setViewport:tv,getViewport:()=>({x:0,y:0,zoom:1}),fitView:tv,setCenter:tv,fitBounds:tv,project:e=>e,viewportInitialized:!1},tM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),tN=()=>{let e=k(),{d3Zoom:t,d3Selection:n}=C(tM,x.Z);return(0,h.useMemo)(()=>n&&t?{zoomIn:e=>t.scaleBy(eC(n,e?.duration),1.2),zoomOut:e=>t.scaleBy(eC(n,e?.duration),1/1.2),zoomTo:(e,o)=>t.scaleTo(eC(n,o?.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(o,r)=>{let[l,a,i]=e.getState().transform,s=v.CR.translate(o.x??l,o.y??a).scale(o.zoom??i);t.transform(eC(n,r?.duration),s)},getViewport:()=>{let[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>tS(e.getState,t),setCenter:(o,r,l)=>{let{width:a,height:i,maxZoom:s}=e.getState(),d=void 0!==l?.zoom?l.zoom:s,c=a/2-o*d,u=i/2-r*d,g=v.CR.translate(c,u).scale(d);t.transform(eC(n,l?.duration),g)},fitBounds:(o,r)=>{let{width:l,height:a,minZoom:i,maxZoom:s}=e.getState(),[d,c,u]=eN(o,l,a,i,s,r?.padding??.1),g=v.CR.translate(d,c).scale(u);t.transform(eC(n,r?.duration),g)},project:t=>{let{transform:n,snapToGrid:o,snapGrid:r}=e.getState();return ew(t,n,o,r)},viewportInitialized:!0}:tE,[t,n])};function tC(){let e=tN(),t=k(),n=(0,h.useCallback)(()=>{let{nodeInternals:e}=t.getState();return Array.from(e.values()).map(e=>({...e}))},[]),o=(0,h.useCallback)(e=>{let{nodeInternals:n}=t.getState();return n.get(e)},[]),r=(0,h.useCallback)(()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},[]),l=(0,h.useCallback)(e=>{let{edges:n=[]}=t.getState();return n.find(t=>t.id===e)},[]),a=(0,h.useCallback)(e=>{let{nodeInternals:n,setNodes:o,hasDefaultNodes:r,onNodesChange:l}=t.getState(),a=Array.from(n.values()),i="function"==typeof e?e(a):e;r?o(i):l&&l(0===i.length?a.map(e=>({type:"remove",id:e.id})):i.map(e=>({item:e,type:"reset"})))},[]),i=(0,h.useCallback)(e=>{let{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:l}=t.getState(),a="function"==typeof e?e(n):e;r?o(a):l&&l(0===a.length?n.map(e=>({type:"remove",id:e.id})):a.map(e=>({item:e,type:"reset"})))},[]),s=(0,h.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{nodeInternals:o,setNodes:r,hasDefaultNodes:l,onNodesChange:a}=t.getState();l?r([...Array.from(o.values()),...n]):a&&a(n.map(e=>({item:e,type:"add"})))},[]),d=(0,h.useCallback)(e=>{let n=Array.isArray(e)?e:[e],{edges:o=[],setEdges:r,hasDefaultEdges:l,onEdgesChange:a}=t.getState();l?r([...o,...n]):a&&a(n.map(e=>({item:e,type:"add"})))},[]),c=(0,h.useCallback)(()=>{let{nodeInternals:e,edges:n=[],transform:o}=t.getState(),r=Array.from(e.values()),[l,a,i]=o;return{nodes:r.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:l,y:a,zoom:i}}},[]),u=(0,h.useCallback)(({nodes:e,edges:n})=>{let{nodeInternals:o,edges:r,hasDefaultNodes:l,hasDefaultEdges:a,onNodesDelete:i,onEdgesDelete:s,onNodesChange:d,onEdgesChange:c}=t.getState(),u=Array.from(o.values()),g=(e||[]).map(e=>e.id),p=(n||[]).map(e=>e.id),h=u.reduce((e,t)=>{let n=!g.includes(t.id)&&t.parentNode&&e.find(e=>e.id===t.parentNode);return("boolean"!=typeof t.deletable||t.deletable)&&(g.includes(t.id)||n)&&e.push(t),e},[]),f=r.filter(e=>"boolean"!=typeof e.deletable||e.deletable),m=f.filter(e=>p.includes(e.id));if(h||m){let e=[...m,...eM(h,f)],n=e.reduce((e,t)=>(e.includes(t.id)||e.push(t.id),e),[]);(a||l)&&(a&&t.setState({edges:r.filter(e=>!n.includes(e.id))}),l&&(h.forEach(e=>{o.delete(e.id)}),t.setState({nodeInternals:new Map(o)}))),n.length>0&&(s?.(e),c&&c(n.map(e=>({id:e,type:"remove"})))),h.length>0&&(i?.(h),d&&d(h.map(e=>({id:e.id,type:"remove"}))))}},[]),g=(0,h.useCallback)(e=>{let n=V(e),o=n?null:t.getState().nodeInternals.get(e.id);return[n?e:F(o),o,n]},[]),p=(0,h.useCallback)((e,n=!0,o)=>{let[r,l,a]=g(e);return r?(o||Array.from(t.getState().nodeInternals.values())).filter(t=>{if(!a&&(t.id===l.id||!t.positionAbsolute))return!1;let o=Y(F(t),r);return n&&o>0||o>=e.width*e.height}):[]},[]),f=(0,h.useCallback)((e,t,n=!0)=>{let[o]=g(e);if(!o)return!1;let r=Y(o,t);return n&&r>0||r>=e.width*e.height},[]);return(0,h.useMemo)(()=>({...e,getNodes:n,getNode:o,getEdges:r,getEdge:l,setNodes:a,setEdges:i,addNodes:s,addEdges:d,toObject:c,deleteElements:u,getIntersectingNodes:p,isNodeIntersecting:f}),[e,n,o,r,l,a,i,s,d,c,u,p,f])}var tk=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{let n=k(),{deleteElements:o}=tC(),r=tf(e),l=tf(t);(0,h.useEffect)(()=>{if(r){let{nodeInternals:e,edges:t}=n.getState();o({nodes:Array.from(e.values()).filter(e=>e.selected),edges:t.filter(e=>e.selected)}),n.setState({nodesSelectionActive:!1})}},[r]),(0,h.useEffect)(()=>{n.setState({multiSelectionActive:l})},[l])};let tA={position:"absolute",width:"100%",height:"100%",top:0,left:0},t_=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,tI=e=>({x:e.x,y:e.y,zoom:e.k}),t$=(e,t)=>e.target.closest(`.${t}`),tj=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler}),tP=({onMove:e,onMoveStart:t,onMoveEnd:n,zoomOnScroll:o=!0,zoomOnPinch:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:i=d.Free,zoomOnDoubleClick:s=!0,selectionKeyPressed:c,elementsSelectable:u,panOnDrag:g=!0,defaultViewport:f,translateExtent:m,minZoom:y,maxZoom:b,zoomActivationKeyCode:E,preventScrolling:M=!0,children:N,noWheelClassName:A,noPanClassName:_})=>{let I=(0,h.useRef)(),$=k(),j=(0,h.useRef)(!1),P=(0,h.useRef)(null),O=(0,h.useRef)({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:L,d3ZoomHandler:D}=C(tj,x.Z),H=tf(E);return!function(e){let t=k();(0,h.useEffect)(()=>{let n;let o=()=>{if(!e.current)return;let n=z(e.current);(0===n.height||0===n.width)&&W("The React Flow parent container needs a width and a height to render the graph. Help: https://reactflow.dev/error#400"),t.setState({width:n.width||500,height:n.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver(()=>o())).observe(e.current),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}},[])}(P),(0,h.useEffect)(()=>{if(P.current){let e=(0,v.sP)().scaleExtent([y,b]).translateExtent(m),t=(0,S.Z)(P.current).call(e),n=R(f.x,m[0][0],m[1][0]),o=R(f.y,m[0][1],m[1][1]),r=R(f.zoom,y,b),l=v.CR.translate(n,o).scale(r);e.transform(t,l),$.setState({d3Zoom:e,d3Selection:t,d3ZoomHandler:t.on("wheel.zoom"),transform:[n,o,r],domNode:P.current.closest(".react-flow")})}},[]),(0,h.useEffect)(()=>{L&&B&&(l&&!H?L.on("wheel.zoom",e=>{if(t$(e,A))return!1;e.preventDefault(),e.stopImmediatePropagation();let t=L.property("__zoom").k||1;if(e.ctrlKey&&r){let n=(0,w.Z)(e),o=-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*10;B.scaleTo(L,t*Math.pow(2,o),n);return}let n=1===e.deltaMode?20:1,o=i===d.Vertical?0:e.deltaX*n,l=i===d.Horizontal?0:e.deltaY*n;B.translateBy(L,-(o/t)*a,-(l/t)*a)}):void 0!==D&&L.on("wheel.zoom",function(e,t){if(!M||t$(e,A))return null;e.preventDefault(),D.call(this,e,t)}))},[l,i,L,B,D,H,r,M,A]),(0,h.useEffect)(()=>{B&&(c&&!j.current?B.on("zoom",null):c||B.on("zoom",t=>{let{onViewportChange:n}=$.getState();if($.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),e||n){let o=tI(t.transform);n?.(o),e?.(t.sourceEvent,o)}}))},[c,B,e]),(0,h.useEffect)(()=>{B&&B.on("start",e=>{if(!e.sourceEvent)return null;let{onViewportChangeStart:n}=$.getState();if(j.current=!0,e.sourceEvent?.type==="mousedown"&&$.setState({paneDragging:!0}),t||n){let o=tI(e.transform);O.current=o,n?.(o),t?.(e.sourceEvent,o)}})},[B,t]),(0,h.useEffect)(()=>{B&&B.on("end",e=>{if(!e.sourceEvent)return null;let{onViewportChangeEnd:t}=$.getState();if(j.current=!1,$.setState({paneDragging:!1}),(n||t)&&t_(O.current,e.transform)){let o=tI(e.transform);O.current=o,clearTimeout(I.current),I.current=setTimeout(()=>{t?.(o),n?.(e.sourceEvent,o)},l?150:0)}})},[B,n,l]),(0,h.useEffect)(()=>{B&&B.filter(e=>{let t=H||o,n=r&&e.ctrlKey;return!!(1===e.button&&"mousedown"===e.type&&e.target.closest(".react-flow__node"))||!(!g&&!t&&!l&&!s&&!r||c||!s&&"dblclick"===e.type||t$(e,A)&&"wheel"===e.type||t$(e,_)&&"wheel"!==e.type)&&(!!r||!e.ctrlKey||"wheel"!==e.type)&&(!!t||!!l||!!n||"wheel"!==e.type)&&(!!g||"mousedown"!==e.type&&"touchstart"!==e.type)&&(!e.ctrlKey||"wheel"===e.type)&&(!e.button||e.button<=1)})},[B,o,r,l,s,g,c,u,H]),(0,p.jsx)("div",{className:"react-flow__renderer",ref:P,style:tA,children:N})};function tO(e,t){let n=e.find(e=>e.id===t.parentNode);if(n){let e=t.position.x+t.width-n.width,o=t.position.y+t.height-n.height;if(e>0||o>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,e>0&&(n.style.width+=e),o>0&&(n.style.height+=o),t.position.x<0){let e=Math.abs(t.position.x);n.position.x=n.position.x-e,n.style.width+=e,t.position.x=0}if(t.position.y<0){let e=Math.abs(t.position.y);n.position.y=n.position.y-e,n.style.height+=e,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function tB(e,t){if(e.some(e=>"reset"===e.type))return e.filter(e=>"reset"===e.type).map(e=>e.item);let n=e.filter(e=>"add"===e.type).map(e=>e.item);return t.reduce((t,n)=>{let o=e.find(e=>e.id===n.id);if(o)switch(o.type){case"select":return t.push({...n,selected:o.selected}),t;case"position":{let e={...n};return void 0!==o.position&&(e.position=o.position),void 0!==o.positionAbsolute&&(e.positionAbsolute=o.positionAbsolute),void 0!==o.dragging&&(e.dragging=o.dragging),e.expandParent&&tO(t,e),t.push(e),t}case"dimensions":{let e={...n};return void 0!==o.dimensions&&(e.width=o.dimensions.width,e.height=o.dimensions.height),e.expandParent&&tO(t,e),t.push(e),t}case"remove":return t}return t.push(n),t},n)}function tz(e,t){return tB(e,t)}let tR=(e,t)=>({id:e,type:"select",selected:t});function tL(e,t){return e.reduce((e,n)=>{let o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(tR(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(tR(n.id,!1))),e},[])}function tD(e,t){return{x:e.clientX-t.left,y:e.clientY-t.top}}let tH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable}),tT={startX:0,startY:0,x:0,y:0,width:0,height:0,draw:!1},tZ=(0,h.memo)(({selectionKeyPressed:e})=>{let t=k(),n=(0,h.useRef)(0),o=(0,h.useRef)(0),r=(0,h.useRef)(),[l,a]=(0,h.useState)(tT),{userSelectionActive:i,elementsSelectable:s}=C(tH,x.Z);if(!s||!(i||e))return null;let d=()=>{a(tT),t.setState({userSelectionActive:!1}),n.current=0,o.current=0};return(0,p.jsx)("div",{className:"react-flow__selectionpane react-flow__container",onMouseDown:e=>{let n=e.target.closest(".react-flow");r.current=n.getBoundingClientRect();let o=tD(e,r.current);a({width:0,height:0,startX:o.x,startY:o.y,x:o.x,y:o.y,draw:!0}),t.setState({userSelectionActive:!0,nodesSelectionActive:!1})},onMouseMove:i=>{if(!e||!l.draw||!r.current)return;let s=tD(i,r.current),d=l.startX??0,c=l.startY??0,u={...l,x:s.x<d?s.x:d,y:s.y<c?s.y:c,width:Math.abs(s.x-d),height:Math.abs(s.y-c)},{nodeInternals:g,edges:p,transform:h,onNodesChange:f,onEdgesChange:m}=t.getState(),y=Array.from(g.values()),x=eE(g,u,h,!1,!0),b=eM(x,p).map(e=>e.id),S=x.map(e=>e.id);if(n.current!==S.length){n.current=S.length;let e=tL(y,S);e.length&&f?.(e)}if(o.current!==b.length){o.current=b.length;let e=tL(p,b);e.length&&m?.(e)}a(u)},onMouseUp:()=>{t.setState({nodesSelectionActive:n.current>0}),d()},onMouseLeave:()=>{t.setState({nodesSelectionActive:!1}),d()},children:l.draw&&(0,p.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:l.width,height:l.height,transform:`translate(${l.x}px, ${l.y}px)`}})})});tZ.displayName="UserSelection";let tF=e=>({transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive,...ev(Array.from(e.nodeInternals.values()).filter(e=>e.selected))}),tY=e=>ev(Array.from(e.nodeInternals.values()).filter(e=>e.selected));var tV=(0,h.memo)(function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let o=k(),{transformString:r,userSelectionActive:l}=C(tF,x.Z),{width:a,height:i,x:s,y:d}=C(tY,x.Z),c=td(),u=(0,h.useRef)(null);return((0,h.useEffect)(()=>{n||u.current?.focus()},[n]),ts({nodeRef:u}),!l&&a&&i)?(0,p.jsx)("div",{className:(0,f.Z)(["react-flow__nodesselection","react-flow__container",t]),style:{transform:r},children:(0,p.jsx)("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:e?t=>{e(t,Array.from(o.getState().nodeInternals.values()).filter(e=>e.selected))}:void 0,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(tc,e.key)&&c(tc[e.key])},style:{width:a,height:i,top:d,left:s}})}):null});let tX=e=>e.paneDragging;function tU({onClick:e,onMouseEnter:t,onMouseMove:n,onMouseLeave:o,onContextMenu:r,onWheel:l}){let a=C(tX);return(0,p.jsx)("div",{className:(0,f.Z)(["react-flow__pane",{dragging:a}]),onClick:e,onMouseEnter:t,onMouseMove:n,onMouseLeave:o,onContextMenu:r,onWheel:l,style:tA})}let tK=e=>e.nodesSelectionActive,tW=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:l,onPaneScroll:a,deleteKeyCode:i,onMove:s,onMoveStart:d,onMoveEnd:c,selectionKeyCode:u,multiSelectionKeyCode:g,zoomActivationKeyCode:h,elementsSelectable:f,zoomOnScroll:m,zoomOnPinch:y,panOnScroll:x,panOnScrollSpeed:b,panOnScrollMode:S,zoomOnDoubleClick:w,panOnDrag:v,defaultViewport:E,translateExtent:M,minZoom:N,maxZoom:A,preventScrolling:_,onSelectionContextMenu:I,noWheelClassName:$,noPanClassName:j,disableKeyboardA11y:P})=>{let O=k(),B=C(tK),z=tf(u);return tk({deleteKeyCode:i,multiSelectionKeyCode:g}),(0,p.jsxs)(tP,{onMove:s,onMoveStart:d,onMoveEnd:c,selectionKeyPressed:z,elementsSelectable:f,zoomOnScroll:m,zoomOnPinch:y,panOnScroll:x,panOnScrollSpeed:b,panOnScrollMode:S,zoomOnDoubleClick:w,panOnDrag:v,defaultViewport:E,translateExtent:M,minZoom:N,maxZoom:A,zoomActivationKeyCode:h,preventScrolling:_,noWheelClassName:$,noPanClassName:j,children:[e,(0,p.jsx)(tZ,{selectionKeyPressed:z}),B&&(0,p.jsx)(tV,{onSelectionContextMenu:I,noPanClassName:j,disableKeyboardA11y:P}),(0,p.jsx)(tU,{onClick:e=>{t?.(e),O.getState().resetSelectedElements(),O.setState({nodesSelectionActive:!1})},onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:l?e=>l(e):void 0,onWheel:a?e=>a(e):void 0})]})};tW.displayName="FlowRenderer";var tG=(0,h.memo)(tW);let tq=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions}),tQ=e=>{var t;let{nodesDraggable:n,nodesConnectable:o,nodesFocusable:r,elementsSelectable:l,updateNodeDimensions:a}=C(tq,x.Z),i=(t=e.onlyRenderVisibleElements,C((0,h.useCallback)(e=>t?eE(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):Array.from(e.nodeInternals.values()),[t]))),s=(0,h.useRef)(),d=(0,h.useMemo)(()=>{if("undefined"==typeof ResizeObserver)return null;let e=new ResizeObserver(e=>{a(e.map(e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})))});return s.current=e,e},[]);return(0,h.useEffect)(()=>()=>{s?.current?.disconnect()},[]),(0,p.jsx)("div",{className:"react-flow__nodes",style:tA,children:i.map(t=>{let a=t.type||"default";e.nodeTypes[a]||(W(`Node type "${a}" not found. Using fallback type "default". Help: https://reactflow.dev/error#300`),a="default");let i=e.nodeTypes[a]||e.nodeTypes.default,s=!!(t.draggable||n&&void 0===t.draggable),c=!!(t.selectable||l&&void 0===t.selectable),u=!!(t.connectable||o&&void 0===t.connectable),h=!!(t.focusable||r&&void 0===t.focusable),f=e.nodeExtent?L(t.positionAbsolute,e.nodeExtent):t.positionAbsolute,m=f?.x??0,y=f?.y??0,x=tp({x:m,y:y,width:t.width??0,height:t.height??0,origin:e.nodeOrigin});return(0,p.jsx)(i,{id:t.id,className:t.className,style:t.style,type:a,data:t.data,sourcePosition:t.sourcePosition||g.Bottom,targetPosition:t.targetPosition||g.To