import{r as h,f6 as qo,K as b}from"./index-Cox3ZWL0.js";import{z as Qo,p as Jo,d as es}from"./zoom-D5h43YeK.js";import{i as Ye,s as Sn}from"./transform-C2GfmqNu.js";function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ie(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var En={exports:{}},wn={},bn={exports:{}},Nn={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ze=h;function ts(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ns=typeof Object.is=="function"?Object.is:ts,os=Ze.useState,ss=Ze.useEffect,rs=Ze.useLayoutEffect,is=Ze.useDebugValue;function cs(e,t){var n=t(),o=os({inst:{value:n,getSnapshot:t}}),s=o[0].inst,i=o[1];return rs(function(){s.value=n,s.getSnapshot=t,xt(s)&&i({inst:s})},[e,n,t]),ss(function(){return xt(s)&&i({inst:s}),e(function(){xt(s)&&i({inst:s})})},[e]),is(n),n}function xt(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ns(e,n)}catch{return!0}}function as(e,t){return t()}var ls=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?as:cs;Nn.useSyncExternalStore=Ze.useSyncExternalStore!==void 0?Ze.useSyncExternalStore:ls;bn.exports=Nn;var us=bn.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var ft=h,ds=us;function fs(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var gs=typeof Object.is=="function"?Object.is:fs,ps=ds.useSyncExternalStore,ys=ft.useRef,hs=ft.useEffect,ms=ft.useMemo,xs=ft.useDebugValue;wn.useSyncExternalStoreWithSelector=function(e,t,n,o,s){var i=ys(null);if(i.current===null){var r={hasValue:!1,value:null};i.current=r}else r=i.current;i=ms(function(){function l(f){if(!d){if(d=!0,a=f,f=o(f),s!==void 0&&r.hasValue){var m=r.value;if(s(m,f))return u=m}return u=f}if(m=u,gs(a,f))return m;var p=o(f);return s!==void 0&&s(m,p)?(a=f,m):(a=f,u=p)}var d=!1,a,u,g=n===void 0?null:n;return[function(){return l(t())},g===null?void 0:function(){return l(g())}]},[t,n,o,s]);var c=ps(e,i[0],i[1]);return hs(function(){r.hasValue=!0,r.value=c},[c]),xs(c),c};En.exports=wn;var Ss=En.exports;const Es=qo(Ss),ws={},Xt=e=>{let t;const n=new Set,o=(a,u)=>{const g=typeof a=="function"?a(t):a;if(!Object.is(g,t)){const f=t;t=u??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(m=>m(t,f))}},s=()=>t,l={setState:o,getState:s,getInitialState:()=>d,subscribe:a=>(n.add(a),()=>n.delete(a)),destroy:()=>{(ws?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(o,s,l);return l},bs=e=>e?Xt(e):Xt,{useDebugValue:Ns}=b,{useSyncExternalStoreWithSelector:vs}=Es,As=e=>e;function vn(e,t=As,n){const o=vs(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ns(o),o}const Gt=(e,t)=>{const n=bs(e),o=(s,i=t)=>vn(n,s,i);return Object.assign(o,n),o},$s=(e,t)=>e?Gt(e,t):Gt;function se(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gt=h.createContext(null),Ms=gt.Provider,xe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},An=xe.error001();function q(e,t){const n=h.useContext(gt);if(n===null)throw new Error(An);return vn(n,e,t)}const ne=()=>{const e=h.useContext(gt);if(e===null)throw new Error(An);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Cs=e=>e.userSelectionActive?"none":"all";function Is({position:e,children:t,className:n,style:o,...s}){const i=q(Cs),r=`${e}`.split("-");return b.createElement("div",{className:ie(["react-flow__panel",n,...r]),style:{...o,pointerEvents:i},...s},t)}function _s({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:b.createElement(Is,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},b.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const Ts=({x:e,y:t,label:n,labelStyle:o={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:r=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...a})=>{const u=h.useRef(null),[g,f]=h.useState({x:0,y:0,width:0,height:0}),m=ie(["react-flow__edge-textwrapper",d]);return h.useEffect(()=>{if(u.current){const p=u.current.getBBox();f({x:p.x,y:p.y,width:p.width,height:p.height})}},[n]),typeof n>"u"||!n?null:b.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...a},s&&b.createElement("rect",{width:g.width+2*r[0],x:-r[0],y:-r[1],height:g.height+2*r[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),b.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:u,style:o},n),l)};var Ds=h.memo(Ts);const Dt=e=>({width:e.offsetWidth,height:e.offsetHeight}),Xe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pt=(e={x:0,y:0},t)=>({x:Xe(e.x,t[0][0],t[1][0]),y:Xe(e.y,t[0][1],t[1][1])}),Kt=(e,t,n)=>e<t?Xe(Math.abs(e-t),1,50)/50:e>n?-Xe(Math.abs(e-n),1,50)/50:0,$n=(e,t)=>{const n=Kt(e.x,35,t.width-35)*20,o=Kt(e.y,35,t.height-35)*20;return[n,o]},Mn=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Ps=(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)}),kt=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),ks=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),jt=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),vt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Rs=e=>le(e.width)&&le(e.height)&&le(e.x)&&le(e.y),le=e=>!isNaN(e)&&isFinite(e),j=Symbol.for("internals"),Cn=["Enter"," ","Escape"],Hs=(e,t)=>{},zs=e=>"nativeEvent"in e;function At(e){var s,i;const t=zs(e)?e.nativeEvent:e,n=((i=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:i[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const In=e=>"clientX"in e,be=(e,t)=>{var i,r;const n=In(e),o=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(r=e.touches)==null?void 0:r[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},at=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},ot=({id:e,path:t,labelX:n,labelY:o,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:a,markerEnd:u,markerStart:g,interactionWidth:f=20})=>b.createElement(b.Fragment,null,b.createElement("path",{id:e,style:a,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:u,markerStart:g}),f&&b.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),s&&le(n)&&le(o)?b.createElement(Ds,{x:n,y:o,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d}):null);ot.displayName="BaseEdge";function Qe(e,t,n){return n===void 0?n:o=>{const s=t().edges.find(i=>i.id===e);s&&n(o,{...s})}}function _n({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,r=Math.abs(o-t)/2,c=o<t?o+r:o-r;return[i,c,s,r]}function Tn({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:i,targetControlX:r,targetControlY:c}){const l=e*.125+s*.375+r*.375+n*.125,d=t*.125+i*.375+c*.375+o*.125,a=Math.abs(l-e),u=Math.abs(d-t);return[l,d,a,u]}var De;(function(e){e.Strict="strict",e.Loose="loose"})(De||(De={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var tt;(function(e){e.Partial="partial",e.Full="full"})(tt||(tt={}));var we;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(we||(we={}));var lt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(lt||(lt={}));var B;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(B||(B={}));function qt({pos:e,x1:t,y1:n,x2:o,y2:s}){return e===B.Left||e===B.Right?[.5*(t+o),n]:[t,.5*(n+s)]}function Dn({sourceX:e,sourceY:t,sourcePosition:n=B.Bottom,targetX:o,targetY:s,targetPosition:i=B.Top}){const[r,c]=qt({pos:n,x1:e,y1:t,x2:o,y2:s}),[l,d]=qt({pos:i,x1:o,y1:s,x2:e,y2:t}),[a,u,g,f]=Tn({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:r,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${r},${c} ${l},${d} ${o},${s}`,a,u,g,f]}const Rt=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:s=B.Bottom,targetPosition:i=B.Top,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:a,labelBgBorderRadius:u,style:g,markerEnd:f,markerStart:m,interactionWidth:p})=>{const[x,y,S]=Dn({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:o,targetPosition:i});return b.createElement(ot,{path:x,labelX:y,labelY:S,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:a,labelBgBorderRadius:u,style:g,markerEnd:f,markerStart:m,interactionWidth:p})});Rt.displayName="SimpleBezierEdge";const Qt={[B.Left]:{x:-1,y:0},[B.Right]:{x:1,y:0},[B.Top]:{x:0,y:-1},[B.Bottom]:{x:0,y:1}},Ls=({source:e,sourcePosition:t=B.Bottom,target:n})=>t===B.Left||t===B.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},Jt=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Bs({source:e,sourcePosition:t=B.Bottom,target:n,targetPosition:o=B.Top,center:s,offset:i}){const r=Qt[t],c=Qt[o],l={x:e.x+r.x*i,y:e.y+r.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},a=Ls({source:l,sourcePosition:t,target:d}),u=a.x!==0?"x":"y",g=a[u];let f=[],m,p;const x={x:0,y:0},y={x:0,y:0},[S,N,A,I]=_n({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(r[u]*c[u]===-1){m=s.x??S,p=s.y??N;const z=[{x:m,y:l.y},{x:m,y:d.y}],R=[{x:l.x,y:p},{x:d.x,y:p}];r[u]===g?f=u==="x"?z:R:f=u==="x"?R:z}else{const z=[{x:l.x,y:d.y}],R=[{x:d.x,y:l.y}];if(u==="x"?f=r.x===g?R:z:f=r.y===g?z:R,t===o){const $=Math.abs(e[u]-n[u]);if($<=i){const E=Math.min(i-1,i-$);r[u]===g?x[u]=(l[u]>e[u]?-1:1)*E:y[u]=(d[u]>n[u]?-1:1)*E}}if(t!==o){const $=u==="x"?"y":"x",E=r[u]===c[$],M=l[$]>d[$],L=l[$]<d[$];(r[u]===1&&(!E&&M||E&&L)||r[u]!==1&&(!E&&L||E&&M))&&(f=u==="x"?z:R)}const v={x:l.x+x.x,y:l.y+x.y},_={x:d.x+y.x,y:d.y+y.y},C=Math.max(Math.abs(v.x-f[0].x),Math.abs(_.x-f[0].x)),D=Math.max(Math.abs(v.y-f[0].y),Math.abs(_.y-f[0].y));C>=D?(m=(v.x+_.x)/2,p=f[0].y):(m=f[0].x,p=(v.y+_.y)/2)}return[[e,{x:l.x+x.x,y:l.y+x.y},...f,{x:d.x+y.x,y:d.y+y.y},n],m,p,A,I]}function Vs(e,t,n,o){const s=Math.min(Jt(e,t)/2,Jt(t,n)/2,o),{x:i,y:r}=t;if(e.x===i&&i===n.x||e.y===r&&r===n.y)return`L${i} ${r}`;if(e.y===r){const d=e.x<n.x?-1:1,a=e.y<n.y?1:-1;return`L ${i+s*d},${r}Q ${i},${r} ${i},${r+s*a}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${r+s*l}Q ${i},${r} ${i+s*c},${r}`}function $t({sourceX:e,sourceY:t,sourcePosition:n=B.Bottom,targetX:o,targetY:s,targetPosition:i=B.Top,borderRadius:r=5,centerX:c,centerY:l,offset:d=20}){const[a,u,g,f,m]=Bs({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:i,center:{x:c,y:l},offset:d});return[a.reduce((x,y,S)=>{let N="";return S>0&&S<a.length-1?N=Vs(a[S-1],y,a[S+1],r):N=`${S===0?"M":"L"}${y.x} ${y.y}`,x+=N,x},""),u,g,f,m]}const pt=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:a,sourcePosition:u=B.Bottom,targetPosition:g=B.Top,markerEnd:f,markerStart:m,pathOptions:p,interactionWidth:x})=>{const[y,S,N]=$t({sourceX:e,sourceY:t,sourcePosition:u,targetX:n,targetY:o,targetPosition:g,borderRadius:p==null?void 0:p.borderRadius,offset:p==null?void 0:p.offset});return b.createElement(ot,{path:y,labelX:S,labelY:N,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:a,markerEnd:f,markerStart:m,interactionWidth:x})});pt.displayName="SmoothStepEdge";const Ht=h.memo(e=>{var t;return b.createElement(pt,{...e,pathOptions:h.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Ht.displayName="StepEdge";function Fs({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,i,r,c]=_n({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,i,r,c]}const zt=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:a,markerEnd:u,markerStart:g,interactionWidth:f})=>{const[m,p,x]=Fs({sourceX:e,sourceY:t,targetX:n,targetY:o});return b.createElement(ot,{path:m,labelX:p,labelY:x,label:s,labelStyle:i,labelShowBg:r,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:a,markerEnd:u,markerStart:g,interactionWidth:f})});zt.displayName="StraightEdge";function st(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function en({pos:e,x1:t,y1:n,x2:o,y2:s,c:i}){switch(e){case B.Left:return[t-st(t-o,i),n];case B.Right:return[t+st(o-t,i),n];case B.Top:return[t,n-st(n-s,i)];case B.Bottom:return[t,n+st(s-n,i)]}}function Pn({sourceX:e,sourceY:t,sourcePosition:n=B.Bottom,targetX:o,targetY:s,targetPosition:i=B.Top,curvature:r=.25}){const[c,l]=en({pos:n,x1:e,y1:t,x2:o,y2:s,c:r}),[d,a]=en({pos:i,x1:o,y1:s,x2:e,y2:t,c:r}),[u,g,f,m]=Tn({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:a});return[`M${e},${t} C${c},${l} ${d},${a} ${o},${s}`,u,g,f,m]}const ut=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:s=B.Bottom,targetPosition:i=B.Top,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:a,labelBgBorderRadius:u,style:g,markerEnd:f,markerStart:m,pathOptions:p,interactionWidth:x})=>{const[y,S,N]=Pn({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:o,targetPosition:i,curvature:p==null?void 0:p.curvature});return b.createElement(ot,{path:y,labelX:S,labelY:N,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:a,labelBgBorderRadius:u,style:g,markerEnd:f,markerStart:m,interactionWidth:x})});ut.displayName="BezierEdge";const Lt=h.createContext(null),Os=Lt.Provider;Lt.Consumer;const Ys=()=>h.useContext(Lt),Us=e=>"id"in e&&"source"in e&&"target"in e,Ws=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,Mt=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`,Zs=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Xs=(e,t)=>{if(!e.source||!e.target)return t;let n;return Us(e)?n={...e}:n={...e,id:Ws(e)},Zs(n,t)?t:t.concat(n)},Ct=({x:e,y:t},[n,o,s],i,[r,c])=>{const l={x:(e-n)/s,y:(t-o)/s};return i?{x:r*Math.round(l.x/r),y:c*Math.round(l.y/c)}:l},kn=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o}),Ue=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-o};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:s}},Bt=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const{x:i,y:r}=Ue(s,t).positionAbsolute;return Ps(o,kt({x:i,y:r,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ks(n)},Rn=(e,t,[n,o,s]=[0,0,1],i=!1,r=!1,c=[0,0])=>{const l={x:(t.x-n)/s,y:(t.y-o)/s,width:t.width/s,height:t.height/s},d=[];return e.forEach(a=>{const{width:u,height:g,selectable:f=!0,hidden:m=!1}=a;if(r&&!f||m)return!1;const{positionAbsolute:p}=Ue(a,c),x={x:p.x,y:p.y,width:u||0,height:g||0},y=vt(l,x),S=typeof u>"u"||typeof g>"u"||u===null||g===null,N=i&&y>0,A=(u||0)*(g||0);(S||N||y>=A||a.dragging)&&d.push(a)}),d},Hn=(e,t)=>{const n=e.map(o=>o.id);return t.filter(o=>n.includes(o.source)||n.includes(o.target))},zn=(e,t,n,o,s,i=.1)=>{const r=t/(e.width*(1+i)),c=n/(e.height*(1+i)),l=Math.min(r,c),d=Xe(l,o,s),a=e.x+e.width/2,u=e.y+e.height/2,g=t/2-a*d,f=n/2-u*d;return{x:g,y:f,zoom:d}},_e=(e,t=0)=>e.transition().duration(t);function tn(e,t,n,o){return(t[n]||[]).reduce((s,i)=>{var r,c;return`${e.id}-${i.id}-${n}`!==o&&s.push({id:i.id||null,type:n,nodeId:e.id,x:(((r=e.positionAbsolute)==null?void 0:r.x)??0)+i.x+i.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+i.y+i.height/2}),s},[])}function Gs(e,t,n,o,s,i){const{x:r,y:c}=be(e),d=t.elementsFromPoint(r,c).find(m=>m.classList.contains("react-flow__handle"));if(d){const m=d.getAttribute("data-nodeid");if(m){const p=Vt(void 0,d),x=d.getAttribute("data-handleid"),y=i({nodeId:m,id:x,type:p});if(y){const S=s.find(N=>N.nodeId===m&&N.type===p&&N.id===x);return{handle:{id:x,type:p,nodeId:m,x:(S==null?void 0:S.x)||n.x,y:(S==null?void 0:S.y)||n.y},validHandleResult:y}}}}let a=[],u=1/0;if(s.forEach(m=>{const p=Math.sqrt((m.x-n.x)**2+(m.y-n.y)**2);if(p<=o){const x=i(m);p<=u&&(p<u?a=[{handle:m,validHandleResult:x}]:p===u&&a.push({handle:m,validHandleResult:x}),u=p)}}),!a.length)return{handle:null,validHandleResult:Ln()};if(a.length===1)return a[0];const g=a.some(({validHandleResult:m})=>m.isValid),f=a.some(({handle:m})=>m.type==="target");return a.find(({handle:m,validHandleResult:p})=>f?m.type==="target":g?p.isValid:!0)||a[0]}const Ks={source:null,target:null,sourceHandle:null,targetHandle:null},Ln=()=>({handleDomNode:null,isValid:!1,connection:Ks,endHandle:null});function Bn(e,t,n,o,s,i,r){const c=s==="target",l=r.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),d={...Ln(),handleDomNode:l};if(l){const a=Vt(void 0,l),u=l.getAttribute("data-nodeid"),g=l.getAttribute("data-handleid"),f=l.classList.contains("connectable"),m=l.classList.contains("connectableend"),p={source:c?u:n,sourceHandle:c?g:o,target:c?n:u,targetHandle:c?o:g};d.connection=p,f&&m&&(t===De.Strict?c&&a==="source"||!c&&a==="target":u!==n||g!==o)&&(d.endHandle={nodeId:u,handleId:g,type:a},d.isValid=i(p))}return d}function js({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce((s,i)=>{if(i[j]){const{handleBounds:r}=i[j];let c=[],l=[];r&&(c=tn(i,r,"source",`${t}-${n}-${o}`),l=tn(i,r,"target",`${t}-${n}-${o}`)),s.push(...c,...l)}return s},[])}function Vt(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function St(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function qs(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Vn({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:s,getState:i,setState:r,isValidConnection:c,edgeUpdaterType:l,onReconnectEnd:d}){const a=Mn(e.target),{connectionMode:u,domNode:g,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:x,getNodes:y,cancelConnection:S}=i();let N=0,A;const{x:I,y:H}=be(e),z=a==null?void 0:a.elementFromPoint(I,H),R=Vt(l,z),v=g==null?void 0:g.getBoundingClientRect();if(!v||!R)return;let _,C=be(e,v),D=!1,$=null,E=!1,M=null;const L=js({nodes:y(),nodeId:n,handleId:t,handleType:R}),Y=()=>{if(!f)return;const[P,k]=$n(C,v);x({x:P,y:k}),N=requestAnimationFrame(Y)};r({connectionPosition:C,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:R,connectionStartHandle:{nodeId:n,handleId:t,type:R},connectionEndHandle:null}),p==null||p(e,{nodeId:n,handleId:t,handleType:R});function O(P){const{transform:k}=i();C=be(P,v);const{handle:T,validHandleResult:F}=Gs(P,a,Ct(C,k,!1,[1,1]),m,L,U=>Bn(U,u,n,t,s?"target":"source",c,a));if(A=T,D||(Y(),D=!0),M=F.handleDomNode,$=F.connection,E=F.isValid,r({connectionPosition:A&&E?kn({x:A.x,y:A.y},k):C,connectionStatus:qs(!!A,E),connectionEndHandle:F.endHandle}),!A&&!E&&!M)return St(_);$.source!==$.target&&M&&(St(_),_=M,M.classList.add("connecting","react-flow__handle-connecting"),M.classList.toggle("valid",E),M.classList.toggle("react-flow__handle-valid",E))}function w(P){var k,T;(A||M)&&$&&E&&(o==null||o($)),(T=(k=i()).onConnectEnd)==null||T.call(k,P),l&&(d==null||d(P)),St(_),S(),cancelAnimationFrame(N),D=!1,E=!1,$=null,M=null,a.removeEventListener("mousemove",O),a.removeEventListener("mouseup",w),a.removeEventListener("touchmove",O),a.removeEventListener("touchend",w)}a.addEventListener("mousemove",O),a.addEventListener("mouseup",w),a.addEventListener("touchmove",O),a.addEventListener("touchend",w)}const nn=()=>!0,Qs=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Js=(e,t,n)=>o=>{const{connectionStartHandle:s,connectionEndHandle:i,connectionClickStartHandle:r}=o;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.handleId)===t&&(r==null?void 0:r.type)===n}},Fn=h.forwardRef(({type:e="source",position:t=B.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:r,onConnect:c,children:l,className:d,onMouseDown:a,onTouchStart:u,...g},f)=>{var v,_;const m=r||null,p=e==="target",x=ne(),y=Ys(),{connectOnClick:S,noPanClassName:N}=q(Qs,se),{connecting:A,clickConnecting:I}=q(Js(y,m,e),se);y||(_=(v=x.getState()).onError)==null||_.call(v,"010",xe.error010());const H=C=>{const{defaultEdgeOptions:D,onConnect:$,hasDefaultEdges:E}=x.getState(),M={...D,...C};if(E){const{edges:L,setEdges:Y}=x.getState();Y(Xs(M,L))}$==null||$(M),c==null||c(M)},z=C=>{if(!y)return;const D=In(C);s&&(D&&C.button===0||!D)&&Vn({event:C,handleId:m,nodeId:y,onConnect:H,isTarget:p,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||nn}),D?a==null||a(C):u==null||u(C)},R=C=>{const{onClickConnectStart:D,onClickConnectEnd:$,connectionClickStartHandle:E,connectionMode:M,isValidConnection:L}=x.getState();if(!y||!E&&!s)return;if(!E){D==null||D(C,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,handleId:m}});return}const Y=Mn(C.target),O=n||L||nn,{connection:w,isValid:P}=Bn({nodeId:y,id:m,type:e},M,E.nodeId,E.handleId||null,E.type,O,Y);P&&H(w),$==null||$(C),x.setState({connectionClickStartHandle:null})};return b.createElement("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${y}-${m}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,d,{source:!p,target:p,connectable:o,connectablestart:s,connectableend:i,connecting:I,connectionindicator:o&&(s&&!A||i&&A)}]),onMouseDown:z,onTouchStart:z,onClick:S?R:void 0,ref:f,...g},l)});Fn.displayName="Handle";var dt=h.memo(Fn);const On=({data:e,isConnectable:t,targetPosition:n=B.Top,sourcePosition:o=B.Bottom})=>b.createElement(b.Fragment,null,b.createElement(dt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,b.createElement(dt,{type:"source",position:o,isConnectable:t}));On.displayName="DefaultNode";var It=h.memo(On);const Yn=({data:e,isConnectable:t,sourcePosition:n=B.Bottom})=>b.createElement(b.Fragment,null,e==null?void 0:e.label,b.createElement(dt,{type:"source",position:n,isConnectable:t}));Yn.displayName="InputNode";var Un=h.memo(Yn);const Wn=({data:e,isConnectable:t,targetPosition:n=B.Top})=>b.createElement(b.Fragment,null,b.createElement(dt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);Wn.displayName="OutputNode";var Zn=h.memo(Wn);const Ft=()=>null;Ft.displayName="GroupNode";const er=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),rt=e=>e.id;function tr(e,t){return se(e.selectedNodes.map(rt),t.selectedNodes.map(rt))&&se(e.selectedEdges.map(rt),t.selectedEdges.map(rt))}const Xn=h.memo(({onSelectionChange:e})=>{const t=ne(),{selectedNodes:n,selectedEdges:o}=q(er,tr);return h.useEffect(()=>{const s={nodes:n,edges:o};e==null||e(s),t.getState().onSelectionChange.forEach(i=>i(s))},[n,o,e]),null});Xn.displayName="SelectionListener";const nr=e=>!!e.onSelectionChange;function or({onSelectionChange:e}){const t=q(nr);return e||t?b.createElement(Xn,{onSelectionChange:e}):null}const sr=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 Le(e,t){h.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function W(e,t,n){h.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const rr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:s,onConnectStart:i,onConnectEnd:r,onClickConnectStart:c,onClickConnectEnd:l,nodesDraggable:d,nodesConnectable:a,nodesFocusable:u,edgesFocusable:g,edgesUpdatable:f,elevateNodesOnSelect:m,minZoom:p,maxZoom:x,nodeExtent:y,onNodesChange:S,onEdgesChange:N,elementsSelectable:A,connectionMode:I,snapGrid:H,snapToGrid:z,translateExtent:R,connectOnClick:v,defaultEdgeOptions:_,fitView:C,fitViewOptions:D,onNodesDelete:$,onEdgesDelete:E,onNodeDrag:M,onNodeDragStart:L,onNodeDragStop:Y,onSelectionDrag:O,onSelectionDragStart:w,onSelectionDragStop:P,noPanClassName:k,nodeOrigin:T,rfId:F,autoPanOnConnect:U,autoPanOnNodeDrag:Z,onError:K,connectionRadius:Q,isValidConnection:te,nodeDragThreshold:ee})=>{const{setNodes:X,setEdges:ue,setDefaultNodesAndEdges:ce,setMinZoom:de,setMaxZoom:ae,setTranslateExtent:J,setNodeExtent:pe,reset:G}=q(sr,se),V=ne();return h.useEffect(()=>{const re=o==null?void 0:o.map(Ne=>({...Ne,..._}));return ce(n,re),()=>{G()}},[]),W("defaultEdgeOptions",_,V.setState),W("connectionMode",I,V.setState),W("onConnect",s,V.setState),W("onConnectStart",i,V.setState),W("onConnectEnd",r,V.setState),W("onClickConnectStart",c,V.setState),W("onClickConnectEnd",l,V.setState),W("nodesDraggable",d,V.setState),W("nodesConnectable",a,V.setState),W("nodesFocusable",u,V.setState),W("edgesFocusable",g,V.setState),W("edgesUpdatable",f,V.setState),W("elementsSelectable",A,V.setState),W("elevateNodesOnSelect",m,V.setState),W("snapToGrid",z,V.setState),W("snapGrid",H,V.setState),W("onNodesChange",S,V.setState),W("onEdgesChange",N,V.setState),W("connectOnClick",v,V.setState),W("fitViewOnInit",C,V.setState),W("fitViewOnInitOptions",D,V.setState),W("onNodesDelete",$,V.setState),W("onEdgesDelete",E,V.setState),W("onNodeDrag",M,V.setState),W("onNodeDragStart",L,V.setState),W("onNodeDragStop",Y,V.setState),W("onSelectionDrag",O,V.setState),W("onSelectionDragStart",w,V.setState),W("onSelectionDragStop",P,V.setState),W("noPanClassName",k,V.setState),W("nodeOrigin",T,V.setState),W("rfId",F,V.setState),W("autoPanOnConnect",U,V.setState),W("autoPanOnNodeDrag",Z,V.setState),W("onError",K,V.setState),W("connectionRadius",Q,V.setState),W("isValidConnection",te,V.setState),W("nodeDragThreshold",ee,V.setState),Le(e,X),Le(t,ue),Le(p,de),Le(x,ae),Le(R,J),Le(y,pe),null},on={display:"none"},ir={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Gn="react-flow__node-desc",Kn="react-flow__edge-desc",cr="react-flow__aria-live",ar=e=>e.ariaLiveMessage;function lr({rfId:e}){const t=q(ar);return b.createElement("div",{id:`${cr}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ir},t)}function ur({rfId:e,disableKeyboardA11y:t}){return b.createElement(b.Fragment,null,b.createElement("div",{id:`${Gn}-${e}`,style:on},"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."," "),b.createElement("div",{id:`${Kn}-${e}`,style:on},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&b.createElement(lr,{rfId:e}))}var nt=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=h.useState(!1),s=h.useRef(!1),i=h.useRef(new Set([])),[r,c]=h.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.split("+")),a=d.reduce((u,g)=>u.concat(...g),[]);return[d,a]}return[[],[]]},[e]);return h.useEffect(()=>{const l=typeof document<"u"?document:null,d=(t==null?void 0:t.target)||l;if(e!==null){const a=f=>{if(s.current=f.ctrlKey||f.metaKey||f.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&At(f))return!1;const p=rn(f.code,c);i.current.add(f[p]),sn(r,i.current,!1)&&(f.preventDefault(),o(!0))},u=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&At(f))return!1;const p=rn(f.code,c);sn(r,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(f[p]),f.key==="Meta"&&i.current.clear(),s.current=!1},g=()=>{i.current.clear(),o(!1)};return d==null||d.addEventListener("keydown",a),d==null||d.addEventListener("keyup",u),window.addEventListener("blur",g),()=>{d==null||d.removeEventListener("keydown",a),d==null||d.removeEventListener("keyup",u),window.removeEventListener("blur",g)}}},[e,o]),n};function sn(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(s=>t.has(s)))}function rn(e,t){return t.includes(e)?"code":"key"}function jn(e,t,n,o){var c,l;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),r=Ue(i,o);return jn(i,t,{x:(n.x??0)+r.x,y:(n.y??0)+r.y,z:(((c=i[j])==null?void 0:c.z)??0)>(n.z??0)?((l=i[j])==null?void 0:l.z)??0:n.z??0},o)}function qn(e,t,n){e.forEach(o=>{var i;const s=o.parentNode||o.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[o.id]){const{x:r,y:c,z:l}=jn(o,e,{...o.position,z:((i=o[j])==null?void 0:i.z)??0},t);o.positionAbsolute={x:r,y:c},o[j].z=l,n!=null&&n[o.id]&&(o[j].isParent=!0)}})}function Et(e,t,n,o){const s=new Map,i={},r=o?1e3:0;return e.forEach(c=>{var f;const l=(le(c.zIndex)?c.zIndex:0)+(c.selected?r:0),d=t.get(c.id),a={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},u=c.parentNode||c.parentId;u&&(i[u]=!0);const g=(d==null?void 0:d.type)&&(d==null?void 0:d.type)!==c.type;Object.defineProperty(a,j,{enumerable:!1,value:{handleBounds:g||(f=d==null?void 0:d[j])==null?void 0:f.handleBounds,z:l}}),s.set(c.id,a)}),qn(s,n,i),s}function Qn(e,t={}){const{getNodes:n,width:o,height:s,minZoom:i,maxZoom:r,d3Zoom:c,d3Selection:l,fitViewOnInitDone:d,fitViewOnInit:a,nodeOrigin:u}=e(),g=t.initial&&!d&&a;if(c&&l&&(g||!t.initial)){const m=n().filter(x=>{var S;const y=t.includeHiddenNodes?x.width&&x.height:!x.hidden;return(S=t.nodes)!=null&&S.length?y&&t.nodes.some(N=>N.id===x.id):y}),p=m.every(x=>x.width&&x.height);if(m.length>0&&p){const x=Bt(m,u),{x:y,y:S,zoom:N}=zn(x,o,s,t.minZoom??i,t.maxZoom??r,t.padding??.1),A=Ye.translate(y,S).scale(N);return typeof t.duration=="number"&&t.duration>0?c.transform(_e(l,t.duration),A):c.transform(l,A),!0}}return!1}function dr(e,t){return e.forEach(n=>{const o=t.get(n.id);o&&t.set(o.id,{...o,[j]:o[j],selected:n.selected})}),new Map(t)}function fr(e,t){return t.map(n=>{const o=e.find(s=>s.id===n.id);return o&&(n.selected=o.selected),n})}function it({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:s,edges:i,onNodesChange:r,onEdgesChange:c,hasDefaultNodes:l,hasDefaultEdges:d}=n();e!=null&&e.length&&(l&&o({nodeInternals:dr(e,s)}),r==null||r(e)),t!=null&&t.length&&(d&&o({edges:fr(t,i)}),c==null||c(t))}const Be=()=>{},gr={zoomIn:Be,zoomOut:Be,zoomTo:Be,getZoom:()=>1,setViewport:Be,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Be,fitBounds:Be,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},pr=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),yr=()=>{const e=ne(),{d3Zoom:t,d3Selection:n}=q(pr,se);return h.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(_e(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(_e(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,i)=>t.scaleTo(_e(n,i==null?void 0:i.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,i)=>{const[r,c,l]=e.getState().transform,d=Ye.translate(s.x??r,s.y??c).scale(s.zoom??l);t.transform(_e(n,i==null?void 0:i.duration),d)},getViewport:()=>{const[s,i,r]=e.getState().transform;return{x:s,y:i,zoom:r}},fitView:s=>Qn(e.getState,s),setCenter:(s,i,r)=>{const{width:c,height:l,maxZoom:d}=e.getState(),a=typeof(r==null?void 0:r.zoom)<"u"?r.zoom:d,u=c/2-s*a,g=l/2-i*a,f=Ye.translate(u,g).scale(a);t.transform(_e(n,r==null?void 0:r.duration),f)},fitBounds:(s,i)=>{const{width:r,height:c,minZoom:l,maxZoom:d}=e.getState(),{x:a,y:u,zoom:g}=zn(s,r,c,l,d,(i==null?void 0:i.padding)??.1),f=Ye.translate(a,u).scale(g);t.transform(_e(n,i==null?void 0:i.duration),f)},project:s=>{const{transform:i,snapToGrid:r,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Ct(s,i,r,c)},screenToFlowPosition:s=>{const{transform:i,snapToGrid:r,snapGrid:c,domNode:l}=e.getState();if(!l)return s;const{x:d,y:a}=l.getBoundingClientRect(),u={x:s.x-d,y:s.y-a};return Ct(u,i,r,c)},flowToScreenPosition:s=>{const{transform:i,domNode:r}=e.getState();if(!r)return s;const{x:c,y:l}=r.getBoundingClientRect(),d=kn(s,i);return{x:d.x+c,y:d.y+l}},viewportInitialized:!0}:gr,[t,n])};function Jn(){const e=yr(),t=ne(),n=h.useCallback(()=>t.getState().getNodes().map(p=>({...p})),[]),o=h.useCallback(p=>t.getState().nodeInternals.get(p),[]),s=h.useCallback(()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},[]),i=h.useCallback(p=>{const{edges:x=[]}=t.getState();return x.find(y=>y.id===p)},[]),r=h.useCallback(p=>{const{getNodes:x,setNodes:y,hasDefaultNodes:S,onNodesChange:N}=t.getState(),A=x(),I=typeof p=="function"?p(A):p;if(S)y(I);else if(N){const H=I.length===0?A.map(z=>({type:"remove",id:z.id})):I.map(z=>({item:z,type:"reset"}));N(H)}},[]),c=h.useCallback(p=>{const{edges:x=[],setEdges:y,hasDefaultEdges:S,onEdgesChange:N}=t.getState(),A=typeof p=="function"?p(x):p;if(S)y(A);else if(N){const I=A.length===0?x.map(H=>({type:"remove",id:H.id})):A.map(H=>({item:H,type:"reset"}));N(I)}},[]),l=h.useCallback(p=>{const x=Array.isArray(p)?p:[p],{getNodes:y,setNodes:S,hasDefaultNodes:N,onNodesChange:A}=t.getState();if(N){const H=[...y(),...x];S(H)}else if(A){const I=x.map(H=>({item:H,type:"add"}));A(I)}},[]),d=h.useCallback(p=>{const x=Array.isArray(p)?p:[p],{edges:y=[],setEdges:S,hasDefaultEdges:N,onEdgesChange:A}=t.getState();if(N)S([...y,...x]);else if(A){const I=x.map(H=>({item:H,type:"add"}));A(I)}},[]),a=h.useCallback(()=>{const{getNodes:p,edges:x=[],transform:y}=t.getState(),[S,N,A]=y;return{nodes:p().map(I=>({...I})),edges:x.map(I=>({...I})),viewport:{x:S,y:N,zoom:A}}},[]),u=h.useCallback(({nodes:p,edges:x})=>{const{nodeInternals:y,getNodes:S,edges:N,hasDefaultNodes:A,hasDefaultEdges:I,onNodesDelete:H,onEdgesDelete:z,onNodesChange:R,onEdgesChange:v}=t.getState(),_=(p||[]).map(M=>M.id),C=(x||[]).map(M=>M.id),D=S().reduce((M,L)=>{const Y=L.parentNode||L.parentId,O=!_.includes(L.id)&&Y&&M.find(P=>P.id===Y);return(typeof L.deletable!="boolean"||L.deletable)&&(_.includes(L.id)||O)&&M.push(L),M},[]),$=N.filter(M=>typeof M.deletable=="boolean"?M.deletable:!0),E=$.filter(M=>C.includes(M.id));if(D||E){const M=Hn(D,$),L=[...E,...M],Y=L.reduce((O,w)=>(O.includes(w.id)||O.push(w.id),O),[]);if((I||A)&&(I&&t.setState({edges:N.filter(O=>!Y.includes(O.id))}),A&&(D.forEach(O=>{y.delete(O.id)}),t.setState({nodeInternals:new Map(y)}))),Y.length>0&&(z==null||z(L),v&&v(Y.map(O=>({id:O,type:"remove"})))),D.length>0&&(H==null||H(D),R)){const O=D.map(w=>({id:w.id,type:"remove"}));R(O)}}},[]),g=h.useCallback(p=>{const x=Rs(p),y=x?null:t.getState().nodeInternals.get(p.id);return!x&&!y?[null,null,x]:[x?p:jt(y),y,x]},[]),f=h.useCallback((p,x=!0,y)=>{const[S,N,A]=g(p);return S?(y||t.getState().getNodes()).filter(I=>{if(!A&&(I.id===N.id||!I.positionAbsolute))return!1;const H=jt(I),z=vt(H,S);return x&&z>0||z>=S.width*S.height}):[]},[]),m=h.useCallback((p,x,y=!0)=>{const[S]=g(p);if(!S)return!1;const N=vt(S,x);return y&&N>0||N>=S.width*S.height},[]);return h.useMemo(()=>({...e,getNodes:n,getNode:o,getEdges:s,getEdge:i,setNodes:r,setEdges:c,addNodes:l,addEdges:d,toObject:a,deleteElements:u,getIntersectingNodes:f,isNodeIntersecting:m}),[e,n,o,s,i,r,c,l,d,a,u,f,m])}const hr={actInsideInputWithModifier:!1};var mr=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=ne(),{deleteElements:o}=Jn(),s=nt(e,hr),i=nt(t);h.useEffect(()=>{if(s){const{edges:r,getNodes:c}=n.getState(),l=c().filter(a=>a.selected),d=r.filter(a=>a.selected);o({nodes:l,edges:d}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])};function xr(e){const t=ne();h.useEffect(()=>{let n;const o=()=>{var i,r;if(!e.current)return;const s=Dt(e.current);(s.height===0||s.width===0)&&((r=(i=t.getState()).onError)==null||r.call(i,"004",xe.error004())),t.setState({width:s.width||500,height:s.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver(()=>o()),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}},[])}const Ot={position:"absolute",width:"100%",height:"100%",top:0,left:0},Sr=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,ct=e=>({x:e.x,y:e.y,zoom:e.k}),Ve=(e,t)=>e.target.closest(`.${t}`),cn=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),an=e=>{const t=e.ctrlKey&&at()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Er=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),wr=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:s=!0,zoomOnPinch:i=!0,panOnScroll:r=!1,panOnScrollSpeed:c=.5,panOnScrollMode:l=Te.Free,zoomOnDoubleClick:d=!0,elementsSelectable:a,panOnDrag:u=!0,defaultViewport:g,translateExtent:f,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:y=!0,children:S,noWheelClassName:N,noPanClassName:A})=>{const I=h.useRef(),H=ne(),z=h.useRef(!1),R=h.useRef(!1),v=h.useRef(null),_=h.useRef({x:0,y:0,zoom:0}),{d3Zoom:C,d3Selection:D,d3ZoomHandler:$,userSelectionActive:E}=q(Er,se),M=nt(x),L=h.useRef(0),Y=h.useRef(!1),O=h.useRef();return xr(v),h.useEffect(()=>{if(v.current){const w=v.current.getBoundingClientRect(),P=Qo().scaleExtent([m,p]).translateExtent(f),k=Sn(v.current).call(P),T=Ye.translate(g.x,g.y).scale(Xe(g.zoom,m,p)),F=[[0,0],[w.width,w.height]],U=P.constrain()(T,F,f);P.transform(k,U),P.wheelDelta(an),H.setState({d3Zoom:P,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[U.x,U.y,U.k],domNode:v.current.closest(".react-flow")})}},[]),h.useEffect(()=>{D&&C&&(r&&!M&&!E?D.on("wheel.zoom",w=>{if(Ve(w,N))return!1;w.preventDefault(),w.stopImmediatePropagation();const P=D.property("__zoom").k||1;if(w.ctrlKey&&i){const te=Jo(w),ee=an(w),X=P*Math.pow(2,ee);C.scaleTo(D,X,te,w);return}const k=w.deltaMode===1?20:1;let T=l===Te.Vertical?0:w.deltaX*k,F=l===Te.Horizontal?0:w.deltaY*k;!at()&&w.shiftKey&&l!==Te.Vertical&&(T=w.deltaY*k,F=0),C.translateBy(D,-(T/P)*c,-(F/P)*c,{internal:!0});const U=ct(D.property("__zoom")),{onViewportChangeStart:Z,onViewportChange:K,onViewportChangeEnd:Q}=H.getState();clearTimeout(O.current),Y.current||(Y.current=!0,t==null||t(w,U),Z==null||Z(U)),Y.current&&(e==null||e(w,U),K==null||K(U),O.current=setTimeout(()=>{n==null||n(w,U),Q==null||Q(U),Y.current=!1},150))},{passive:!1}):typeof $<"u"&&D.on("wheel.zoom",function(w,P){if(!y&&w.type==="wheel"&&!w.ctrlKey||Ve(w,N))return null;w.preventDefault(),$.call(this,w,P)},{passive:!1}))},[E,r,l,D,C,$,M,i,y,N,t,e,n]),h.useEffect(()=>{C&&C.on("start",w=>{var T,F;if(!w.sourceEvent||w.sourceEvent.internal)return null;L.current=(T=w.sourceEvent)==null?void 0:T.button;const{onViewportChangeStart:P}=H.getState(),k=ct(w.transform);z.current=!0,_.current=k,((F=w.sourceEvent)==null?void 0:F.type)==="mousedown"&&H.setState({paneDragging:!0}),P==null||P(k),t==null||t(w.sourceEvent,k)})},[C,t]),h.useEffect(()=>{C&&(E&&!z.current?C.on("zoom",null):E||C.on("zoom",w=>{var k;const{onViewportChange:P}=H.getState();if(H.setState({transform:[w.transform.x,w.transform.y,w.transform.k]}),R.current=!!(o&&cn(u,L.current??0)),(e||P)&&!((k=w.sourceEvent)!=null&&k.internal)){const T=ct(w.transform);P==null||P(T),e==null||e(w.sourceEvent,T)}}))},[E,C,e,u,o]),h.useEffect(()=>{C&&C.on("end",w=>{if(!w.sourceEvent||w.sourceEvent.internal)return null;const{onViewportChangeEnd:P}=H.getState();if(z.current=!1,H.setState({paneDragging:!1}),o&&cn(u,L.current??0)&&!R.current&&o(w.sourceEvent),R.current=!1,(n||P)&&Sr(_.current,w.transform)){const k=ct(w.transform);_.current=k,clearTimeout(I.current),I.current=setTimeout(()=>{P==null||P(k),n==null||n(w.sourceEvent,k)},r?150:0)}})},[C,r,u,n,o]),h.useEffect(()=>{C&&C.filter(w=>{const P=M||s,k=i&&w.ctrlKey;if((u===!0||Array.isArray(u)&&u.includes(1))&&w.button===1&&w.type==="mousedown"&&(Ve(w,"react-flow__node")||Ve(w,"react-flow__edge")))return!0;if(!u&&!P&&!r&&!d&&!i||E||!d&&w.type==="dblclick"||Ve(w,N)&&w.type==="wheel"||Ve(w,A)&&(w.type!=="wheel"||r&&w.type==="wheel"&&!M)||!i&&w.ctrlKey&&w.type==="wheel"||!P&&!r&&!k&&w.type==="wheel"||!u&&(w.type==="mousedown"||w.type==="touchstart")||Array.isArray(u)&&!u.includes(w.button)&&w.type==="mousedown")return!1;const T=Array.isArray(u)&&u.includes(w.button)||!w.button||w.button<=1;return(!w.ctrlKey||w.type==="wheel")&&T})},[E,C,s,i,r,d,u,a,M]),b.createElement("div",{className:"react-flow__renderer",ref:v,style:Ot},S)},br=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Nr(){const{userSelectionActive:e,userSelectionRect:t}=q(br,se);return e&&t?b.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function ln(e,t){const n=t.parentNode||t.parentId,o=e.find(s=>s.id===n);if(o){const s=t.position.x+t.width-o.width,i=t.position.y+t.height-o.height;if(s>0||i>0||t.position.x<0||t.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,s>0&&(o.style.width+=s),i>0&&(o.style.height+=i),t.position.x<0){const r=Math.abs(t.position.x);o.position.x=o.position.x-r,o.style.width+=r,t.position.x=0}if(t.position.y<0){const r=Math.abs(t.position.y);o.position.y=o.position.y-r,o.style.height+=r,t.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function eo(e,t){if(e.some(o=>o.type==="reset"))return e.filter(o=>o.type==="reset").map(o=>o.item);const n=e.filter(o=>o.type==="add").map(o=>o.item);return t.reduce((o,s)=>{const i=e.filter(c=>c.id===s.id);if(i.length===0)return o.push(s),o;const r={...s};for(const c of i)if(c)switch(c.type){case"select":{r.selected=c.selected;break}case"position":{typeof c.position<"u"&&(r.position=c.position),typeof c.positionAbsolute<"u"&&(r.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(r.dragging=c.dragging),r.expandParent&&ln(o,r);break}case"dimensions":{typeof c.dimensions<"u"&&(r.width=c.dimensions.width,r.height=c.dimensions.height),typeof c.updateStyle<"u"&&(r.style={...r.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(r.resizing=c.resizing),r.expandParent&&ln(o,r);break}case"remove":return o}return o.push(r),o},n)}function to(e,t){return eo(e,t)}function vr(e,t){return eo(e,t)}const Ee=(e,t)=>({id:e,type:"select",selected:t});function Oe(e,t){return e.reduce((n,o)=>{const s=t.includes(o.id);return!o.selected&&s?(o.selected=!0,n.push(Ee(o.id,!0))):o.selected&&!s&&(o.selected=!1,n.push(Ee(o.id,!1))),n},[])}const wt=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Ar=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),no=h.memo(({isSelecting:e,selectionMode:t=tt.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:s,onPaneClick:i,onPaneContextMenu:r,onPaneScroll:c,onPaneMouseEnter:l,onPaneMouseMove:d,onPaneMouseLeave:a,children:u})=>{const g=h.useRef(null),f=ne(),m=h.useRef(0),p=h.useRef(0),x=h.useRef(),{userSelectionActive:y,elementsSelectable:S,dragging:N}=q(Ar,se),A=()=>{f.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,p.current=0},I=$=>{i==null||i($),f.getState().resetSelectedElements(),f.setState({nodesSelectionActive:!1})},H=$=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){$.preventDefault();return}r==null||r($)},z=c?$=>c($):void 0,R=$=>{const{resetSelectedElements:E,domNode:M}=f.getState();if(x.current=M==null?void 0:M.getBoundingClientRect(),!S||!e||$.button!==0||$.target!==g.current||!x.current)return;const{x:L,y:Y}=be($,x.current);E(),f.setState({userSelectionRect:{width:0,height:0,startX:L,startY:Y,x:L,y:Y}}),o==null||o($)},v=$=>{const{userSelectionRect:E,nodeInternals:M,edges:L,transform:Y,onNodesChange:O,onEdgesChange:w,nodeOrigin:P,getNodes:k}=f.getState();if(!e||!x.current||!E)return;f.setState({userSelectionActive:!0,nodesSelectionActive:!1});const T=be($,x.current),F=E.startX??0,U=E.startY??0,Z={...E,x:T.x<F?T.x:F,y:T.y<U?T.y:U,width:Math.abs(T.x-F),height:Math.abs(T.y-U)},K=k(),Q=Rn(M,Z,Y,t===tt.Partial,!0,P),te=Hn(Q,L).map(X=>X.id),ee=Q.map(X=>X.id);if(m.current!==ee.length){m.current=ee.length;const X=Oe(K,ee);X.length&&(O==null||O(X))}if(p.current!==te.length){p.current=te.length;const X=Oe(L,te);X.length&&(w==null||w(X))}f.setState({userSelectionRect:Z})},_=$=>{if($.button!==0)return;const{userSelectionRect:E}=f.getState();!y&&E&&$.target===g.current&&(I==null||I($)),f.setState({nodesSelectionActive:m.current>0}),A(),s==null||s($)},C=$=>{y&&(f.setState({nodesSelectionActive:m.current>0}),s==null||s($)),A()},D=S&&(e||y);return b.createElement("div",{className:ie(["react-flow__pane",{dragging:N,selection:e}]),onClick:D?void 0:wt(I,g),onContextMenu:wt(H,g),onWheel:wt(z,g),onMouseEnter:D?void 0:l,onMouseDown:D?R:void 0,onMouseMove:D?v:d,onMouseUp:D?_:void 0,onMouseLeave:D?C:a,ref:g,style:Ot},u,b.createElement(Nr,null))});no.displayName="Pane";function oo(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const o=t.get(n);return o?o.selected?!0:oo(o,t):!1}function un(e,t,n){let o=e;do{if(o!=null&&o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function $r(e,t,n,o){return Array.from(e.values()).filter(s=>(s.selected||s.id===o)&&(!s.parentNode||s.parentId||!oo(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var i,r;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((i=s.positionAbsolute)==null?void 0:i.x)??0),y:n.y-(((r=s.positionAbsolute)==null?void 0:r.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function Mr(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function so(e,t,n,o,s=[0,0],i){const r=Mr(e,e.extent||o);let c=r;const l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){const u=n.get(l),{x:g,y:f}=Ue(u,s).positionAbsolute;c=u&&le(g)&&le(f)&&le(u.width)&&le(u.height)?[[g+e.width*s[0],f+e.height*s[1]],[g+u.width-e.width+e.width*s[0],f+u.height-e.height+e.height*s[1]]]:c}else i==null||i("005",xe.error005()),c=r;else if(e.extent&&l&&e.extent!=="parent"){const u=n.get(l),{x:g,y:f}=Ue(u,s).positionAbsolute;c=[[e.extent[0][0]+g,e.extent[0][1]+f],[e.extent[1][0]+g,e.extent[1][1]+f]]}let d={x:0,y:0};if(l){const u=n.get(l);d=Ue(u,s).positionAbsolute}const a=c&&c!=="parent"?Pt(t,c):t;return{position:{x:a.x-d.x,y:a.y-d.y},positionAbsolute:a}}function bt({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?o.find(s=>s.id===e):o[0],o]}const dn=(e,t,n,o)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const i=Array.from(s),r=t.getBoundingClientRect(),c={x:r.width*o[0],y:r.height*o[1]};return i.map(l=>{const d=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(d.left-r.left-c.x)/n,y:(d.top-r.top-c.y)/n,...Dt(l)}})};function Je(e,t,n){return n===void 0?n:o=>{const s=t().nodeInternals.get(e);s&&n(o,{...s})}}function _t({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:r,nodeInternals:c,onError:l}=t.getState(),d=c.get(e);if(!d){l==null||l("012",xe.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&r)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var a;return(a=o==null?void 0:o.current)==null?void 0:a.blur()})):s([e])}function Cr(){const e=ne();return h.useCallback(({sourceEvent:n})=>{const{transform:o,snapGrid:s,snapToGrid:i}=e.getState(),r=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,l={x:(r-o[0])/o[2],y:(c-o[1])/o[2]};return{xSnapped:i?s[0]*Math.round(l.x/s[0]):l.x,ySnapped:i?s[1]*Math.round(l.y/s[1]):l.y,...l}},[])}function Nt(e){return(t,n,o)=>e==null?void 0:e(t,o)}function ro({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:s,isSelectable:i,selectNodesOnDrag:r}){const c=ne(),[l,d]=h.useState(!1),a=h.useRef([]),u=h.useRef({x:null,y:null}),g=h.useRef(0),f=h.useRef(null),m=h.useRef({x:0,y:0}),p=h.useRef(null),x=h.useRef(!1),y=h.useRef(!1),S=h.useRef(!1),N=Cr();return h.useEffect(()=>{if(e!=null&&e.current){const A=Sn(e.current),I=({x:R,y:v})=>{const{nodeInternals:_,onNodeDrag:C,onSelectionDrag:D,updateNodePositions:$,nodeExtent:E,snapGrid:M,snapToGrid:L,nodeOrigin:Y,onError:O}=c.getState();u.current={x:R,y:v};let w=!1,P={x:0,y:0,x2:0,y2:0};if(a.current.length>1&&E){const T=Bt(a.current,Y);P=kt(T)}if(a.current=a.current.map(T=>{const F={x:R-T.distance.x,y:v-T.distance.y};L&&(F.x=M[0]*Math.round(F.x/M[0]),F.y=M[1]*Math.round(F.y/M[1]));const U=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];a.current.length>1&&E&&!T.extent&&(U[0][0]=T.positionAbsolute.x-P.x+E[0][0],U[1][0]=T.positionAbsolute.x+(T.width??0)-P.x2+E[1][0],U[0][1]=T.positionAbsolute.y-P.y+E[0][1],U[1][1]=T.positionAbsolute.y+(T.height??0)-P.y2+E[1][1]);const Z=so(T,F,_,U,Y,O);return w=w||T.position.x!==Z.position.x||T.position.y!==Z.position.y,T.position=Z.position,T.positionAbsolute=Z.positionAbsolute,T}),!w)return;$(a.current,!0,!0),d(!0);const k=s?C:Nt(D);if(k&&p.current){const[T,F]=bt({nodeId:s,dragItems:a.current,nodeInternals:_});k(p.current,T,F)}},H=()=>{if(!f.current)return;const[R,v]=$n(m.current,f.current);if(R!==0||v!==0){const{transform:_,panBy:C}=c.getState();u.current.x=(u.current.x??0)-R/_[2],u.current.y=(u.current.y??0)-v/_[2],C({x:R,y:v})&&I(u.current)}g.current=requestAnimationFrame(H)},z=R=>{var Y;const{nodeInternals:v,multiSelectionActive:_,nodesDraggable:C,unselectNodesAndEdges:D,onNodeDragStart:$,onSelectionDragStart:E}=c.getState();y.current=!0;const M=s?$:Nt(E);(!r||!i)&&!_&&s&&((Y=v.get(s))!=null&&Y.selected||D()),s&&i&&r&&_t({id:s,store:c,nodeRef:e});const L=N(R);if(u.current=L,a.current=$r(v,C,L,s),M&&a.current){const[O,w]=bt({nodeId:s,dragItems:a.current,nodeInternals:v});M(R.sourceEvent,O,w)}};if(t)A.on(".drag",null);else{const R=es().on("start",v=>{const{domNode:_,nodeDragThreshold:C}=c.getState();C===0&&z(v),S.current=!1;const D=N(v);u.current=D,f.current=(_==null?void 0:_.getBoundingClientRect())||null,m.current=be(v.sourceEvent,f.current)}).on("drag",v=>{var $,E;const _=N(v),{autoPanOnNodeDrag:C,nodeDragThreshold:D}=c.getState();if(v.sourceEvent.type==="touchmove"&&v.sourceEvent.touches.length>1&&(S.current=!0),!S.current){if(!x.current&&y.current&&C&&(x.current=!0,H()),!y.current){const M=_.xSnapped-((($=u==null?void 0:u.current)==null?void 0:$.x)??0),L=_.ySnapped-(((E=u==null?void 0:u.current)==null?void 0:E.y)??0);Math.sqrt(M*M+L*L)>D&&z(v)}(u.current.x!==_.xSnapped||u.current.y!==_.ySnapped)&&a.current&&y.current&&(p.current=v.sourceEvent,m.current=be(v.sourceEvent,f.current),I(_))}}).on("end",v=>{if(!(!y.current||S.current)&&(d(!1),x.current=!1,y.current=!1,cancelAnimationFrame(g.current),a.current)){const{updateNodePositions:_,nodeInternals:C,onNodeDragStop:D,onSelectionDragStop:$}=c.getState(),E=s?D:Nt($);if(_(a.current,!1,!1),E){const[M,L]=bt({nodeId:s,dragItems:a.current,nodeInternals:C});E(v.sourceEvent,M,L)}}}).filter(v=>{const _=v.target;return!v.button&&(!n||!un(_,`.${n}`,e))&&(!o||un(_,o,e))});return A.call(R),()=>{A.on(".drag",null)}}}},[e,t,n,o,i,c,s,r,N]),l}function io(){const e=ne();return h.useCallback(n=>{const{nodeInternals:o,nodeExtent:s,updateNodePositions:i,getNodes:r,snapToGrid:c,snapGrid:l,onError:d,nodesDraggable:a}=e.getState(),u=r().filter(S=>S.selected&&(S.draggable||a&&typeof S.draggable>"u")),g=c?l[0]:5,f=c?l[1]:5,m=n.isShiftPressed?4:1,p=n.x*g*m,x=n.y*f*m,y=u.map(S=>{if(S.positionAbsolute){const N={x:S.positionAbsolute.x+p,y:S.positionAbsolute.y+x};c&&(N.x=l[0]*Math.round(N.x/l[0]),N.y=l[1]*Math.round(N.y/l[1]));const{positionAbsolute:A,position:I}=so(S,N,o,s,void 0,d);S.position=I,S.positionAbsolute=A}return S});i(y,!0,!1)},[])}const We={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var et=e=>{const t=({id:n,type:o,data:s,xPos:i,yPos:r,xPosOrigin:c,yPosOrigin:l,selected:d,onClick:a,onMouseEnter:u,onMouseMove:g,onMouseLeave:f,onContextMenu:m,onDoubleClick:p,style:x,className:y,isDraggable:S,isSelectable:N,isConnectable:A,isFocusable:I,selectNodesOnDrag:H,sourcePosition:z,targetPosition:R,hidden:v,resizeObserver:_,dragHandle:C,zIndex:D,isParent:$,noDragClassName:E,noPanClassName:M,initialized:L,disableKeyboardA11y:Y,ariaLabel:O,rfId:w,hasHandleBounds:P})=>{const k=ne(),T=h.useRef(null),F=h.useRef(null),U=h.useRef(z),Z=h.useRef(R),K=h.useRef(o),Q=N||S||a||u||g||f,te=io(),ee=Je(n,k.getState,u),X=Je(n,k.getState,g),ue=Je(n,k.getState,f),ce=Je(n,k.getState,m),de=Je(n,k.getState,p),ae=G=>{const{nodeDragThreshold:V}=k.getState();if(N&&(!H||!S||V>0)&&_t({id:n,store:k,nodeRef:T}),a){const re=k.getState().nodeInternals.get(n);re&&a(G,{...re})}},J=G=>{if(!At(G)&&!Y)if(Cn.includes(G.key)&&N){const V=G.key==="Escape";_t({id:n,store:k,unselect:V,nodeRef:T})}else S&&d&&Object.prototype.hasOwnProperty.call(We,G.key)&&(k.setState({ariaLiveMessage:`Moved selected node ${G.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~r}`}),te({x:We[G.key].x,y:We[G.key].y,isShiftPressed:G.shiftKey}))};h.useEffect(()=>()=>{F.current&&(_==null||_.unobserve(F.current),F.current=null)},[]),h.useEffect(()=>{if(T.current&&!v){const G=T.current;(!L||!P||F.current!==G)&&(F.current&&(_==null||_.unobserve(F.current)),_==null||_.observe(G),F.current=G)}},[v,L,P]),h.useEffect(()=>{const G=K.current!==o,V=U.current!==z,re=Z.current!==R;T.current&&(G||V||re)&&(G&&(K.current=o),V&&(U.current=z),re&&(Z.current=R),k.getState().updateNodeDimensions([{id:n,nodeElement:T.current,forceUpdate:!0}]))},[n,o,z,R]);const pe=ro({nodeRef:T,disabled:v||!S,noDragClassName:E,handleSelector:C,nodeId:n,isSelectable:N,selectNodesOnDrag:H});return v?null:b.createElement("div",{className:ie(["react-flow__node",`react-flow__node-${o}`,{[M]:S},y,{selected:d,selectable:N,parent:$,dragging:pe}]),ref:T,style:{zIndex:D,transform:`translate(${c}px,${l}px)`,pointerEvents:Q?"all":"none",visibility:L?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ee,onMouseMove:X,onMouseLeave:ue,onContextMenu:ce,onClick:ae,onDoubleClick:de,onKeyDown:I?J:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":Y?void 0:`${Gn}-${w}`,"aria-label":O},b.createElement(Os,{value:n},b.createElement(e,{id:n,data:s,type:o,xPos:i,yPos:r,selected:d,isConnectable:A,sourcePosition:z,targetPosition:R,dragging:pe,dragHandle:C,zIndex:D})))};return t.displayName="NodeWrapper",h.memo(t)};const Ir=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Bt(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function _r({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ne(),{width:s,height:i,x:r,y:c,transformString:l,userSelectionActive:d}=q(Ir,se),a=io(),u=h.useRef(null);if(h.useEffect(()=>{var m;n||(m=u.current)==null||m.focus({preventScroll:!0})},[n]),ro({nodeRef:u}),d||!s||!i)return null;const g=e?m=>{const p=o.getState().getNodes().filter(x=>x.selected);e(m,p)}:void 0,f=m=>{Object.prototype.hasOwnProperty.call(We,m.key)&&a({x:We[m.key].x,y:We[m.key].y,isShiftPressed:m.shiftKey})};return b.createElement("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},b.createElement("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i,top:c,left:r}}))}var Tr=h.memo(_r);const Dr=e=>e.nodesSelectionActive,co=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:r,deleteKeyCode:c,onMove:l,onMoveStart:d,onMoveEnd:a,selectionKeyCode:u,selectionOnDrag:g,selectionMode:f,onSelectionStart:m,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:y,zoomActivationKeyCode:S,elementsSelectable:N,zoomOnScroll:A,zoomOnPinch:I,panOnScroll:H,panOnScrollSpeed:z,panOnScrollMode:R,zoomOnDoubleClick:v,panOnDrag:_,defaultViewport:C,translateExtent:D,minZoom:$,maxZoom:E,preventScrolling:M,onSelectionContextMenu:L,noWheelClassName:Y,noPanClassName:O,disableKeyboardA11y:w})=>{const P=q(Dr),k=nt(u),T=nt(y),F=T||_,U=T||H,Z=k||g&&F!==!0;return mr({deleteKeyCode:c,multiSelectionKeyCode:x}),b.createElement(wr,{onMove:l,onMoveStart:d,onMoveEnd:a,onPaneContextMenu:i,elementsSelectable:N,zoomOnScroll:A,zoomOnPinch:I,panOnScroll:U,panOnScrollSpeed:z,panOnScrollMode:R,zoomOnDoubleClick:v,panOnDrag:!k&&F,defaultViewport:C,translateExtent:D,minZoom:$,maxZoom:E,zoomActivationKeyCode:S,preventScrolling:M,noWheelClassName:Y,noPanClassName:O},b.createElement(no,{onSelectionStart:m,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:r,panOnDrag:F,isSelecting:!!Z,selectionMode:f},e,P&&b.createElement(Tr,{onSelectionContextMenu:L,noPanClassName:O,disableKeyboardA11y:w})))};co.displayName="FlowRenderer";var Pr=h.memo(co);function kr(e){return q(h.useCallback(n=>e?Rn(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function Rr(e){const t={input:et(e.input||Un),default:et(e.default||It),output:et(e.output||Zn),group:et(e.group||Ft)},n={},o=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,i)=>(s[i]=et(e[i]||It),s),n);return{...t,...o}}const Hr=({x:e,y:t,width:n,height:o,origin:s})=>!n||!o?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-o*s[1]},zr=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),ao=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,updateNodeDimensions:i,onError:r}=q(zr,se),c=kr(e.onlyRenderVisibleElements),l=h.useRef(),d=h.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const a=new ResizeObserver(u=>{const g=u.map(f=>({id:f.target.getAttribute("data-id"),nodeElement:f.target,forceUpdate:!0}));i(g)});return l.current=a,a},[]);return h.useEffect(()=>()=>{var a;(a=l==null?void 0:l.current)==null||a.disconnect()},[]),b.createElement("div",{className:"react-flow__nodes",style:Ot},c.map(a=>{var I,H,z;let u=a.type||"default";e.nodeTypes[u]||(r==null||r("003",xe.error003(u)),u="default");const g=e.nodeTypes[u]||e.nodeTypes.default,f=!!(a.draggable||t&&typeof a.draggable>"u"),m=!!(a.selectable||s&&typeof a.selectable>"u"),p=!!(a.connectable||n&&typeof a.connectable>"u"),x=!!(a.focusable||o&&typeof a.focusable>"u"),y=e.nodeExtent?Pt(a.positionAbsolute,e.nodeExtent):a.positionAbsolute,S=(y==null?void 0:y.x)??0,N=(y==null?void 0:y.y)??0,A=Hr({x:S,y:N,width:a.width??0,height:a.height??0,origin:e.nodeOrigin});return b.createElement(g,{key:a.id,id:a.id,className:a.className,style:a.style,type:u,data:a.data,sourcePosition:a.sourcePosition||B.Bottom,targetPosition:a.targetPosition||B.Top,hidden:a.hidden,xPos:S,yPos:N,xPosOrigin:A.x,yPosOrigin:A.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!a.selected,isDraggable:f,isSelectable:m,isConnectable:p,isFocusable:x,resizeObserver:d,dragHandle:a.dragHandle,zIndex:((I=a[j])==null?void 0:I.z)??0,isParent:!!((H=a[j])!=null&&H.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!a.width&&!!a.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:a.ariaLabel,hasHandleBounds:!!((z=a[j])!=null&&z.handleBounds)})}))};ao.displayName="NodeRenderer";var Lr=h.memo(ao);const Br=(e,t,n)=>n===B.Left?e-t:n===B.Right?e+t:e,Vr=(e,t,n)=>n===B.Top?e-t:n===B.Bottom?e+t:e,fn="react-flow__edgeupdater",gn=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:s,onMouseEnter:i,onMouseOut:r,type:c})=>b.createElement("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:r,className:ie([fn,`${fn}-${c}`]),cx:Br(t,o,e),cy:Vr(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),Fr=()=>!0;var Fe=e=>{const t=({id:n,className:o,type:s,data:i,onClick:r,onEdgeDoubleClick:c,selected:l,animated:d,label:a,labelStyle:u,labelShowBg:g,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:x,source:y,target:S,sourceX:N,sourceY:A,targetX:I,targetY:H,sourcePosition:z,targetPosition:R,elementsSelectable:v,hidden:_,sourceHandleId:C,targetHandleId:D,onContextMenu:$,onMouseEnter:E,onMouseMove:M,onMouseLeave:L,reconnectRadius:Y,onReconnect:O,onReconnectStart:w,onReconnectEnd:P,markerEnd:k,markerStart:T,rfId:F,ariaLabel:U,isFocusable:Z,isReconnectable:K,pathOptions:Q,interactionWidth:te,disableKeyboardA11y:ee})=>{const X=h.useRef(null),[ue,ce]=h.useState(!1),[de,ae]=h.useState(!1),J=ne(),pe=h.useMemo(()=>`url('#${Mt(T,F)}')`,[T,F]),G=h.useMemo(()=>`url('#${Mt(k,F)}')`,[k,F]);if(_)return null;const V=oe=>{var ye;const{edges:fe,addSelectedEdges:$e,unselectNodesAndEdges:Me,multiSelectionActive:Ce}=J.getState(),me=fe.find(je=>je.id===n);me&&(v&&(J.setState({nodesSelectionActive:!1}),me.selected&&Ce?(Me({nodes:[],edges:[me]}),(ye=X.current)==null||ye.blur()):$e([n])),r&&r(oe,me))},re=Qe(n,J.getState,c),Ne=Qe(n,J.getState,$),Ge=Qe(n,J.getState,E),Pe=Qe(n,J.getState,M),ke=Qe(n,J.getState,L),he=(oe,fe)=>{if(oe.button!==0)return;const{edges:$e,isValidConnection:Me}=J.getState(),Ce=fe?S:y,me=(fe?D:C)||null,ye=fe?"target":"source",je=Me||Fr,yt=fe,qe=$e.find(Ie=>Ie.id===n);ae(!0),w==null||w(oe,qe,ye);const ht=Ie=>{ae(!1),P==null||P(Ie,qe,ye)};Vn({event:oe,handleId:me,nodeId:Ce,onConnect:Ie=>O==null?void 0:O(qe,Ie),isTarget:yt,getState:J.getState,setState:J.setState,isValidConnection:je,edgeUpdaterType:ye,onReconnectEnd:ht})},Re=oe=>he(oe,!0),ve=oe=>he(oe,!1),Ae=()=>ce(!0),He=()=>ce(!1),ze=!v&&!r,Ke=oe=>{var fe;if(!ee&&Cn.includes(oe.key)&&v){const{unselectNodesAndEdges:$e,addSelectedEdges:Me,edges:Ce}=J.getState();oe.key==="Escape"?((fe=X.current)==null||fe.blur(),$e({edges:[Ce.find(ye=>ye.id===n)]})):Me([n])}};return b.createElement("g",{className:ie(["react-flow__edge",`react-flow__edge-${s}`,o,{selected:l,animated:d,inactive:ze,updating:ue}]),onClick:V,onDoubleClick:re,onContextMenu:Ne,onMouseEnter:Ge,onMouseMove:Pe,onMouseLeave:ke,onKeyDown:Z?Ke:void 0,tabIndex:Z?0:void 0,role:Z?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":U===null?void 0:U||`Edge from ${y} to ${S}`,"aria-describedby":Z?`${Kn}-${F}`:void 0,ref:X},!de&&b.createElement(e,{id:n,source:y,target:S,selected:l,animated:d,label:a,labelStyle:u,labelShowBg:g,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,data:i,style:x,sourceX:N,sourceY:A,targetX:I,targetY:H,sourcePosition:z,targetPosition:R,sourceHandleId:C,targetHandleId:D,markerStart:pe,markerEnd:G,pathOptions:Q,interactionWidth:te}),K&&b.createElement(b.Fragment,null,(K==="source"||K===!0)&&b.createElement(gn,{position:z,centerX:N,centerY:A,radius:Y,onMouseDown:Re,onMouseEnter:Ae,onMouseOut:He,type:"source"}),(K==="target"||K===!0)&&b.createElement(gn,{position:R,centerX:I,centerY:H,radius:Y,onMouseDown:ve,onMouseEnter:Ae,onMouseOut:He,type:"target"})))};return t.displayName="EdgeWrapper",h.memo(t)};function Or(e){const t={default:Fe(e.default||ut),straight:Fe(e.bezier||zt),step:Fe(e.step||Ht),smoothstep:Fe(e.step||pt),simplebezier:Fe(e.simplebezier||Rt)},n={},o=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,i)=>(s[i]=Fe(e[i]||ut),s),n);return{...t,...o}}function pn(e,t,n=null){const o=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,i=(n==null?void 0:n.width)||t.width,r=(n==null?void 0:n.height)||t.height;switch(e){case B.Top:return{x:o+i/2,y:s};case B.Right:return{x:o+i,y:s+r/2};case B.Bottom:return{x:o+i/2,y:s+r};case B.Left:return{x:o,y:s+r/2}}}function yn(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const Yr=(e,t,n,o,s,i)=>{const r=pn(n,e,t),c=pn(i,o,s);return{sourceX:r.x,sourceY:r.y,targetX:c.x,targetY:c.y}};function Ur({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:s,targetHeight:i,width:r,height:c,transform:l}){const d={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+o,t.y+i)};d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const a=kt({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:r/l[2],height:c/l[2]}),u=Math.max(0,Math.min(a.x2,d.x2)-Math.max(a.x,d.x)),g=Math.max(0,Math.min(a.y2,d.y2)-Math.max(a.y,d.y));return Math.ceil(u*g)>0}function hn(e){var o,s,i,r,c;const t=((o=e==null?void 0:e[j])==null?void 0:o.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.y)<"u";return[{x:((r=e==null?void 0:e.positionAbsolute)==null?void 0:r.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const Wr=[{level:0,isMaxLevel:!0,edges:[]}];function Zr(e,t,n=!1){let o=-1;const s=e.reduce((r,c)=>{var a,u;const l=le(c.zIndex);let d=l?c.zIndex:0;if(n){const g=t.get(c.target),f=t.get(c.source),m=c.selected||(g==null?void 0:g.selected)||(f==null?void 0:f.selected),p=Math.max(((a=f==null?void 0:f[j])==null?void 0:a.z)||0,((u=g==null?void 0:g[j])==null?void 0:u.z)||0,1e3);d=(l?c.zIndex:0)+(m?p:0)}return r[d]?r[d].push(c):r[d]=[c],o=d>o?d:o,r},{}),i=Object.entries(s).map(([r,c])=>{const l=+r;return{edges:c,level:l,isMaxLevel:l===o}});return i.length===0?Wr:i}function Xr(e,t,n){const o=q(h.useCallback(s=>e?s.edges.filter(i=>{const r=t.get(i.source),c=t.get(i.target);return(r==null?void 0:r.width)&&(r==null?void 0:r.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&Ur({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:c.width,targetHeight:c.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return Zr(o,t,n)}const Gr=({color:e="none",strokeWidth:t=1})=>b.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Kr=({color:e="none",strokeWidth:t=1})=>b.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),mn={[lt.Arrow]:Gr,[lt.ArrowClosed]:Kr};function jr(e){const t=ne();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(mn,e)?mn[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",xe.error009(e)),null)},[e])}const qr=({id:e,type:t,color:n,width:o=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:r,orient:c="auto-start-reverse"})=>{const l=jr(t);return l?b.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0"},b.createElement(l,{color:n,strokeWidth:r})):null},Qr=({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce((s,i)=>([i.markerStart,i.markerEnd].forEach(r=>{if(r&&typeof r=="object"){const c=Mt(r,t);o.includes(c)||(s.push({id:c,color:r.color||e,...r}),o.push(c))}}),s),[]).sort((s,i)=>s.id.localeCompare(i.id))},lo=({defaultColor:e,rfId:t})=>{const n=q(h.useCallback(Qr({defaultColor:e,rfId:t}),[e,t]),(o,s)=>!(o.length!==s.length||o.some((i,r)=>i.id!==s[r].id)));return b.createElement("defs",null,n.map(o=>b.createElement(qr,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};lo.displayName="MarkerDefinitions";var Jr=h.memo(lo);const ei=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),uo=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:s,noPanClassName:i,onEdgeContextMenu:r,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:a,onEdgeDoubleClick:u,onReconnect:g,onReconnectStart:f,onReconnectEnd:m,reconnectRadius:p,children:x,disableKeyboardA11y:y})=>{const{edgesFocusable:S,edgesUpdatable:N,elementsSelectable:A,width:I,height:H,connectionMode:z,nodeInternals:R,onError:v}=q(ei,se),_=Xr(t,R,n);return I?b.createElement(b.Fragment,null,_.map(({level:C,edges:D,isMaxLevel:$})=>b.createElement("svg",{key:C,style:{zIndex:C},width:I,height:H,className:"react-flow__edges react-flow__container"},$&&b.createElement(Jr,{defaultColor:e,rfId:o}),b.createElement("g",null,D.map(E=>{const[M,L,Y]=hn(R.get(E.source)),[O,w,P]=hn(R.get(E.target));if(!Y||!P)return null;let k=E.type||"default";s[k]||(v==null||v("011",xe.error011(k)),k="default");const T=s[k]||s.default,F=z===De.Strict?w.target:(w.target??[]).concat(w.source??[]),U=yn(L.source,E.sourceHandle),Z=yn(F,E.targetHandle),K=(U==null?void 0:U.position)||B.Bottom,Q=(Z==null?void 0:Z.position)||B.Top,te=!!(E.focusable||S&&typeof E.focusable>"u"),ee=E.reconnectable||E.updatable,X=typeof g<"u"&&(ee||N&&typeof ee>"u");if(!U||!Z)return v==null||v("008",xe.error008(U,E)),null;const{sourceX:ue,sourceY:ce,targetX:de,targetY:ae}=Yr(M,U,K,O,Z,Q);return b.createElement(T,{key:E.id,id:E.id,className:ie([E.className,i]),type:k,data:E.data,selected:!!E.selected,animated:!!E.animated,hidden:!!E.hidden,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,style:E.style,source:E.source,target:E.target,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerEnd:E.markerEnd,markerStart:E.markerStart,sourceX:ue,sourceY:ce,targetX:de,targetY:ae,sourcePosition:K,targetPosition:Q,elementsSelectable:A,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:a,onEdgeDoubleClick:u,onReconnect:g,onReconnectStart:f,onReconnectEnd:m,reconnectRadius:p,rfId:o,ariaLabel:E.ariaLabel,isFocusable:te,isReconnectable:X,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth,disableKeyboardA11y:y})})))),x):null};uo.displayName="EdgeRenderer";var ti=h.memo(uo);const ni=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function oi({children:e}){const t=q(ni);return b.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function si(e){const t=Jn(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const ri={[B.Left]:B.Right,[B.Right]:B.Left,[B.Top]:B.Bottom,[B.Bottom]:B.Top},fo=({nodeId:e,handleType:t,style:n,type:o=we.Bezier,CustomComponent:s,connectionStatus:i})=>{var H,z,R;const{fromNode:r,handleId:c,toX:l,toY:d,connectionMode:a}=q(h.useCallback(v=>({fromNode:v.nodeInternals.get(e),handleId:v.connectionHandleId,toX:(v.connectionPosition.x-v.transform[0])/v.transform[2],toY:(v.connectionPosition.y-v.transform[1])/v.transform[2],connectionMode:v.connectionMode}),[e]),se),u=(H=r==null?void 0:r[j])==null?void 0:H.handleBounds;let g=u==null?void 0:u[t];if(a===De.Loose&&(g=g||(u==null?void 0:u[t==="source"?"target":"source"])),!r||!g)return null;const f=c?g.find(v=>v.id===c):g[0],m=f?f.x+f.width/2:(r.width??0)/2,p=f?f.y+f.height/2:r.height??0,x=(((z=r.positionAbsolute)==null?void 0:z.x)??0)+m,y=(((R=r.positionAbsolute)==null?void 0:R.y)??0)+p,S=f==null?void 0:f.position,N=S?ri[S]:null;if(!S||!N)return null;if(s)return b.createElement(s,{connectionLineType:o,connectionLineStyle:n,fromNode:r,fromHandle:f,fromX:x,fromY:y,toX:l,toY:d,fromPosition:S,toPosition:N,connectionStatus:i});let A="";const I={sourceX:x,sourceY:y,sourcePosition:S,targetX:l,targetY:d,targetPosition:N};return o===we.Bezier?[A]=Pn(I):o===we.Step?[A]=$t({...I,borderRadius:0}):o===we.SmoothStep?[A]=$t(I):o===we.SimpleBezier?[A]=Dn(I):A=`M${x},${y} ${l},${d}`,b.createElement("path",{d:A,fill:"none",className:"react-flow__connection-path",style:n})};fo.displayName="ConnectionLine";const ii=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function ci({containerStyle:e,style:t,type:n,component:o}){const{nodeId:s,handleType:i,nodesConnectable:r,width:c,height:l,connectionStatus:d}=q(ii,se);return!(s&&i&&c&&r)?null:b.createElement("svg",{style:e,width:c,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},b.createElement("g",{className:ie(["react-flow__connection",d])},b.createElement(fo,{nodeId:s,handleType:i,style:t,type:n,CustomComponent:o,connectionStatus:d})))}function xn(e,t){return h.useRef(null),ne(),h.useMemo(()=>t(e),[e])}const go=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:s,onInit:i,onNodeClick:r,onEdgeClick:c,onNodeDoubleClick:l,onEdgeDoubleClick:d,onNodeMouseEnter:a,onNodeMouseMove:u,onNodeMouseLeave:g,onNodeContextMenu:f,onSelectionContextMenu:m,onSelectionStart:p,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:S,connectionLineComponent:N,connectionLineContainerStyle:A,selectionKeyCode:I,selectionOnDrag:H,selectionMode:z,multiSelectionKeyCode:R,panActivationKeyCode:v,zoomActivationKeyCode:_,deleteKeyCode:C,onlyRenderVisibleElements:D,elementsSelectable:$,selectNodesOnDrag:E,defaultViewport:M,translateExtent:L,minZoom:Y,maxZoom:O,preventScrolling:w,defaultMarkerColor:P,zoomOnScroll:k,zoomOnPinch:T,panOnScroll:F,panOnScrollSpeed:U,panOnScrollMode:Z,zoomOnDoubleClick:K,panOnDrag:Q,onPaneClick:te,onPaneMouseEnter:ee,onPaneMouseMove:X,onPaneMouseLeave:ue,onPaneScroll:ce,onPaneContextMenu:de,onEdgeContextMenu:ae,onEdgeMouseEnter:J,onEdgeMouseMove:pe,onEdgeMouseLeave:G,onReconnect:V,onReconnectStart:re,onReconnectEnd:Ne,reconnectRadius:Ge,noDragClassName:Pe,noWheelClassName:ke,noPanClassName:he,elevateEdgesOnSelect:Re,disableKeyboardA11y:ve,nodeOrigin:Ae,nodeExtent:He,rfId:ze})=>{const Ke=xn(e,Rr),oe=xn(t,Or);return si(i),b.createElement(Pr,{onPaneClick:te,onPaneMouseEnter:ee,onPaneMouseMove:X,onPaneMouseLeave:ue,onPaneContextMenu:de,onPaneScroll:ce,deleteKeyCode:C,selectionKeyCode:I,selectionOnDrag:H,selectionMode:z,onSelectionStart:p,onSelectionEnd:x,multiSelectionKeyCode:R,panActivationKeyCode:v,zoomActivationKeyCode:_,elementsSelectable:$,onMove:n,onMoveStart:o,onMoveEnd:s,zoomOnScroll:k,zoomOnPinch:T,zoomOnDoubleClick:K,panOnScroll:F,panOnScrollSpeed:U,panOnScrollMode:Z,panOnDrag:Q,defaultViewport:M,translateExtent:L,minZoom:Y,maxZoom:O,onSelectionContextMenu:m,preventScrolling:w,noDragClassName:Pe,noWheelClassName:ke,noPanClassName:he,disableKeyboardA11y:ve},b.createElement(oi,null,b.createElement(ti,{edgeTypes:oe,onEdgeClick:c,onEdgeDoubleClick:d,onlyRenderVisibleElements:D,onEdgeContextMenu:ae,onEdgeMouseEnter:J,onEdgeMouseMove:pe,onEdgeMouseLeave:G,onReconnect:V,onReconnectStart:re,onReconnectEnd:Ne,reconnectRadius:Ge,defaultMarkerColor:P,noPanClassName:he,elevateEdgesOnSelect:!!Re,disableKeyboardA11y:ve,rfId:ze},b.createElement(ci,{style:S,type:y,component:N,containerStyle:A})),b.createElement("div",{className:"react-flow__edgelabel-renderer"}),b.createElement(Lr,{nodeTypes:Ke,onNodeClick:r,onNodeDoubleClick:l,onNodeMouseEnter:a,onNodeMouseMove:u,onNodeMouseLeave:g,onNodeContextMenu:f,selectNodesOnDrag:E,onlyRenderVisibleElements:D,noPanClassName:he,noDragClassName:Pe,disableKeyboardA11y:ve,nodeOrigin:Ae,nodeExtent:He,rfId:ze})))};go.displayName="GraphView";var ai=h.memo(go);const Tt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Se={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Tt,nodeExtent:Tt,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:De.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Hs,isValidConnection:void 0},li=()=>$s((e,t)=>({...Se,setNodes:n=>{const{nodeInternals:o,nodeOrigin:s,elevateNodesOnSelect:i}=t();e({nodeInternals:Et(n,o,s,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map(s=>({...o,...s}))})},setDefaultNodesAndEdges:(n,o)=>{const s=typeof n<"u",i=typeof o<"u",r=s?Et(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:r,edges:i?o:[],hasDefaultNodes:s,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:s,fitViewOnInit:i,fitViewOnInitDone:r,fitViewOnInitOptions:c,domNode:l,nodeOrigin:d}=t(),a=l==null?void 0:l.querySelector(".react-flow__viewport");if(!a)return;const u=window.getComputedStyle(a),{m22:g}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce((p,x)=>{const y=s.get(x.id);if(y!=null&&y.hidden)s.set(y.id,{...y,[j]:{...y[j],handleBounds:void 0}});else if(y){const S=Dt(x.nodeElement);S.width&&S.height&&(y.width!==S.width||y.height!==S.height||x.forceUpdate)&&(s.set(y.id,{...y,[j]:{...y[j],handleBounds:{source:dn(".source",x.nodeElement,g,d),target:dn(".target",x.nodeElement,g,d)}},...S}),p.push({id:y.id,type:"dimensions",dimensions:S}))}return p},[]);qn(s,d);const m=r||i&&!r&&Qn(t,{initial:!0,...c});e({nodeInternals:new Map(s),fitViewOnInitDone:m}),(f==null?void 0:f.length)>0&&(o==null||o(f))},updateNodePositions:(n,o=!0,s=!1)=>{const{triggerNodeChanges:i}=t(),r=n.map(c=>{const l={id:c.id,type:"position",dragging:s};return o&&(l.positionAbsolute=c.positionAbsolute,l.position=c.position),l});i(r)},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:s,hasDefaultNodes:i,nodeOrigin:r,getNodes:c,elevateNodesOnSelect:l}=t();if(n!=null&&n.length){if(i){const d=to(n,c()),a=Et(d,s,r,l);e({nodeInternals:a})}o==null||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:s,getNodes:i}=t();let r,c=null;o?r=n.map(l=>Ee(l,!0)):(r=Oe(i(),n),c=Oe(s,[])),it({changedNodes:r,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:s,getNodes:i}=t();let r,c=null;o?r=n.map(l=>Ee(l,!0)):(r=Oe(s,n),c=Oe(i(),[])),it({changedNodes:c,changedEdges:r,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:s,getNodes:i}=t(),r=n||i(),c=o||s,l=r.map(a=>(a.selected=!1,Ee(a.id,!1))),d=c.map(a=>Ee(a.id,!1));it({changedNodes:l,changedEdges:d,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:s}=t();o==null||o.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:s}=t();o==null||o.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;(o=t().d3Zoom)==null||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t(),i=o().filter(c=>c.selected).map(c=>Ee(c.id,!1)),r=n.filter(c=>c.selected).map(c=>Ee(c.id,!1));it({changedNodes:i,changedEdges:r,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach(s=>{s.positionAbsolute=Pt(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:n=>{const{transform:o,width:s,height:i,d3Zoom:r,d3Selection:c,translateExtent:l}=t();if(!r||!c||!n.x&&!n.y)return!1;const d=Ye.translate(o[0]+n.x,o[1]+n.y).scale(o[2]),a=[[0,0],[s,i]],u=r==null?void 0:r.constrain()(d,a,l);return r.transform(c,u),o[0]!==u.x||o[1]!==u.y||o[2]!==u.k},cancelConnection:()=>e({connectionNodeId:Se.connectionNodeId,connectionHandleId:Se.connectionHandleId,connectionHandleType:Se.connectionHandleType,connectionStatus:Se.connectionStatus,connectionStartHandle:Se.connectionStartHandle,connectionEndHandle:Se.connectionEndHandle}),reset:()=>e({...Se})}),Object.is),po=({children:e})=>{const t=h.useRef(null);return t.current||(t.current=li()),b.createElement(Ms,{value:t.current},e)};po.displayName="ReactFlowProvider";const yo=({children:e})=>h.useContext(gt)?b.createElement(b.Fragment,null,e):b.createElement(po,null,e);yo.displayName="ReactFlowWrapper";const ui={input:Un,default:It,output:Zn,group:Ft},di={default:ut,straight:zt,step:Ht,smoothstep:pt,simplebezier:Rt},fi=[0,0],gi=[15,15],pi={x:0,y:0,zoom:1},yi={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},hi=h.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:s,nodeTypes:i=ui,edgeTypes:r=di,onNodeClick:c,onEdgeClick:l,onInit:d,onMove:a,onMoveStart:u,onMoveEnd:g,onConnect:f,onConnectStart:m,onConnectEnd:p,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:S,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:I,onNodeDoubleClick:H,onNodeDragStart:z,onNodeDrag:R,onNodeDragStop:v,onNodesDelete:_,onEdgesDelete:C,onSelectionChange:D,onSelectionDragStart:$,onSelectionDrag:E,onSelectionDragStop:M,onSelectionContextMenu:L,onSelectionStart:Y,onSelectionEnd:O,connectionMode:w=De.Strict,connectionLineType:P=we.Bezier,connectionLineStyle:k,connectionLineComponent:T,connectionLineContainerStyle:F,deleteKeyCode:U="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:K=!1,selectionMode:Q=tt.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:ee=at()?"Meta":"Control",zoomActivationKeyCode:X=at()?"Meta":"Control",snapToGrid:ue=!1,snapGrid:ce=gi,onlyRenderVisibleElements:de=!1,selectNodesOnDrag:ae=!0,nodesDraggable:J,nodesConnectable:pe,nodesFocusable:G,nodeOrigin:V=fi,edgesFocusable:re,edgesUpdatable:Ne,elementsSelectable:Ge,defaultViewport:Pe=pi,minZoom:ke=.5,maxZoom:he=2,translateExtent:Re=Tt,preventScrolling:ve=!0,nodeExtent:Ae,defaultMarkerColor:He="#b1b1b7",zoomOnScroll:ze=!0,zoomOnPinch:Ke=!0,panOnScroll:oe=!1,panOnScrollSpeed:fe=.5,panOnScrollMode:$e=Te.Free,zoomOnDoubleClick:Me=!0,panOnDrag:Ce=!0,onPaneClick:me,onPaneMouseEnter:ye,onPaneMouseMove:je,onPaneMouseLeave:yt,onPaneScroll:qe,onPaneContextMenu:ht,children:Yt,onEdgeContextMenu:Ie,onEdgeDoubleClick:xo,onEdgeMouseEnter:So,onEdgeMouseMove:Eo,onEdgeMouseLeave:wo,onEdgeUpdate:bo,onEdgeUpdateStart:No,onEdgeUpdateEnd:vo,onReconnect:Ao,onReconnectStart:$o,onReconnectEnd:Mo,reconnectRadius:Co=10,edgeUpdaterRadius:Io=10,onNodesChange:_o,onEdgesChange:To,noDragClassName:Do="nodrag",noWheelClassName:Po="nowheel",noPanClassName:Ut="nopan",fitView:ko=!1,fitViewOptions:Ro,connectOnClick:Ho=!0,attributionPosition:zo,proOptions:Lo,defaultEdgeOptions:Bo,elevateNodesOnSelect:Vo=!0,elevateEdgesOnSelect:Fo=!1,disableKeyboardA11y:Wt=!1,autoPanOnConnect:Oo=!0,autoPanOnNodeDrag:Yo=!0,connectionRadius:Uo=20,isValidConnection:Wo,onError:Zo,style:Xo,id:Zt,nodeDragThreshold:Go,...Ko},jo)=>{const mt=Zt||"1";return b.createElement("div",{...Ko,style:{...Xo,...yi},ref:jo,className:ie(["react-flow",s]),"data-testid":"rf__wrapper",id:Zt},b.createElement(yo,null,b.createElement(ai,{onInit:d,onMove:a,onMoveStart:u,onMoveEnd:g,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:S,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:I,onNodeDoubleClick:H,nodeTypes:i,edgeTypes:r,connectionLineType:P,connectionLineStyle:k,connectionLineComponent:T,connectionLineContainerStyle:F,selectionKeyCode:Z,selectionOnDrag:K,selectionMode:Q,deleteKeyCode:U,multiSelectionKeyCode:ee,panActivationKeyCode:te,zoomActivationKeyCode:X,onlyRenderVisibleElements:de,selectNodesOnDrag:ae,defaultViewport:Pe,translateExtent:Re,minZoom:ke,maxZoom:he,preventScrolling:ve,zoomOnScroll:ze,zoomOnPinch:Ke,zoomOnDoubleClick:Me,panOnScroll:oe,panOnScrollSpeed:fe,panOnScrollMode:$e,panOnDrag:Ce,onPaneClick:me,onPaneMouseEnter:ye,onPaneMouseMove:je,onPaneMouseLeave:yt,onPaneScroll:qe,onPaneContextMenu:ht,onSelectionContextMenu:L,onSelectionStart:Y,onSelectionEnd:O,onEdgeContextMenu:Ie,onEdgeDoubleClick:xo,onEdgeMouseEnter:So,onEdgeMouseMove:Eo,onEdgeMouseLeave:wo,onReconnect:Ao??bo,onReconnectStart:$o??No,onReconnectEnd:Mo??vo,reconnectRadius:Co??Io,defaultMarkerColor:He,noDragClassName:Do,noWheelClassName:Po,noPanClassName:Ut,elevateEdgesOnSelect:Fo,rfId:mt,disableKeyboardA11y:Wt,nodeOrigin:V,nodeExtent:Ae}),b.createElement(rr,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:f,onConnectStart:m,onConnectEnd:p,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:J,nodesConnectable:pe,nodesFocusable:G,edgesFocusable:re,edgesUpdatable:Ne,elementsSelectable:Ge,elevateNodesOnSelect:Vo,minZoom:ke,maxZoom:he,nodeExtent:Ae,onNodesChange:_o,onEdgesChange:To,snapToGrid:ue,snapGrid:ce,connectionMode:w,translateExtent:Re,connectOnClick:Ho,defaultEdgeOptions:Bo,fitView:ko,fitViewOptions:Ro,onNodesDelete:_,onEdgesDelete:C,onNodeDragStart:z,onNodeDrag:R,onNodeDragStop:v,onSelectionDrag:E,onSelectionDragStart:$,onSelectionDragStop:M,noPanClassName:Ut,nodeOrigin:V,rfId:mt,autoPanOnConnect:Oo,autoPanOnNodeDrag:Yo,onError:Zo,connectionRadius:Uo,isValidConnection:Wo,nodeDragThreshold:Go}),b.createElement(or,{onSelectionChange:D}),Yt,b.createElement(_s,{proOptions:Lo,position:zo}),b.createElement(ur,{rfId:mt,disableKeyboardA11y:Wt})))});hi.displayName="ReactFlow";function ho(e){return t=>{const[n,o]=h.useState(t),s=h.useCallback(i=>o(r=>e(i,r)),[]);return[n,o,s]}}const Ai=ho(to),$i=ho(vr);var ge;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ge||(ge={}));function mi({color:e,dimensions:t,lineWidth:n}){return b.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function xi({color:e,radius:t}){return b.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const Si={[ge.Dots]:"#91919a",[ge.Lines]:"#eee",[ge.Cross]:"#e2e2e2"},Ei={[ge.Dots]:1,[ge.Lines]:1,[ge.Cross]:6},wi=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function mo({id:e,variant:t=ge.Dots,gap:n=20,size:o,lineWidth:s=1,offset:i=2,color:r,style:c,className:l}){const d=h.useRef(null),{transform:a,patternId:u}=q(wi,se),g=r||Si[t],f=o||Ei[t],m=t===ge.Dots,p=t===ge.Cross,x=Array.isArray(n)?n:[n,n],y=[x[0]*a[2]||1,x[1]*a[2]||1],S=f*a[2],N=p?[S,S]:y,A=m?[S/i,S/i]:[N[0]/i,N[1]/i];return b.createElement("svg",{className:ie(["react-flow__background",l]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},b.createElement("pattern",{id:u+e,x:a[0]%y[0],y:a[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`},m?b.createElement(xi,{color:g,radius:S/i}):b.createElement(mi,{dimensions:N,color:g,lineWidth:s})),b.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${u+e})`}))}mo.displayName="Background";var Mi=h.memo(mo);export{Mi as B,dt as H,lt as M,B as P,po as R,$i as a,hi as b,ge as c,ne as d,q as e,Jn as f,Is as g,ie as h,se as s,Ai as u};
