purecontext-mcp 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/token-tracker.d.ts +0 -9
- package/dist/core/token-tracker.d.ts.map +1 -1
- package/dist/core/token-tracker.js +0 -21
- package/dist/core/token-tracker.js.map +1 -1
- package/dist/server/http-server.d.ts.map +1 -1
- package/dist/server/http-server.js +30 -1
- package/dist/server/http-server.js.map +1 -1
- package/dist/server/tools/_meta.d.ts +0 -2
- package/dist/server/tools/_meta.d.ts.map +1 -1
- package/dist/server/tools/_meta.js +1 -4
- package/dist/server/tools/_meta.js.map +1 -1
- package/dist/server/tools/get-savings-stats.d.ts.map +1 -1
- package/dist/server/tools/get-savings-stats.js +1 -3
- package/dist/server/tools/get-savings-stats.js.map +1 -1
- package/dist/ui/assets/{BlastRadius-BDZWhEk-.js → BlastRadius-RP7vJEyQ.js} +1 -1
- package/dist/ui/assets/{DependencyGraph-CDtBHM0U.js → DependencyGraph-B60SMPbX.js} +6 -6
- package/dist/ui/assets/{NotFound-Cdt6X8pl.js → NotFound-Bsg8Wppk.js} +1 -1
- package/dist/ui/assets/RepoDetail-Cie0D4_s.js +1 -0
- package/dist/ui/assets/{RepoList-B9LaZvob.js → RepoList-CldNt89M.js} +1 -1
- package/dist/ui/assets/{Search-CLqv2KGV.js → Search-CgvpHMOi.js} +1 -1
- package/dist/ui/assets/{SymbolView-BlbDR1DU.js → SymbolView-B9h0LZTz.js} +1 -1
- package/dist/ui/assets/{index-i3Q1XbEh.js → index-eK0wMkUR.js} +6 -6
- package/dist/ui/assets/{useSearch-mbMk6-M1.js → useSearch-KAl3Qyi2.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/RepoDetail-M6WaYbZ3.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as Ca,i as Do,k as ka,R as Ia,r as P,j as b,d as Aa,a as $a,L as Pa}from"./index-i3Q1XbEh.js";Ca();function it(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=it(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var Ta={value:()=>{}};function Ne(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Xe(n)}function Xe(t){this._=t}function za(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Xe.prototype=Ne.prototype={constructor:Xe,on:function(t,e){var n=this._,r=za(t+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(t=r[i]).type)&&(o=La(n[o],t.name)))return o;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<s;)if(o=(t=r[i]).type)n[o]=_r(n[o],t.name,e);else if(e==null)for(o in n)n[o]=_r(n[o],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Xe(t)},call:function(t,e){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],r=0,o=i.length;r<o;++r)i[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],o=0,i=r.length;o<i;++o)r[o].value.apply(e,n)}};function La(t,e){for(var n=0,r=t.length,o;n<r;++n)if((o=t[n]).name===e)return o.value}function _r(t,e,n){for(var r=0,o=t.length;r<o;++r)if(t[r].name===e){t[r]=Ta,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Tn="http://www.w3.org/1999/xhtml";const Nr={svg:"http://www.w3.org/2000/svg",xhtml:Tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sn(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Nr.hasOwnProperty(e)?{space:Nr[e],local:t}:t}function Da(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Tn&&e.documentElement.namespaceURI===Tn?e.createElement(t):e.createElementNS(n,t)}}function ja(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function jo(t){var e=sn(t);return(e.local?ja:Da)(e)}function Ra(){}function qn(t){return t==null?Ra:function(){return this.querySelector(t)}}function Ha(t){typeof t!="function"&&(t=qn(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=new Array(s),l,c,f=0;f<s;++f)(l=i[f])&&(c=t.call(l,l.__data__,f,i))&&("__data__"in l&&(c.__data__=l.__data__),a[f]=c);return new ft(r,this._parents)}function Va(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Ba(){return[]}function Ro(t){return t==null?Ba:function(){return this.querySelectorAll(t)}}function Fa(t){return function(){return Va(t.apply(this,arguments))}}function Oa(t){typeof t=="function"?t=Fa(t):t=Ro(t);for(var e=this._groups,n=e.length,r=[],o=[],i=0;i<n;++i)for(var s=e[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(r.push(t.call(l,l.__data__,c,s)),o.push(l));return new ft(r,o)}function Ho(t){return function(){return this.matches(t)}}function Vo(t){return function(e){return e.matches(t)}}var Xa=Array.prototype.find;function Ya(t){return function(){return Xa.call(this.children,t)}}function Wa(){return this.firstElementChild}function Ga(t){return this.select(t==null?Wa:Ya(typeof t=="function"?t:Vo(t)))}var qa=Array.prototype.filter;function Ua(){return Array.from(this.children)}function Za(t){return function(){return qa.call(this.children,t)}}function Ka(t){return this.selectAll(t==null?Ua:Za(typeof t=="function"?t:Vo(t)))}function Qa(t){typeof t!="function"&&(t=Ho(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&a.push(l);return new ft(r,this._parents)}function Bo(t){return new Array(t.length)}function Ja(){return new ft(this._enter||this._groups.map(Bo),this._parents)}function Ue(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Ue.prototype={constructor:Ue,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function tc(t){return function(){return t}}function ec(t,e,n,r,o,i){for(var s=0,a,l=e.length,c=i.length;s<c;++s)(a=e[s])?(a.__data__=i[s],r[s]=a):n[s]=new Ue(t,i[s]);for(;s<l;++s)(a=e[s])&&(o[s]=a)}function nc(t,e,n,r,o,i,s){var a,l,c=new Map,f=e.length,u=i.length,d=new Array(f),h;for(a=0;a<f;++a)(l=e[a])&&(d[a]=h=s.call(l,l.__data__,a,e)+"",c.has(h)?o[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(t,i[a],a,i)+"",(l=c.get(h))?(r[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ue(t,i[a]);for(a=0;a<f;++a)(l=e[a])&&c.get(d[a])===l&&(o[a]=l)}function rc(t){return t.__data__}function oc(t,e){if(!arguments.length)return Array.from(this,rc);var n=e?nc:ec,r=this._parents,o=this._groups;typeof t!="function"&&(t=tc(t));for(var i=o.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var f=r[c],u=o[c],d=u.length,h=ic(t.call(f,f&&f.__data__,c,r)),g=h.length,y=a[c]=new Array(g),p=s[c]=new Array(g),m=l[c]=new Array(d);n(f,u,y,p,m,h,e);for(var v=0,x=0,w,E;v<g;++v)if(w=y[v]){for(v>=x&&(x=v+1);!(E=p[x])&&++x<g;);w._next=E||null}}return s=new ft(s,r),s._enter=a,s._exit=l,s}function ic(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function sc(){return new ft(this._exit||this._groups.map(Bo),this._parents)}function ac(t,e,n){var r=this.enter(),o=this,i=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function cc(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),l=0;l<s;++l)for(var c=n[l],f=r[l],u=c.length,d=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||f[g])&&(d[g]=h);for(;l<o;++l)a[l]=n[l];return new ft(a,this._parents)}function lc(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function uc(t){t||(t=fc);function e(u,d){return u&&d?t(u.__data__,d.__data__):!u-!d}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,l=o[i]=new Array(a),c,f=0;f<a;++f)(c=s[f])&&(l[f]=c);l.sort(e)}return new ft(o,this._parents).order()}function fc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function dc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function hc(){return Array.from(this)}function gc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function pc(){let t=0;for(const e of this)++t;return t}function mc(){return!this.node()}function yc(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var o=e[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&t.call(a,a.__data__,i,o);return this}function xc(t){return function(){this.removeAttribute(t)}}function wc(t){return function(){this.removeAttributeNS(t.space,t.local)}}function vc(t,e){return function(){this.setAttribute(t,e)}}function bc(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function _c(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Nc(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Ec(t,e){var n=sn(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?wc:xc:typeof e=="function"?n.local?Nc:_c:n.local?bc:vc)(n,e))}function Fo(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Sc(t){return function(){this.style.removeProperty(t)}}function Mc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Cc(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function kc(t,e,n){return arguments.length>1?this.each((e==null?Sc:typeof e=="function"?Cc:Mc)(t,e,n??"")):qt(this.node(),t)}function qt(t,e){return t.style.getPropertyValue(e)||Fo(t).getComputedStyle(t,null).getPropertyValue(e)}function Ic(t){return function(){delete this[t]}}function Ac(t,e){return function(){this[t]=e}}function $c(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Pc(t,e){return arguments.length>1?this.each((e==null?Ic:typeof e=="function"?$c:Ac)(t,e)):this.node()[t]}function Oo(t){return t.trim().split(/^|\s+/)}function Un(t){return t.classList||new Xo(t)}function Xo(t){this._node=t,this._names=Oo(t.getAttribute("class")||"")}Xo.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Yo(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.add(e[r])}function Wo(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.remove(e[r])}function Tc(t){return function(){Yo(this,t)}}function zc(t){return function(){Wo(this,t)}}function Lc(t,e){return function(){(e.apply(this,arguments)?Yo:Wo)(this,t)}}function Dc(t,e){var n=Oo(t+"");if(arguments.length<2){for(var r=Un(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof e=="function"?Lc:e?Tc:zc)(n,e))}function jc(){this.textContent=""}function Rc(t){return function(){this.textContent=t}}function Hc(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Vc(t){return arguments.length?this.each(t==null?jc:(typeof t=="function"?Hc:Rc)(t)):this.node().textContent}function Bc(){this.innerHTML=""}function Fc(t){return function(){this.innerHTML=t}}function Oc(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Xc(t){return arguments.length?this.each(t==null?Bc:(typeof t=="function"?Oc:Fc)(t)):this.node().innerHTML}function Yc(){this.nextSibling&&this.parentNode.appendChild(this)}function Wc(){return this.each(Yc)}function Gc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qc(){return this.each(Gc)}function Uc(t){var e=typeof t=="function"?t:jo(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Zc(){return null}function Kc(t,e){var n=typeof t=="function"?t:jo(t),r=e==null?Zc:typeof e=="function"?e:qn(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Qc(){var t=this.parentNode;t&&t.removeChild(this)}function Jc(){return this.each(Qc)}function tl(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function el(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function nl(t){return this.select(t?el:tl)}function rl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function ol(t){return function(e){t.call(this,e,this.__data__)}}function il(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function sl(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,o=e.length,i;n<o;++n)i=e[n],(!t.type||i.type===t.type)&&i.name===t.name?this.removeEventListener(i.type,i.listener,i.options):e[++r]=i;++r?e.length=r:delete this.__on}}}function al(t,e,n){return function(){var r=this.__on,o,i=ol(e);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=e;return}}this.addEventListener(t.type,i,n),o={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(o):this.__on=[o]}}function cl(t,e,n){var r=il(t+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,f;l<c;++l)for(o=0,f=a[l];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(a=e?al:sl,o=0;o<i;++o)this.each(a(r[o],e,n));return this}function Go(t,e,n){var r=Fo(t),o=r.CustomEvent;typeof o=="function"?o=new o(e,n):(o=r.document.createEvent("Event"),n?(o.initEvent(e,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function ll(t,e){return function(){return Go(this,t,e)}}function ul(t,e){return function(){return Go(this,t,e.apply(this,arguments))}}function fl(t,e){return this.each((typeof e=="function"?ul:ll)(t,e))}function*dl(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var qo=[null];function ft(t,e){this._groups=t,this._parents=e}function Ee(){return new ft([[document.documentElement]],qo)}function hl(){return this}ft.prototype=Ee.prototype={constructor:ft,select:Ha,selectAll:Oa,selectChild:Ga,selectChildren:Ka,filter:Qa,data:oc,enter:Ja,exit:sc,join:ac,merge:cc,selection:hl,order:lc,sort:uc,call:dc,nodes:hc,node:gc,size:pc,empty:mc,each:yc,attr:Ec,style:kc,property:Pc,classed:Dc,text:Vc,html:Xc,raise:Wc,lower:qc,append:Uc,insert:Kc,remove:Jc,clone:nl,datum:rl,on:cl,dispatch:fl,[Symbol.iterator]:dl};function ut(t){return typeof t=="string"?new ft([[document.querySelector(t)]],[document.documentElement]):new ft([[t]],qo)}function gl(t){let e;for(;e=t.sourceEvent;)t=e;return t}function dt(t,e){if(t=gl(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[t.clientX-o.left-e.clientLeft,t.clientY-o.top-e.clientTop]}}return[t.pageX,t.pageY]}const pl={passive:!1},ge={capture:!0,passive:!1};function vn(t){t.stopImmediatePropagation()}function Wt(t){t.preventDefault(),t.stopImmediatePropagation()}function Uo(t){var e=t.document.documentElement,n=ut(t).on("dragstart.drag",Wt,ge);"onselectstart"in e?n.on("selectstart.drag",Wt,ge):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Zo(t,e){var n=t.document.documentElement,r=ut(t).on("dragstart.drag",null);e&&(r.on("click.drag",Wt,ge),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Te=t=>()=>t;function zn(t,{sourceEvent:e,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:l,dy:c,dispatch:f}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}zn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ml(t){return!t.ctrlKey&&!t.button}function yl(){return this.parentNode}function xl(t,e){return e??{x:t.x,y:t.y}}function wl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ko(){var t=ml,e=yl,n=xl,r=wl,o={},i=Ne("start","drag","end"),s=0,a,l,c,f,u=0;function d(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",p).on("touchmove.drag",m,pl).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,E){if(!(f||!t.call(this,w,E))){var N=x(this,e.call(this,w,E),w,E,"mouse");N&&(ut(w.view).on("mousemove.drag",g,ge).on("mouseup.drag",y,ge),Uo(w.view),vn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Wt(w),!c){var E=w.clientX-a,N=w.clientY-l;c=E*E+N*N>u}o.mouse("drag",w)}function y(w){ut(w.view).on("mousemove.drag mouseup.drag",null),Zo(w.view,c),Wt(w),o.mouse("end",w)}function p(w,E){if(t.call(this,w,E)){var N=w.changedTouches,S=e.call(this,w,E),I=N.length,T,j;for(T=0;T<I;++T)(j=x(this,S,w,E,N[T].identifier,N[T]))&&(vn(w),j("start",w,N[T]))}}function m(w){var E=w.changedTouches,N=E.length,S,I;for(S=0;S<N;++S)(I=o[E[S].identifier])&&(Wt(w),I("drag",w,E[S]))}function v(w){var E=w.changedTouches,N=E.length,S,I;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),S=0;S<N;++S)(I=o[E[S].identifier])&&(vn(w),I("end",w,E[S]))}function x(w,E,N,S,I,T){var j=i.copy(),k=dt(T||N,E),L,H,_;if((_=n.call(w,new zn("beforestart",{sourceEvent:N,target:d,identifier:I,active:s,x:k[0],y:k[1],dx:0,dy:0,dispatch:j}),S))!=null)return L=_.x-k[0]||0,H=_.y-k[1]||0,function $(C,z,A){var M=k,D;switch(C){case"start":o[I]=$,D=s++;break;case"end":delete o[I],--s;case"drag":k=dt(A||z,E),D=s;break}j.call(C,w,new zn(C,{sourceEvent:z,subject:_,target:d,identifier:I,active:D,x:k[0]+L,y:k[1]+H,dx:k[0]-M[0],dy:k[1]-M[1],dispatch:j}),S)}}return d.filter=function(w){return arguments.length?(t=typeof w=="function"?w:Te(!!w),d):t},d.container=function(w){return arguments.length?(e=typeof w=="function"?w:Te(w),d):e},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Te(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Te(!!w),d):r},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,d):Math.sqrt(u)},d}function Zn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Qo(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Se(){}var pe=.7,Ze=1/pe,Gt="\\s*([+-]?\\d+)\\s*",me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vl=/^#([0-9a-f]{3,8})$/,bl=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),_l=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),Nl=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${me}\\)$`),El=new RegExp(`^rgba\\(${xt},${xt},${xt},${me}\\)$`),Sl=new RegExp(`^hsl\\(${me},${xt},${xt}\\)$`),Ml=new RegExp(`^hsla\\(${me},${xt},${xt},${me}\\)$`),Er={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Zn(Se,Rt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Sr,formatHex:Sr,formatHex8:Cl,formatHsl:kl,formatRgb:Mr,toString:Mr});function Sr(){return this.rgb().formatHex()}function Cl(){return this.rgb().formatHex8()}function kl(){return Jo(this).formatHsl()}function Mr(){return this.rgb().formatRgb()}function Rt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=vl.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Cr(e):n===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ze(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ze(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=bl.exec(t))?new lt(e[1],e[2],e[3],1):(e=_l.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Nl.exec(t))?ze(e[1],e[2],e[3],e[4]):(e=El.exec(t))?ze(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Sl.exec(t))?Ar(e[1],e[2]/100,e[3]/100,1):(e=Ml.exec(t))?Ar(e[1],e[2]/100,e[3]/100,e[4]):Er.hasOwnProperty(t)?Cr(Er[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function Cr(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function ze(t,e,n,r){return r<=0&&(t=e=n=NaN),new lt(t,e,n,r)}function Il(t){return t instanceof Se||(t=Rt(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function Ln(t,e,n,r){return arguments.length===1?Il(t):new lt(t,e,n,r??1)}function lt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Zn(lt,Ln,Qo(Se,{brighter(t){return t=t==null?Ze:Math.pow(Ze,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?pe:Math.pow(pe,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(Lt(this.r),Lt(this.g),Lt(this.b),Ke(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:kr,formatHex:kr,formatHex8:Al,formatRgb:Ir,toString:Ir}));function kr(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function Al(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ir(){const t=Ke(this.opacity);return`${t===1?"rgb(":"rgba("}${Lt(this.r)}, ${Lt(this.g)}, ${Lt(this.b)}${t===1?")":`, ${t})`}`}function Ke(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Lt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function zt(t){return t=Lt(t),(t<16?"0":"")+t.toString(16)}function Ar(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ht(t,e,n,r)}function Jo(t){if(t instanceof ht)return new ht(t.h,t.s,t.l,t.opacity);if(t instanceof Se||(t=Rt(t)),!t)return new ht;if(t instanceof ht)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,o=Math.min(e,n,r),i=Math.max(e,n,r),s=NaN,a=i-o,l=(i+o)/2;return a?(e===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-e)/a+2:s=(e-n)/a+4,a/=l<.5?i+o:2-i-o,s*=60):a=l>0&&l<1?0:s,new ht(s,a,l,t.opacity)}function $l(t,e,n,r){return arguments.length===1?Jo(t):new ht(t,e,n,r??1)}function ht(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Zn(ht,$l,Qo(Se,{brighter(t){return t=t==null?Ze:Math.pow(Ze,t),new ht(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?pe:Math.pow(pe,t),new ht(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,o=2*n-r;return new lt(bn(t>=240?t-240:t+120,o,r),bn(t,o,r),bn(t<120?t+240:t-120,o,r),this.opacity)},clamp(){return new ht($r(this.h),Le(this.s),Le(this.l),Ke(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Ke(this.opacity);return`${t===1?"hsl(":"hsla("}${$r(this.h)}, ${Le(this.s)*100}%, ${Le(this.l)*100}%${t===1?")":`, ${t})`}`}}));function $r(t){return t=(t||0)%360,t<0?t+360:t}function Le(t){return Math.max(0,Math.min(1,t||0))}function bn(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Kn=t=>()=>t;function Pl(t,e){return function(n){return t+n*e}}function Tl(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function zl(t){return(t=+t)==1?ti:function(e,n){return n-e?Tl(e,n,t):Kn(isNaN(e)?n:e)}}function ti(t,e){var n=e-t;return n?Pl(t,n):Kn(isNaN(t)?e:t)}const Qe=(function t(e){var n=zl(e);function r(o,i){var s=n((o=Ln(o)).r,(i=Ln(i)).r),a=n(o.g,i.g),l=n(o.b,i.b),c=ti(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=a(f),o.b=l(f),o.opacity=c(f),o+""}}return r.gamma=t,r})(1);function Ll(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=t[o]*(1-i)+e[o]*i;return r}}function Dl(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function jl(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=de(t[s],e[s]);for(;s<n;++s)i[s]=e[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function Rl(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function yt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Hl(t,e){var n={},r={},o;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(o in e)o in t?n[o]=de(t[o],e[o]):r[o]=e[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Dn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_n=new RegExp(Dn.source,"g");function Vl(t){return function(){return t}}function Bl(t){return function(e){return t(e)+""}}function ei(t,e){var n=Dn.lastIndex=_n.lastIndex=0,r,o,i,s=-1,a=[],l=[];for(t=t+"",e=e+"";(r=Dn.exec(t))&&(o=_n.exec(e));)(i=o.index)>n&&(i=e.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,l.push({i:s,x:yt(r,o)})),n=_n.lastIndex;return n<e.length&&(i=e.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Bl(l[0].x):Vl(e):(e=l.length,function(c){for(var f=0,u;f<e;++f)a[(u=l[f]).i]=u.x(c);return a.join("")})}function de(t,e){var n=typeof e,r;return e==null||n==="boolean"?Kn(e):(n==="number"?yt:n==="string"?(r=Rt(e))?(e=r,Qe):ei:e instanceof Rt?Qe:e instanceof Date?Rl:Dl(e)?Ll:Array.isArray(e)?jl:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Hl:yt)(t,e)}var Pr=180/Math.PI,jn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ni(t,e,n,r,o,i){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(e,t)*Pr,skewX:Math.atan(l)*Pr,scaleX:s,scaleY:a}}var De;function Fl(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?jn:ni(e.a,e.b,e.c,e.d,e.e,e.f)}function Ol(t){return t==null||(De||(De=document.createElementNS("http://www.w3.org/2000/svg","g")),De.setAttribute("transform",t),!(t=De.transform.baseVal.consolidate()))?jn:(t=t.matrix,ni(t.a,t.b,t.c,t.d,t.e,t.f))}function ri(t,e,n,r){function o(c){return c.length?c.pop()+" ":""}function i(c,f,u,d,h,g){if(c!==u||f!==d){var y=h.push("translate(",null,e,null,n);g.push({i:y-4,x:yt(c,u)},{i:y-2,x:yt(f,d)})}else(u||d)&&h.push("translate("+u+e+d+n)}function s(c,f,u,d){c!==f?(c-f>180?f+=360:f-c>180&&(c+=360),d.push({i:u.push(o(u)+"rotate(",null,r)-2,x:yt(c,f)})):f&&u.push(o(u)+"rotate("+f+r)}function a(c,f,u,d){c!==f?d.push({i:u.push(o(u)+"skewX(",null,r)-2,x:yt(c,f)}):f&&u.push(o(u)+"skewX("+f+r)}function l(c,f,u,d,h,g){if(c!==u||f!==d){var y=h.push(o(h)+"scale(",null,",",null,")");g.push({i:y-4,x:yt(c,u)},{i:y-2,x:yt(f,d)})}else(u!==1||d!==1)&&h.push(o(h)+"scale("+u+","+d+")")}return function(c,f){var u=[],d=[];return c=t(c),f=t(f),i(c.translateX,c.translateY,f.translateX,f.translateY,u,d),s(c.rotate,f.rotate,u,d),a(c.skewX,f.skewX,u,d),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,u,d),c=f=null,function(h){for(var g=-1,y=d.length,p;++g<y;)u[(p=d[g]).i]=p.x(h);return u.join("")}}}var Xl=ri(Fl,"px, ","px)","deg)"),Yl=ri(Ol,", ",")",")"),Wl=1e-12;function Tr(t){return((t=Math.exp(t))+1/t)/2}function Gl(t){return((t=Math.exp(t))-1/t)/2}function ql(t){return((t=Math.exp(2*t))-1)/(t+1)}const Ye=(function t(e,n,r){function o(i,s){var a=i[0],l=i[1],c=i[2],f=s[0],u=s[1],d=s[2],h=f-a,g=u-l,y=h*h+g*g,p,m;if(y<Wl)m=Math.log(d/c)/e,p=function(S){return[a+S*h,l+S*g,c*Math.exp(e*S*m)]};else{var v=Math.sqrt(y),x=(d*d-c*c+r*y)/(2*c*n*v),w=(d*d-c*c-r*y)/(2*d*n*v),E=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-E)/e,p=function(S){var I=S*m,T=Tr(E),j=c/(n*v)*(T*ql(e*I+E)-Gl(E));return[a+j*h,l+j*g,c*T/Tr(e*I+E)]}}return p.duration=m*1e3*e/Math.SQRT2,p}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return t(s,a,l)},o})(Math.SQRT2,2,4);var Ut=0,ue=0,ae=0,oi=1e3,Je,fe,tn=0,Ht=0,an=0,ye=typeof performance=="object"&&performance.now?performance:Date,ii=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Qn(){return Ht||(ii(Ul),Ht=ye.now()+an)}function Ul(){Ht=0}function en(){this._call=this._time=this._next=null}en.prototype=Jn.prototype={constructor:en,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Qn():+n)+(e==null?0:+e),!this._next&&fe!==this&&(fe?fe._next=this:Je=this,fe=this),this._call=t,this._time=n,Rn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rn())}};function Jn(t,e,n){var r=new en;return r.restart(t,e,n),r}function Zl(){Qn(),++Ut;for(var t=Je,e;t;)(e=Ht-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ut}function zr(){Ht=(tn=ye.now())+an,Ut=ue=0;try{Zl()}finally{Ut=0,Ql(),Ht=0}}function Kl(){var t=ye.now(),e=t-tn;e>oi&&(an-=e,tn=t)}function Ql(){for(var t,e=Je,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Je=n);fe=t,Rn(r)}function Rn(t){if(!Ut){ue&&(ue=clearTimeout(ue));var e=t-Ht;e>24?(t<1/0&&(ue=setTimeout(zr,t-ye.now()-an)),ae&&(ae=clearInterval(ae))):(ae||(tn=ye.now(),ae=setInterval(Kl,oi)),Ut=1,ii(zr))}}function Lr(t,e,n){var r=new en;return e=e==null?0:+e,r.restart(o=>{r.stop(),t(o+e)},e,n),r}var Jl=Ne("start","end","cancel","interrupt"),tu=[],si=0,Dr=1,Hn=2,We=3,jr=4,Vn=5,Ge=6;function cn(t,e,n,r,o,i){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;eu(t,n,{name:e,index:r,group:o,on:Jl,tween:tu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:si})}function tr(t,e){var n=mt(t,e);if(n.state>si)throw new Error("too late; already scheduled");return n}function vt(t,e){var n=mt(t,e);if(n.state>We)throw new Error("too late; already running");return n}function mt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function eu(t,e,n){var r=t.__transition,o;r[e]=n,n.timer=Jn(i,0,n.time);function i(c){n.state=Dr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var f,u,d,h;if(n.state!==Dr)return l();for(f in r)if(h=r[f],h.name===n.name){if(h.state===We)return Lr(s);h.state===jr?(h.state=Ge,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete r[f]):+f<e&&(h.state=Ge,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete r[f])}if(Lr(function(){n.state===We&&(n.state=jr,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Hn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Hn){for(n.state=We,o=new Array(d=n.tween.length),f=0,u=-1;f<d;++f)(h=n.tween[f].value.call(t,t.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(c){for(var f=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Vn,1),u=-1,d=o.length;++u<d;)o[u].call(t,f);n.state===Vn&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Ge,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function qe(t,e){var n=t.__transition,r,o,i=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){i=!1;continue}o=r.state>Hn&&r.state<Vn,r.state=Ge,r.timer.stop(),r.on.call(o?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}i&&delete t.__transition}}function nu(t){return this.each(function(){qe(this,t)})}function ru(t,e){var n,r;return function(){var o=vt(this,t),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function ou(t,e,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=vt(this,t),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:e,value:n},l=0,c=o.length;l<c;++l)if(o[l].name===e){o[l]=a;break}l===c&&o.push(a)}i.tween=o}}function iu(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=mt(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===t)return s.value;return null}return this.each((e==null?ru:ou)(n,t,e))}function er(t,e,n){var r=t._id;return t.each(function(){var o=vt(this,r);(o.value||(o.value={}))[e]=n.apply(this,arguments)}),function(o){return mt(o,r).value[e]}}function ai(t,e){var n;return(typeof e=="number"?yt:e instanceof Rt?Qe:(n=Rt(e))?(e=n,Qe):ei)(t,e)}function su(t){return function(){this.removeAttribute(t)}}function au(t){return function(){this.removeAttributeNS(t.space,t.local)}}function cu(t,e,n){var r,o=n+"",i;return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function lu(t,e,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function uu(t,e,n){var r,o,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=a+"",s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a)))}}function fu(t,e,n){var r,o,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=a+"",s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a)))}}function du(t,e){var n=sn(t),r=n==="transform"?Yl:ai;return this.attrTween(t,typeof e=="function"?(n.local?fu:uu)(n,r,er(this,"attr."+t,e)):e==null?(n.local?au:su)(n):(n.local?lu:cu)(n,r,e))}function hu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function gu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function pu(t,e){var n,r;function o(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&gu(t,i)),n}return o._value=e,o}function mu(t,e){var n,r;function o(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&hu(t,i)),n}return o._value=e,o}function yu(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=sn(t);return this.tween(n,(r.local?pu:mu)(r,e))}function xu(t,e){return function(){tr(this,t).delay=+e.apply(this,arguments)}}function wu(t,e){return e=+e,function(){tr(this,t).delay=e}}function vu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?xu:wu)(e,t)):mt(this.node(),e).delay}function bu(t,e){return function(){vt(this,t).duration=+e.apply(this,arguments)}}function _u(t,e){return e=+e,function(){vt(this,t).duration=e}}function Nu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?bu:_u)(e,t)):mt(this.node(),e).duration}function Eu(t,e){if(typeof e!="function")throw new Error;return function(){vt(this,t).ease=e}}function Su(t){var e=this._id;return arguments.length?this.each(Eu(e,t)):mt(this.node(),e).ease}function Mu(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;vt(this,t).ease=n}}function Cu(t){if(typeof t!="function")throw new Error;return this.each(Mu(this._id,t))}function ku(t){typeof t!="function"&&(t=Ho(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&a.push(l);return new St(r,this._parents,this._name,this._id)}function Iu(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var l=e[a],c=n[a],f=l.length,u=s[a]=new Array(f),d,h=0;h<f;++h)(d=l[h]||c[h])&&(u[h]=d);for(;a<r;++a)s[a]=e[a];return new St(s,this._parents,this._name,this._id)}function Au(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function $u(t,e,n){var r,o,i=Au(e)?tr:vt;return function(){var s=i(this,t),a=s.on;a!==r&&(o=(r=a).copy()).on(e,n),s.on=o}}function Pu(t,e){var n=this._id;return arguments.length<2?mt(this.node(),n).on.on(t):this.each($u(n,t,e))}function Tu(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function zu(){return this.on("end.remove",Tu(this._id))}function Lu(t){var e=this._name,n=this._id;typeof t!="function"&&(t=qn(t));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],l=a.length,c=i[s]=new Array(l),f,u,d=0;d<l;++d)(f=a[d])&&(u=t.call(f,f.__data__,d,a))&&("__data__"in f&&(u.__data__=f.__data__),c[d]=u,cn(c[d],e,n,d,c,mt(f,n)));return new St(i,this._parents,e,n)}function Du(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Ro(t));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var l=r[a],c=l.length,f,u=0;u<c;++u)if(f=l[u]){for(var d=t.call(f,f.__data__,u,l),h,g=mt(f,n),y=0,p=d.length;y<p;++y)(h=d[y])&&cn(h,e,n,y,d,g);i.push(d),s.push(f)}return new St(i,s,e,n)}var ju=Ee.prototype.constructor;function Ru(){return new ju(this._groups,this._parents)}function Hu(t,e){var n,r,o;return function(){var i=qt(this,t),s=(this.style.removeProperty(t),qt(this,t));return i===s?null:i===n&&s===r?o:o=e(n=i,r=s)}}function ci(t){return function(){this.style.removeProperty(t)}}function Vu(t,e,n){var r,o=n+"",i;return function(){var s=qt(this,t);return s===o?null:s===r?i:i=e(r=s,n)}}function Bu(t,e,n){var r,o,i;return function(){var s=qt(this,t),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),qt(this,t))),s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a))}}function Fu(t,e){var n,r,o,i="style."+e,s="end."+i,a;return function(){var l=vt(this,t),c=l.on,f=l.value[i]==null?a||(a=ci(e)):void 0;(c!==n||o!==f)&&(r=(n=c).copy()).on(s,o=f),l.on=r}}function Ou(t,e,n){var r=(t+="")=="transform"?Xl:ai;return e==null?this.styleTween(t,Hu(t,r)).on("end.style."+t,ci(t)):typeof e=="function"?this.styleTween(t,Bu(t,r,er(this,"style."+t,e))).each(Fu(this._id,t)):this.styleTween(t,Vu(t,r,e),n).on("end.style."+t,null)}function Xu(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Yu(t,e,n){var r,o;function i(){var s=e.apply(this,arguments);return s!==o&&(r=(o=s)&&Xu(t,s,n)),r}return i._value=e,i}function Wu(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Yu(t,e,n??""))}function Gu(t){return function(){this.textContent=t}}function qu(t){return function(){var e=t(this);this.textContent=e??""}}function Uu(t){return this.tween("text",typeof t=="function"?qu(er(this,"text",t)):Gu(t==null?"":t+""))}function Zu(t){return function(e){this.textContent=t.call(this,e)}}function Ku(t){var e,n;function r(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&Zu(o)),e}return r._value=t,r}function Qu(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Ku(t))}function Ju(){for(var t=this._name,e=this._id,n=li(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var f=mt(l,e);cn(l,t,n,c,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new St(r,this._parents,t,n)}function tf(){var t,e,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--o===0&&i()}};n.each(function(){var c=vt(this,r),f=c.on;f!==t&&(e=(t=f).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),o===0&&i()})}var ef=0;function St(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function li(){return++ef}var _t=Ee.prototype;St.prototype={constructor:St,select:Lu,selectAll:Du,selectChild:_t.selectChild,selectChildren:_t.selectChildren,filter:ku,merge:Iu,selection:Ru,transition:Ju,call:_t.call,nodes:_t.nodes,node:_t.node,size:_t.size,empty:_t.empty,each:_t.each,on:Pu,attr:du,attrTween:yu,style:Ou,styleTween:Wu,text:Uu,textTween:Qu,remove:zu,tween:iu,delay:vu,duration:Nu,ease:Su,easeVarying:Cu,end:tf,[Symbol.iterator]:_t[Symbol.iterator]};function nf(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var rf={time:null,delay:0,duration:250,ease:nf};function of(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function sf(t){var e,n;t instanceof St?(e=t._id,t=t._name):(e=li(),(n=rf).time=Qn(),t=t==null?null:t+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&cn(l,t,e,c,s,n||of(l,e));return new St(r,this._parents,t,e)}Ee.prototype.interrupt=nu;Ee.prototype.transition=sf;const je=t=>()=>t;function af(t,{sourceEvent:e,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Nt(t,e,n){this.k=t,this.x=e,this.y=n}Nt.prototype={constructor:Nt,scale:function(t){return t===1?this:new Nt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Nt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ln=new Nt(1,0,0);ui.prototype=Nt.prototype;function ui(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ln;return t.__zoom}function Nn(t){t.stopImmediatePropagation()}function ce(t){t.preventDefault(),t.stopImmediatePropagation()}function cf(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function lf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Rr(){return this.__zoom||ln}function uf(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function ff(){return navigator.maxTouchPoints||"ontouchstart"in this}function df(t,e,n){var r=t.invertX(e[0][0])-n[0][0],o=t.invertX(e[1][0])-n[1][0],i=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function fi(){var t=cf,e=lf,n=df,r=uf,o=ff,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Ye,c=Ne("start","zoom","end"),f,u,d,h=500,g=150,y=0,p=10;function m(_){_.property("__zoom",Rr).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",j).filter(o).on("touchstart.zoom",k).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(_,$,C,z){var A=_.selection?_.selection():_;A.property("__zoom",Rr),_!==A?E(_,$,C,z):A.interrupt().each(function(){N(this,arguments).event(z).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},m.scaleBy=function(_,$,C,z){m.scaleTo(_,function(){var A=this.__zoom.k,M=typeof $=="function"?$.apply(this,arguments):$;return A*M},C,z)},m.scaleTo=function(_,$,C,z){m.transform(_,function(){var A=e.apply(this,arguments),M=this.__zoom,D=C==null?w(A):typeof C=="function"?C.apply(this,arguments):C,V=M.invert(D),R=typeof $=="function"?$.apply(this,arguments):$;return n(x(v(M,R),D,V),A,s)},C,z)},m.translateBy=function(_,$,C,z){m.transform(_,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof C=="function"?C.apply(this,arguments):C),e.apply(this,arguments),s)},null,z)},m.translateTo=function(_,$,C,z,A){m.transform(_,function(){var M=e.apply(this,arguments),D=this.__zoom,V=z==null?w(M):typeof z=="function"?z.apply(this,arguments):z;return n(ln.translate(V[0],V[1]).scale(D.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof C=="function"?-C.apply(this,arguments):-C),M,s)},z,A)};function v(_,$){return $=Math.max(i[0],Math.min(i[1],$)),$===_.k?_:new Nt($,_.x,_.y)}function x(_,$,C){var z=$[0]-C[0]*_.k,A=$[1]-C[1]*_.k;return z===_.x&&A===_.y?_:new Nt(_.k,z,A)}function w(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function E(_,$,C,z){_.on("start.zoom",function(){N(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,M=arguments,D=N(A,M).event(z),V=e.apply(A,M),R=C==null?w(V):typeof C=="function"?C.apply(A,M):C,X=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=A.__zoom,W=typeof $=="function"?$.apply(A,M):$,q=l(Y.invert(R).concat(X/Y.k),W.invert(R).concat(X/W.k));return function(F){if(F===1)F=W;else{var B=q(F),O=X/B[2];F=new Nt(O,R[0]-B[0]*O,R[1]-B[1]*O)}D.zoom(null,F)}})}function N(_,$,C){return!C&&_.__zooming||new S(_,$)}function S(_,$){this.that=_,this.args=$,this.active=0,this.sourceEvent=null,this.extent=e.apply(_,$),this.taps=0}S.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,$){return this.mouse&&_!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var $=ut(this.that).datum();c.call(_,this.that,new af(_,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),$)}};function I(_,...$){if(!t.apply(this,arguments))return;var C=N(this,$).event(_),z=this.__zoom,A=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),M=dt(_);if(C.wheel)(C.mouse[0][0]!==M[0]||C.mouse[0][1]!==M[1])&&(C.mouse[1]=z.invert(C.mouse[0]=M)),clearTimeout(C.wheel);else{if(z.k===A)return;C.mouse=[M,z.invert(M)],qe(this),C.start()}ce(_),C.wheel=setTimeout(D,g),C.zoom("mouse",n(x(v(z,A),C.mouse[0],C.mouse[1]),C.extent,s));function D(){C.wheel=null,C.end()}}function T(_,...$){if(d||!t.apply(this,arguments))return;var C=_.currentTarget,z=N(this,$,!0).event(_),A=ut(_.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",X,!0),M=dt(_,C),D=_.clientX,V=_.clientY;Uo(_.view),Nn(_),z.mouse=[M,this.__zoom.invert(M)],qe(this),z.start();function R(Y){if(ce(Y),!z.moved){var W=Y.clientX-D,q=Y.clientY-V;z.moved=W*W+q*q>y}z.event(Y).zoom("mouse",n(x(z.that.__zoom,z.mouse[0]=dt(Y,C),z.mouse[1]),z.extent,s))}function X(Y){A.on("mousemove.zoom mouseup.zoom",null),Zo(Y.view,z.moved),ce(Y),z.event(Y).end()}}function j(_,...$){if(t.apply(this,arguments)){var C=this.__zoom,z=dt(_.changedTouches?_.changedTouches[0]:_,this),A=C.invert(z),M=C.k*(_.shiftKey?.5:2),D=n(x(v(C,M),z,A),e.apply(this,$),s);ce(_),a>0?ut(this).transition().duration(a).call(E,D,z,_):ut(this).call(m.transform,D,z,_)}}function k(_,...$){if(t.apply(this,arguments)){var C=_.touches,z=C.length,A=N(this,$,_.changedTouches.length===z).event(_),M,D,V,R;for(Nn(_),D=0;D<z;++D)V=C[D],R=dt(V,this),R=[R,this.__zoom.invert(R),V.identifier],A.touch0?!A.touch1&&A.touch0[2]!==R[2]&&(A.touch1=R,A.taps=0):(A.touch0=R,M=!0,A.taps=1+!!f);f&&(f=clearTimeout(f)),M&&(A.taps<2&&(u=R[0],f=setTimeout(function(){f=null},h)),qe(this),A.start())}}function L(_,...$){if(this.__zooming){var C=N(this,$).event(_),z=_.changedTouches,A=z.length,M,D,V,R;for(ce(_),M=0;M<A;++M)D=z[M],V=dt(D,this),C.touch0&&C.touch0[2]===D.identifier?C.touch0[0]=V:C.touch1&&C.touch1[2]===D.identifier&&(C.touch1[0]=V);if(D=C.that.__zoom,C.touch1){var X=C.touch0[0],Y=C.touch0[1],W=C.touch1[0],q=C.touch1[1],F=(F=W[0]-X[0])*F+(F=W[1]-X[1])*F,B=(B=q[0]-Y[0])*B+(B=q[1]-Y[1])*B;D=v(D,Math.sqrt(F/B)),V=[(X[0]+W[0])/2,(X[1]+W[1])/2],R=[(Y[0]+q[0])/2,(Y[1]+q[1])/2]}else if(C.touch0)V=C.touch0[0],R=C.touch0[1];else return;C.zoom("touch",n(x(D,V,R),C.extent,s))}}function H(_,...$){if(this.__zooming){var C=N(this,$).event(_),z=_.changedTouches,A=z.length,M,D;for(Nn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),M=0;M<A;++M)D=z[M],C.touch0&&C.touch0[2]===D.identifier?delete C.touch0:C.touch1&&C.touch1[2]===D.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(D=dt(D,this),Math.hypot(u[0]-D[0],u[1]-D[1])<p)){var V=ut(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return m.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:je(+_),m):r},m.filter=function(_){return arguments.length?(t=typeof _=="function"?_:je(!!_),m):t},m.touchable=function(_){return arguments.length?(o=typeof _=="function"?_:je(!!_),m):o},m.extent=function(_){return arguments.length?(e=typeof _=="function"?_:je([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),m):e},m.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],m):[i[0],i[1]]},m.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(_){return arguments.length?(n=_,m):n},m.duration=function(_){return arguments.length?(a=+_,m):a},m.interpolate=function(_){return arguments.length?(l=_,m):l},m.on=function(){var _=c.on.apply(c,arguments);return _===c?m:_},m.clickDistance=function(_){return arguments.length?(y=(_=+_)*_,m):Math.sqrt(y)},m.tapDistance=function(_){return arguments.length?(p=+_,m):p},m}const wt={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:t=>`Node type "${t}" 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},xe=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],di=["Enter"," ","Escape"],hi={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Zt;(function(t){t.Strict="strict",t.Loose="loose"})(Zt||(Zt={}));var Dt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Dt||(Dt={}));var we;(function(t){t.Partial="partial",t.Full="full"})(we||(we={}));const gi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var At;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(At||(At={}));var Kt;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Kt||(Kt={}));var G;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(G||(G={}));const Hr={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top};function pi(t){return t===null?null:t?"valid":"invalid"}const mi=t=>"id"in t&&"source"in t&&"target"in t,hf=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),nr=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Me=(t,e=[0,0])=>{const{width:n,height:r}=Mt(t),o=t.origin??e,i=n*o[0],s=r*o[1];return{x:t.position.x-i,y:t.position.y-s}},gf=(t,e={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,o)=>{const i=typeof o=="string";let s=!e.nodeLookup&&!i?o:void 0;e.nodeLookup&&(s=i?e.nodeLookup.get(o):nr(o)?o:e.nodeLookup.get(o.id));const a=s?nn(s,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return un(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fn(n)},Ce=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return t.forEach(o=>{(e.filter===void 0||e.filter(o))&&(n=un(n,nn(o)),r=!0)}),r?fn(n):{x:0,y:0,width:0,height:0}},rr=(t,e,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a={...Ie(e,[n,r,o]),width:e.width/o,height:e.height/o},l=[];for(const c of t.values()){const{measured:f,selectable:u=!0,hidden:d=!1}=c;if(s&&!u||d)continue;const h=f.width??c.width??c.initialWidth??null,g=f.height??c.height??c.initialHeight??null,y=ve(a,Jt(c)),p=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=p||c.dragging)&&l.push(c)}return l},pf=(t,e)=>{const n=new Set;return t.forEach(r=>{n.add(r.id)}),e.filter(r=>n.has(r.source)||n.has(r.target))};function mf(t,e){const n=new Map,r=e!=null&&e.nodes?new Set(e.nodes.map(o=>o.id)):null;return t.forEach(o=>{o.measured.width&&o.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function yf({nodes:t,width:e,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(t.size===0)return Promise.resolve(!0);const a=mf(t,s),l=Ce(a),c=or(l,e,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(c,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function yi({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(t),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let u=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",wt.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&te(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const d=te(u)?Vt(e,u,s.measured):e;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",wt.error015())),{position:{x:d.x-l+(s.measured.width??0)*f[0],y:d.y-c+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function xf({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(t.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&s.find(y=>y.id===d.parentId);(h||g)&&s.push(d)}const a=new Set(e.map(d=>d.id)),l=r.filter(d=>d.deletable!==!1),f=pf(s,l);for(const d of l)a.has(d.id)&&!f.find(g=>g.id===d.id)&&f.push(d);if(!o)return{edges:f,nodes:s};const u=await o({nodes:s,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:s}:{edges:[],nodes:[]}:u}const Qt=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),Vt=(t={x:0,y:0},e,n)=>({x:Qt(t.x,e[0][0],e[1][0]-((n==null?void 0:n.width)??0)),y:Qt(t.y,e[0][1],e[1][1]-((n==null?void 0:n.height)??0))});function xi(t,e,n){const{width:r,height:o}=Mt(n),{x:i,y:s}=n.internals.positionAbsolute;return Vt(t,[[i,s],[i+r,s+o]],e)}const Vr=(t,e,n)=>t<e?Qt(Math.abs(t-e),1,e)/e:t>n?-Qt(Math.abs(t-n),1,e)/e:0,wi=(t,e,n=15,r=40)=>{const o=Vr(t.x,r,e.width-r)*n,i=Vr(t.y,r,e.height-r)*n;return[o,i]},un=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),Bn=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),fn=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Jt=(t,e=[0,0])=>{var o,i;const{x:n,y:r}=nr(t)?t.internals.positionAbsolute:Me(t,e);return{x:n,y:r,width:((o=t.measured)==null?void 0:o.width)??t.width??t.initialWidth??0,height:((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0}},nn=(t,e=[0,0])=>{var o,i;const{x:n,y:r}=nr(t)?t.internals.positionAbsolute:Me(t,e);return{x:n,y:r,x2:n+(((o=t.measured)==null?void 0:o.width)??t.width??t.initialWidth??0),y2:r+(((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0)}},vi=(t,e)=>fn(un(Bn(t),Bn(e))),ve=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},Br=t=>gt(t.width)&>(t.height)&>(t.x)&>(t.y),gt=t=>!isNaN(t)&&isFinite(t),wf=(t,e)=>{},ke=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),Ie=({x:t,y:e},[n,r,o],i=!1,s=[1,1])=>{const a={x:(t-n)/o,y:(e-r)/o};return i?ke(a,s):a},rn=({x:t,y:e},[n,r,o])=>({x:t*o+n,y:e*o+r});function Ot(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function vf(t,e,n){if(typeof t=="string"||typeof t=="number"){const r=Ot(t,n),o=Ot(t,e);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof t=="object"){const r=Ot(t.top??t.y??0,n),o=Ot(t.bottom??t.y??0,n),i=Ot(t.left??t.x??0,e),s=Ot(t.right??t.x??0,e);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function bf(t,e,n,r,o,i){const{x:s,y:a}=rn(t,[e,n,r]),{x:l,y:c}=rn({x:t.x+t.width,y:t.y+t.height},[e,n,r]),f=o-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(u)}}const or=(t,e,n,r,o,i)=>{const s=vf(i,e,n),a=(e-s.x)/t.width,l=(n-s.y)/t.height,c=Math.min(a,l),f=Qt(c,r,o),u=t.x+t.width/2,d=t.y+t.height/2,h=e/2-u*f,g=n/2-d*f,y=bf(t,h,g,f,e,n),p={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-p.left+p.right,y:g-p.top+p.bottom,zoom:f}},be=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function te(t){return t!=null&&t!=="parent"}function Mt(t){var e,n;return{width:((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function bi(t){var e,n;return(((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function _i(t,e={width:0,height:0},n,r,o){const i={...t},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(e.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(e.height??0)*a[1]}return i}function Fr(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function _f(){let t,e;return{promise:new Promise((r,o)=>{t=r,e=o}),resolve:t,reject:e}}function Nf(t){return{...hi,...t||{}}}function he(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pt(t),a=Ie({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:l,y:c}=n?ke(a,e):a;return{xSnapped:l,ySnapped:c,...a}}const ir=t=>({width:t.offsetWidth,height:t.offsetHeight}),Ni=t=>{var e;return((e=t==null?void 0:t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},Ef=["INPUT","SELECT","TEXTAREA"];function Ei(t){var r,o;const e=((o=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:o[0])||t.target;return(e==null?void 0:e.nodeType)!==1?!1:Ef.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}const Si=t=>"clientX"in t,pt=(t,e)=>{var i,s;const n=Si(t),r=n?t.clientX:(i=t.touches)==null?void 0:i[0].clientX,o=n?t.clientY:(s=t.touches)==null?void 0:s[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:o-((e==null?void 0:e.top)??0)}},Or=(t,e,n,r,o)=>{const i=e.querySelectorAll(`.${t}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:t,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ir(s)}})};function Mi({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=t*.125+o*.375+s*.375+n*.125,c=e*.125+i*.375+a*.375+r*.125,f=Math.abs(l-t),u=Math.abs(c-e);return[l,c,f,u]}function Re(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function Xr({pos:t,x1:e,y1:n,x2:r,y2:o,c:i}){switch(t){case G.Left:return[e-Re(e-r,i),n];case G.Right:return[e+Re(r-e,i),n];case G.Top:return[e,n-Re(n-o,i)];case G.Bottom:return[e,n+Re(o-n,i)]}}function Ci({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,curvature:s=.25}){const[a,l]=Xr({pos:n,x1:t,y1:e,x2:r,y2:o,c:s}),[c,f]=Xr({pos:i,x1:r,y1:o,x2:t,y2:e,c:s}),[u,d,h,g]=Mi({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:f});return[`M${t},${e} C${a},${l} ${c},${f} ${r},${o}`,u,d,h,g]}function ki({sourceX:t,sourceY:e,targetX:n,targetY:r}){const o=Math.abs(n-t)/2,i=n<t?n+o:n-o,s=Math.abs(r-e)/2,a=r<e?r+s:r-s;return[i,a,o,s]}function Sf({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(t.parentId||o&&t.selected?t.internals.z:0,e.parentId||o&&e.selected?e.internals.z:0);return s+a}function Mf({sourceNode:t,targetNode:e,width:n,height:r,transform:o}){const i=un(nn(t),nn(e));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return ve(s,fn(i))>0}const Cf=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,kf=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),If=(t,e,n={})=>{if(!t.source||!t.target)return e;const r=n.getEdgeId||Cf;let o;return mi(t)?o={...t}:o={...t,id:r(t)},kf(o,e)?e:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,e.concat(o))};function Ii({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[o,i,s,a]=ki({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,o,i,s,a]}const Yr={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},Af=({source:t,sourcePosition:e=G.Bottom,target:n})=>e===G.Left||e===G.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},Wr=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function $f({source:t,sourcePosition:e=G.Bottom,target:n,targetPosition:r=G.Top,center:o,offset:i,stepPosition:s}){const a=Yr[e],l=Yr[r],c={x:t.x+a.x*i,y:t.y+a.y*i},f={x:n.x+l.x*i,y:n.y+l.y*i},u=Af({source:c,sourcePosition:e,target:f}),d=u.x!==0?"x":"y",h=u[d];let g=[],y,p;const m={x:0,y:0},v={x:0,y:0},[,,x,w]=ki({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(a[d]*l[d]===-1){d==="x"?(y=o.x??c.x+(f.x-c.x)*s,p=o.y??(c.y+f.y)/2):(y=o.x??(c.x+f.x)/2,p=o.y??c.y+(f.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:f.y}],T=[{x:c.x,y:p},{x:f.x,y:p}];a[d]===h?g=d==="x"?I:T:g=d==="x"?T:I}else{const I=[{x:c.x,y:f.y}],T=[{x:f.x,y:c.y}];if(d==="x"?g=a.x===h?T:I:g=a.y===h?I:T,e===r){const _=Math.abs(t[d]-n[d]);if(_<=i){const $=Math.min(i-1,i-_);a[d]===h?m[d]=(c[d]>t[d]?-1:1)*$:v[d]=(f[d]>n[d]?-1:1)*$}}if(e!==r){const _=d==="x"?"y":"x",$=a[d]===l[_],C=c[_]>f[_],z=c[_]<f[_];(a[d]===1&&(!$&&C||$&&z)||a[d]!==1&&(!$&&z||$&&C))&&(g=d==="x"?I:T)}const j={x:c.x+m.x,y:c.y+m.y},k={x:f.x+v.x,y:f.y+v.y},L=Math.max(Math.abs(j.x-g[0].x),Math.abs(k.x-g[0].x)),H=Math.max(Math.abs(j.y-g[0].y),Math.abs(k.y-g[0].y));L>=H?(y=(j.x+k.x)/2,p=g[0].y):(y=g[0].x,p=(j.y+k.y)/2)}const E={x:c.x+m.x,y:c.y+m.y},N={x:f.x+v.x,y:f.y+v.y};return[[t,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,p,x,w]}function Pf(t,e,n,r){const o=Math.min(Wr(t,e)/2,Wr(e,n)/2,r),{x:i,y:s}=e;if(t.x===i&&i===n.x||t.y===s&&s===n.y)return`L${i} ${s}`;if(t.y===s){const c=t.x<n.x?-1:1,f=t.y<n.y?1:-1;return`L ${i+o*c},${s}Q ${i},${s} ${i},${s+o*f}`}const a=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${i},${s+o*l}Q ${i},${s} ${i+o*a},${s}`}function Fn({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:f=.5}){const[u,d,h,g,y]=$f({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:f});let p=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)p+=Pf(u[m-1],u[m],u[m+1],s);return p+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[p,d,h,g,y]}function Gr(t){var e;return t&&!!(t.internals.handleBounds||(e=t.handles)!=null&&e.length)&&!!(t.measured.width||t.width||t.initialWidth)}function Tf(t){var u;const{sourceNode:e,targetNode:n}=t;if(!Gr(e)||!Gr(n))return null;const r=e.internals.handleBounds||qr(e.handles),o=n.internals.handleBounds||qr(n.handles),i=Ur((r==null?void 0:r.source)??[],t.sourceHandle),s=Ur(t.connectionMode===Zt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),t.targetHandle);if(!i||!s)return(u=t.onError)==null||u.call(t,"008",wt.error008(i?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const a=(i==null?void 0:i.position)||G.Bottom,l=(s==null?void 0:s.position)||G.Top,c=Bt(e,i,a),f=Bt(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:l}}function qr(t){if(!t)return null;const e=[],n=[];for(const r of t)r.width=r.width??1,r.height=r.height??1,r.type==="source"?e.push(r):r.type==="target"&&n.push(r);return{source:e,target:n}}function Bt(t,e,n=G.Left,r=!1){const o=((e==null?void 0:e.x)??0)+t.internals.positionAbsolute.x,i=((e==null?void 0:e.y)??0)+t.internals.positionAbsolute.y,{width:s,height:a}=e??Mt(t);if(r)return{x:o+s/2,y:i+a/2};switch((e==null?void 0:e.position)??n){case G.Top:return{x:o+s/2,y:i};case G.Right:return{x:o+s,y:i+a/2};case G.Bottom:return{x:o+s/2,y:i+a};case G.Left:return{x:o,y:i+a/2}}}function Ur(t,e){return t&&(e?t.find(n=>n.id===e):t[0])||null}function On(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`:""}function zf(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return t.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const c=On(l,e);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Ai=1e3,Lf=10,sr={nodeOrigin:[0,0],nodeExtent:xe,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Df={...sr,checkEquality:!0};function ar(t,e){const n={...t};for(const r in e)e[r]!==void 0&&(n[r]=e[r]);return n}function jf(t,e,n){const r=ar(sr,n);for(const o of t.values())if(o.parentId)lr(o,t,e,r);else{const i=Me(o,r.nodeOrigin),s=te(o.extent)?o.extent:r.nodeExtent,a=Vt(i,s,Mt(o));o.internals.positionAbsolute=a}}function Rf(t,e){if(!t.handles)return t.measured?e==null?void 0:e.internals.handleBounds:void 0;const n=[],r=[];for(const o of t.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:t.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function cr(t){return t==="manual"}function Xn(t,e,n,r={}){var f,u;const o=ar(Df,r),i={i:0},s=new Map(e),a=o!=null&&o.elevateNodesOnSelect&&!cr(o.zIndexMode)?Ai:0;let l=t.length>0,c=!1;e.clear(),n.clear();for(const d of t){let h=s.get(d.id);if(o.checkEquality&&d===(h==null?void 0:h.internals.userNode))e.set(d.id,h);else{const g=Me(d,o.nodeOrigin),y=te(d.extent)?d.extent:o.nodeExtent,p=Vt(g,y,Mt(d));h={...o.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(u=d.measured)==null?void 0:u.height},internals:{positionAbsolute:p,handleBounds:Rf(d,h),z:$i(d,a,o.zIndexMode),userNode:d}},e.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),d.parentId&&lr(h,e,n,r,i),c||(c=d.selected??!1)}return{nodesInitialized:l,hasSelectedNodes:c}}function Hf(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function lr(t,e,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=ar(sr,r),c=t.parentId,f=e.get(c);if(!f){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Hf(t,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&l==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*Lf),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const u=i&&!cr(l)?Ai:0,{x:d,y:h,z:g}=Vf(t,f,s,a,u,l),{positionAbsolute:y}=t.internals,p=d!==y.x||h!==y.y;(p||g!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:p?{x:d,y:h}:y,z:g}})}function $i(t,e,n){const r=gt(t.zIndex)?t.zIndex:0;return cr(n)?r:r+(t.selected?e:0)}function Vf(t,e,n,r,o,i){const{x:s,y:a}=e.internals.positionAbsolute,l=Mt(t),c=Me(t,n),f=te(t.extent)?Vt(c,t.extent,l):c;let u=Vt({x:s+f.x,y:a+f.y},r,l);t.extent==="parent"&&(u=xi(u,l,e));const d=$i(t,o,i),h=e.internals.z??0;return{x:u.x,y:u.y,z:h>=d?h+1:d}}function ur(t,e,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of t){const l=e.get(a.parentId);if(!l)continue;const c=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Jt(l),f=vi(c,a.rect);i.set(a.parentId,{expandedRect:f,parent:l})}return i.size>0&&i.forEach(({expandedRect:a,parent:l},c)=>{var x;const f=l.internals.positionAbsolute,u=Mt(l),d=l.origin??r,h=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,y=Math.max(u.width,Math.round(a.width)),p=Math.max(u.height,Math.round(a.height)),m=(y-u.width)*d[0],v=(p-u.height)*d[1];(h>0||g>0||m||v)&&(o.push({id:c,type:"position",position:{x:l.position.x-h+m,y:l.position.y-g+v}}),(x=n.get(c))==null||x.forEach(w=>{t.some(E=>E.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+g}})})),(u.width<a.width||u.height<a.height||h||g)&&o.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:y+(h?d[0]*h-m:0),height:p+(g?d[1]*g-v:0)}})}),o}function Bf(t,e,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],f=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const h of t.values()){const g=e.get(h.id);if(!g)continue;if(g.hidden){e.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const y=ir(h.nodeElement),p=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(p||!g.internals.handleBounds||h.force))){const v=h.nodeElement.getBoundingClientRect(),x=te(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=xi(w,y,e.get(g.parentId)):x&&(w=Vt(w,x,y));const E={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Or("source",h.nodeElement,v,u,g.id),target:Or("target",h.nodeElement,v,u,g.id)}}};e.set(g.id,E),g.parentId&&lr(E,e,n,{nodeOrigin:o,zIndexMode:s}),l=!0,p&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Jt(E,o)}))}}if(d.length>0){const h=ur(d,e,n,o);c.push(...h)}return{changes:c,updatedInternals:l}}async function Ff({delta:t,panZoom:e,transform:n,translateExtent:r,width:o,height:i}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);const s=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[o,i]],r),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Zr(t,e,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,e)),s=`${o}-${t}`;const l=r.get(s)||new Map;if(r.set(s,l.set(n,e)),i){s=`${o}-${t}-${i}`;const c=r.get(s)||new Map;r.set(s,c.set(n,e))}}function Pi(t,e,n){t.clear(),e.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,l={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},c=`${o}-${s}--${i}-${a}`,f=`${i}-${a}--${o}-${s}`;Zr("source",l,f,t,o,s),Zr("target",l,c,t,i,a),e.set(r.id,r)}}function Ti(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return n?n.selected?!0:Ti(n,e):!1}function Kr(t,e,n){var o;let r=t;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,e))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Of(t,e,n,r){const o=new Map;for(const[i,s]of t)if((s.selected||s.id===r)&&(!s.parentId||!Ti(s,t))&&(s.draggable||e&&typeof s.draggable>"u")){const a=t.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function En({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){var s,a,l;const o=[];for(const[c,f]of e){const u=(s=n.get(c))==null?void 0:s.internals.userNode;u&&o.push({...u,position:f.position,dragging:r})}if(!t)return[o[0],o];const i=(a=n.get(t))==null?void 0:a.internals.userNode;return[i?{...i,position:((l=e.get(t))==null?void 0:l.position)||i.position,dragging:r}:o[0],o]}function Xf({dragItems:t,snapGrid:e,x:n,y:r}){const o=t.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=ke(i,e);return{x:s.x-i.x,y:s.y-i.y}}function Yf({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},f=null,u=!1,d=null,h=!1,g=!1,y=null;function p({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:E,nodeId:N,nodeClickDistance:S=0}){d=ut(w);function I({x:L,y:H}){const{nodeLookup:_,nodeExtent:$,snapGrid:C,snapToGrid:z,nodeOrigin:A,onNodeDrag:M,onSelectionDrag:D,onError:V,updateNodePositions:R}=e();i={x:L,y:H};let X=!1;const Y=a.size>1,W=Y&&$?Bn(Ce(a)):null,q=Y&&z?Xf({dragItems:a,snapGrid:C,x:L,y:H}):null;for(const[F,B]of a){if(!_.has(F))continue;let O={x:L-B.distance.x,y:H-B.distance.y};z&&(O=q?{x:Math.round(O.x+q.x),y:Math.round(O.y+q.y)}:ke(O,C));let Z=null;if(Y&&$&&!B.extent&&W){const{positionAbsolute:U}=B.internals,et=U.x-W.x+$[0][0],nt=U.x+B.measured.width-W.x2+$[1][0],tt=U.y-W.y+$[0][1],st=U.y+B.measured.height-W.y2+$[1][1];Z=[[et,tt],[nt,st]]}const{position:Q,positionAbsolute:K}=yi({nodeId:F,nextPosition:O,nodeLookup:_,nodeExtent:Z||$,nodeOrigin:A,onError:V});X=X||B.position.x!==Q.x||B.position.y!==Q.y,B.position=Q,B.internals.positionAbsolute=K}if(g=g||X,!!X&&(R(a,!0),y&&(r||M||!N&&D))){const[F,B]=En({nodeId:N,dragItems:a,nodeLookup:_});r==null||r(y,a,F,B),M==null||M(y,F,B),N||D==null||D(y,B)}}async function T(){if(!f)return;const{transform:L,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:$}=e();if(!$){l=!1,cancelAnimationFrame(s);return}const[C,z]=wi(c,f,_);(C!==0||z!==0)&&(i.x=(i.x??0)-C/L[2],i.y=(i.y??0)-z/L[2],await H({x:C,y:z})&&I(i)),s=requestAnimationFrame(T)}function j(L){var Y;const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:$,transform:C,snapGrid:z,snapToGrid:A,selectNodesOnDrag:M,onNodeDragStart:D,onSelectionDragStart:V,unselectNodesAndEdges:R}=e();u=!0,(!M||!E)&&!_&&N&&((Y=H.get(N))!=null&&Y.selected||R()),E&&M&&N&&(t==null||t(N));const X=he(L.sourceEvent,{transform:C,snapGrid:z,snapToGrid:A,containerBounds:f});if(i=X,a=Of(H,$,X,N),a.size>0&&(n||D||!N&&V)){const[W,q]=En({nodeId:N,dragItems:a,nodeLookup:H});n==null||n(L.sourceEvent,a,W,q),D==null||D(L.sourceEvent,W,q),N||V==null||V(L.sourceEvent,q)}}const k=Ko().clickDistance(S).on("start",L=>{const{domNode:H,nodeDragThreshold:_,transform:$,snapGrid:C,snapToGrid:z}=e();f=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,g=!1,y=L.sourceEvent,_===0&&j(L),i=he(L.sourceEvent,{transform:$,snapGrid:C,snapToGrid:z,containerBounds:f}),c=pt(L.sourceEvent,f)}).on("drag",L=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:$,snapToGrid:C,nodeDragThreshold:z,nodeLookup:A}=e(),M=he(L.sourceEvent,{transform:_,snapGrid:$,snapToGrid:C,containerBounds:f});if(y=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!A.has(N))&&(h=!0),!h){if(!l&&H&&u&&(l=!0,T()),!u){const D=pt(L.sourceEvent,f),V=D.x-c.x,R=D.y-c.y;Math.sqrt(V*V+R*R)>z&&j(L)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&a&&u&&(c=pt(L.sourceEvent,f),I(M))}}).on("end",L=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:$,onSelectionDragStop:C}=e();if(g&&(_(a,!1),g=!1),o||$||!N&&C){const[z,A]=En({nodeId:N,dragItems:a,nodeLookup:H,dragging:!1});o==null||o(L.sourceEvent,a,z,A),$==null||$(L.sourceEvent,z,A),N||C==null||C(L.sourceEvent,A)}}}).filter(L=>{const H=L.target;return!L.button&&(!v||!Kr(H,`.${v}`,w))&&(!x||Kr(H,x,w))});d.call(k)}function m(){d==null||d.on(".drag",null)}return{update:p,destroy:m}}function Wf(t,e,n){const r=[],o={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const i of e.values())ve(o,Jt(i))>0&&r.push(i);return r}const Gf=250;function qf(t,e,n,r){var a,l;let o=[],i=1/0;const s=Wf(t,n,e+Gf);for(const c of s){const f=[...((a=c.internals.handleBounds)==null?void 0:a.source)??[],...((l=c.internals.handleBounds)==null?void 0:l.target)??[]];for(const u of f){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:d,y:h}=Bt(c,u,u.position,!0),g=Math.sqrt(Math.pow(d-t.x,2)+Math.pow(h-t.y,2));g>e||(g<i?(o=[{...u,x:d,y:h}],i=g):g===i&&o.push({...u,x:d,y:h}))}}if(!o.length)return null;if(o.length>1){const c=r.type==="source"?"target":"source";return o.find(f=>f.type===c)??o[0]}return o[0]}function zi(t,e,n,r,o,i=!1){var c,f,u;const s=r.get(t);if(!s)return null;const a=o==="strict"?(c=s.internals.handleBounds)==null?void 0:c[e]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((u=s.internals.handleBounds)==null?void 0:u.target)??[]],l=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return l&&i?{...l,...Bt(s,l,l.position,!0)}:l}function Li(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Uf(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}const Di=()=>!0;function Zf(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:f,flowId:u,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:p,isValidConnection:m=Di,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:E,autoPanSpeed:N,dragThreshold:S=1,handleDomNode:I}){const T=Ni(t.target);let j=0,k;const{x:L,y:H}=pt(t),_=Li(i,I),$=a==null?void 0:a.getBoundingClientRect();let C=!1;if(!$||!_)return;const z=zi(o,_,r,l,e);if(!z)return;let A=pt(t,$),M=!1,D=null,V=!1,R=null;function X(){if(!f||!$)return;const[Q,K]=wi(A,$,N);d({x:Q,y:K}),j=requestAnimationFrame(X)}const Y={...z,nodeId:o,type:_,position:z.position},W=l.get(o);let F={inProgress:!0,isValid:null,from:Bt(W,Y,G.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:W,to:A,toHandle:null,toPosition:Hr[Y.position],toNode:null,pointer:A};function B(){C=!0,x(F),g==null||g(t,{nodeId:o,handleId:r,handleType:_})}S===0&&B();function O(Q){if(!C){const{x:st,y:Ct}=pt(Q),bt=st-L,Pt=Ct-H;if(!(bt*bt+Pt*Pt>S*S))return;B()}if(!E()||!Y){Z(Q);return}const K=w();A=pt(Q,$),k=qf(Ie(A,K,!1,[1,1]),n,l,Y),M||(X(),M=!0);const U=ji(Q,{handle:k,connectionMode:e,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:T,lib:c,flowId:u,nodeLookup:l});R=U.handleDomNode,D=U.connection,V=Uf(!!k,U.isValid);const et=l.get(o),nt=et?Bt(et,Y,G.Left,!0):F.from,tt={...F,from:nt,isValid:V,to:U.toHandle&&V?rn({x:U.toHandle.x,y:U.toHandle.y},K):A,toHandle:U.toHandle,toPosition:V&&U.toHandle?U.toHandle.position:Hr[Y.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:A};x(tt),F=tt}function Z(Q){if(!("touches"in Q&&Q.touches.length>0)){if(C){(k||R)&&D&&V&&(y==null||y(D));const{inProgress:K,...U}=F,et={...U,toPosition:F.toHandle?F.toPosition:null};p==null||p(Q,et),i&&(v==null||v(Q,et))}h(),cancelAnimationFrame(j),M=!1,V=!1,D=null,R=null,T.removeEventListener("mousemove",O),T.removeEventListener("mouseup",Z),T.removeEventListener("touchmove",O),T.removeEventListener("touchend",Z)}}T.addEventListener("mousemove",O),T.addEventListener("mouseup",Z),T.addEventListener("touchmove",O),T.addEventListener("touchend",Z)}function ji(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Di,nodeLookup:f}){const u=i==="target",d=e?s.querySelector(`.${a}-flow__handle[data-id="${l}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:h,y:g}=pt(t),y=s.elementFromPoint(h,g),p=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:d,m={handleDomNode:p,isValid:!1,connection:null,toHandle:null};if(p){const v=Li(void 0,p),x=p.getAttribute("data-nodeid"),w=p.getAttribute("data-handleid"),E=p.classList.contains("connectable"),N=p.classList.contains("connectableend");if(!x||!v)return m;const S={source:u?x:r,sourceHandle:u?w:o,target:u?r:x,targetHandle:u?o:w};m.connection=S;const T=E&&N&&(n===Zt.Strict?u&&v==="source"||!u&&v==="target":x!==r||w!==o);m.isValid=T&&c(S),m.toHandle=zi(x,v,w,f,n,!0)}return m}const Yn={onPointerDown:Zf,isValid:ji};function Kf({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){const o=ut(t);function i({translateExtent:a,width:l,height:c,zoomStep:f=1,pannable:u=!0,zoomable:d=!0,inversePan:h=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!e)return;const w=n(),E=x.sourceEvent.ctrlKey&&be()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*f,S=w[2]*Math.pow(2,N*E);e.scaleTo(S)};let y=[0,0];const p=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(y=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},m=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!e)return;const E=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[E[0]-y[0],E[1]-y[1]];y=E;const S=r()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*S,y:w[1]-N[1]*S},T=[[0,0],[l,c]];e.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},T,a)},v=fi().on("start",p).on("zoom",u?m:null).on("zoom.wheel",d?g:null);o.call(v,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:dt}}const dn=t=>({x:t.x,y:t.y,zoom:t.k}),Sn=({x:t,y:e,zoom:n})=>ln.translate(t,e).scale(n),Xt=(t,e)=>t.target.closest(`.${e}`),Ri=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Qf=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Mn=(t,e=0,n=Qf,r=()=>{})=>{const o=typeof e=="number"&&e>0;return o||r(),o?t.transition().duration(e).ease(n).on("end",r):t},Hi=t=>{const e=t.ctrlKey&&be()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};function Jf({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return f=>{if(Xt(f,e))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&s){const p=dt(f),m=Hi(f),v=u*Math.pow(2,m);r.scaleTo(n,v,p,f);return}const d=f.deltaMode===1?20:1;let h=o===Dt.Vertical?0:f.deltaX*d,g=o===Dt.Horizontal?0:f.deltaY*d;!be()&&f.shiftKey&&o!==Dt.Vertical&&(h=f.deltaY*d,g=0),r.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=dn(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?(l==null||l(f,y),t.panScrollTimeout=setTimeout(()=>{c==null||c(f,y),t.isPanScrolling=!1},150)):(t.isPanScrolling=!0,a==null||a(f,y))}}function td({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!e&&i&&!r.ctrlKey,a=Xt(r,t);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function ed({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=dn(r.transform);t.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&e(!0),n&&(n==null||n(r.sourceEvent,o))}}function nd({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;t.usedRightMouseButton=!!(n&&Ri(e,t.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,dn(i.transform)))}}function rd({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(t.isZoomingOrPanning=!1,i&&Ri(e,t.mouseButton??0)&&!t.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),t.usedRightMouseButton=!1,r(!1),o)){const l=dn(s.transform);t.prevViewport=l,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,l)},n?150:0)}}}function od({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:f}){return u=>{var p;const d=t||e,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Xt(u,`${c}-flow__node`)||Xt(u,`${c}-flow__edge`)))return!0;if(!r&&!d&&!o&&!i&&!n||s||f&&!g||Xt(u,a)&&g||Xt(u,l)&&(!g||o&&g&&!t)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((p=u.touches)==null?void 0:p.length)>1)return u.preventDefault(),!1;if(!d&&!o&&!h&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function id({domNode:t,minZoom:e,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=t.getBoundingClientRect(),u=fi().scaleExtent([e,n]).translateExtent(r),d=ut(t).call(u);v({x:o.x,y:o.y,zoom:Qt(o.zoom,e,n)},[[0,0],[f.width,f.height]],r);const h=d.on("wheel.zoom"),g=d.on("dblclick.zoom");u.wheelDelta(Hi);function y(k,L){return d?new Promise(H=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?de:Ye).transform(Mn(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function p({noWheelClassName:k,noPanClassName:L,onPaneContextMenu:H,userSelectionActive:_,panOnScroll:$,panOnDrag:C,panOnScrollMode:z,panOnScrollSpeed:A,preventScrolling:M,zoomOnPinch:D,zoomOnScroll:V,zoomOnDoubleClick:R,zoomActivationKeyPressed:X,lib:Y,onTransformChange:W,connectionInProgress:q,paneClickDistance:F,selectionOnDrag:B}){_&&!c.isZoomingOrPanning&&m();const O=$&&!X&&!_;u.clickDistance(B?1/0:!gt(F)||F<0?0:F);const Z=O?Jf({zoomPanValues:c,noWheelClassName:k,d3Selection:d,d3Zoom:u,panOnScrollMode:z,panOnScrollSpeed:A,zoomOnPinch:D,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):td({noWheelClassName:k,preventScrolling:M,d3ZoomHandler:h});if(d.on("wheel.zoom",Z,{passive:!1}),!_){const K=ed({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",K);const U=nd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:W});u.on("zoom",U);const et=rd({zoomPanValues:c,panOnDrag:C,panOnScroll:$,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:l});u.on("end",et)}const Q=od({zoomActivationKeyPressed:X,panOnDrag:C,zoomOnScroll:V,panOnScroll:$,zoomOnDoubleClick:R,zoomOnPinch:D,userSelectionActive:_,noPanClassName:L,noWheelClassName:k,lib:Y,connectionInProgress:q});u.filter(Q),R?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function v(k,L,H){const _=Sn(k),$=u==null?void 0:u.constrain()(_,L,H);return $&&await y($),new Promise(C=>C($))}async function x(k,L){const H=Sn(k);return await y(H,L),new Promise(_=>_(H))}function w(k){if(d){const L=Sn(k),H=d.property("__zoom");(H.k!==k.zoom||H.x!==k.x||H.y!==k.y)&&(u==null||u.transform(d,L,null,{sync:!0}))}}function E(){const k=d?ui(d.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function N(k,L){return d?new Promise(H=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?de:Ye).scaleTo(Mn(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function S(k,L){return d?new Promise(H=>{u==null||u.interpolate((L==null?void 0:L.interpolate)==="linear"?de:Ye).scaleBy(Mn(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function I(k){u==null||u.scaleExtent(k)}function T(k){u==null||u.translateExtent(k)}function j(k){const L=!gt(k)||k<0?0:k;u==null||u.clickDistance(L)}return{update:p,destroy:m,setViewport:x,setViewportConstrained:v,getViewport:E,scaleTo:N,scaleBy:S,setScaleExtent:I,setTranslateExtent:T,syncViewport:w,setClickDistance:j}}var ee;(function(t){t.Line="line",t.Handle="handle"})(ee||(ee={}));function sd({width:t,prevWidth:e,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=t-e,a=n-r,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Qr(t){const e=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),r=t.includes("left"),o=t.includes("top");return{isHorizontal:e,isVertical:n,affectsX:r,affectsY:o}}function kt(t,e){return Math.max(0,e-t)}function It(t,e){return Math.max(0,t-e)}function He(t,e,n){return Math.max(0,e-t,t-n)}function Jr(t,e){return t?!e:e}function ad(t,e,n,r,o,i,s,a){let{affectsX:l,affectsY:c}=e;const{isHorizontal:f,isVertical:u}=e,d=f&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:p,minHeight:m,maxHeight:v}=r,{x,y:w,width:E,height:N,aspectRatio:S}=t;let I=Math.floor(f?h-t.pointerX:0),T=Math.floor(u?g-t.pointerY:0);const j=E+(l?-I:I),k=N+(c?-T:T),L=-i[0]*E,H=-i[1]*N;let _=He(j,y,p),$=He(k,m,v);if(s){let A=0,M=0;l&&I<0?A=kt(x+I+L,s[0][0]):!l&&I>0&&(A=It(x+j+L,s[1][0])),c&&T<0?M=kt(w+T+H,s[0][1]):!c&&T>0&&(M=It(w+k+H,s[1][1])),_=Math.max(_,A),$=Math.max($,M)}if(a){let A=0,M=0;l&&I>0?A=It(x+I,a[0][0]):!l&&I<0&&(A=kt(x+j,a[1][0])),c&&T>0?M=It(w+T,a[0][1]):!c&&T<0&&(M=kt(w+k,a[1][1])),_=Math.max(_,A),$=Math.max($,M)}if(o){if(f){const A=He(j/S,m,v)*S;if(_=Math.max(_,A),s){let M=0;!l&&!c||l&&!c&&d?M=It(w+H+j/S,s[1][1])*S:M=kt(w+H+(l?I:-I)/S,s[0][1])*S,_=Math.max(_,M)}if(a){let M=0;!l&&!c||l&&!c&&d?M=kt(w+j/S,a[1][1])*S:M=It(w+(l?I:-I)/S,a[0][1])*S,_=Math.max(_,M)}}if(u){const A=He(k*S,y,p)/S;if($=Math.max($,A),s){let M=0;!l&&!c||c&&!l&&d?M=It(x+k*S+L,s[1][0])/S:M=kt(x+(c?T:-T)*S+L,s[0][0])/S,$=Math.max($,M)}if(a){let M=0;!l&&!c||c&&!l&&d?M=kt(x+k*S,a[1][0])/S:M=It(x+(c?T:-T)*S,a[0][0])/S,$=Math.max($,M)}}}T=T+(T<0?$:-$),I=I+(I<0?_:-_),o&&(d?j>k*S?T=(Jr(l,c)?-I:I)/S:I=(Jr(l,c)?-T:T)*S:f?(T=I/S,c=l):(I=T*S,l=c));const C=l?x+I:x,z=c?w+T:w;return{width:E+(l?-I:I),height:N+(c?-T:T),x:i[0]*I*(l?-1:1)+C,y:i[1]*T*(c?-1:1)+z}}const Vi={width:0,height:0,x:0,y:0},cd={...Vi,pointerX:0,pointerY:0,aspectRatio:1};function ld(t){return[[0,0],[t.measured.width,t.measured.height]]}function ud(t,e,n){const r=e.position.x+t.position.x,o=e.position.y+t.position.y,i=t.measured.width??0,s=t.measured.height??0,a=n[0]*i,l=n[1]*s;return[[r-a,o-l],[r+i-a,o+s-l]]}function fd({domNode:t,nodeId:e,getStoreItems:n,onChange:r,onEnd:o}){const i=ut(t);let s={controlDirection:Qr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:f,keepAspectRatio:u,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:p}){let m={...Vi},v={...cd};s={boundaries:f,resizeDirection:d,keepAspectRatio:u,controlDirection:Qr(c)};let x,w=null,E=[],N,S,I,T=!1;const j=Ko().on("start",k=>{const{nodeLookup:L,transform:H,snapGrid:_,snapToGrid:$,nodeOrigin:C,paneDomNode:z}=n();if(x=L.get(e),!x)return;w=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:M}=he(k.sourceEvent,{transform:H,snapGrid:_,snapToGrid:$,containerBounds:w});m={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...m,pointerX:A,pointerY:M,aspectRatio:m.width/m.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=L.get(x.parentId),S=N&&x.extent==="parent"?ld(N):void 0),E=[],I=void 0;for(const[D,V]of L)if(V.parentId===e&&(E.push({id:D,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const R=ud(V,x,V.origin??C);I?I=[[Math.min(R[0][0],I[0][0]),Math.min(R[0][1],I[0][1])],[Math.max(R[1][0],I[1][0]),Math.max(R[1][1],I[1][1])]]:I=R}h==null||h(k,{...m})}).on("drag",k=>{const{transform:L,snapGrid:H,snapToGrid:_,nodeOrigin:$}=n(),C=he(k.sourceEvent,{transform:L,snapGrid:H,snapToGrid:_,containerBounds:w}),z=[];if(!x)return;const{x:A,y:M,width:D,height:V}=m,R={},X=x.origin??$,{width:Y,height:W,x:q,y:F}=ad(v,s.controlDirection,C,s.boundaries,s.keepAspectRatio,X,S,I),B=Y!==D,O=W!==V,Z=q!==A&&B,Q=F!==M&&O;if(!Z&&!Q&&!B&&!O)return;if((Z||Q||X[0]===1||X[1]===1)&&(R.x=Z?q:m.x,R.y=Q?F:m.y,m.x=R.x,m.y=R.y,E.length>0)){const nt=q-A,tt=F-M;for(const st of E)st.position={x:st.position.x-nt+X[0]*(Y-D),y:st.position.y-tt+X[1]*(W-V)},z.push(st)}if((B||O)&&(R.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,R.height=O&&(!s.resizeDirection||s.resizeDirection==="vertical")?W:m.height,m.width=R.width,m.height=R.height),N&&x.expandParent){const nt=X[0]*(R.width??0);R.x&&R.x<nt&&(m.x=nt,v.x=v.x-(R.x-nt));const tt=X[1]*(R.height??0);R.y&&R.y<tt&&(m.y=tt,v.y=v.y-(R.y-tt))}const K=sd({width:m.width,prevWidth:D,height:m.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:K};(p==null?void 0:p(k,U))!==!1&&(T=!0,g==null||g(k,U),r(R,z))}).on("end",k=>{T&&(y==null||y(k,{...m}),o==null||o({...m}),T=!1)});i.call(j)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var Cn={exports:{}},kn={},In={exports:{}},An={};/**
|
|
1
|
+
import{h as ka,i as Lo,k as Ia,R as Aa,r as P,j as b,d as $a,a as Pa,L as Do}from"./index-eK0wMkUR.js";ka();function it(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=it(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var Ta={value:()=>{}};function Ne(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Xe(n)}function Xe(t){this._=t}function za(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Xe.prototype=Ne.prototype={constructor:Xe,on:function(t,e){var n=this._,r=za(t+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(t=r[i]).type)&&(o=ja(n[o],t.name)))return o;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<s;)if(o=(t=r[i]).type)n[o]=_r(n[o],t.name,e);else if(e==null)for(o in n)n[o]=_r(n[o],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Xe(t)},call:function(t,e){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],r=0,o=i.length;r<o;++r)i[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],o=0,i=r.length;o<i;++o)r[o].value.apply(e,n)}};function ja(t,e){for(var n=0,r=t.length,o;n<r;++n)if((o=t[n]).name===e)return o.value}function _r(t,e,n){for(var r=0,o=t.length;r<o;++r)if(t[r].name===e){t[r]=Ta,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Tn="http://www.w3.org/1999/xhtml";const Nr={svg:"http://www.w3.org/2000/svg",xhtml:Tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sn(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Nr.hasOwnProperty(e)?{space:Nr[e],local:t}:t}function La(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Tn&&e.documentElement.namespaceURI===Tn?e.createElement(t):e.createElementNS(n,t)}}function Da(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ro(t){var e=sn(t);return(e.local?Da:La)(e)}function Ra(){}function qn(t){return t==null?Ra:function(){return this.querySelector(t)}}function Ha(t){typeof t!="function"&&(t=qn(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=new Array(s),l,c,f=0;f<s;++f)(l=i[f])&&(c=t.call(l,l.__data__,f,i))&&("__data__"in l&&(c.__data__=l.__data__),a[f]=c);return new ft(r,this._parents)}function Va(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Ba(){return[]}function Ho(t){return t==null?Ba:function(){return this.querySelectorAll(t)}}function Fa(t){return function(){return Va(t.apply(this,arguments))}}function Oa(t){typeof t=="function"?t=Fa(t):t=Ho(t);for(var e=this._groups,n=e.length,r=[],o=[],i=0;i<n;++i)for(var s=e[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(r.push(t.call(l,l.__data__,c,s)),o.push(l));return new ft(r,o)}function Vo(t){return function(){return this.matches(t)}}function Bo(t){return function(e){return e.matches(t)}}var Xa=Array.prototype.find;function Ya(t){return function(){return Xa.call(this.children,t)}}function Wa(){return this.firstElementChild}function Ga(t){return this.select(t==null?Wa:Ya(typeof t=="function"?t:Bo(t)))}var qa=Array.prototype.filter;function Ua(){return Array.from(this.children)}function Za(t){return function(){return qa.call(this.children,t)}}function Ka(t){return this.selectAll(t==null?Ua:Za(typeof t=="function"?t:Bo(t)))}function Qa(t){typeof t!="function"&&(t=Vo(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&a.push(l);return new ft(r,this._parents)}function Fo(t){return new Array(t.length)}function Ja(){return new ft(this._enter||this._groups.map(Fo),this._parents)}function Ue(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Ue.prototype={constructor:Ue,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function tc(t){return function(){return t}}function ec(t,e,n,r,o,i){for(var s=0,a,l=e.length,c=i.length;s<c;++s)(a=e[s])?(a.__data__=i[s],r[s]=a):n[s]=new Ue(t,i[s]);for(;s<l;++s)(a=e[s])&&(o[s]=a)}function nc(t,e,n,r,o,i,s){var a,l,c=new Map,f=e.length,u=i.length,d=new Array(f),h;for(a=0;a<f;++a)(l=e[a])&&(d[a]=h=s.call(l,l.__data__,a,e)+"",c.has(h)?o[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(t,i[a],a,i)+"",(l=c.get(h))?(r[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ue(t,i[a]);for(a=0;a<f;++a)(l=e[a])&&c.get(d[a])===l&&(o[a]=l)}function rc(t){return t.__data__}function oc(t,e){if(!arguments.length)return Array.from(this,rc);var n=e?nc:ec,r=this._parents,o=this._groups;typeof t!="function"&&(t=tc(t));for(var i=o.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var f=r[c],u=o[c],d=u.length,h=ic(t.call(f,f&&f.__data__,c,r)),g=h.length,y=a[c]=new Array(g),p=s[c]=new Array(g),m=l[c]=new Array(d);n(f,u,y,p,m,h,e);for(var v=0,x=0,w,E;v<g;++v)if(w=y[v]){for(v>=x&&(x=v+1);!(E=p[x])&&++x<g;);w._next=E||null}}return s=new ft(s,r),s._enter=a,s._exit=l,s}function ic(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function sc(){return new ft(this._exit||this._groups.map(Fo),this._parents)}function ac(t,e,n){var r=this.enter(),o=this,i=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function cc(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),l=0;l<s;++l)for(var c=n[l],f=r[l],u=c.length,d=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||f[g])&&(d[g]=h);for(;l<o;++l)a[l]=n[l];return new ft(a,this._parents)}function lc(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function uc(t){t||(t=fc);function e(u,d){return u&&d?t(u.__data__,d.__data__):!u-!d}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,l=o[i]=new Array(a),c,f=0;f<a;++f)(c=s[f])&&(l[f]=c);l.sort(e)}return new ft(o,this._parents).order()}function fc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function dc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function hc(){return Array.from(this)}function gc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function pc(){let t=0;for(const e of this)++t;return t}function mc(){return!this.node()}function yc(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var o=e[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&t.call(a,a.__data__,i,o);return this}function xc(t){return function(){this.removeAttribute(t)}}function wc(t){return function(){this.removeAttributeNS(t.space,t.local)}}function vc(t,e){return function(){this.setAttribute(t,e)}}function bc(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function _c(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Nc(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Ec(t,e){var n=sn(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?wc:xc:typeof e=="function"?n.local?Nc:_c:n.local?bc:vc)(n,e))}function Oo(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Sc(t){return function(){this.style.removeProperty(t)}}function Mc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Cc(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function kc(t,e,n){return arguments.length>1?this.each((e==null?Sc:typeof e=="function"?Cc:Mc)(t,e,n??"")):qt(this.node(),t)}function qt(t,e){return t.style.getPropertyValue(e)||Oo(t).getComputedStyle(t,null).getPropertyValue(e)}function Ic(t){return function(){delete this[t]}}function Ac(t,e){return function(){this[t]=e}}function $c(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Pc(t,e){return arguments.length>1?this.each((e==null?Ic:typeof e=="function"?$c:Ac)(t,e)):this.node()[t]}function Xo(t){return t.trim().split(/^|\s+/)}function Un(t){return t.classList||new Yo(t)}function Yo(t){this._node=t,this._names=Xo(t.getAttribute("class")||"")}Yo.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Wo(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.add(e[r])}function Go(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.remove(e[r])}function Tc(t){return function(){Wo(this,t)}}function zc(t){return function(){Go(this,t)}}function jc(t,e){return function(){(e.apply(this,arguments)?Wo:Go)(this,t)}}function Lc(t,e){var n=Xo(t+"");if(arguments.length<2){for(var r=Un(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof e=="function"?jc:e?Tc:zc)(n,e))}function Dc(){this.textContent=""}function Rc(t){return function(){this.textContent=t}}function Hc(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Vc(t){return arguments.length?this.each(t==null?Dc:(typeof t=="function"?Hc:Rc)(t)):this.node().textContent}function Bc(){this.innerHTML=""}function Fc(t){return function(){this.innerHTML=t}}function Oc(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Xc(t){return arguments.length?this.each(t==null?Bc:(typeof t=="function"?Oc:Fc)(t)):this.node().innerHTML}function Yc(){this.nextSibling&&this.parentNode.appendChild(this)}function Wc(){return this.each(Yc)}function Gc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qc(){return this.each(Gc)}function Uc(t){var e=typeof t=="function"?t:Ro(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Zc(){return null}function Kc(t,e){var n=typeof t=="function"?t:Ro(t),r=e==null?Zc:typeof e=="function"?e:qn(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Qc(){var t=this.parentNode;t&&t.removeChild(this)}function Jc(){return this.each(Qc)}function tl(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function el(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function nl(t){return this.select(t?el:tl)}function rl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function ol(t){return function(e){t.call(this,e,this.__data__)}}function il(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function sl(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,o=e.length,i;n<o;++n)i=e[n],(!t.type||i.type===t.type)&&i.name===t.name?this.removeEventListener(i.type,i.listener,i.options):e[++r]=i;++r?e.length=r:delete this.__on}}}function al(t,e,n){return function(){var r=this.__on,o,i=ol(e);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=e;return}}this.addEventListener(t.type,i,n),o={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(o):this.__on=[o]}}function cl(t,e,n){var r=il(t+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,f;l<c;++l)for(o=0,f=a[l];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(a=e?al:sl,o=0;o<i;++o)this.each(a(r[o],e,n));return this}function qo(t,e,n){var r=Oo(t),o=r.CustomEvent;typeof o=="function"?o=new o(e,n):(o=r.document.createEvent("Event"),n?(o.initEvent(e,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function ll(t,e){return function(){return qo(this,t,e)}}function ul(t,e){return function(){return qo(this,t,e.apply(this,arguments))}}function fl(t,e){return this.each((typeof e=="function"?ul:ll)(t,e))}function*dl(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Uo=[null];function ft(t,e){this._groups=t,this._parents=e}function Ee(){return new ft([[document.documentElement]],Uo)}function hl(){return this}ft.prototype=Ee.prototype={constructor:ft,select:Ha,selectAll:Oa,selectChild:Ga,selectChildren:Ka,filter:Qa,data:oc,enter:Ja,exit:sc,join:ac,merge:cc,selection:hl,order:lc,sort:uc,call:dc,nodes:hc,node:gc,size:pc,empty:mc,each:yc,attr:Ec,style:kc,property:Pc,classed:Lc,text:Vc,html:Xc,raise:Wc,lower:qc,append:Uc,insert:Kc,remove:Jc,clone:nl,datum:rl,on:cl,dispatch:fl,[Symbol.iterator]:dl};function ut(t){return typeof t=="string"?new ft([[document.querySelector(t)]],[document.documentElement]):new ft([[t]],Uo)}function gl(t){let e;for(;e=t.sourceEvent;)t=e;return t}function dt(t,e){if(t=gl(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[t.clientX-o.left-e.clientLeft,t.clientY-o.top-e.clientTop]}}return[t.pageX,t.pageY]}const pl={passive:!1},ge={capture:!0,passive:!1};function vn(t){t.stopImmediatePropagation()}function Wt(t){t.preventDefault(),t.stopImmediatePropagation()}function Zo(t){var e=t.document.documentElement,n=ut(t).on("dragstart.drag",Wt,ge);"onselectstart"in e?n.on("selectstart.drag",Wt,ge):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Ko(t,e){var n=t.document.documentElement,r=ut(t).on("dragstart.drag",null);e&&(r.on("click.drag",Wt,ge),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Te=t=>()=>t;function zn(t,{sourceEvent:e,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:l,dy:c,dispatch:f}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}zn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ml(t){return!t.ctrlKey&&!t.button}function yl(){return this.parentNode}function xl(t,e){return e??{x:t.x,y:t.y}}function wl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qo(){var t=ml,e=yl,n=xl,r=wl,o={},i=Ne("start","drag","end"),s=0,a,l,c,f,u=0;function d(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",p).on("touchmove.drag",m,pl).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,E){if(!(f||!t.call(this,w,E))){var N=x(this,e.call(this,w,E),w,E,"mouse");N&&(ut(w.view).on("mousemove.drag",g,ge).on("mouseup.drag",y,ge),Zo(w.view),vn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Wt(w),!c){var E=w.clientX-a,N=w.clientY-l;c=E*E+N*N>u}o.mouse("drag",w)}function y(w){ut(w.view).on("mousemove.drag mouseup.drag",null),Ko(w.view,c),Wt(w),o.mouse("end",w)}function p(w,E){if(t.call(this,w,E)){var N=w.changedTouches,S=e.call(this,w,E),I=N.length,T,D;for(T=0;T<I;++T)(D=x(this,S,w,E,N[T].identifier,N[T]))&&(vn(w),D("start",w,N[T]))}}function m(w){var E=w.changedTouches,N=E.length,S,I;for(S=0;S<N;++S)(I=o[E[S].identifier])&&(Wt(w),I("drag",w,E[S]))}function v(w){var E=w.changedTouches,N=E.length,S,I;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),S=0;S<N;++S)(I=o[E[S].identifier])&&(vn(w),I("end",w,E[S]))}function x(w,E,N,S,I,T){var D=i.copy(),k=dt(T||N,E),j,H,_;if((_=n.call(w,new zn("beforestart",{sourceEvent:N,target:d,identifier:I,active:s,x:k[0],y:k[1],dx:0,dy:0,dispatch:D}),S))!=null)return j=_.x-k[0]||0,H=_.y-k[1]||0,function $(C,z,A){var M=k,L;switch(C){case"start":o[I]=$,L=s++;break;case"end":delete o[I],--s;case"drag":k=dt(A||z,E),L=s;break}D.call(C,w,new zn(C,{sourceEvent:z,subject:_,target:d,identifier:I,active:L,x:k[0]+j,y:k[1]+H,dx:k[0]-M[0],dy:k[1]-M[1],dispatch:D}),S)}}return d.filter=function(w){return arguments.length?(t=typeof w=="function"?w:Te(!!w),d):t},d.container=function(w){return arguments.length?(e=typeof w=="function"?w:Te(w),d):e},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Te(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Te(!!w),d):r},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,d):Math.sqrt(u)},d}function Zn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Jo(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Se(){}var pe=.7,Ze=1/pe,Gt="\\s*([+-]?\\d+)\\s*",me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vl=/^#([0-9a-f]{3,8})$/,bl=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),_l=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),Nl=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${me}\\)$`),El=new RegExp(`^rgba\\(${xt},${xt},${xt},${me}\\)$`),Sl=new RegExp(`^hsl\\(${me},${xt},${xt}\\)$`),Ml=new RegExp(`^hsla\\(${me},${xt},${xt},${me}\\)$`),Er={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Zn(Se,Rt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Sr,formatHex:Sr,formatHex8:Cl,formatHsl:kl,formatRgb:Mr,toString:Mr});function Sr(){return this.rgb().formatHex()}function Cl(){return this.rgb().formatHex8()}function kl(){return ti(this).formatHsl()}function Mr(){return this.rgb().formatRgb()}function Rt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=vl.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Cr(e):n===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ze(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ze(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=bl.exec(t))?new lt(e[1],e[2],e[3],1):(e=_l.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Nl.exec(t))?ze(e[1],e[2],e[3],e[4]):(e=El.exec(t))?ze(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Sl.exec(t))?Ar(e[1],e[2]/100,e[3]/100,1):(e=Ml.exec(t))?Ar(e[1],e[2]/100,e[3]/100,e[4]):Er.hasOwnProperty(t)?Cr(Er[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function Cr(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function ze(t,e,n,r){return r<=0&&(t=e=n=NaN),new lt(t,e,n,r)}function Il(t){return t instanceof Se||(t=Rt(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function jn(t,e,n,r){return arguments.length===1?Il(t):new lt(t,e,n,r??1)}function lt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Zn(lt,jn,Jo(Se,{brighter(t){return t=t==null?Ze:Math.pow(Ze,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?pe:Math.pow(pe,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(jt(this.r),jt(this.g),jt(this.b),Ke(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:kr,formatHex:kr,formatHex8:Al,formatRgb:Ir,toString:Ir}));function kr(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function Al(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ir(){const t=Ke(this.opacity);return`${t===1?"rgb(":"rgba("}${jt(this.r)}, ${jt(this.g)}, ${jt(this.b)}${t===1?")":`, ${t})`}`}function Ke(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function jt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function zt(t){return t=jt(t),(t<16?"0":"")+t.toString(16)}function Ar(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ht(t,e,n,r)}function ti(t){if(t instanceof ht)return new ht(t.h,t.s,t.l,t.opacity);if(t instanceof Se||(t=Rt(t)),!t)return new ht;if(t instanceof ht)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,o=Math.min(e,n,r),i=Math.max(e,n,r),s=NaN,a=i-o,l=(i+o)/2;return a?(e===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-e)/a+2:s=(e-n)/a+4,a/=l<.5?i+o:2-i-o,s*=60):a=l>0&&l<1?0:s,new ht(s,a,l,t.opacity)}function $l(t,e,n,r){return arguments.length===1?ti(t):new ht(t,e,n,r??1)}function ht(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Zn(ht,$l,Jo(Se,{brighter(t){return t=t==null?Ze:Math.pow(Ze,t),new ht(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?pe:Math.pow(pe,t),new ht(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,o=2*n-r;return new lt(bn(t>=240?t-240:t+120,o,r),bn(t,o,r),bn(t<120?t+240:t-120,o,r),this.opacity)},clamp(){return new ht($r(this.h),je(this.s),je(this.l),Ke(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Ke(this.opacity);return`${t===1?"hsl(":"hsla("}${$r(this.h)}, ${je(this.s)*100}%, ${je(this.l)*100}%${t===1?")":`, ${t})`}`}}));function $r(t){return t=(t||0)%360,t<0?t+360:t}function je(t){return Math.max(0,Math.min(1,t||0))}function bn(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Kn=t=>()=>t;function Pl(t,e){return function(n){return t+n*e}}function Tl(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function zl(t){return(t=+t)==1?ei:function(e,n){return n-e?Tl(e,n,t):Kn(isNaN(e)?n:e)}}function ei(t,e){var n=e-t;return n?Pl(t,n):Kn(isNaN(t)?e:t)}const Qe=(function t(e){var n=zl(e);function r(o,i){var s=n((o=jn(o)).r,(i=jn(i)).r),a=n(o.g,i.g),l=n(o.b,i.b),c=ei(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=a(f),o.b=l(f),o.opacity=c(f),o+""}}return r.gamma=t,r})(1);function jl(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=t[o]*(1-i)+e[o]*i;return r}}function Ll(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Dl(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=de(t[s],e[s]);for(;s<n;++s)i[s]=e[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function Rl(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function yt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Hl(t,e){var n={},r={},o;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(o in e)o in t?n[o]=de(t[o],e[o]):r[o]=e[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Ln=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_n=new RegExp(Ln.source,"g");function Vl(t){return function(){return t}}function Bl(t){return function(e){return t(e)+""}}function ni(t,e){var n=Ln.lastIndex=_n.lastIndex=0,r,o,i,s=-1,a=[],l=[];for(t=t+"",e=e+"";(r=Ln.exec(t))&&(o=_n.exec(e));)(i=o.index)>n&&(i=e.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,l.push({i:s,x:yt(r,o)})),n=_n.lastIndex;return n<e.length&&(i=e.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Bl(l[0].x):Vl(e):(e=l.length,function(c){for(var f=0,u;f<e;++f)a[(u=l[f]).i]=u.x(c);return a.join("")})}function de(t,e){var n=typeof e,r;return e==null||n==="boolean"?Kn(e):(n==="number"?yt:n==="string"?(r=Rt(e))?(e=r,Qe):ni:e instanceof Rt?Qe:e instanceof Date?Rl:Ll(e)?jl:Array.isArray(e)?Dl:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Hl:yt)(t,e)}var Pr=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ri(t,e,n,r,o,i){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(e,t)*Pr,skewX:Math.atan(l)*Pr,scaleX:s,scaleY:a}}var Le;function Fl(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Dn:ri(e.a,e.b,e.c,e.d,e.e,e.f)}function Ol(t){return t==null||(Le||(Le=document.createElementNS("http://www.w3.org/2000/svg","g")),Le.setAttribute("transform",t),!(t=Le.transform.baseVal.consolidate()))?Dn:(t=t.matrix,ri(t.a,t.b,t.c,t.d,t.e,t.f))}function oi(t,e,n,r){function o(c){return c.length?c.pop()+" ":""}function i(c,f,u,d,h,g){if(c!==u||f!==d){var y=h.push("translate(",null,e,null,n);g.push({i:y-4,x:yt(c,u)},{i:y-2,x:yt(f,d)})}else(u||d)&&h.push("translate("+u+e+d+n)}function s(c,f,u,d){c!==f?(c-f>180?f+=360:f-c>180&&(c+=360),d.push({i:u.push(o(u)+"rotate(",null,r)-2,x:yt(c,f)})):f&&u.push(o(u)+"rotate("+f+r)}function a(c,f,u,d){c!==f?d.push({i:u.push(o(u)+"skewX(",null,r)-2,x:yt(c,f)}):f&&u.push(o(u)+"skewX("+f+r)}function l(c,f,u,d,h,g){if(c!==u||f!==d){var y=h.push(o(h)+"scale(",null,",",null,")");g.push({i:y-4,x:yt(c,u)},{i:y-2,x:yt(f,d)})}else(u!==1||d!==1)&&h.push(o(h)+"scale("+u+","+d+")")}return function(c,f){var u=[],d=[];return c=t(c),f=t(f),i(c.translateX,c.translateY,f.translateX,f.translateY,u,d),s(c.rotate,f.rotate,u,d),a(c.skewX,f.skewX,u,d),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,u,d),c=f=null,function(h){for(var g=-1,y=d.length,p;++g<y;)u[(p=d[g]).i]=p.x(h);return u.join("")}}}var Xl=oi(Fl,"px, ","px)","deg)"),Yl=oi(Ol,", ",")",")"),Wl=1e-12;function Tr(t){return((t=Math.exp(t))+1/t)/2}function Gl(t){return((t=Math.exp(t))-1/t)/2}function ql(t){return((t=Math.exp(2*t))-1)/(t+1)}const Ye=(function t(e,n,r){function o(i,s){var a=i[0],l=i[1],c=i[2],f=s[0],u=s[1],d=s[2],h=f-a,g=u-l,y=h*h+g*g,p,m;if(y<Wl)m=Math.log(d/c)/e,p=function(S){return[a+S*h,l+S*g,c*Math.exp(e*S*m)]};else{var v=Math.sqrt(y),x=(d*d-c*c+r*y)/(2*c*n*v),w=(d*d-c*c-r*y)/(2*d*n*v),E=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-E)/e,p=function(S){var I=S*m,T=Tr(E),D=c/(n*v)*(T*ql(e*I+E)-Gl(E));return[a+D*h,l+D*g,c*T/Tr(e*I+E)]}}return p.duration=m*1e3*e/Math.SQRT2,p}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return t(s,a,l)},o})(Math.SQRT2,2,4);var Ut=0,ue=0,ae=0,ii=1e3,Je,fe,tn=0,Ht=0,an=0,ye=typeof performance=="object"&&performance.now?performance:Date,si=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Qn(){return Ht||(si(Ul),Ht=ye.now()+an)}function Ul(){Ht=0}function en(){this._call=this._time=this._next=null}en.prototype=Jn.prototype={constructor:en,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Qn():+n)+(e==null?0:+e),!this._next&&fe!==this&&(fe?fe._next=this:Je=this,fe=this),this._call=t,this._time=n,Rn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rn())}};function Jn(t,e,n){var r=new en;return r.restart(t,e,n),r}function Zl(){Qn(),++Ut;for(var t=Je,e;t;)(e=Ht-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ut}function zr(){Ht=(tn=ye.now())+an,Ut=ue=0;try{Zl()}finally{Ut=0,Ql(),Ht=0}}function Kl(){var t=ye.now(),e=t-tn;e>ii&&(an-=e,tn=t)}function Ql(){for(var t,e=Je,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Je=n);fe=t,Rn(r)}function Rn(t){if(!Ut){ue&&(ue=clearTimeout(ue));var e=t-Ht;e>24?(t<1/0&&(ue=setTimeout(zr,t-ye.now()-an)),ae&&(ae=clearInterval(ae))):(ae||(tn=ye.now(),ae=setInterval(Kl,ii)),Ut=1,si(zr))}}function jr(t,e,n){var r=new en;return e=e==null?0:+e,r.restart(o=>{r.stop(),t(o+e)},e,n),r}var Jl=Ne("start","end","cancel","interrupt"),tu=[],ai=0,Lr=1,Hn=2,We=3,Dr=4,Vn=5,Ge=6;function cn(t,e,n,r,o,i){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;eu(t,n,{name:e,index:r,group:o,on:Jl,tween:tu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ai})}function tr(t,e){var n=mt(t,e);if(n.state>ai)throw new Error("too late; already scheduled");return n}function vt(t,e){var n=mt(t,e);if(n.state>We)throw new Error("too late; already running");return n}function mt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function eu(t,e,n){var r=t.__transition,o;r[e]=n,n.timer=Jn(i,0,n.time);function i(c){n.state=Lr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var f,u,d,h;if(n.state!==Lr)return l();for(f in r)if(h=r[f],h.name===n.name){if(h.state===We)return jr(s);h.state===Dr?(h.state=Ge,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete r[f]):+f<e&&(h.state=Ge,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete r[f])}if(jr(function(){n.state===We&&(n.state=Dr,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Hn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Hn){for(n.state=We,o=new Array(d=n.tween.length),f=0,u=-1;f<d;++f)(h=n.tween[f].value.call(t,t.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(c){for(var f=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Vn,1),u=-1,d=o.length;++u<d;)o[u].call(t,f);n.state===Vn&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Ge,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function qe(t,e){var n=t.__transition,r,o,i=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){i=!1;continue}o=r.state>Hn&&r.state<Vn,r.state=Ge,r.timer.stop(),r.on.call(o?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}i&&delete t.__transition}}function nu(t){return this.each(function(){qe(this,t)})}function ru(t,e){var n,r;return function(){var o=vt(this,t),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function ou(t,e,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=vt(this,t),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:e,value:n},l=0,c=o.length;l<c;++l)if(o[l].name===e){o[l]=a;break}l===c&&o.push(a)}i.tween=o}}function iu(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=mt(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===t)return s.value;return null}return this.each((e==null?ru:ou)(n,t,e))}function er(t,e,n){var r=t._id;return t.each(function(){var o=vt(this,r);(o.value||(o.value={}))[e]=n.apply(this,arguments)}),function(o){return mt(o,r).value[e]}}function ci(t,e){var n;return(typeof e=="number"?yt:e instanceof Rt?Qe:(n=Rt(e))?(e=n,Qe):ni)(t,e)}function su(t){return function(){this.removeAttribute(t)}}function au(t){return function(){this.removeAttributeNS(t.space,t.local)}}function cu(t,e,n){var r,o=n+"",i;return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function lu(t,e,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function uu(t,e,n){var r,o,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=a+"",s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a)))}}function fu(t,e,n){var r,o,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=a+"",s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a)))}}function du(t,e){var n=sn(t),r=n==="transform"?Yl:ci;return this.attrTween(t,typeof e=="function"?(n.local?fu:uu)(n,r,er(this,"attr."+t,e)):e==null?(n.local?au:su)(n):(n.local?lu:cu)(n,r,e))}function hu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function gu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function pu(t,e){var n,r;function o(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&gu(t,i)),n}return o._value=e,o}function mu(t,e){var n,r;function o(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&hu(t,i)),n}return o._value=e,o}function yu(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=sn(t);return this.tween(n,(r.local?pu:mu)(r,e))}function xu(t,e){return function(){tr(this,t).delay=+e.apply(this,arguments)}}function wu(t,e){return e=+e,function(){tr(this,t).delay=e}}function vu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?xu:wu)(e,t)):mt(this.node(),e).delay}function bu(t,e){return function(){vt(this,t).duration=+e.apply(this,arguments)}}function _u(t,e){return e=+e,function(){vt(this,t).duration=e}}function Nu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?bu:_u)(e,t)):mt(this.node(),e).duration}function Eu(t,e){if(typeof e!="function")throw new Error;return function(){vt(this,t).ease=e}}function Su(t){var e=this._id;return arguments.length?this.each(Eu(e,t)):mt(this.node(),e).ease}function Mu(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;vt(this,t).ease=n}}function Cu(t){if(typeof t!="function")throw new Error;return this.each(Mu(this._id,t))}function ku(t){typeof t!="function"&&(t=Vo(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var i=e[o],s=i.length,a=r[o]=[],l,c=0;c<s;++c)(l=i[c])&&t.call(l,l.__data__,c,i)&&a.push(l);return new St(r,this._parents,this._name,this._id)}function Iu(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var l=e[a],c=n[a],f=l.length,u=s[a]=new Array(f),d,h=0;h<f;++h)(d=l[h]||c[h])&&(u[h]=d);for(;a<r;++a)s[a]=e[a];return new St(s,this._parents,this._name,this._id)}function Au(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function $u(t,e,n){var r,o,i=Au(e)?tr:vt;return function(){var s=i(this,t),a=s.on;a!==r&&(o=(r=a).copy()).on(e,n),s.on=o}}function Pu(t,e){var n=this._id;return arguments.length<2?mt(this.node(),n).on.on(t):this.each($u(n,t,e))}function Tu(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function zu(){return this.on("end.remove",Tu(this._id))}function ju(t){var e=this._name,n=this._id;typeof t!="function"&&(t=qn(t));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],l=a.length,c=i[s]=new Array(l),f,u,d=0;d<l;++d)(f=a[d])&&(u=t.call(f,f.__data__,d,a))&&("__data__"in f&&(u.__data__=f.__data__),c[d]=u,cn(c[d],e,n,d,c,mt(f,n)));return new St(i,this._parents,e,n)}function Lu(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Ho(t));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var l=r[a],c=l.length,f,u=0;u<c;++u)if(f=l[u]){for(var d=t.call(f,f.__data__,u,l),h,g=mt(f,n),y=0,p=d.length;y<p;++y)(h=d[y])&&cn(h,e,n,y,d,g);i.push(d),s.push(f)}return new St(i,s,e,n)}var Du=Ee.prototype.constructor;function Ru(){return new Du(this._groups,this._parents)}function Hu(t,e){var n,r,o;return function(){var i=qt(this,t),s=(this.style.removeProperty(t),qt(this,t));return i===s?null:i===n&&s===r?o:o=e(n=i,r=s)}}function li(t){return function(){this.style.removeProperty(t)}}function Vu(t,e,n){var r,o=n+"",i;return function(){var s=qt(this,t);return s===o?null:s===r?i:i=e(r=s,n)}}function Bu(t,e,n){var r,o,i;return function(){var s=qt(this,t),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),qt(this,t))),s===l?null:s===r&&l===o?i:(o=l,i=e(r=s,a))}}function Fu(t,e){var n,r,o,i="style."+e,s="end."+i,a;return function(){var l=vt(this,t),c=l.on,f=l.value[i]==null?a||(a=li(e)):void 0;(c!==n||o!==f)&&(r=(n=c).copy()).on(s,o=f),l.on=r}}function Ou(t,e,n){var r=(t+="")=="transform"?Xl:ci;return e==null?this.styleTween(t,Hu(t,r)).on("end.style."+t,li(t)):typeof e=="function"?this.styleTween(t,Bu(t,r,er(this,"style."+t,e))).each(Fu(this._id,t)):this.styleTween(t,Vu(t,r,e),n).on("end.style."+t,null)}function Xu(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Yu(t,e,n){var r,o;function i(){var s=e.apply(this,arguments);return s!==o&&(r=(o=s)&&Xu(t,s,n)),r}return i._value=e,i}function Wu(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Yu(t,e,n??""))}function Gu(t){return function(){this.textContent=t}}function qu(t){return function(){var e=t(this);this.textContent=e??""}}function Uu(t){return this.tween("text",typeof t=="function"?qu(er(this,"text",t)):Gu(t==null?"":t+""))}function Zu(t){return function(e){this.textContent=t.call(this,e)}}function Ku(t){var e,n;function r(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&Zu(o)),e}return r._value=t,r}function Qu(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Ku(t))}function Ju(){for(var t=this._name,e=this._id,n=ui(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var f=mt(l,e);cn(l,t,n,c,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new St(r,this._parents,t,n)}function tf(){var t,e,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--o===0&&i()}};n.each(function(){var c=vt(this,r),f=c.on;f!==t&&(e=(t=f).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),c.on=e}),o===0&&i()})}var ef=0;function St(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function ui(){return++ef}var _t=Ee.prototype;St.prototype={constructor:St,select:ju,selectAll:Lu,selectChild:_t.selectChild,selectChildren:_t.selectChildren,filter:ku,merge:Iu,selection:Ru,transition:Ju,call:_t.call,nodes:_t.nodes,node:_t.node,size:_t.size,empty:_t.empty,each:_t.each,on:Pu,attr:du,attrTween:yu,style:Ou,styleTween:Wu,text:Uu,textTween:Qu,remove:zu,tween:iu,delay:vu,duration:Nu,ease:Su,easeVarying:Cu,end:tf,[Symbol.iterator]:_t[Symbol.iterator]};function nf(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var rf={time:null,delay:0,duration:250,ease:nf};function of(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function sf(t){var e,n;t instanceof St?(e=t._id,t=t._name):(e=ui(),(n=rf).time=Qn(),t=t==null?null:t+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&cn(l,t,e,c,s,n||of(l,e));return new St(r,this._parents,t,e)}Ee.prototype.interrupt=nu;Ee.prototype.transition=sf;const De=t=>()=>t;function af(t,{sourceEvent:e,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Nt(t,e,n){this.k=t,this.x=e,this.y=n}Nt.prototype={constructor:Nt,scale:function(t){return t===1?this:new Nt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Nt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ln=new Nt(1,0,0);fi.prototype=Nt.prototype;function fi(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ln;return t.__zoom}function Nn(t){t.stopImmediatePropagation()}function ce(t){t.preventDefault(),t.stopImmediatePropagation()}function cf(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function lf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Rr(){return this.__zoom||ln}function uf(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function ff(){return navigator.maxTouchPoints||"ontouchstart"in this}function df(t,e,n){var r=t.invertX(e[0][0])-n[0][0],o=t.invertX(e[1][0])-n[1][0],i=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function di(){var t=cf,e=lf,n=df,r=uf,o=ff,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Ye,c=Ne("start","zoom","end"),f,u,d,h=500,g=150,y=0,p=10;function m(_){_.property("__zoom",Rr).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",D).filter(o).on("touchstart.zoom",k).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(_,$,C,z){var A=_.selection?_.selection():_;A.property("__zoom",Rr),_!==A?E(_,$,C,z):A.interrupt().each(function(){N(this,arguments).event(z).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},m.scaleBy=function(_,$,C,z){m.scaleTo(_,function(){var A=this.__zoom.k,M=typeof $=="function"?$.apply(this,arguments):$;return A*M},C,z)},m.scaleTo=function(_,$,C,z){m.transform(_,function(){var A=e.apply(this,arguments),M=this.__zoom,L=C==null?w(A):typeof C=="function"?C.apply(this,arguments):C,V=M.invert(L),R=typeof $=="function"?$.apply(this,arguments):$;return n(x(v(M,R),L,V),A,s)},C,z)},m.translateBy=function(_,$,C,z){m.transform(_,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof C=="function"?C.apply(this,arguments):C),e.apply(this,arguments),s)},null,z)},m.translateTo=function(_,$,C,z,A){m.transform(_,function(){var M=e.apply(this,arguments),L=this.__zoom,V=z==null?w(M):typeof z=="function"?z.apply(this,arguments):z;return n(ln.translate(V[0],V[1]).scale(L.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof C=="function"?-C.apply(this,arguments):-C),M,s)},z,A)};function v(_,$){return $=Math.max(i[0],Math.min(i[1],$)),$===_.k?_:new Nt($,_.x,_.y)}function x(_,$,C){var z=$[0]-C[0]*_.k,A=$[1]-C[1]*_.k;return z===_.x&&A===_.y?_:new Nt(_.k,z,A)}function w(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function E(_,$,C,z){_.on("start.zoom",function(){N(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,M=arguments,L=N(A,M).event(z),V=e.apply(A,M),R=C==null?w(V):typeof C=="function"?C.apply(A,M):C,X=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=A.__zoom,W=typeof $=="function"?$.apply(A,M):$,q=l(Y.invert(R).concat(X/Y.k),W.invert(R).concat(X/W.k));return function(F){if(F===1)F=W;else{var B=q(F),O=X/B[2];F=new Nt(O,R[0]-B[0]*O,R[1]-B[1]*O)}L.zoom(null,F)}})}function N(_,$,C){return!C&&_.__zooming||new S(_,$)}function S(_,$){this.that=_,this.args=$,this.active=0,this.sourceEvent=null,this.extent=e.apply(_,$),this.taps=0}S.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,$){return this.mouse&&_!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var $=ut(this.that).datum();c.call(_,this.that,new af(_,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),$)}};function I(_,...$){if(!t.apply(this,arguments))return;var C=N(this,$).event(_),z=this.__zoom,A=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),M=dt(_);if(C.wheel)(C.mouse[0][0]!==M[0]||C.mouse[0][1]!==M[1])&&(C.mouse[1]=z.invert(C.mouse[0]=M)),clearTimeout(C.wheel);else{if(z.k===A)return;C.mouse=[M,z.invert(M)],qe(this),C.start()}ce(_),C.wheel=setTimeout(L,g),C.zoom("mouse",n(x(v(z,A),C.mouse[0],C.mouse[1]),C.extent,s));function L(){C.wheel=null,C.end()}}function T(_,...$){if(d||!t.apply(this,arguments))return;var C=_.currentTarget,z=N(this,$,!0).event(_),A=ut(_.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",X,!0),M=dt(_,C),L=_.clientX,V=_.clientY;Zo(_.view),Nn(_),z.mouse=[M,this.__zoom.invert(M)],qe(this),z.start();function R(Y){if(ce(Y),!z.moved){var W=Y.clientX-L,q=Y.clientY-V;z.moved=W*W+q*q>y}z.event(Y).zoom("mouse",n(x(z.that.__zoom,z.mouse[0]=dt(Y,C),z.mouse[1]),z.extent,s))}function X(Y){A.on("mousemove.zoom mouseup.zoom",null),Ko(Y.view,z.moved),ce(Y),z.event(Y).end()}}function D(_,...$){if(t.apply(this,arguments)){var C=this.__zoom,z=dt(_.changedTouches?_.changedTouches[0]:_,this),A=C.invert(z),M=C.k*(_.shiftKey?.5:2),L=n(x(v(C,M),z,A),e.apply(this,$),s);ce(_),a>0?ut(this).transition().duration(a).call(E,L,z,_):ut(this).call(m.transform,L,z,_)}}function k(_,...$){if(t.apply(this,arguments)){var C=_.touches,z=C.length,A=N(this,$,_.changedTouches.length===z).event(_),M,L,V,R;for(Nn(_),L=0;L<z;++L)V=C[L],R=dt(V,this),R=[R,this.__zoom.invert(R),V.identifier],A.touch0?!A.touch1&&A.touch0[2]!==R[2]&&(A.touch1=R,A.taps=0):(A.touch0=R,M=!0,A.taps=1+!!f);f&&(f=clearTimeout(f)),M&&(A.taps<2&&(u=R[0],f=setTimeout(function(){f=null},h)),qe(this),A.start())}}function j(_,...$){if(this.__zooming){var C=N(this,$).event(_),z=_.changedTouches,A=z.length,M,L,V,R;for(ce(_),M=0;M<A;++M)L=z[M],V=dt(L,this),C.touch0&&C.touch0[2]===L.identifier?C.touch0[0]=V:C.touch1&&C.touch1[2]===L.identifier&&(C.touch1[0]=V);if(L=C.that.__zoom,C.touch1){var X=C.touch0[0],Y=C.touch0[1],W=C.touch1[0],q=C.touch1[1],F=(F=W[0]-X[0])*F+(F=W[1]-X[1])*F,B=(B=q[0]-Y[0])*B+(B=q[1]-Y[1])*B;L=v(L,Math.sqrt(F/B)),V=[(X[0]+W[0])/2,(X[1]+W[1])/2],R=[(Y[0]+q[0])/2,(Y[1]+q[1])/2]}else if(C.touch0)V=C.touch0[0],R=C.touch0[1];else return;C.zoom("touch",n(x(L,V,R),C.extent,s))}}function H(_,...$){if(this.__zooming){var C=N(this,$).event(_),z=_.changedTouches,A=z.length,M,L;for(Nn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),M=0;M<A;++M)L=z[M],C.touch0&&C.touch0[2]===L.identifier?delete C.touch0:C.touch1&&C.touch1[2]===L.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(L=dt(L,this),Math.hypot(u[0]-L[0],u[1]-L[1])<p)){var V=ut(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return m.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:De(+_),m):r},m.filter=function(_){return arguments.length?(t=typeof _=="function"?_:De(!!_),m):t},m.touchable=function(_){return arguments.length?(o=typeof _=="function"?_:De(!!_),m):o},m.extent=function(_){return arguments.length?(e=typeof _=="function"?_:De([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),m):e},m.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],m):[i[0],i[1]]},m.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(_){return arguments.length?(n=_,m):n},m.duration=function(_){return arguments.length?(a=+_,m):a},m.interpolate=function(_){return arguments.length?(l=_,m):l},m.on=function(){var _=c.on.apply(c,arguments);return _===c?m:_},m.clickDistance=function(_){return arguments.length?(y=(_=+_)*_,m):Math.sqrt(y)},m.tapDistance=function(_){return arguments.length?(p=+_,m):p},m}const wt={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:t=>`Node type "${t}" 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},xe=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],hi=["Enter"," ","Escape"],gi={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Zt;(function(t){t.Strict="strict",t.Loose="loose"})(Zt||(Zt={}));var Lt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Lt||(Lt={}));var we;(function(t){t.Partial="partial",t.Full="full"})(we||(we={}));const pi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var At;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(At||(At={}));var Kt;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Kt||(Kt={}));var G;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(G||(G={}));const Hr={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top};function mi(t){return t===null?null:t?"valid":"invalid"}const yi=t=>"id"in t&&"source"in t&&"target"in t,hf=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),nr=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Me=(t,e=[0,0])=>{const{width:n,height:r}=Mt(t),o=t.origin??e,i=n*o[0],s=r*o[1];return{x:t.position.x-i,y:t.position.y-s}},gf=(t,e={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,o)=>{const i=typeof o=="string";let s=!e.nodeLookup&&!i?o:void 0;e.nodeLookup&&(s=i?e.nodeLookup.get(o):nr(o)?o:e.nodeLookup.get(o.id));const a=s?nn(s,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return un(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fn(n)},Ce=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return t.forEach(o=>{(e.filter===void 0||e.filter(o))&&(n=un(n,nn(o)),r=!0)}),r?fn(n):{x:0,y:0,width:0,height:0}},rr=(t,e,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a={...Ie(e,[n,r,o]),width:e.width/o,height:e.height/o},l=[];for(const c of t.values()){const{measured:f,selectable:u=!0,hidden:d=!1}=c;if(s&&!u||d)continue;const h=f.width??c.width??c.initialWidth??null,g=f.height??c.height??c.initialHeight??null,y=ve(a,Jt(c)),p=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=p||c.dragging)&&l.push(c)}return l},pf=(t,e)=>{const n=new Set;return t.forEach(r=>{n.add(r.id)}),e.filter(r=>n.has(r.source)||n.has(r.target))};function mf(t,e){const n=new Map,r=e!=null&&e.nodes?new Set(e.nodes.map(o=>o.id)):null;return t.forEach(o=>{o.measured.width&&o.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function yf({nodes:t,width:e,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(t.size===0)return Promise.resolve(!0);const a=mf(t,s),l=Ce(a),c=or(l,e,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(c,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function xi({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(t),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let u=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",wt.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&te(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const d=te(u)?Vt(e,u,s.measured):e;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",wt.error015())),{position:{x:d.x-l+(s.measured.width??0)*f[0],y:d.y-c+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function xf({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(t.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&s.find(y=>y.id===d.parentId);(h||g)&&s.push(d)}const a=new Set(e.map(d=>d.id)),l=r.filter(d=>d.deletable!==!1),f=pf(s,l);for(const d of l)a.has(d.id)&&!f.find(g=>g.id===d.id)&&f.push(d);if(!o)return{edges:f,nodes:s};const u=await o({nodes:s,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:s}:{edges:[],nodes:[]}:u}const Qt=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),Vt=(t={x:0,y:0},e,n)=>({x:Qt(t.x,e[0][0],e[1][0]-((n==null?void 0:n.width)??0)),y:Qt(t.y,e[0][1],e[1][1]-((n==null?void 0:n.height)??0))});function wi(t,e,n){const{width:r,height:o}=Mt(n),{x:i,y:s}=n.internals.positionAbsolute;return Vt(t,[[i,s],[i+r,s+o]],e)}const Vr=(t,e,n)=>t<e?Qt(Math.abs(t-e),1,e)/e:t>n?-Qt(Math.abs(t-n),1,e)/e:0,vi=(t,e,n=15,r=40)=>{const o=Vr(t.x,r,e.width-r)*n,i=Vr(t.y,r,e.height-r)*n;return[o,i]},un=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),Bn=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),fn=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Jt=(t,e=[0,0])=>{var o,i;const{x:n,y:r}=nr(t)?t.internals.positionAbsolute:Me(t,e);return{x:n,y:r,width:((o=t.measured)==null?void 0:o.width)??t.width??t.initialWidth??0,height:((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0}},nn=(t,e=[0,0])=>{var o,i;const{x:n,y:r}=nr(t)?t.internals.positionAbsolute:Me(t,e);return{x:n,y:r,x2:n+(((o=t.measured)==null?void 0:o.width)??t.width??t.initialWidth??0),y2:r+(((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0)}},bi=(t,e)=>fn(un(Bn(t),Bn(e))),ve=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},Br=t=>gt(t.width)&>(t.height)&>(t.x)&>(t.y),gt=t=>!isNaN(t)&&isFinite(t),wf=(t,e)=>{},ke=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),Ie=({x:t,y:e},[n,r,o],i=!1,s=[1,1])=>{const a={x:(t-n)/o,y:(e-r)/o};return i?ke(a,s):a},rn=({x:t,y:e},[n,r,o])=>({x:t*o+n,y:e*o+r});function Ot(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function vf(t,e,n){if(typeof t=="string"||typeof t=="number"){const r=Ot(t,n),o=Ot(t,e);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof t=="object"){const r=Ot(t.top??t.y??0,n),o=Ot(t.bottom??t.y??0,n),i=Ot(t.left??t.x??0,e),s=Ot(t.right??t.x??0,e);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function bf(t,e,n,r,o,i){const{x:s,y:a}=rn(t,[e,n,r]),{x:l,y:c}=rn({x:t.x+t.width,y:t.y+t.height},[e,n,r]),f=o-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(u)}}const or=(t,e,n,r,o,i)=>{const s=vf(i,e,n),a=(e-s.x)/t.width,l=(n-s.y)/t.height,c=Math.min(a,l),f=Qt(c,r,o),u=t.x+t.width/2,d=t.y+t.height/2,h=e/2-u*f,g=n/2-d*f,y=bf(t,h,g,f,e,n),p={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-p.left+p.right,y:g-p.top+p.bottom,zoom:f}},be=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function te(t){return t!=null&&t!=="parent"}function Mt(t){var e,n;return{width:((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function _i(t){var e,n;return(((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function Ni(t,e={width:0,height:0},n,r,o){const i={...t},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(e.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(e.height??0)*a[1]}return i}function Fr(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function _f(){let t,e;return{promise:new Promise((r,o)=>{t=r,e=o}),resolve:t,reject:e}}function Nf(t){return{...gi,...t||{}}}function he(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pt(t),a=Ie({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:l,y:c}=n?ke(a,e):a;return{xSnapped:l,ySnapped:c,...a}}const ir=t=>({width:t.offsetWidth,height:t.offsetHeight}),Ei=t=>{var e;return((e=t==null?void 0:t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},Ef=["INPUT","SELECT","TEXTAREA"];function Si(t){var r,o;const e=((o=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:o[0])||t.target;return(e==null?void 0:e.nodeType)!==1?!1:Ef.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}const Mi=t=>"clientX"in t,pt=(t,e)=>{var i,s;const n=Mi(t),r=n?t.clientX:(i=t.touches)==null?void 0:i[0].clientX,o=n?t.clientY:(s=t.touches)==null?void 0:s[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:o-((e==null?void 0:e.top)??0)}},Or=(t,e,n,r,o)=>{const i=e.querySelectorAll(`.${t}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:t,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ir(s)}})};function Ci({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=t*.125+o*.375+s*.375+n*.125,c=e*.125+i*.375+a*.375+r*.125,f=Math.abs(l-t),u=Math.abs(c-e);return[l,c,f,u]}function Re(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function Xr({pos:t,x1:e,y1:n,x2:r,y2:o,c:i}){switch(t){case G.Left:return[e-Re(e-r,i),n];case G.Right:return[e+Re(r-e,i),n];case G.Top:return[e,n-Re(n-o,i)];case G.Bottom:return[e,n+Re(o-n,i)]}}function ki({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,curvature:s=.25}){const[a,l]=Xr({pos:n,x1:t,y1:e,x2:r,y2:o,c:s}),[c,f]=Xr({pos:i,x1:r,y1:o,x2:t,y2:e,c:s}),[u,d,h,g]=Ci({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:f});return[`M${t},${e} C${a},${l} ${c},${f} ${r},${o}`,u,d,h,g]}function Ii({sourceX:t,sourceY:e,targetX:n,targetY:r}){const o=Math.abs(n-t)/2,i=n<t?n+o:n-o,s=Math.abs(r-e)/2,a=r<e?r+s:r-s;return[i,a,o,s]}function Sf({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(t.parentId||o&&t.selected?t.internals.z:0,e.parentId||o&&e.selected?e.internals.z:0);return s+a}function Mf({sourceNode:t,targetNode:e,width:n,height:r,transform:o}){const i=un(nn(t),nn(e));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return ve(s,fn(i))>0}const Cf=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,kf=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),If=(t,e,n={})=>{if(!t.source||!t.target)return e;const r=n.getEdgeId||Cf;let o;return yi(t)?o={...t}:o={...t,id:r(t)},kf(o,e)?e:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,e.concat(o))};function Ai({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[o,i,s,a]=Ii({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,o,i,s,a]}const Yr={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},Af=({source:t,sourcePosition:e=G.Bottom,target:n})=>e===G.Left||e===G.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},Wr=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function $f({source:t,sourcePosition:e=G.Bottom,target:n,targetPosition:r=G.Top,center:o,offset:i,stepPosition:s}){const a=Yr[e],l=Yr[r],c={x:t.x+a.x*i,y:t.y+a.y*i},f={x:n.x+l.x*i,y:n.y+l.y*i},u=Af({source:c,sourcePosition:e,target:f}),d=u.x!==0?"x":"y",h=u[d];let g=[],y,p;const m={x:0,y:0},v={x:0,y:0},[,,x,w]=Ii({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(a[d]*l[d]===-1){d==="x"?(y=o.x??c.x+(f.x-c.x)*s,p=o.y??(c.y+f.y)/2):(y=o.x??(c.x+f.x)/2,p=o.y??c.y+(f.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:f.y}],T=[{x:c.x,y:p},{x:f.x,y:p}];a[d]===h?g=d==="x"?I:T:g=d==="x"?T:I}else{const I=[{x:c.x,y:f.y}],T=[{x:f.x,y:c.y}];if(d==="x"?g=a.x===h?T:I:g=a.y===h?I:T,e===r){const _=Math.abs(t[d]-n[d]);if(_<=i){const $=Math.min(i-1,i-_);a[d]===h?m[d]=(c[d]>t[d]?-1:1)*$:v[d]=(f[d]>n[d]?-1:1)*$}}if(e!==r){const _=d==="x"?"y":"x",$=a[d]===l[_],C=c[_]>f[_],z=c[_]<f[_];(a[d]===1&&(!$&&C||$&&z)||a[d]!==1&&(!$&&z||$&&C))&&(g=d==="x"?I:T)}const D={x:c.x+m.x,y:c.y+m.y},k={x:f.x+v.x,y:f.y+v.y},j=Math.max(Math.abs(D.x-g[0].x),Math.abs(k.x-g[0].x)),H=Math.max(Math.abs(D.y-g[0].y),Math.abs(k.y-g[0].y));j>=H?(y=(D.x+k.x)/2,p=g[0].y):(y=g[0].x,p=(D.y+k.y)/2)}const E={x:c.x+m.x,y:c.y+m.y},N={x:f.x+v.x,y:f.y+v.y};return[[t,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,p,x,w]}function Pf(t,e,n,r){const o=Math.min(Wr(t,e)/2,Wr(e,n)/2,r),{x:i,y:s}=e;if(t.x===i&&i===n.x||t.y===s&&s===n.y)return`L${i} ${s}`;if(t.y===s){const c=t.x<n.x?-1:1,f=t.y<n.y?1:-1;return`L ${i+o*c},${s}Q ${i},${s} ${i},${s+o*f}`}const a=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${i},${s+o*l}Q ${i},${s} ${i+o*a},${s}`}function Fn({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:f=.5}){const[u,d,h,g,y]=$f({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:f});let p=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)p+=Pf(u[m-1],u[m],u[m+1],s);return p+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[p,d,h,g,y]}function Gr(t){var e;return t&&!!(t.internals.handleBounds||(e=t.handles)!=null&&e.length)&&!!(t.measured.width||t.width||t.initialWidth)}function Tf(t){var u;const{sourceNode:e,targetNode:n}=t;if(!Gr(e)||!Gr(n))return null;const r=e.internals.handleBounds||qr(e.handles),o=n.internals.handleBounds||qr(n.handles),i=Ur((r==null?void 0:r.source)??[],t.sourceHandle),s=Ur(t.connectionMode===Zt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),t.targetHandle);if(!i||!s)return(u=t.onError)==null||u.call(t,"008",wt.error008(i?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const a=(i==null?void 0:i.position)||G.Bottom,l=(s==null?void 0:s.position)||G.Top,c=Bt(e,i,a),f=Bt(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:l}}function qr(t){if(!t)return null;const e=[],n=[];for(const r of t)r.width=r.width??1,r.height=r.height??1,r.type==="source"?e.push(r):r.type==="target"&&n.push(r);return{source:e,target:n}}function Bt(t,e,n=G.Left,r=!1){const o=((e==null?void 0:e.x)??0)+t.internals.positionAbsolute.x,i=((e==null?void 0:e.y)??0)+t.internals.positionAbsolute.y,{width:s,height:a}=e??Mt(t);if(r)return{x:o+s/2,y:i+a/2};switch((e==null?void 0:e.position)??n){case G.Top:return{x:o+s/2,y:i};case G.Right:return{x:o+s,y:i+a/2};case G.Bottom:return{x:o+s/2,y:i+a};case G.Left:return{x:o,y:i+a/2}}}function Ur(t,e){return t&&(e?t.find(n=>n.id===e):t[0])||null}function On(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`:""}function zf(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return t.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const c=On(l,e);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const $i=1e3,jf=10,sr={nodeOrigin:[0,0],nodeExtent:xe,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Lf={...sr,checkEquality:!0};function ar(t,e){const n={...t};for(const r in e)e[r]!==void 0&&(n[r]=e[r]);return n}function Df(t,e,n){const r=ar(sr,n);for(const o of t.values())if(o.parentId)lr(o,t,e,r);else{const i=Me(o,r.nodeOrigin),s=te(o.extent)?o.extent:r.nodeExtent,a=Vt(i,s,Mt(o));o.internals.positionAbsolute=a}}function Rf(t,e){if(!t.handles)return t.measured?e==null?void 0:e.internals.handleBounds:void 0;const n=[],r=[];for(const o of t.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:t.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function cr(t){return t==="manual"}function Xn(t,e,n,r={}){var f,u;const o=ar(Lf,r),i={i:0},s=new Map(e),a=o!=null&&o.elevateNodesOnSelect&&!cr(o.zIndexMode)?$i:0;let l=t.length>0,c=!1;e.clear(),n.clear();for(const d of t){let h=s.get(d.id);if(o.checkEquality&&d===(h==null?void 0:h.internals.userNode))e.set(d.id,h);else{const g=Me(d,o.nodeOrigin),y=te(d.extent)?d.extent:o.nodeExtent,p=Vt(g,y,Mt(d));h={...o.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(u=d.measured)==null?void 0:u.height},internals:{positionAbsolute:p,handleBounds:Rf(d,h),z:Pi(d,a,o.zIndexMode),userNode:d}},e.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),d.parentId&&lr(h,e,n,r,i),c||(c=d.selected??!1)}return{nodesInitialized:l,hasSelectedNodes:c}}function Hf(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function lr(t,e,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=ar(sr,r),c=t.parentId,f=e.get(c);if(!f){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Hf(t,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&l==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*jf),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const u=i&&!cr(l)?$i:0,{x:d,y:h,z:g}=Vf(t,f,s,a,u,l),{positionAbsolute:y}=t.internals,p=d!==y.x||h!==y.y;(p||g!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:p?{x:d,y:h}:y,z:g}})}function Pi(t,e,n){const r=gt(t.zIndex)?t.zIndex:0;return cr(n)?r:r+(t.selected?e:0)}function Vf(t,e,n,r,o,i){const{x:s,y:a}=e.internals.positionAbsolute,l=Mt(t),c=Me(t,n),f=te(t.extent)?Vt(c,t.extent,l):c;let u=Vt({x:s+f.x,y:a+f.y},r,l);t.extent==="parent"&&(u=wi(u,l,e));const d=Pi(t,o,i),h=e.internals.z??0;return{x:u.x,y:u.y,z:h>=d?h+1:d}}function ur(t,e,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of t){const l=e.get(a.parentId);if(!l)continue;const c=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Jt(l),f=bi(c,a.rect);i.set(a.parentId,{expandedRect:f,parent:l})}return i.size>0&&i.forEach(({expandedRect:a,parent:l},c)=>{var x;const f=l.internals.positionAbsolute,u=Mt(l),d=l.origin??r,h=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,y=Math.max(u.width,Math.round(a.width)),p=Math.max(u.height,Math.round(a.height)),m=(y-u.width)*d[0],v=(p-u.height)*d[1];(h>0||g>0||m||v)&&(o.push({id:c,type:"position",position:{x:l.position.x-h+m,y:l.position.y-g+v}}),(x=n.get(c))==null||x.forEach(w=>{t.some(E=>E.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+g}})})),(u.width<a.width||u.height<a.height||h||g)&&o.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:y+(h?d[0]*h-m:0),height:p+(g?d[1]*g-v:0)}})}),o}function Bf(t,e,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],f=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const h of t.values()){const g=e.get(h.id);if(!g)continue;if(g.hidden){e.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const y=ir(h.nodeElement),p=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(p||!g.internals.handleBounds||h.force))){const v=h.nodeElement.getBoundingClientRect(),x=te(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=wi(w,y,e.get(g.parentId)):x&&(w=Vt(w,x,y));const E={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Or("source",h.nodeElement,v,u,g.id),target:Or("target",h.nodeElement,v,u,g.id)}}};e.set(g.id,E),g.parentId&&lr(E,e,n,{nodeOrigin:o,zIndexMode:s}),l=!0,p&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Jt(E,o)}))}}if(d.length>0){const h=ur(d,e,n,o);c.push(...h)}return{changes:c,updatedInternals:l}}async function Ff({delta:t,panZoom:e,transform:n,translateExtent:r,width:o,height:i}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);const s=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[o,i]],r),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Zr(t,e,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,e)),s=`${o}-${t}`;const l=r.get(s)||new Map;if(r.set(s,l.set(n,e)),i){s=`${o}-${t}-${i}`;const c=r.get(s)||new Map;r.set(s,c.set(n,e))}}function Ti(t,e,n){t.clear(),e.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,l={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},c=`${o}-${s}--${i}-${a}`,f=`${i}-${a}--${o}-${s}`;Zr("source",l,f,t,o,s),Zr("target",l,c,t,i,a),e.set(r.id,r)}}function zi(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return n?n.selected?!0:zi(n,e):!1}function Kr(t,e,n){var o;let r=t;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,e))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Of(t,e,n,r){const o=new Map;for(const[i,s]of t)if((s.selected||s.id===r)&&(!s.parentId||!zi(s,t))&&(s.draggable||e&&typeof s.draggable>"u")){const a=t.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function En({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){var s,a,l;const o=[];for(const[c,f]of e){const u=(s=n.get(c))==null?void 0:s.internals.userNode;u&&o.push({...u,position:f.position,dragging:r})}if(!t)return[o[0],o];const i=(a=n.get(t))==null?void 0:a.internals.userNode;return[i?{...i,position:((l=e.get(t))==null?void 0:l.position)||i.position,dragging:r}:o[0],o]}function Xf({dragItems:t,snapGrid:e,x:n,y:r}){const o=t.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=ke(i,e);return{x:s.x-i.x,y:s.y-i.y}}function Yf({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},f=null,u=!1,d=null,h=!1,g=!1,y=null;function p({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:E,nodeId:N,nodeClickDistance:S=0}){d=ut(w);function I({x:j,y:H}){const{nodeLookup:_,nodeExtent:$,snapGrid:C,snapToGrid:z,nodeOrigin:A,onNodeDrag:M,onSelectionDrag:L,onError:V,updateNodePositions:R}=e();i={x:j,y:H};let X=!1;const Y=a.size>1,W=Y&&$?Bn(Ce(a)):null,q=Y&&z?Xf({dragItems:a,snapGrid:C,x:j,y:H}):null;for(const[F,B]of a){if(!_.has(F))continue;let O={x:j-B.distance.x,y:H-B.distance.y};z&&(O=q?{x:Math.round(O.x+q.x),y:Math.round(O.y+q.y)}:ke(O,C));let Z=null;if(Y&&$&&!B.extent&&W){const{positionAbsolute:U}=B.internals,et=U.x-W.x+$[0][0],nt=U.x+B.measured.width-W.x2+$[1][0],tt=U.y-W.y+$[0][1],st=U.y+B.measured.height-W.y2+$[1][1];Z=[[et,tt],[nt,st]]}const{position:Q,positionAbsolute:K}=xi({nodeId:F,nextPosition:O,nodeLookup:_,nodeExtent:Z||$,nodeOrigin:A,onError:V});X=X||B.position.x!==Q.x||B.position.y!==Q.y,B.position=Q,B.internals.positionAbsolute=K}if(g=g||X,!!X&&(R(a,!0),y&&(r||M||!N&&L))){const[F,B]=En({nodeId:N,dragItems:a,nodeLookup:_});r==null||r(y,a,F,B),M==null||M(y,F,B),N||L==null||L(y,B)}}async function T(){if(!f)return;const{transform:j,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:$}=e();if(!$){l=!1,cancelAnimationFrame(s);return}const[C,z]=vi(c,f,_);(C!==0||z!==0)&&(i.x=(i.x??0)-C/j[2],i.y=(i.y??0)-z/j[2],await H({x:C,y:z})&&I(i)),s=requestAnimationFrame(T)}function D(j){var Y;const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:$,transform:C,snapGrid:z,snapToGrid:A,selectNodesOnDrag:M,onNodeDragStart:L,onSelectionDragStart:V,unselectNodesAndEdges:R}=e();u=!0,(!M||!E)&&!_&&N&&((Y=H.get(N))!=null&&Y.selected||R()),E&&M&&N&&(t==null||t(N));const X=he(j.sourceEvent,{transform:C,snapGrid:z,snapToGrid:A,containerBounds:f});if(i=X,a=Of(H,$,X,N),a.size>0&&(n||L||!N&&V)){const[W,q]=En({nodeId:N,dragItems:a,nodeLookup:H});n==null||n(j.sourceEvent,a,W,q),L==null||L(j.sourceEvent,W,q),N||V==null||V(j.sourceEvent,q)}}const k=Qo().clickDistance(S).on("start",j=>{const{domNode:H,nodeDragThreshold:_,transform:$,snapGrid:C,snapToGrid:z}=e();f=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,g=!1,y=j.sourceEvent,_===0&&D(j),i=he(j.sourceEvent,{transform:$,snapGrid:C,snapToGrid:z,containerBounds:f}),c=pt(j.sourceEvent,f)}).on("drag",j=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:$,snapToGrid:C,nodeDragThreshold:z,nodeLookup:A}=e(),M=he(j.sourceEvent,{transform:_,snapGrid:$,snapToGrid:C,containerBounds:f});if(y=j.sourceEvent,(j.sourceEvent.type==="touchmove"&&j.sourceEvent.touches.length>1||N&&!A.has(N))&&(h=!0),!h){if(!l&&H&&u&&(l=!0,T()),!u){const L=pt(j.sourceEvent,f),V=L.x-c.x,R=L.y-c.y;Math.sqrt(V*V+R*R)>z&&D(j)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&a&&u&&(c=pt(j.sourceEvent,f),I(M))}}).on("end",j=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:$,onSelectionDragStop:C}=e();if(g&&(_(a,!1),g=!1),o||$||!N&&C){const[z,A]=En({nodeId:N,dragItems:a,nodeLookup:H,dragging:!1});o==null||o(j.sourceEvent,a,z,A),$==null||$(j.sourceEvent,z,A),N||C==null||C(j.sourceEvent,A)}}}).filter(j=>{const H=j.target;return!j.button&&(!v||!Kr(H,`.${v}`,w))&&(!x||Kr(H,x,w))});d.call(k)}function m(){d==null||d.on(".drag",null)}return{update:p,destroy:m}}function Wf(t,e,n){const r=[],o={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const i of e.values())ve(o,Jt(i))>0&&r.push(i);return r}const Gf=250;function qf(t,e,n,r){var a,l;let o=[],i=1/0;const s=Wf(t,n,e+Gf);for(const c of s){const f=[...((a=c.internals.handleBounds)==null?void 0:a.source)??[],...((l=c.internals.handleBounds)==null?void 0:l.target)??[]];for(const u of f){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:d,y:h}=Bt(c,u,u.position,!0),g=Math.sqrt(Math.pow(d-t.x,2)+Math.pow(h-t.y,2));g>e||(g<i?(o=[{...u,x:d,y:h}],i=g):g===i&&o.push({...u,x:d,y:h}))}}if(!o.length)return null;if(o.length>1){const c=r.type==="source"?"target":"source";return o.find(f=>f.type===c)??o[0]}return o[0]}function ji(t,e,n,r,o,i=!1){var c,f,u;const s=r.get(t);if(!s)return null;const a=o==="strict"?(c=s.internals.handleBounds)==null?void 0:c[e]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((u=s.internals.handleBounds)==null?void 0:u.target)??[]],l=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return l&&i?{...l,...Bt(s,l,l.position,!0)}:l}function Li(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Uf(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}const Di=()=>!0;function Zf(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:f,flowId:u,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:p,isValidConnection:m=Di,onReconnectEnd:v,updateConnection:x,getTransform:w,getFromHandle:E,autoPanSpeed:N,dragThreshold:S=1,handleDomNode:I}){const T=Ei(t.target);let D=0,k;const{x:j,y:H}=pt(t),_=Li(i,I),$=a==null?void 0:a.getBoundingClientRect();let C=!1;if(!$||!_)return;const z=ji(o,_,r,l,e);if(!z)return;let A=pt(t,$),M=!1,L=null,V=!1,R=null;function X(){if(!f||!$)return;const[Q,K]=vi(A,$,N);d({x:Q,y:K}),D=requestAnimationFrame(X)}const Y={...z,nodeId:o,type:_,position:z.position},W=l.get(o);let F={inProgress:!0,isValid:null,from:Bt(W,Y,G.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:W,to:A,toHandle:null,toPosition:Hr[Y.position],toNode:null,pointer:A};function B(){C=!0,x(F),g==null||g(t,{nodeId:o,handleId:r,handleType:_})}S===0&&B();function O(Q){if(!C){const{x:st,y:Ct}=pt(Q),bt=st-j,Pt=Ct-H;if(!(bt*bt+Pt*Pt>S*S))return;B()}if(!E()||!Y){Z(Q);return}const K=w();A=pt(Q,$),k=qf(Ie(A,K,!1,[1,1]),n,l,Y),M||(X(),M=!0);const U=Ri(Q,{handle:k,connectionMode:e,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:T,lib:c,flowId:u,nodeLookup:l});R=U.handleDomNode,L=U.connection,V=Uf(!!k,U.isValid);const et=l.get(o),nt=et?Bt(et,Y,G.Left,!0):F.from,tt={...F,from:nt,isValid:V,to:U.toHandle&&V?rn({x:U.toHandle.x,y:U.toHandle.y},K):A,toHandle:U.toHandle,toPosition:V&&U.toHandle?U.toHandle.position:Hr[Y.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:A};x(tt),F=tt}function Z(Q){if(!("touches"in Q&&Q.touches.length>0)){if(C){(k||R)&&L&&V&&(y==null||y(L));const{inProgress:K,...U}=F,et={...U,toPosition:F.toHandle?F.toPosition:null};p==null||p(Q,et),i&&(v==null||v(Q,et))}h(),cancelAnimationFrame(D),M=!1,V=!1,L=null,R=null,T.removeEventListener("mousemove",O),T.removeEventListener("mouseup",Z),T.removeEventListener("touchmove",O),T.removeEventListener("touchend",Z)}}T.addEventListener("mousemove",O),T.addEventListener("mouseup",Z),T.addEventListener("touchmove",O),T.addEventListener("touchend",Z)}function Ri(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Di,nodeLookup:f}){const u=i==="target",d=e?s.querySelector(`.${a}-flow__handle[data-id="${l}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:h,y:g}=pt(t),y=s.elementFromPoint(h,g),p=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:d,m={handleDomNode:p,isValid:!1,connection:null,toHandle:null};if(p){const v=Li(void 0,p),x=p.getAttribute("data-nodeid"),w=p.getAttribute("data-handleid"),E=p.classList.contains("connectable"),N=p.classList.contains("connectableend");if(!x||!v)return m;const S={source:u?x:r,sourceHandle:u?w:o,target:u?r:x,targetHandle:u?o:w};m.connection=S;const T=E&&N&&(n===Zt.Strict?u&&v==="source"||!u&&v==="target":x!==r||w!==o);m.isValid=T&&c(S),m.toHandle=ji(x,v,w,f,n,!0)}return m}const Yn={onPointerDown:Zf,isValid:Ri};function Kf({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){const o=ut(t);function i({translateExtent:a,width:l,height:c,zoomStep:f=1,pannable:u=!0,zoomable:d=!0,inversePan:h=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!e)return;const w=n(),E=x.sourceEvent.ctrlKey&&be()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*f,S=w[2]*Math.pow(2,N*E);e.scaleTo(S)};let y=[0,0];const p=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(y=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},m=x=>{const w=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!e)return;const E=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[E[0]-y[0],E[1]-y[1]];y=E;const S=r()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*S,y:w[1]-N[1]*S},T=[[0,0],[l,c]];e.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},T,a)},v=di().on("start",p).on("zoom",u?m:null).on("zoom.wheel",d?g:null);o.call(v,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:dt}}const dn=t=>({x:t.x,y:t.y,zoom:t.k}),Sn=({x:t,y:e,zoom:n})=>ln.translate(t,e).scale(n),Xt=(t,e)=>t.target.closest(`.${e}`),Hi=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Qf=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Mn=(t,e=0,n=Qf,r=()=>{})=>{const o=typeof e=="number"&&e>0;return o||r(),o?t.transition().duration(e).ease(n).on("end",r):t},Vi=t=>{const e=t.ctrlKey&&be()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};function Jf({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return f=>{if(Xt(f,e))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&s){const p=dt(f),m=Vi(f),v=u*Math.pow(2,m);r.scaleTo(n,v,p,f);return}const d=f.deltaMode===1?20:1;let h=o===Lt.Vertical?0:f.deltaX*d,g=o===Lt.Horizontal?0:f.deltaY*d;!be()&&f.shiftKey&&o!==Lt.Vertical&&(h=f.deltaY*d,g=0),r.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=dn(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?(l==null||l(f,y),t.panScrollTimeout=setTimeout(()=>{c==null||c(f,y),t.isPanScrolling=!1},150)):(t.isPanScrolling=!0,a==null||a(f,y))}}function td({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!e&&i&&!r.ctrlKey,a=Xt(r,t);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function ed({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=dn(r.transform);t.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&e(!0),n&&(n==null||n(r.sourceEvent,o))}}function nd({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;t.usedRightMouseButton=!!(n&&Hi(e,t.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,dn(i.transform)))}}function rd({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(t.isZoomingOrPanning=!1,i&&Hi(e,t.mouseButton??0)&&!t.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),t.usedRightMouseButton=!1,r(!1),o)){const l=dn(s.transform);t.prevViewport=l,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,l)},n?150:0)}}}function od({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:f}){return u=>{var p;const d=t||e,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Xt(u,`${c}-flow__node`)||Xt(u,`${c}-flow__edge`)))return!0;if(!r&&!d&&!o&&!i&&!n||s||f&&!g||Xt(u,a)&&g||Xt(u,l)&&(!g||o&&g&&!t)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((p=u.touches)==null?void 0:p.length)>1)return u.preventDefault(),!1;if(!d&&!o&&!h&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function id({domNode:t,minZoom:e,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=t.getBoundingClientRect(),u=di().scaleExtent([e,n]).translateExtent(r),d=ut(t).call(u);v({x:o.x,y:o.y,zoom:Qt(o.zoom,e,n)},[[0,0],[f.width,f.height]],r);const h=d.on("wheel.zoom"),g=d.on("dblclick.zoom");u.wheelDelta(Vi);function y(k,j){return d?new Promise(H=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?de:Ye).transform(Mn(d,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function p({noWheelClassName:k,noPanClassName:j,onPaneContextMenu:H,userSelectionActive:_,panOnScroll:$,panOnDrag:C,panOnScrollMode:z,panOnScrollSpeed:A,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:V,zoomOnDoubleClick:R,zoomActivationKeyPressed:X,lib:Y,onTransformChange:W,connectionInProgress:q,paneClickDistance:F,selectionOnDrag:B}){_&&!c.isZoomingOrPanning&&m();const O=$&&!X&&!_;u.clickDistance(B?1/0:!gt(F)||F<0?0:F);const Z=O?Jf({zoomPanValues:c,noWheelClassName:k,d3Selection:d,d3Zoom:u,panOnScrollMode:z,panOnScrollSpeed:A,zoomOnPinch:L,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):td({noWheelClassName:k,preventScrolling:M,d3ZoomHandler:h});if(d.on("wheel.zoom",Z,{passive:!1}),!_){const K=ed({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",K);const U=nd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:W});u.on("zoom",U);const et=rd({zoomPanValues:c,panOnDrag:C,panOnScroll:$,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:l});u.on("end",et)}const Q=od({zoomActivationKeyPressed:X,panOnDrag:C,zoomOnScroll:V,panOnScroll:$,zoomOnDoubleClick:R,zoomOnPinch:L,userSelectionActive:_,noPanClassName:j,noWheelClassName:k,lib:Y,connectionInProgress:q});u.filter(Q),R?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function v(k,j,H){const _=Sn(k),$=u==null?void 0:u.constrain()(_,j,H);return $&&await y($),new Promise(C=>C($))}async function x(k,j){const H=Sn(k);return await y(H,j),new Promise(_=>_(H))}function w(k){if(d){const j=Sn(k),H=d.property("__zoom");(H.k!==k.zoom||H.x!==k.x||H.y!==k.y)&&(u==null||u.transform(d,j,null,{sync:!0}))}}function E(){const k=d?fi(d.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function N(k,j){return d?new Promise(H=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?de:Ye).scaleTo(Mn(d,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function S(k,j){return d?new Promise(H=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?de:Ye).scaleBy(Mn(d,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>H(!0)),k)}):Promise.resolve(!1)}function I(k){u==null||u.scaleExtent(k)}function T(k){u==null||u.translateExtent(k)}function D(k){const j=!gt(k)||k<0?0:k;u==null||u.clickDistance(j)}return{update:p,destroy:m,setViewport:x,setViewportConstrained:v,getViewport:E,scaleTo:N,scaleBy:S,setScaleExtent:I,setTranslateExtent:T,syncViewport:w,setClickDistance:D}}var ee;(function(t){t.Line="line",t.Handle="handle"})(ee||(ee={}));function sd({width:t,prevWidth:e,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=t-e,a=n-r,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Qr(t){const e=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),r=t.includes("left"),o=t.includes("top");return{isHorizontal:e,isVertical:n,affectsX:r,affectsY:o}}function kt(t,e){return Math.max(0,e-t)}function It(t,e){return Math.max(0,t-e)}function He(t,e,n){return Math.max(0,e-t,t-n)}function Jr(t,e){return t?!e:e}function ad(t,e,n,r,o,i,s,a){let{affectsX:l,affectsY:c}=e;const{isHorizontal:f,isVertical:u}=e,d=f&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:p,minHeight:m,maxHeight:v}=r,{x,y:w,width:E,height:N,aspectRatio:S}=t;let I=Math.floor(f?h-t.pointerX:0),T=Math.floor(u?g-t.pointerY:0);const D=E+(l?-I:I),k=N+(c?-T:T),j=-i[0]*E,H=-i[1]*N;let _=He(D,y,p),$=He(k,m,v);if(s){let A=0,M=0;l&&I<0?A=kt(x+I+j,s[0][0]):!l&&I>0&&(A=It(x+D+j,s[1][0])),c&&T<0?M=kt(w+T+H,s[0][1]):!c&&T>0&&(M=It(w+k+H,s[1][1])),_=Math.max(_,A),$=Math.max($,M)}if(a){let A=0,M=0;l&&I>0?A=It(x+I,a[0][0]):!l&&I<0&&(A=kt(x+D,a[1][0])),c&&T>0?M=It(w+T,a[0][1]):!c&&T<0&&(M=kt(w+k,a[1][1])),_=Math.max(_,A),$=Math.max($,M)}if(o){if(f){const A=He(D/S,m,v)*S;if(_=Math.max(_,A),s){let M=0;!l&&!c||l&&!c&&d?M=It(w+H+D/S,s[1][1])*S:M=kt(w+H+(l?I:-I)/S,s[0][1])*S,_=Math.max(_,M)}if(a){let M=0;!l&&!c||l&&!c&&d?M=kt(w+D/S,a[1][1])*S:M=It(w+(l?I:-I)/S,a[0][1])*S,_=Math.max(_,M)}}if(u){const A=He(k*S,y,p)/S;if($=Math.max($,A),s){let M=0;!l&&!c||c&&!l&&d?M=It(x+k*S+j,s[1][0])/S:M=kt(x+(c?T:-T)*S+j,s[0][0])/S,$=Math.max($,M)}if(a){let M=0;!l&&!c||c&&!l&&d?M=kt(x+k*S,a[1][0])/S:M=It(x+(c?T:-T)*S,a[0][0])/S,$=Math.max($,M)}}}T=T+(T<0?$:-$),I=I+(I<0?_:-_),o&&(d?D>k*S?T=(Jr(l,c)?-I:I)/S:I=(Jr(l,c)?-T:T)*S:f?(T=I/S,c=l):(I=T*S,l=c));const C=l?x+I:x,z=c?w+T:w;return{width:E+(l?-I:I),height:N+(c?-T:T),x:i[0]*I*(l?-1:1)+C,y:i[1]*T*(c?-1:1)+z}}const Bi={width:0,height:0,x:0,y:0},cd={...Bi,pointerX:0,pointerY:0,aspectRatio:1};function ld(t){return[[0,0],[t.measured.width,t.measured.height]]}function ud(t,e,n){const r=e.position.x+t.position.x,o=e.position.y+t.position.y,i=t.measured.width??0,s=t.measured.height??0,a=n[0]*i,l=n[1]*s;return[[r-a,o-l],[r+i-a,o+s-l]]}function fd({domNode:t,nodeId:e,getStoreItems:n,onChange:r,onEnd:o}){const i=ut(t);let s={controlDirection:Qr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:f,keepAspectRatio:u,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:p}){let m={...Bi},v={...cd};s={boundaries:f,resizeDirection:d,keepAspectRatio:u,controlDirection:Qr(c)};let x,w=null,E=[],N,S,I,T=!1;const D=Qo().on("start",k=>{const{nodeLookup:j,transform:H,snapGrid:_,snapToGrid:$,nodeOrigin:C,paneDomNode:z}=n();if(x=j.get(e),!x)return;w=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:M}=he(k.sourceEvent,{transform:H,snapGrid:_,snapToGrid:$,containerBounds:w});m={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...m,pointerX:A,pointerY:M,aspectRatio:m.width/m.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=j.get(x.parentId),S=N&&x.extent==="parent"?ld(N):void 0),E=[],I=void 0;for(const[L,V]of j)if(V.parentId===e&&(E.push({id:L,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const R=ud(V,x,V.origin??C);I?I=[[Math.min(R[0][0],I[0][0]),Math.min(R[0][1],I[0][1])],[Math.max(R[1][0],I[1][0]),Math.max(R[1][1],I[1][1])]]:I=R}h==null||h(k,{...m})}).on("drag",k=>{const{transform:j,snapGrid:H,snapToGrid:_,nodeOrigin:$}=n(),C=he(k.sourceEvent,{transform:j,snapGrid:H,snapToGrid:_,containerBounds:w}),z=[];if(!x)return;const{x:A,y:M,width:L,height:V}=m,R={},X=x.origin??$,{width:Y,height:W,x:q,y:F}=ad(v,s.controlDirection,C,s.boundaries,s.keepAspectRatio,X,S,I),B=Y!==L,O=W!==V,Z=q!==A&&B,Q=F!==M&&O;if(!Z&&!Q&&!B&&!O)return;if((Z||Q||X[0]===1||X[1]===1)&&(R.x=Z?q:m.x,R.y=Q?F:m.y,m.x=R.x,m.y=R.y,E.length>0)){const nt=q-A,tt=F-M;for(const st of E)st.position={x:st.position.x-nt+X[0]*(Y-L),y:st.position.y-tt+X[1]*(W-V)},z.push(st)}if((B||O)&&(R.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,R.height=O&&(!s.resizeDirection||s.resizeDirection==="vertical")?W:m.height,m.width=R.width,m.height=R.height),N&&x.expandParent){const nt=X[0]*(R.width??0);R.x&&R.x<nt&&(m.x=nt,v.x=v.x-(R.x-nt));const tt=X[1]*(R.height??0);R.y&&R.y<tt&&(m.y=tt,v.y=v.y-(R.y-tt))}const K=sd({width:m.width,prevWidth:L,height:m.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:K};(p==null?void 0:p(k,U))!==!1&&(T=!0,g==null||g(k,U),r(R,z))}).on("end",k=>{T&&(y==null||y(k,{...m}),o==null||o({...m}),T=!1)});i.call(D)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var Cn={exports:{}},kn={},In={exports:{}},An={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ import{h as Ca,i as Do,k as ka,R as Ia,r as P,j as b,d as Aa,a as $a,L as Pa}fro
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var to;function dd(){if(to)return An;to=1;var t=
|
|
9
|
+
*/var to;function dd(){if(to)return An;to=1;var t=Lo();function e(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,i=t.useLayoutEffect,s=t.useDebugValue;function a(u,d){var h=d(),g=r({inst:{value:h,getSnapshot:d}}),y=g[0].inst,p=g[1];return i(function(){y.value=h,y.getSnapshot=d,l(y)&&p({inst:y})},[u,h,d]),o(function(){return l(y)&&p({inst:y}),u(function(){l(y)&&p({inst:y})})},[u]),s(h),h}function l(u){var d=u.getSnapshot;u=u.value;try{var h=d();return!n(u,h)}catch{return!0}}function c(u,d){return d()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return An.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,An}var eo;function hd(){return eo||(eo=1,In.exports=dd()),In.exports}/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-shim/with-selector.production.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,14 @@ import{h as Ca,i as Do,k as ka,R as Ia,r as P,j as b,d as Aa,a as $a,L as Pa}fro
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var no;function gd(){if(no)return kn;no=1;var t=
|
|
17
|
+
*/var no;function gd(){if(no)return kn;no=1;var t=Lo(),e=hd();function n(c,f){return c===f&&(c!==0||1/c===1/f)||c!==c&&f!==f}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;return kn.useSyncExternalStoreWithSelector=function(c,f,u,d,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(N){if(!v){if(v=!0,x=N,N=d(N),h!==void 0&&y.hasValue){var S=y.value;if(h(S,N))return w=S}return w=N}if(S=w,r(x,N))return S;var I=d(N);return h!==void 0&&h(S,I)?(x=N,S):(x=N,w=I)}var v=!1,x,w,E=u===void 0?null:u;return[function(){return m(f())},E===null?void 0:function(){return m(E())}]},[f,u,d,h]);var p=o(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=p},[p]),l(p),p},kn}var ro;function pd(){return ro||(ro=1,Cn.exports=gd()),Cn.exports}var md=pd();const yd=Ia(md),xd={},oo=t=>{let e;const n=new Set,r=(f,u)=>{const d=typeof f=="function"?f(e):f;if(!Object.is(d,e)){const h=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(g=>g(e,h))}},o=()=>e,l={setState:r,getState:o,getInitialState:()=>c,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(xd?"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()}},c=e=t(r,o,l);return l},wd=t=>t?oo(t):oo,{useDebugValue:vd}=Aa,{useSyncExternalStoreWithSelector:bd}=yd,_d=t=>t;function Fi(t,e=_d,n){const r=bd(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return vd(r),r}const io=(t,e)=>{const n=wd(t),r=(o,i=e)=>Fi(n,o,i);return Object.assign(r,n),r},Nd=(t,e)=>t?io(t,e):io;function rt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,o]of t)if(!Object.is(o,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}const hn=P.createContext(null),Ed=hn.Provider,Oi=wt.error001();function J(t,e){const n=P.useContext(hn);if(n===null)throw new Error(Oi);return Fi(n,t,e)}function ot(){const t=P.useContext(hn);if(t===null)throw new Error(Oi);return P.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const so={display:"none"},Sd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Xi="react-flow__node-desc",Yi="react-flow__edge-desc",Md="react-flow__aria-live",Cd=t=>t.ariaLiveMessage,kd=t=>t.ariaLabelConfig;function Id({rfId:t}){const e=J(Cd);return b.jsx("div",{id:`${Md}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Sd,children:e})}function Ad({rfId:t,disableKeyboardA11y:e}){const n=J(kd);return b.jsxs(b.Fragment,{children:[b.jsx("div",{id:`${Xi}-${t}`,style:so,children:e?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),b.jsx("div",{id:`${Yi}-${t}`,style:so,children:n["edge.a11yDescription.default"]}),!e&&b.jsx(Id,{rfId:t})]})}const gn=P.forwardRef(({position:t="top-left",children:e,className:n,style:r,...o},i)=>{const s=`${t}`.split("-");return b.jsx("div",{className:it(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:e})});gn.displayName="Panel";function $d({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:b.jsx(gn,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:b.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Pd=t=>{const e=[],n=[];for(const[,r]of t.nodeLookup)r.selected&&e.push(r.internals.userNode);for(const[,r]of t.edgeLookup)r.selected&&n.push(r);return{selectedNodes:e,selectedEdges:n}},Ve=t=>t.id;function Td(t,e){return rt(t.selectedNodes.map(Ve),e.selectedNodes.map(Ve))&&rt(t.selectedEdges.map(Ve),e.selectedEdges.map(Ve))}function zd({onSelectionChange:t}){const e=ot(),{selectedNodes:n,selectedEdges:r}=J(Pd,Td);return P.useEffect(()=>{const o={nodes:n,edges:r};t==null||t(o),e.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,t]),null}const jd=t=>!!t.onSelectionChangeHandlers;function Ld({onSelectionChange:t}){const e=J(jd);return t||e?b.jsx(zd,{onSelectionChange:t}):null}const Wn=typeof window<"u"?P.useLayoutEffect:P.useEffect,Wi=[0,0],Dd={x:0,y:0,zoom:1},Rd=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],ao=[...Rd,"rfId"],Hd=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),co={translateExtent:xe,nodeOrigin:Wi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Vd(t){const{setNodes:e,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=J(Hd,rt),c=ot();Wn(()=>(l(t.defaultNodes,t.defaultEdges),()=>{f.current=co,a()}),[]);const f=P.useRef(co);return Wn(()=>{for(const u of ao){const d=t[u],h=f.current[u];d!==h&&(typeof t[u]>"u"||(u==="nodes"?e(d):u==="edges"?n(d):u==="minZoom"?r(d):u==="maxZoom"?o(d):u==="translateExtent"?i(d):u==="nodeExtent"?s(d):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:Nf(d)}):u==="fitView"?c.setState({fitViewQueued:d}):u==="fitViewOptions"?c.setState({fitViewOptions:d}):c.setState({[u]:d})))}f.current=t},ao.map(u=>t[u])),null}function lo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Bd(t){var r;const[e,n]=P.useState(t==="system"?null:t);return P.useEffect(()=>{if(t!=="system"){n(t);return}const o=lo(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[t]),e!==null?e:(r=lo())!=null&&r.matches?"dark":"light"}const uo=typeof document<"u"?document:null;function _e(t=null,e={target:uo,actInsideInputWithModifier:!0}){const[n,r]=P.useState(!1),o=P.useRef(!1),i=P.useRef(new Set([])),[s,a]=P.useMemo(()=>{if(t!==null){const c=(Array.isArray(t)?t:[t]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
18
18
|
`).replace(`
|
|
19
19
|
|
|
20
20
|
`,`
|
|
21
21
|
+`).split(`
|
|
22
|
-
`)),f=c.reduce((u,d)=>u.concat(...d),[]);return[c,f]}return[[],[]]},[t]);return P.useEffect(()=>{const l=(e==null?void 0:e.target)??uo,c=(e==null?void 0:e.actInsideInputWithModifier)??!0;if(t!==null){const f=h=>{var p,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!c)&&Ei(h))return!1;const y=ho(h.code,a);if(i.current.add(h[y]),fo(s,i.current,!1)){const v=((m=(p=h.composedPath)==null?void 0:p.call(h))==null?void 0:m[0])||h.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";e.preventDefault!==!1&&(o.current||!x)&&h.preventDefault(),r(!0)}},u=h=>{const g=ho(h.code,a);fo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},d=()=>{i.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",f),l==null||l.addEventListener("keyup",u),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{l==null||l.removeEventListener("keydown",f),l==null||l.removeEventListener("keyup",u),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[t,r]),n}function fo(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(o=>e.has(o)))}function ho(t,e){return e.includes(t)?"code":"key"}const Fd=()=>{const t=ot();return P.useMemo(()=>({zoomIn:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,e):Promise.resolve(!1)},zoomOut:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,e):Promise.resolve(!1)},zoomTo:(e,n)=>{const{panZoom:r}=t.getState();return r?r.scaleTo(e,n):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,n)=>{const{transform:[r,o,i],panZoom:s}=t.getState();return s?(await s.setViewport({x:e.x??r,y:e.y??o,zoom:e.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},setCenter:async(e,n,r)=>t.getState().setCenter(e,n,r),fitBounds:async(e,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=t.getState(),l=or(e,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=t.getState();if(!s)return e;const{x:a,y:l}=s.getBoundingClientRect(),c={x:e.x-a,y:e.y-l},f=n.snapGrid??o,u=n.snapToGrid??i;return Ie(c,r,u,f)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:o,y:i}=r.getBoundingClientRect(),s=rn(e,n);return{x:s.x+o,y:s.y+i}}}),[])};function Wi(t,e){const n=[],r=new Map,o=[];for(const i of t)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of e){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const l of s)Od(l,a);n.push(a)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Od(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function Gi(t,e){return Wi(t,e)}function qi(t,e){return Wi(t,e)}function Tt(t,e){return{id:t,type:"select",selected:e}}function Yt(t,e=new Set,n=!1){const r=[];for(const[o,i]of t){const s=e.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(Tt(i.id,s)))}return r}function go({items:t=[],lookup:e}){var o;const n=[],r=new Map(t.map(i=>[i.id,i]));for(const[i,s]of t.entries()){const a=e.get(s.id),l=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;l!==void 0&&l!==s&&n.push({id:s.id,item:s,type:"replace"}),l===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of e)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function po(t){return{id:t.id,type:"remove"}}const mo=t=>hf(t),Xd=t=>mi(t);function Ui(t){return P.forwardRef(t)}function yo(t){const[e,n]=P.useState(BigInt(0)),[r]=P.useState(()=>Yd(()=>n(o=>o+BigInt(1))));return Wn(()=>{const o=r.get();o.length&&(t(o),r.reset())},[e]),r}function Yd(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:n=>{e.push(n),t()}}}const Zi=P.createContext(null);function Wd({children:t}){const e=ot(),n=P.useCallback(a=>{const{nodes:l=[],setNodes:c,hasDefaultNodes:f,onNodesChange:u,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=e.getState();let y=l;for(const m of a)y=typeof m=="function"?m(y):m;let p=go({items:y,lookup:d});for(const m of g.values())p=m(p);f&&c(y),p.length>0?u==null||u(p):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:v,setNodes:x}=e.getState();m&&x(v)})},[]),r=yo(n),o=P.useCallback(a=>{const{edges:l=[],setEdges:c,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:d}=e.getState();let h=l;for(const g of a)h=typeof g=="function"?g(h):g;f?c(h):u&&u(go({items:h,lookup:d}))},[]),i=yo(o),s=P.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return b.jsx(Zi.Provider,{value:s,children:t})}function Gd(){const t=P.useContext(Zi);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const qd=t=>!!t.panZoom;function Ae(){const t=Fd(),e=ot(),n=Gd(),r=J(qd),o=P.useMemo(()=>{const i=u=>e.getState().nodeLookup.get(u),s=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},l=u=>{var m,v;const{nodeLookup:d,nodeOrigin:h}=e.getState(),g=mo(u)?u:d.get(u.id),y=g.parentId?_i(g.position,g.measured,g.parentId,d,h):g.position,p={...g,position:y,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return Jt(p)},c=(u,d,h={replace:!1})=>{s(g=>g.map(y=>{if(y.id===u){const p=typeof d=="function"?d(y):d;return h.replace&&mo(p)?p:{...y,...p}}return y}))},f=(u,d,h={replace:!1})=>{a(g=>g.map(y=>{if(y.id===u){const p=typeof d=="function"?d(y):d;return h.replace&&Xd(p)?p:{...y,...p}}return y}))};return{getNodes:()=>e.getState().nodes.map(u=>({...u})),getNode:u=>{var d;return(d=i(u))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=e.getState();return u.map(d=>({...d}))},getEdge:u=>e.getState().edgeLookup.get(u),setNodes:s,setEdges:a,addNodes:u=>{const d=Array.isArray(u)?u:[u];n.nodeQueue.push(h=>[...h,...d])},addEdges:u=>{const d=Array.isArray(u)?u:[u];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:u=[],edges:d=[],transform:h}=e.getState(),[g,y,p]=h;return{nodes:u.map(m=>({...m})),edges:d.map(m=>({...m})),viewport:{x:g,y,zoom:p}}},deleteElements:async({nodes:u=[],edges:d=[]})=>{const{nodes:h,edges:g,onNodesDelete:y,onEdgesDelete:p,triggerNodeChanges:m,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:w}=e.getState(),{nodes:E,edges:N}=await xf({nodesToRemove:u,edgesToRemove:d,nodes:h,edges:g,onBeforeDelete:w}),S=N.length>0,I=E.length>0;if(S){const T=N.map(po);p==null||p(N),v(T)}if(I){const T=E.map(po);y==null||y(E),m(T)}return(I||S)&&(x==null||x({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(u,d=!0,h)=>{const g=Br(u),y=g?u:l(u),p=h!==void 0;return y?(h||e.getState().nodes).filter(m=>{const v=e.getState().nodeLookup.get(m.id);if(v&&!g&&(m.id===u.id||!v.internals.positionAbsolute))return!1;const x=Jt(p?m:v),w=ve(x,y);return d&&w>0||w>=x.width*x.height||w>=y.width*y.height}):[]},isNodeIntersecting:(u,d,h=!0)=>{const y=Br(u)?u:l(u);if(!y)return!1;const p=ve(y,d);return h&&p>0||p>=d.width*d.height||p>=y.width*y.height},updateNode:c,updateNodeData:(u,d,h={replace:!1})=>{c(u,g=>{const y=typeof d=="function"?d(g):d;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},updateEdge:f,updateEdgeData:(u,d,h={replace:!1})=>{f(u,g=>{const y=typeof d=="function"?d(g):d;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},getNodesBounds:u=>{const{nodeLookup:d,nodeOrigin:h}=e.getState();return gf(u,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:u,id:d,nodeId:h})=>{var g;return Array.from(((g=e.getState().connectionLookup.get(`${h}-${u}${d?`-${d}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:d,nodeId:h})=>{var g;return Array.from(((g=e.getState().connectionLookup.get(`${h}${u?d?`-${u}-${d}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const d=e.getState().fitViewResolver??_f();return e.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return P.useMemo(()=>({...o,...t,viewportInitialized:r}),[r])}const xo=t=>t.selected,Ud=typeof window<"u"?window:void 0;function Zd({deleteKeyCode:t,multiSelectionKeyCode:e}){const n=ot(),{deleteElements:r}=Ae(),o=_e(t,{actInsideInputWithModifier:!1}),i=_e(e,{target:Ud});P.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(xo),edges:s.filter(xo)}),n.setState({nodesSelectionActive:!1})}},[o]),P.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Kd(t){const e=ot();P.useEffect(()=>{const n=()=>{var o,i,s,a;if(!t.current||!(((i=(o=t.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=ir(t.current);(r.height===0||r.width===0)&&((a=(s=e.getState()).onError)==null||a.call(s,"004",wt.error004())),e.setState({width:r.width||500,height:r.height||500})};if(t.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(t.current),()=>{window.removeEventListener("resize",n),r&&t.current&&r.unobserve(t.current)}}},[])}const pn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Qd=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Jd({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Dt.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:f,maxZoom:u,zoomActivationKeyCode:d,preventScrolling:h=!0,children:g,noWheelClassName:y,noPanClassName:p,onViewportChange:m,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:w}){const E=ot(),N=P.useRef(null),{userSelectionActive:S,lib:I,connectionInProgress:T}=J(Qd,rt),j=_e(d),k=P.useRef();Kd(N);const L=P.useCallback(H=>{m==null||m({x:H[0],y:H[1],zoom:H[2]}),v||E.setState({transform:H})},[m,v]);return P.useEffect(()=>{if(N.current){k.current=id({domNode:N.current,minZoom:f,maxZoom:u,translateExtent:c,viewport:l,onDraggingChange:C=>E.setState(z=>z.paneDragging===C?z:{paneDragging:C}),onPanZoomStart:(C,z)=>{const{onViewportChangeStart:A,onMoveStart:M}=E.getState();M==null||M(C,z),A==null||A(z)},onPanZoom:(C,z)=>{const{onViewportChange:A,onMove:M}=E.getState();M==null||M(C,z),A==null||A(z)},onPanZoomEnd:(C,z)=>{const{onViewportChangeEnd:A,onMoveEnd:M}=E.getState();M==null||M(C,z),A==null||A(z)}});const{x:H,y:_,zoom:$}=k.current.getViewport();return E.setState({panZoom:k.current,transform:[H,_,$],domNode:N.current.closest(".react-flow")}),()=>{var C;(C=k.current)==null||C.destroy()}}},[]),P.useEffect(()=>{var H;(H=k.current)==null||H.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:j,preventScrolling:h,noPanClassName:p,userSelectionActive:S,noWheelClassName:y,lib:I,onTransformChange:L,connectionInProgress:T,selectionOnDrag:w,paneClickDistance:x})},[t,e,n,r,o,i,s,a,j,h,p,S,y,I,L,T,w,x]),b.jsx("div",{className:"react-flow__renderer",ref:N,style:pn,children:g})}const th=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function eh(){const{userSelectionActive:t,userSelectionRect:e}=J(th,rt);return t&&e?b.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}const $n=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},nh=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});function rh({isSelecting:t,selectionKeyPressed:e,selectionMode:n=we.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:d,onPaneMouseLeave:h,children:g}){const y=ot(),{userSelectionActive:p,elementsSelectable:m,dragging:v,connectionInProgress:x}=J(nh,rt),w=m&&(t||p),E=P.useRef(null),N=P.useRef(),S=P.useRef(new Set),I=P.useRef(new Set),T=P.useRef(!1),j=A=>{if(T.current||x){T.current=!1;return}l==null||l(A),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},k=A=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){A.preventDefault();return}c==null||c(A)},L=f?A=>f(A):void 0,H=A=>{T.current&&(A.stopPropagation(),T.current=!1)},_=A=>{var W,q;const{domNode:M}=y.getState();if(N.current=M==null?void 0:M.getBoundingClientRect(),!N.current)return;const D=A.target===E.current;if(!D&&!!A.target.closest(".nokey")||!t||!(i&&D||e)||A.button!==0||!A.isPrimary)return;(q=(W=A.target)==null?void 0:W.setPointerCapture)==null||q.call(W,A.pointerId),T.current=!1;const{x:X,y:Y}=pt(A.nativeEvent,N.current);y.setState({userSelectionRect:{width:0,height:0,startX:X,startY:Y,x:X,y:Y}}),D||(A.stopPropagation(),A.preventDefault())},$=A=>{const{userSelectionRect:M,transform:D,nodeLookup:V,edgeLookup:R,connectionLookup:X,triggerNodeChanges:Y,triggerEdgeChanges:W,defaultEdgeOptions:q,resetSelectedElements:F}=y.getState();if(!N.current||!M)return;const{x:B,y:O}=pt(A.nativeEvent,N.current),{startX:Z,startY:Q}=M;if(!T.current){const tt=e?0:o;if(Math.hypot(B-Z,O-Q)<=tt)return;F(),s==null||s(A)}T.current=!0;const K={startX:Z,startY:Q,x:B<Z?B:Z,y:O<Q?O:Q,width:Math.abs(B-Z),height:Math.abs(O-Q)},U=S.current,et=I.current;S.current=new Set(rr(V,K,D,n===we.Partial,!0).map(tt=>tt.id)),I.current=new Set;const nt=(q==null?void 0:q.selectable)??!0;for(const tt of S.current){const st=X.get(tt);if(st)for(const{edgeId:Ct}of st.values()){const bt=R.get(Ct);bt&&(bt.selectable??nt)&&I.current.add(Ct)}}if(!Fr(U,S.current)){const tt=Yt(V,S.current,!0);Y(tt)}if(!Fr(et,I.current)){const tt=Yt(R,I.current);W(tt)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},C=A=>{var M,D;A.button===0&&((D=(M=A.target)==null?void 0:M.releasePointerCapture)==null||D.call(M,A.pointerId),!p&&A.target===E.current&&y.getState().userSelectionRect&&(j==null||j(A)),y.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(a==null||a(A),y.setState({nodesSelectionActive:S.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return b.jsxs("div",{className:it(["react-flow__pane",{draggable:z,dragging:v,selection:t}]),onClick:w?void 0:$n(j,E),onContextMenu:$n(k,E),onWheel:$n(L,E),onPointerEnter:w?void 0:u,onPointerMove:w?$:d,onPointerUp:w?C:void 0,onPointerDownCapture:w?_:void 0,onClickCapture:w?H:void 0,onPointerLeave:h,ref:E,style:pn,children:[g,b.jsx(eh,{})]})}function Gn({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=e.getState(),c=a.get(t);if(!c){l==null||l("012",wt.error012(t));return}e.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):o([t])}function Ki({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=ot(),[l,c]=P.useState(!1),f=P.useRef();return P.useEffect(()=>{f.current=Yf({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Gn({id:u,store:a,nodeRef:t})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),P.useEffect(()=>{if(!(e||!t.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:t.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,e,i,t,o,s]),l}const oh=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");function Qi(){const t=ot();return P.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:l,nodeLookup:c,nodeOrigin:f}=t.getState(),u=new Map,d=oh(s),h=o?i[0]:5,g=o?i[1]:5,y=n.direction.x*h*n.factor,p=n.direction.y*g*n.factor;for(const[,m]of c){if(!d(m))continue;let v={x:m.internals.positionAbsolute.x+y,y:m.internals.positionAbsolute.y+p};o&&(v=ke(v,i));const{position:x,positionAbsolute:w}=yi({nodeId:m.id,nextPosition:v,nodeLookup:c,nodeExtent:r,nodeOrigin:f,onError:a});m.position=x,m.internals.positionAbsolute=w,u.set(m.id,m)}l(u)},[])}const fr=P.createContext(null),ih=fr.Provider;fr.Consumer;const Ji=()=>P.useContext(fr),sh=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),ah=(t,e,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:l,isValid:c}=s,f=(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===e&&(l==null?void 0:l.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===e&&(a==null?void 0:a.type)===n,connectingTo:f,clickConnecting:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.id)===e&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Zt.Strict?(a==null?void 0:a.type)!==n:t!==(a==null?void 0:a.nodeId)||e!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:f&&c}};function ch({type:t="source",position:e=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:l,className:c,onMouseDown:f,onTouchStart:u,...d},h){var $,C;const g=s||null,y=t==="target",p=ot(),m=Ji(),{connectOnClick:v,noPanClassName:x,rfId:w}=J(sh,rt),{connectingFrom:E,connectingTo:N,clickConnecting:S,isPossibleEndHandle:I,connectionInProcess:T,clickConnectionInProcess:j,valid:k}=J(ah(m,g,t),rt);m||(C=($=p.getState()).onError)==null||C.call($,"010",wt.error010());const L=z=>{const{defaultEdgeOptions:A,onConnect:M,hasDefaultEdges:D}=p.getState(),V={...A,...z};if(D){const{edges:R,setEdges:X}=p.getState();X(If(V,R))}M==null||M(V),a==null||a(V)},H=z=>{if(!m)return;const A=Si(z.nativeEvent);if(o&&(A&&z.button===0||!A)){const M=p.getState();Yn.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:y,handleId:g,nodeId:m,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...D)=>{var V,R;return(R=(V=p.getState()).onConnectEnd)==null?void 0:R.call(V,...D)},updateConnection:M.updateConnection,onConnect:L,isValidConnection:n||((...D)=>{var V,R;return((R=(V=p.getState()).isValidConnection)==null?void 0:R.call(V,...D))??!0}),getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}A?f==null||f(z):u==null||u(z)},_=z=>{const{onClickConnectStart:A,onClickConnectEnd:M,connectionClickStartHandle:D,connectionMode:V,isValidConnection:R,lib:X,rfId:Y,nodeLookup:W,connection:q}=p.getState();if(!m||!D&&!o)return;if(!D){A==null||A(z.nativeEvent,{nodeId:m,handleId:g,handleType:t}),p.setState({connectionClickStartHandle:{nodeId:m,type:t,id:g}});return}const F=Ni(z.target),B=n||R,{connection:O,isValid:Z}=Yn.isValid(z.nativeEvent,{handle:{nodeId:m,id:g,type:t},connectionMode:V,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:B,flowId:Y,doc:F,lib:X,nodeLookup:W});Z&&O&&L(O);const Q=structuredClone(q);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,M==null||M(z,Q),p.setState({connectionClickStartHandle:null})};return b.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":e,"data-id":`${w}-${m}-${g}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",x,c,{source:!y,target:y,connectable:r,connectablestart:o,connectableend:i,clickconnecting:S,connectingfrom:E,connectingto:N,valid:k,connectionindicator:r&&(!T||I)&&(T||j?i:o)}]),onMouseDown:H,onTouchStart:H,onClick:v?_:void 0,ref:h,...d,children:l})}const ne=P.memo(Ui(ch));function lh({data:t,isConnectable:e,sourcePosition:n=G.Bottom}){return b.jsxs(b.Fragment,{children:[t==null?void 0:t.label,b.jsx(ne,{type:"source",position:n,isConnectable:e})]})}function uh({data:t,isConnectable:e,targetPosition:n=G.Top,sourcePosition:r=G.Bottom}){return b.jsxs(b.Fragment,{children:[b.jsx(ne,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,b.jsx(ne,{type:"source",position:r,isConnectable:e})]})}function fh(){return null}function dh({data:t,isConnectable:e,targetPosition:n=G.Top}){return b.jsxs(b.Fragment,{children:[b.jsx(ne,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label]})}const on={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},wo={input:lh,default:uh,output:dh,group:fh};function hh(t){var e,n,r,o;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((e=t.style)==null?void 0:e.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((r=t.style)==null?void 0:r.width),height:t.height??((o=t.style)==null?void 0:o.height)}}const gh=t=>{const{width:e,height:n,x:r,y:o}=Ce(t.nodeLookup,{filter:i=>!!i.selected});return{width:gt(e)?e:null,height:gt(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${r}px,${o}px)`}};function ph({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ot(),{width:o,height:i,transformString:s,userSelectionActive:a}=J(gh,rt),l=Qi(),c=P.useRef(null);P.useEffect(()=>{var h;n||(h=c.current)==null||h.focus({preventScroll:!0})},[n]);const f=!a&&o!==null&&i!==null;if(Ki({nodeRef:c,disabled:!f}),!f)return null;const u=t?h=>{const g=r.getState().nodes.filter(y=>y.selected);t(h,g)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(on,h.key)&&(h.preventDefault(),l({direction:on[h.key],factor:h.shiftKey?4:1}))};return b.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",e]),style:{transform:s},children:b.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:o,height:i}})})}const vo=typeof window<"u"?window:void 0,mh=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function ts({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:f,selectionMode:u,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:p,elementsSelectable:m,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:w,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:S,panOnDrag:I,defaultViewport:T,translateExtent:j,minZoom:k,maxZoom:L,preventScrolling:H,onSelectionContextMenu:_,noWheelClassName:$,noPanClassName:C,disableKeyboardA11y:z,onViewportChange:A,isControlledViewport:M}){const{nodesSelectionActive:D,userSelectionActive:V}=J(mh,rt),R=_e(c,{target:vo}),X=_e(y,{target:vo}),Y=X||I,W=X||w,q=f&&Y!==!0,F=R||V||q;return Zd({deleteKeyCode:l,multiSelectionKeyCode:g}),b.jsx(Jd,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:S,panOnDrag:!R&&Y,defaultViewport:T,translateExtent:j,minZoom:k,maxZoom:L,zoomActivationKeyCode:p,preventScrolling:H,noWheelClassName:$,noPanClassName:C,onViewportChange:A,isControlledViewport:M,paneClickDistance:a,selectionOnDrag:q,children:b.jsxs(rh,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:Y,isSelecting:!!F,selectionMode:u,selectionKeyPressed:R,paneClickDistance:a,selectionOnDrag:q,children:[t,D&&b.jsx(ph,{onSelectionContextMenu:_,noPanClassName:C,disableKeyboardA11y:z})]})})}ts.displayName="FlowRenderer";const yh=P.memo(ts),xh=t=>e=>t?rr(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(n=>n.id):Array.from(e.nodeLookup.keys());function wh(t){return J(P.useCallback(xh(t),[t]),rt)}const vh=t=>t.updateNodeInternals;function bh(){const t=J(vh),[e]=P.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),t(r)}));return P.useEffect(()=>()=>{e==null||e.disconnect()},[e]),e}function _h({node:t,nodeType:e,hasDimensions:n,resizeObserver:r}){const o=ot(),i=P.useRef(null),s=P.useRef(null),a=P.useRef(t.sourcePosition),l=P.useRef(t.targetPosition),c=P.useRef(e),f=n&&!!t.internals.handleBounds;return P.useEffect(()=>{i.current&&!t.hidden&&(!f||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[f,t.hidden]),P.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),P.useEffect(()=>{if(i.current){const u=c.current!==e,d=a.current!==t.sourcePosition,h=l.current!==t.targetPosition;(u||d||h)&&(c.current=e,a.current=t.sourcePosition,l.current=t.targetPosition,o.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:i.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),i}function Nh({id:t,onClick:e,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:f,resizeObserver:u,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:g,rfId:y,nodeTypes:p,nodeClickDistance:m,onError:v}){const{node:x,internals:w,isParent:E}=J(B=>{const O=B.nodeLookup.get(t),Z=B.parentLookup.has(t);return{node:O,internals:O.internals,isParent:Z}},rt);let N=x.type||"default",S=(p==null?void 0:p[N])||wo[N];S===void 0&&(v==null||v("003",wt.error003(N)),N="default",S=(p==null?void 0:p.default)||wo.default);const I=!!(x.draggable||a&&typeof x.draggable>"u"),T=!!(x.selectable||l&&typeof x.selectable>"u"),j=!!(x.connectable||c&&typeof x.connectable>"u"),k=!!(x.focusable||f&&typeof x.focusable>"u"),L=ot(),H=bi(x),_=_h({node:x,nodeType:N,hasDimensions:H,resizeObserver:u}),$=Ki({nodeRef:_,disabled:x.hidden||!I,noDragClassName:d,handleSelector:x.dragHandle,nodeId:t,isSelectable:T,nodeClickDistance:m}),C=Qi();if(x.hidden)return null;const z=Mt(x),A=hh(x),M=T||I||e||n||r||o,D=n?B=>n(B,{...w.userNode}):void 0,V=r?B=>r(B,{...w.userNode}):void 0,R=o?B=>o(B,{...w.userNode}):void 0,X=i?B=>i(B,{...w.userNode}):void 0,Y=s?B=>s(B,{...w.userNode}):void 0,W=B=>{const{selectNodesOnDrag:O,nodeDragThreshold:Z}=L.getState();T&&(!O||!I||Z>0)&&Gn({id:t,store:L,nodeRef:_}),e&&e(B,{...w.userNode})},q=B=>{if(!(Ei(B.nativeEvent)||g)){if(di.includes(B.key)&&T){const O=B.key==="Escape";Gn({id:t,store:L,unselect:O,nodeRef:_})}else if(I&&x.selected&&Object.prototype.hasOwnProperty.call(on,B.key)){B.preventDefault();const{ariaLabelConfig:O}=L.getState();L.setState({ariaLiveMessage:O["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),C({direction:on[B.key],factor:B.shiftKey?4:1})}}},F=()=>{var et;if(g||!((et=_.current)!=null&&et.matches(":focus-visible")))return;const{transform:B,width:O,height:Z,autoPanOnNodeFocus:Q,setCenter:K}=L.getState();if(!Q)return;rr(new Map([[t,x]]),{x:0,y:0,width:O,height:Z},B,!0).length>0||K(x.position.x+z.width/2,x.position.y+z.height/2,{zoom:B[2]})};return b.jsx("div",{className:it(["react-flow__node",`react-flow__node-${N}`,{[h]:I},x.className,{selected:x.selected,selectable:T,parent:E,draggable:I,dragging:$}]),ref:_,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:H?"visible":"hidden",...x.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:D,onMouseMove:V,onMouseLeave:R,onContextMenu:X,onClick:W,onDoubleClick:Y,onKeyDown:k?q:void 0,tabIndex:k?0:void 0,onFocus:k?F:void 0,role:x.ariaRole??(k?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Oi}-${y}`,"aria-label":x.ariaLabel,...x.domAttributes,children:b.jsx(ih,{value:t,children:b.jsx(S,{id:t,data:x.data,type:N,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:x.selected??!1,selectable:T,draggable:I,deletable:x.deletable??!0,isConnectable:j,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:$,dragHandle:x.dragHandle,zIndex:w.z,parentId:x.parentId,...z})})})}var Eh=P.memo(Nh);const Sh=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function es(t){const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=J(Sh,rt),s=wh(t.onlyRenderVisibleElements),a=bh();return b.jsx("div",{className:"react-flow__nodes",style:pn,children:s.map(l=>b.jsx(Eh,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:a,nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}es.displayName="NodeRenderer";const Mh=P.memo(es);function Ch(t){return J(P.useCallback(n=>{if(!t)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&Mf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[t]),rt)}const kh=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t}};return b.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Ih=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t,fill:t}};return b.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bo={[Kt.Arrow]:kh,[Kt.ArrowClosed]:Ih};function Ah(t){const e=ot();return P.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(bo,t)?bo[t]:((i=(o=e.getState()).onError)==null||i.call(o,"009",wt.error009(t)),null)},[t])}const $h=({id:t,type:e,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const l=Ah(e);return l?b.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:b.jsx(l,{color:n,strokeWidth:s})}):null},ns=({defaultColor:t,rfId:e})=>{const n=J(i=>i.edges),r=J(i=>i.defaultEdgeOptions),o=P.useMemo(()=>zf(n,{id:e,defaultColor:t,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,e,t]);return o.length?b.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:b.jsx("defs",{children:o.map(i=>b.jsx($h,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};ns.displayName="MarkerDefinitions";var Ph=P.memo(ns);function rs({x:t,y:e,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...f}){const[u,d]=P.useState({x:1,y:0,width:0,height:0}),h=it(["react-flow__edge-textwrapper",c]),g=P.useRef(null);return P.useEffect(()=>{if(g.current){const y=g.current.getBBox();d({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?b.jsxs("g",{transform:`translate(${t-u.width/2} ${e-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...f,children:[o&&b.jsx("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),b.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),l]}):null}rs.displayName="EdgeText";const Th=P.memo(rs);function mn({path:t,labelX:e,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...f}){return b.jsxs(b.Fragment,{children:[b.jsx("path",{...f,d:t,fill:"none",className:it(["react-flow__edge-path",f.className])}),c?b.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,r&>(e)&>(n)?b.jsx(Th,{x:e,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function _o({pos:t,x1:e,y1:n,x2:r,y2:o}){return t===G.Left||t===G.Right?[.5*(e+r),n]:[e,.5*(n+o)]}function os({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top}){const[s,a]=_o({pos:n,x1:t,y1:e,x2:r,y2:o}),[l,c]=_o({pos:i,x1:r,y1:o,x2:t,y2:e}),[f,u,d,h]=Mi({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${t},${e} C${s},${a} ${l},${c} ${r},${o}`,f,u,d,h]}function is(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:m})=>{const[v,x,w]=os({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),E=t.isInternal?void 0:e;return b.jsx(mn,{id:E,path:v,labelX:x,labelY:w,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:m})})}const zh=is({isInternal:!1}),ss=is({isInternal:!0});zh.displayName="SimpleBezierEdge";ss.displayName="SimpleBezierEdgeInternal";function as(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,sourcePosition:h=G.Bottom,targetPosition:g=G.Top,markerEnd:y,markerStart:p,pathOptions:m,interactionWidth:v})=>{const[x,w,E]=Fn({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:i,targetPosition:g,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),N=t.isInternal?void 0:e;return b.jsx(mn,{id:N,path:x,labelX:w,labelY:E,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:y,markerStart:p,interactionWidth:v})})}const cs=as({isInternal:!1}),ls=as({isInternal:!0});cs.displayName="SmoothStepEdge";ls.displayName="SmoothStepEdgeInternal";function us(t){return P.memo(({id:e,...n})=>{var o;const r=t.isInternal?void 0:e;return b.jsx(cs,{...n,id:r,pathOptions:P.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const Lh=us({isInternal:!1}),fs=us({isInternal:!0});Lh.displayName="StepEdge";fs.displayName="StepEdgeInternal";function ds(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:g,interactionWidth:y})=>{const[p,m,v]=Ii({sourceX:n,sourceY:r,targetX:o,targetY:i}),x=t.isInternal?void 0:e;return b.jsx(mn,{id:x,path:p,labelX:m,labelY:v,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:g,interactionWidth:y})})}const Dh=ds({isInternal:!1}),hs=ds({isInternal:!0});Dh.displayName="StraightEdge";hs.displayName="StraightEdgeInternal";function gs(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=G.Bottom,targetPosition:a=G.Top,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,pathOptions:m,interactionWidth:v})=>{const[x,w,E]=Ci({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),N=t.isInternal?void 0:e;return b.jsx(mn,{id:N,path:x,labelX:w,labelY:E,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:v})})}const jh=gs({isInternal:!1}),ps=gs({isInternal:!0});jh.displayName="BezierEdge";ps.displayName="BezierEdgeInternal";const No={default:ps,straight:hs,step:fs,smoothstep:ls,simplebezier:ss},Eo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Rh=(t,e,n)=>n===G.Left?t-e:n===G.Right?t+e:t,Hh=(t,e,n)=>n===G.Top?t-e:n===G.Bottom?t+e:t,So="react-flow__edgeupdater";function Mo({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return b.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:it([So,`${So}-${a}`]),cx:Rh(e,r,t),cy:Hh(n,r,t),r,stroke:"transparent",fill:"transparent"})}function Vh({isReconnectable:t,reconnectRadius:e,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:f,onReconnectEnd:u,setReconnecting:d,setUpdateHover:h}){const g=ot(),y=(w,E)=>{if(w.button!==0)return;const{autoPanOnConnect:N,domNode:S,connectionMode:I,connectionRadius:T,lib:j,onConnectStart:k,cancelConnection:L,nodeLookup:H,rfId:_,panBy:$,updateConnection:C}=g.getState(),z=E.type==="target",A=(V,R)=>{d(!1),u==null||u(V,n,E.type,R)},M=V=>c==null?void 0:c(n,V),D=(V,R)=>{d(!0),f==null||f(w,n,E.type),k==null||k(V,R)};Yn.onPointerDown(w.nativeEvent,{autoPanOnConnect:N,connectionMode:I,connectionRadius:T,domNode:S,handleId:E.id,nodeId:E.nodeId,nodeLookup:H,isTarget:z,edgeUpdaterType:E.type,lib:j,flowId:_,cancelConnection:L,panBy:$,isValidConnection:(...V)=>{var R,X;return((X=(R=g.getState()).isValidConnection)==null?void 0:X.call(R,...V))??!0},onConnect:M,onConnectStart:D,onConnectEnd:(...V)=>{var R,X;return(X=(R=g.getState()).onConnectEnd)==null?void 0:X.call(R,...V)},onReconnectEnd:A,updateConnection:C,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},p=w=>y(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>y(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>h(!0),x=()=>h(!1);return b.jsxs(b.Fragment,{children:[(t===!0||t==="source")&&b.jsx(Mo,{position:a,centerX:r,centerY:o,radius:e,onMouseDown:p,onMouseEnter:v,onMouseOut:x,type:"source"}),(t===!0||t==="target")&&b.jsx(Mo,{position:l,centerX:i,centerY:s,radius:e,onMouseDown:m,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function Bh({id:t,edgesFocusable:e,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:h,rfId:g,edgeTypes:y,noPanClassName:p,onError:m,disableKeyboardA11y:v}){let x=J(K=>K.edgeLookup.get(t));const w=J(K=>K.defaultEdgeOptions);x=w?{...w,...x}:x;let E=x.type||"default",N=(y==null?void 0:y[E])||No[E];N===void 0&&(m==null||m("011",wt.error011(E)),E="default",N=(y==null?void 0:y.default)||No.default);const S=!!(x.focusable||e&&typeof x.focusable>"u"),I=typeof u<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),T=!!(x.selectable||r&&typeof x.selectable>"u"),j=P.useRef(null),[k,L]=P.useState(!1),[H,_]=P.useState(!1),$=ot(),{zIndex:C,sourceX:z,sourceY:A,targetX:M,targetY:D,sourcePosition:V,targetPosition:R}=J(P.useCallback(K=>{const U=K.nodeLookup.get(x.source),et=K.nodeLookup.get(x.target);if(!U||!et)return{zIndex:x.zIndex,...Eo};const nt=Tf({id:t,sourceNode:U,targetNode:et,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:K.connectionMode,onError:m});return{zIndex:Sf({selected:x.selected,zIndex:x.zIndex,sourceNode:U,targetNode:et,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...nt||Eo}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),rt),X=P.useMemo(()=>x.markerStart?`url('#${On(x.markerStart,g)}')`:void 0,[x.markerStart,g]),Y=P.useMemo(()=>x.markerEnd?`url('#${On(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||z===null||A===null||M===null||D===null)return null;const W=K=>{var tt;const{addSelectedEdges:U,unselectNodesAndEdges:et,multiSelectionActive:nt}=$.getState();T&&($.setState({nodesSelectionActive:!1}),x.selected&&nt?(et({nodes:[],edges:[x]}),(tt=j.current)==null||tt.blur()):U([t])),o&&o(K,x)},q=i?K=>{i(K,{...x})}:void 0,F=s?K=>{s(K,{...x})}:void 0,B=a?K=>{a(K,{...x})}:void 0,O=l?K=>{l(K,{...x})}:void 0,Z=c?K=>{c(K,{...x})}:void 0,Q=K=>{var U;if(!v&&di.includes(K.key)&&T){const{unselectNodesAndEdges:et,addSelectedEdges:nt}=$.getState();K.key==="Escape"?((U=j.current)==null||U.blur(),et({edges:[x]})):nt([t])}};return b.jsx("svg",{style:{zIndex:C},children:b.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${E}`,x.className,p,{selected:x.selected,animated:x.animated,inactive:!T&&!o,updating:k,selectable:T}]),onClick:W,onDoubleClick:q,onContextMenu:F,onMouseEnter:B,onMouseMove:O,onMouseLeave:Z,onKeyDown:S?Q:void 0,tabIndex:S?0:void 0,role:x.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":S?`${Xi}-${g}`:void 0,ref:j,...x.domAttributes,children:[!H&&b.jsx(N,{id:t,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:T,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:M,targetY:D,sourcePosition:V,targetPosition:R,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:X,markerEnd:Y,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),I&&b.jsx(Vh,{edge:x,isReconnectable:I,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:h,sourceX:z,sourceY:A,targetX:M,targetY:D,sourcePosition:V,targetPosition:R,setUpdateHover:L,setReconnecting:_})]})})}var Fh=P.memo(Bh);const Oh=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function ms({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:p,edgesReconnectable:m,elementsSelectable:v,onError:x}=J(Oh,rt),w=Ch(e);return b.jsxs("div",{className:"react-flow__edges",children:[b.jsx(Ph,{defaultColor:t,rfId:n}),w.map(E=>b.jsx(Fh,{id:E,edgesFocusable:p,edgesReconnectable:m,elementsSelectable:v,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:f,reconnectRadius:u,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:y},E))]})}ms.displayName="EdgeRenderer";const Xh=P.memo(ms),Yh=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function Wh({children:t}){const e=J(Yh);return b.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function Gh(t){const e=Ae(),n=P.useRef(!1);P.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const qh=t=>{var e;return(e=t.panZoom)==null?void 0:e.syncViewport};function Uh(t){const e=J(qh),n=ot();return P.useEffect(()=>{t&&(e==null||e(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function Zh(t){return t.connection.inProgress?{...t.connection,to:Ie(t.connection.to,t.transform)}:{...t.connection}}function Kh(t){return Zh}function Qh(t){const e=Kh();return J(e,rt)}const Jh=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function tg({containerStyle:t,style:e,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:l}=J(Jh,rt);return!(i&&o&&l)?null:b.jsx("svg",{style:t,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:b.jsx("g",{className:it(["react-flow__connection",pi(a)]),children:b.jsx(ys,{style:e,type:n,CustomComponent:r,isValid:a})})})}const ys=({style:t,type:e=At.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:l,to:c,toNode:f,toHandle:u,toPosition:d,pointer:h}=Qh();if(!o)return;if(n)return b.jsx(n,{connectionLineType:e,connectionLineStyle:t,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:d,connectionStatus:pi(r),toNode:f,toHandle:u,pointer:h});let g="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:d};switch(e){case At.Bezier:[g]=Ci(y);break;case At.SimpleBezier:[g]=os(y);break;case At.Step:[g]=Fn({...y,borderRadius:0});break;case At.SmoothStep:[g]=Fn(y);break;default:[g]=Ii(y)}return b.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:t})};ys.displayName="ConnectionLine";const eg={};function Co(t=eg){P.useRef(t),ot(),P.useEffect(()=>{},[t])}function ng(){ot(),P.useRef(!1),P.useEffect(()=>{},[])}function xs({nodeTypes:t,edgeTypes:e,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:d,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:p,connectionLineContainerStyle:m,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:S,deleteKeyCode:I,onlyRenderVisibleElements:T,elementsSelectable:j,defaultViewport:k,translateExtent:L,minZoom:H,maxZoom:_,preventScrolling:$,defaultMarkerColor:C,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:M,panOnScrollSpeed:D,panOnScrollMode:V,zoomOnDoubleClick:R,panOnDrag:X,onPaneClick:Y,onPaneMouseEnter:W,onPaneMouseMove:q,onPaneMouseLeave:F,onPaneScroll:B,onPaneContextMenu:O,paneClickDistance:Z,nodeClickDistance:Q,onEdgeContextMenu:K,onEdgeMouseEnter:U,onEdgeMouseMove:et,onEdgeMouseLeave:nt,reconnectRadius:tt,onReconnect:st,onReconnectStart:Ct,onReconnectEnd:bt,noDragClassName:Pt,noWheelClassName:re,noPanClassName:oe,disableKeyboardA11y:ie,nodeExtent:yn,rfId:$e,viewport:Ft,onViewportChange:se}){return Co(t),Co(e),ng(),Gh(n),Uh(Ft),b.jsx(yh,{onPaneClick:Y,onPaneMouseEnter:W,onPaneMouseMove:q,onPaneMouseLeave:F,onPaneContextMenu:O,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:I,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:S,elementsSelectable:j,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:R,panOnScroll:M,panOnScrollSpeed:D,panOnScrollMode:V,panOnDrag:X,defaultViewport:k,translateExtent:L,minZoom:H,maxZoom:_,onSelectionContextMenu:u,preventScrolling:$,noDragClassName:Pt,noWheelClassName:re,noPanClassName:oe,disableKeyboardA11y:ie,onViewportChange:se,isControlledViewport:!!Ft,children:b.jsxs(Wh,{children:[b.jsx(Xh,{edgeTypes:e,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:st,onReconnectStart:Ct,onReconnectEnd:bt,onlyRenderVisibleElements:T,onEdgeContextMenu:K,onEdgeMouseEnter:U,onEdgeMouseMove:et,onEdgeMouseLeave:nt,reconnectRadius:tt,defaultMarkerColor:C,noPanClassName:oe,disableKeyboardA11y:ie,rfId:$e}),b.jsx(tg,{style:y,type:g,component:p,containerStyle:m}),b.jsx("div",{className:"react-flow__edgelabel-renderer"}),b.jsx(Mh,{nodeTypes:t,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,nodeClickDistance:Q,onlyRenderVisibleElements:T,noPanClassName:oe,noDragClassName:Pt,disableKeyboardA11y:ie,nodeExtent:yn,rfId:$e}),b.jsx("div",{className:"react-flow__viewport-portal"})]})})}xs.displayName="GraphView";const rg=P.memo(xs),ko=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:f,nodeExtent:u,zIndexMode:d="basic"}={})=>{const h=new Map,g=new Map,y=new Map,p=new Map,m=r??e??[],v=n??t??[],x=f??[0,0],w=u??xe;Pi(y,p,m);const{nodesInitialized:E}=Xn(v,h,g,{nodeOrigin:x,nodeExtent:w,zIndexMode:d});let N=[0,0,1];if(s&&o&&i){const S=Ce(h,{filter:k=>!!((k.width||k.initialWidth)&&(k.height||k.initialHeight))}),{x:I,y:T,zoom:j}=or(S,o,i,l,c,(a==null?void 0:a.padding)??.1);N=[I,T,j]}return{rfId:"1",width:o??0,height:i??0,transform:N,nodes:v,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:p,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:xe,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...gi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:wf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:hi,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},og=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d})=>Nd((h,g)=>{async function y(){const{nodeLookup:p,panZoom:m,fitViewOptions:v,fitViewResolver:x,width:w,height:E,minZoom:N,maxZoom:S}=g();m&&(await yf({nodes:p,width:w,height:E,panZoom:m,minZoom:N,maxZoom:S},v),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...ko({nodes:t,edges:e,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:p=>{const{nodeLookup:m,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:w,fitViewQueued:E,zIndexMode:N,nodesSelectionActive:S}=g(),{nodesInitialized:I,hasSelectedNodes:T}=Xn(p,m,v,{nodeOrigin:x,nodeExtent:u,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:N}),j=S&&T;E&&I?(y(),h({nodes:p,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:j})):h({nodes:p,nodesInitialized:I,nodesSelectionActive:j})},setEdges:p=>{const{connectionLookup:m,edgeLookup:v}=g();Pi(m,v,p),h({edges:p})},setDefaultNodesAndEdges:(p,m)=>{if(p){const{setNodes:v}=g();v(p),h({hasDefaultNodes:!0})}if(m){const{setEdges:v}=g();v(m),h({hasDefaultEdges:!0})}},updateNodeInternals:p=>{const{triggerNodeChanges:m,nodeLookup:v,parentLookup:x,domNode:w,nodeOrigin:E,nodeExtent:N,debug:S,fitViewQueued:I,zIndexMode:T}=g(),{changes:j,updatedInternals:k}=Bf(p,v,x,w,E,N,T);k&&(jf(v,x,{nodeOrigin:E,nodeExtent:N,zIndexMode:T}),I?(y(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(j==null?void 0:j.length)>0&&(S&&console.log("React Flow: trigger node changes",j),m==null||m(j)))},updateNodePositions:(p,m=!1)=>{const v=[];let x=[];const{nodeLookup:w,triggerNodeChanges:E,connection:N,updateConnection:S,onNodesChangeMiddlewareMap:I}=g();for(const[T,j]of p){const k=w.get(T),L=!!(k!=null&&k.expandParent&&(k!=null&&k.parentId)&&(j!=null&&j.position)),H={id:T,type:"position",position:L?{x:Math.max(0,j.position.x),y:Math.max(0,j.position.y)}:j.position,dragging:m};if(k&&N.inProgress&&N.fromNode.id===k.id){const _=Bt(k,N.fromHandle,G.Left,!0);S({...N,from:_})}L&&k.parentId&&v.push({id:T,parentId:k.parentId,rect:{...j.internals.positionAbsolute,width:j.measured.width??0,height:j.measured.height??0}}),x.push(H)}if(v.length>0){const{parentLookup:T,nodeOrigin:j}=g(),k=ur(v,w,T,j);x.push(...k)}for(const T of I.values())x=T(x);E(x)},triggerNodeChanges:p=>{const{onNodesChange:m,setNodes:v,nodes:x,hasDefaultNodes:w,debug:E}=g();if(p!=null&&p.length){if(w){const N=Gi(p,x);v(N)}E&&console.log("React Flow: trigger node changes",p),m==null||m(p)}},triggerEdgeChanges:p=>{const{onEdgesChange:m,setEdges:v,edges:x,hasDefaultEdges:w,debug:E}=g();if(p!=null&&p.length){if(w){const N=qi(p,x);v(N)}E&&console.log("React Flow: trigger edge changes",p),m==null||m(p)}},addSelectedNodes:p=>{const{multiSelectionActive:m,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(m){const N=p.map(S=>Tt(S,!0));w(N);return}w(Yt(x,new Set([...p]),!0)),E(Yt(v))},addSelectedEdges:p=>{const{multiSelectionActive:m,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(m){const N=p.map(S=>Tt(S,!0));E(N);return}E(Yt(v,new Set([...p]))),w(Yt(x,new Set,!0))},unselectNodesAndEdges:({nodes:p,edges:m}={})=>{const{edges:v,nodes:x,nodeLookup:w,triggerNodeChanges:E,triggerEdgeChanges:N}=g(),S=p||x,I=m||v,T=[];for(const k of S){if(!k.selected)continue;const L=w.get(k.id);L&&(L.selected=!1),T.push(Tt(k.id,!1))}const j=[];for(const k of I)k.selected&&j.push(Tt(k.id,!1));E(T),N(j)},setMinZoom:p=>{const{panZoom:m,maxZoom:v}=g();m==null||m.setScaleExtent([p,v]),h({minZoom:p})},setMaxZoom:p=>{const{panZoom:m,minZoom:v}=g();m==null||m.setScaleExtent([v,p]),h({maxZoom:p})},setTranslateExtent:p=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(p),h({translateExtent:p})},resetSelectedElements:()=>{const{edges:p,nodes:m,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:w}=g();if(!w)return;const E=m.reduce((S,I)=>I.selected?[...S,Tt(I.id,!1)]:S,[]),N=p.reduce((S,I)=>I.selected?[...S,Tt(I.id,!1)]:S,[]);v(E),x(N)},setNodeExtent:p=>{const{nodes:m,nodeLookup:v,parentLookup:x,nodeOrigin:w,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:S}=g();p[0][0]===N[0][0]&&p[0][1]===N[0][1]&&p[1][0]===N[1][0]&&p[1][1]===N[1][1]||(Xn(m,v,x,{nodeOrigin:w,nodeExtent:p,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:S}),h({nodeExtent:p}))},panBy:p=>{const{transform:m,width:v,height:x,panZoom:w,translateExtent:E}=g();return Ff({delta:p,panZoom:w,transform:m,translateExtent:E,width:v,height:x})},setCenter:async(p,m,v)=>{const{width:x,height:w,maxZoom:E,panZoom:N}=g();if(!N)return Promise.resolve(!1);const S=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:E;return await N.setViewport({x:x/2-p*S,y:w/2-m*S,zoom:S},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...gi}})},updateConnection:p=>{h({connection:p})},reset:()=>h({...ko()})}},Object.is);function ws({initialNodes:t,initialEdges:e,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d,children:h}){const[g]=P.useState(()=>og({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:c,minZoom:s,maxZoom:a,fitViewOptions:l,nodeOrigin:f,nodeExtent:u,zIndexMode:d}));return b.jsx(Ed,{value:g,children:b.jsx(Wd,{children:h})})}function ig({children:t,nodes:e,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:h}){return P.useContext(hn)?b.jsx(b.Fragment,{children:t}):b.jsx(ws,{initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:h,children:t})}const sg={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ag({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:f,onMoveStart:u,onMoveEnd:d,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:p,onClickConnectEnd:m,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:S,onNodeDrag:I,onNodeDragStop:T,onNodesDelete:j,onEdgesDelete:k,onDelete:L,onSelectionChange:H,onSelectionDragStart:_,onSelectionDrag:$,onSelectionDragStop:C,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:M,onBeforeDelete:D,connectionMode:V,connectionLineType:R=At.Bezier,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:W,deleteKeyCode:q="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:B=!1,selectionMode:O=we.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:Q=be()?"Meta":"Control",zoomActivationKeyCode:K=be()?"Meta":"Control",snapToGrid:U,snapGrid:et,onlyRenderVisibleElements:nt=!1,selectNodesOnDrag:tt,nodesDraggable:st,autoPanOnNodeFocus:Ct,nodesConnectable:bt,nodesFocusable:Pt,nodeOrigin:re=Yi,edgesFocusable:oe,edgesReconnectable:ie,elementsSelectable:yn=!0,defaultViewport:$e=jd,minZoom:Ft=.5,maxZoom:se=2,translateExtent:gr=xe,preventScrolling:Es=!0,nodeExtent:xn,defaultMarkerColor:Ss="#b1b1b7",zoomOnScroll:Ms=!0,zoomOnPinch:Cs=!0,panOnScroll:ks=!1,panOnScrollSpeed:Is=.5,panOnScrollMode:As=Dt.Free,zoomOnDoubleClick:$s=!0,panOnDrag:Ps=!0,onPaneClick:Ts,onPaneMouseEnter:zs,onPaneMouseMove:Ls,onPaneMouseLeave:Ds,onPaneScroll:js,onPaneContextMenu:Rs,paneClickDistance:Hs=1,nodeClickDistance:Vs=0,children:Bs,onReconnect:Fs,onReconnectStart:Os,onReconnectEnd:Xs,onEdgeContextMenu:Ys,onEdgeDoubleClick:Ws,onEdgeMouseEnter:Gs,onEdgeMouseMove:qs,onEdgeMouseLeave:Us,reconnectRadius:Zs=10,onNodesChange:Ks,onEdgesChange:Qs,noDragClassName:Js="nodrag",noWheelClassName:ta="nowheel",noPanClassName:pr="nopan",fitView:mr,fitViewOptions:yr,connectOnClick:ea,attributionPosition:na,proOptions:ra,defaultEdgeOptions:oa,elevateNodesOnSelect:ia=!0,elevateEdgesOnSelect:sa=!1,disableKeyboardA11y:xr=!1,autoPanOnConnect:aa,autoPanOnNodeDrag:ca,autoPanSpeed:la,connectionRadius:ua,isValidConnection:fa,onError:da,style:ha,id:wr,nodeDragThreshold:ga,connectionDragThreshold:pa,viewport:ma,onViewportChange:ya,width:xa,height:wa,colorMode:va="light",debug:ba,onScroll:Pe,ariaLabelConfig:_a,zIndexMode:vr="basic",...Na},Ea){const wn=wr||"1",Sa=Bd(va),Ma=P.useCallback(br=>{br.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pe==null||Pe(br)},[Pe]);return b.jsx("div",{"data-testid":"rf__wrapper",...Na,onScroll:Ma,style:{...ha,...sg},ref:Ea,className:it(["react-flow",o,Sa]),id:wr,role:"application",children:b.jsxs(ig,{nodes:t,edges:e,width:xa,height:wa,fitView:mr,fitViewOptions:yr,minZoom:Ft,maxZoom:se,nodeOrigin:re,nodeExtent:xn,zIndexMode:vr,children:[b.jsx(Vd,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:p,onClickConnectEnd:m,nodesDraggable:st,autoPanOnNodeFocus:Ct,nodesConnectable:bt,nodesFocusable:Pt,edgesFocusable:oe,edgesReconnectable:ie,elementsSelectable:yn,elevateNodesOnSelect:ia,elevateEdgesOnSelect:sa,minZoom:Ft,maxZoom:se,nodeExtent:xn,onNodesChange:Ks,onEdgesChange:Qs,snapToGrid:U,snapGrid:et,connectionMode:V,translateExtent:gr,connectOnClick:ea,defaultEdgeOptions:oa,fitView:mr,fitViewOptions:yr,onNodesDelete:j,onEdgesDelete:k,onDelete:L,onNodeDragStart:S,onNodeDrag:I,onNodeDragStop:T,onSelectionDrag:$,onSelectionDragStart:_,onSelectionDragStop:C,onMove:f,onMoveStart:u,onMoveEnd:d,noPanClassName:pr,nodeOrigin:re,rfId:wn,autoPanOnConnect:aa,autoPanOnNodeDrag:ca,autoPanSpeed:la,onError:da,connectionRadius:ua,isValidConnection:fa,selectNodesOnDrag:tt,nodeDragThreshold:ga,connectionDragThreshold:pa,onBeforeDelete:D,debug:ba,ariaLabelConfig:_a,zIndexMode:vr}),b.jsx(rg,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:R,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:W,selectionKeyCode:F,selectionOnDrag:B,selectionMode:O,deleteKeyCode:q,multiSelectionKeyCode:Q,panActivationKeyCode:Z,zoomActivationKeyCode:K,onlyRenderVisibleElements:nt,defaultViewport:$e,translateExtent:gr,minZoom:Ft,maxZoom:se,preventScrolling:Es,zoomOnScroll:Ms,zoomOnPinch:Cs,zoomOnDoubleClick:$s,panOnScroll:ks,panOnScrollSpeed:Is,panOnScrollMode:As,panOnDrag:Ps,onPaneClick:Ts,onPaneMouseEnter:zs,onPaneMouseMove:Ls,onPaneMouseLeave:Ds,onPaneScroll:js,onPaneContextMenu:Rs,paneClickDistance:Hs,nodeClickDistance:Vs,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:M,onReconnect:Fs,onReconnectStart:Os,onReconnectEnd:Xs,onEdgeContextMenu:Ys,onEdgeDoubleClick:Ws,onEdgeMouseEnter:Gs,onEdgeMouseMove:qs,onEdgeMouseLeave:Us,reconnectRadius:Zs,defaultMarkerColor:Ss,noDragClassName:Js,noWheelClassName:ta,noPanClassName:pr,rfId:wn,disableKeyboardA11y:xr,nodeExtent:xn,viewport:ma,onViewportChange:ya}),b.jsx(Dd,{onSelectionChange:H}),Bs,b.jsx($d,{proOptions:ra,position:na}),b.jsx(Ad,{rfId:wn,disableKeyboardA11y:xr})]})})}var cg=Ui(ag);function lg(t){const[e,n]=P.useState(t),r=P.useCallback(o=>n(i=>Gi(o,i)),[]);return[e,n,r]}function ug(t){const[e,n]=P.useState(t),r=P.useCallback(o=>n(i=>qi(o,i)),[]);return[e,n,r]}function fg({dimensions:t,lineWidth:e,variant:n,className:r}){return b.jsx("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",n,r])})}function dg({radius:t,className:e}){return b.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",e])})}var Et;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Et||(Et={}));const hg={[Et.Dots]:1,[Et.Lines]:1,[Et.Cross]:6},gg=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function vs({id:t,variant:e=Et.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:l,className:c,patternClassName:f}){const u=P.useRef(null),{transform:d,patternId:h}=J(gg,rt),g=r||hg[e],y=e===Et.Dots,p=e===Et.Cross,m=Array.isArray(n)?n:[n,n],v=[m[0]*d[2]||1,m[1]*d[2]||1],x=g*d[2],w=Array.isArray(i)?i:[i,i],E=p?[x,x]:v,N=[w[0]*d[2]||1+E[0]/2,w[1]*d[2]||1+E[1]/2],S=`${h}${t||""}`;return b.jsxs("svg",{className:it(["react-flow__background",c]),style:{...l,...pn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[b.jsx("pattern",{id:S,x:d[0]%v[0],y:d[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:y?b.jsx(dg,{radius:x/2,className:f}):b.jsx(fg,{dimensions:E,lineWidth:o,variant:e,className:f})}),b.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}vs.displayName="Background";const pg=P.memo(vs);function mg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:b.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function yg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:b.jsx("path",{d:"M0 0h32v4.2H0z"})})}function xg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:b.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function wg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:b.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function vg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:b.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Be({children:t,className:e,...n}){return b.jsx("button",{type:"button",className:it(["react-flow__controls-button",e]),...n,children:t})}const bg=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function bs({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:l,className:c,children:f,position:u="bottom-left",orientation:d="vertical","aria-label":h}){const g=ot(),{isInteractive:y,minZoomReached:p,maxZoomReached:m,ariaLabelConfig:v}=J(bg,rt),{zoomIn:x,zoomOut:w,fitView:E}=Ae(),N=()=>{x(),i==null||i()},S=()=>{w(),s==null||s()},I=()=>{E(o),a==null||a()},T=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l==null||l(!y)},j=d==="horizontal"?"horizontal":"vertical";return b.jsxs(gn,{className:it(["react-flow__controls",j,c]),position:u,style:t,"data-testid":"rf__controls","aria-label":h??v["controls.ariaLabel"],children:[e&&b.jsxs(b.Fragment,{children:[b.jsx(Be,{onClick:N,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:m,children:b.jsx(mg,{})}),b.jsx(Be,{onClick:S,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:p,children:b.jsx(yg,{})})]}),n&&b.jsx(Be,{className:"react-flow__controls-fitview",onClick:I,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:b.jsx(xg,{})}),r&&b.jsx(Be,{className:"react-flow__controls-interactive",onClick:T,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:y?b.jsx(vg,{}):b.jsx(wg,{})}),f]})}bs.displayName="Controls";P.memo(bs);function _g({id:t,x:e,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:l,className:c,borderRadius:f,shapeRendering:u,selected:d,onClick:h}){const{background:g,backgroundColor:y}=i||{},p=s||g||y;return b.jsx("rect",{className:it(["react-flow__minimap-node",{selected:d},c]),x:e,y:n,rx:f,ry:f,width:r,height:o,style:{fill:p,stroke:a,strokeWidth:l},shapeRendering:u,onClick:h?m=>h(m,t):void 0})}const Ng=P.memo(_g),Eg=t=>t.nodes.map(e=>e.id),Pn=t=>t instanceof Function?t:()=>t;function Sg({nodeStrokeColor:t,nodeColor:e,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Ng,onClick:s}){const a=J(Eg,rt),l=Pn(e),c=Pn(t),f=Pn(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return b.jsx(b.Fragment,{children:a.map(d=>b.jsx(Cg,{id:d,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:u},d))})}function Mg({id:t,nodeColorFunc:e,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:l}){const{node:c,x:f,y:u,width:d,height:h}=J(g=>{const y=g.nodeLookup.get(t);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const p=y.internals.userNode,{x:m,y:v}=y.internals.positionAbsolute,{width:x,height:w}=Mt(p);return{node:p,x:m,y:v,width:x,height:w}},rt);return!c||c.hidden||!bi(c)?null:b.jsx(a,{x:f,y:u,width:d,height:h,style:c.style,selected:!!c.selected,className:r(c),color:e(c),borderRadius:o,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:l,id:c.id})}const Cg=P.memo(Mg);var kg=P.memo(Sg);const Ig=200,Ag=150,$g=t=>!t.hidden,Pg=t=>{const e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?vi(Ce(t.nodeLookup,{filter:$g}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Tg="react-flow__minimap-desc";function _s({style:t,className:e,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:f,maskStrokeWidth:u,position:d="bottom-right",onClick:h,onNodeClick:g,pannable:y=!1,zoomable:p=!1,ariaLabel:m,inversePan:v,zoomStep:x=1,offsetScale:w=5}){const E=ot(),N=P.useRef(null),{boundingRect:S,viewBB:I,rfId:T,panZoom:j,translateExtent:k,flowWidth:L,flowHeight:H,ariaLabelConfig:_}=J(Pg,rt),$=(t==null?void 0:t.width)??Ig,C=(t==null?void 0:t.height)??Ag,z=S.width/$,A=S.height/C,M=Math.max(z,A),D=M*$,V=M*C,R=w*M,X=S.x-(D-S.width)/2-R,Y=S.y-(V-S.height)/2-R,W=D+R*2,q=V+R*2,F=`${Tg}-${T}`,B=P.useRef(0),O=P.useRef();B.current=M,P.useEffect(()=>{if(N.current&&j)return O.current=Kf({domNode:N.current,panZoom:j,getTransform:()=>E.getState().transform,getViewScale:()=>B.current}),()=>{var U;(U=O.current)==null||U.destroy()}},[j]),P.useEffect(()=>{var U;(U=O.current)==null||U.update({translateExtent:k,width:L,height:H,inversePan:v,pannable:y,zoomStep:x,zoomable:p})},[y,p,v,x,k,L,H]);const Z=h?U=>{var tt;const[et,nt]=((tt=O.current)==null?void 0:tt.pointer(U))||[0,0];h(U,{x:et,y:nt})}:void 0,Q=g?P.useCallback((U,et)=>{const nt=E.getState().nodeLookup.get(et).internals.userNode;g(U,nt)},[]):void 0,K=m??_["minimap.ariaLabel"];return b.jsx(gn,{position:d,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:it(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:b.jsxs("svg",{width:$,height:C,viewBox:`${X} ${Y} ${W} ${q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":F,ref:N,onClick:Z,children:[K&&b.jsx("title",{id:F,children:K}),b.jsx(kg,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),b.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-R},${Y-R}h${W+R*2}v${q+R*2}h${-W-R*2}z
|
|
23
|
-
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_s.displayName="MiniMap";const zg=P.memo(_s),Lg=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,Dg={[ee.Line]:"right",[ee.Handle]:"bottom-right"};function jg({nodeId:t,position:e,variant:n=ee.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:d,autoScale:h=!0,shouldResize:g,onResizeStart:y,onResize:p,onResizeEnd:m}){const v=Ji(),x=typeof t=="string"?t:v,w=ot(),E=P.useRef(null),N=n===ee.Handle,S=J(P.useCallback(Lg(N&&h),[N,h]),rt),I=P.useRef(null),T=e??Dg[n];P.useEffect(()=>{if(!(!E.current||!x))return I.current||(I.current=fd({domNode:E.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:k,transform:L,snapGrid:H,snapToGrid:_,nodeOrigin:$,domNode:C}=w.getState();return{nodeLookup:k,transform:L,snapGrid:H,snapToGrid:_,nodeOrigin:$,paneDomNode:C}},onChange:(k,L)=>{const{triggerNodeChanges:H,nodeLookup:_,parentLookup:$,nodeOrigin:C}=w.getState(),z=[],A={x:k.x,y:k.y},M=_.get(x);if(M&&M.expandParent&&M.parentId){const D=M.origin??C,V=k.width??M.measured.width??0,R=k.height??M.measured.height??0,X={id:M.id,parentId:M.parentId,rect:{width:V,height:R,..._i({x:k.x??M.position.x,y:k.y??M.position.y},{width:V,height:R},M.parentId,_,D)}},Y=ur([X],_,$,C);z.push(...Y),A.x=k.x?Math.max(D[0]*V,k.x):void 0,A.y=k.y?Math.max(D[1]*R,k.y):void 0}if(A.x!==void 0&&A.y!==void 0){const D={id:x,type:"position",position:{...A}};z.push(D)}if(k.width!==void 0&&k.height!==void 0){const V={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:k.width,height:k.height}};z.push(V)}for(const D of L){const V={...D,type:"position"};z.push(V)}H(z)},onEnd:({width:k,height:L})=>{const H={id:x,type:"dimensions",resizing:!1,dimensions:{width:k,height:L}};w.getState().triggerNodeChanges([H])}})),I.current.update({controlPosition:T,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:f},keepAspectRatio:u,resizeDirection:d,onResizeStart:y,onResize:p,onResizeEnd:m,shouldResize:g}),()=>{var k;(k=I.current)==null||k.destroy()}},[T,a,l,c,f,u,y,p,m,g]);const j=T.split("-");return b.jsx("div",{className:it(["react-flow__resize-control","nodrag",...j,n,r]),ref:E,style:{...o,scale:S,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}P.memo(jg);function Rg(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function o(){var i,s=n.length,a,l=0,c=0;for(i=0;i<s;++i)a=n[i],l+=a.x,c+=a.y;for(l=(l/s-t)*r,c=(c/s-e)*r,i=0;i<s;++i)a=n[i],a.x-=l,a.y-=c}return o.initialize=function(i){n=i},o.x=function(i){return arguments.length?(t=+i,o):t},o.y=function(i){return arguments.length?(e=+i,o):e},o.strength=function(i){return arguments.length?(r=+i,o):r},o}function Hg(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Ns(this.cover(e,n),e,n,t)}function Ns(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var o,i=t._root,s={data:r},a=t._x0,l=t._y0,c=t._x1,f=t._y1,u,d,h,g,y,p,m,v;if(!i)return t._root=s,t;for(;i.length;)if((y=e>=(u=(a+c)/2))?a=u:c=u,(p=n>=(d=(l+f)/2))?l=d:f=d,o=i,!(i=i[m=p<<1|y]))return o[m]=s,t;if(h=+t._x.call(null,i.data),g=+t._y.call(null,i.data),e===h&&n===g)return s.next=i,o?o[m]=s:t._root=s,t;do o=o?o[m]=new Array(4):t._root=new Array(4),(y=e>=(u=(a+c)/2))?a=u:c=u,(p=n>=(d=(l+f)/2))?l=d:f=d;while((m=p<<1|y)===(v=(g>=d)<<1|h>=u));return o[v]=i,o[m]=s,t}function Vg(t){var e,n,r=t.length,o,i,s=new Array(r),a=new Array(r),l=1/0,c=1/0,f=-1/0,u=-1/0;for(n=0;n<r;++n)isNaN(o=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(s[n]=o,a[n]=i,o<l&&(l=o),o>f&&(f=o),i<c&&(c=i),i>u&&(u=i));if(l>f||c>u)return this;for(this.cover(l,c).cover(f,u),n=0;n<r;++n)Ns(this,s[n],a[n],t[n]);return this}function Bg(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,o=this._x1,i=this._y1;if(isNaN(n))o=(n=Math.floor(t))+1,i=(r=Math.floor(e))+1;else{for(var s=o-n||1,a=this._root,l,c;n>t||t>=o||r>e||e>=i;)switch(c=(e<r)<<1|t<n,l=new Array(4),l[c]=a,a=l,s*=2,c){case 0:o=n+s,i=r+s;break;case 1:n=o-s,i=r+s;break;case 2:o=n+s,r=i-s;break;case 3:n=o-s,r=i-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=n,this._y0=r,this._x1=o,this._y1=i,this}function Fg(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Og(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function at(t,e,n,r,o){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=o}function Xg(t,e,n){var r,o=this._x0,i=this._y0,s,a,l,c,f=this._x1,u=this._y1,d=[],h=this._root,g,y;for(h&&d.push(new at(h,o,i,f,u)),n==null?n=1/0:(o=t-n,i=e-n,f=t+n,u=e+n,n*=n);g=d.pop();)if(!(!(h=g.node)||(s=g.x0)>f||(a=g.y0)>u||(l=g.x1)<o||(c=g.y1)<i))if(h.length){var p=(s+l)/2,m=(a+c)/2;d.push(new at(h[3],p,m,l,c),new at(h[2],s,m,p,c),new at(h[1],p,a,l,m),new at(h[0],s,a,p,m)),(y=(e>=m)<<1|t>=p)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-y],d[d.length-1-y]=g)}else{var v=t-+this._x.call(null,h.data),x=e-+this._y.call(null,h.data),w=v*v+x*x;if(w<n){var E=Math.sqrt(n=w);o=t-E,i=e-E,f=t+E,u=e+E,r=h.data}}return r}function Yg(t){if(isNaN(f=+this._x.call(null,t))||isNaN(u=+this._y.call(null,t)))return this;var e,n=this._root,r,o,i,s=this._x0,a=this._y0,l=this._x1,c=this._y1,f,u,d,h,g,y,p,m;if(!n)return this;if(n.length)for(;;){if((g=f>=(d=(s+l)/2))?s=d:l=d,(y=u>=(h=(a+c)/2))?a=h:c=h,e=n,!(n=n[p=y<<1|g]))return this;if(!n.length)break;(e[p+1&3]||e[p+2&3]||e[p+3&3])&&(r=e,m=p)}for(;n.data!==t;)if(o=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,o?(i?o.next=i:delete o.next,this):e?(i?e[p]=i:delete e[p],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[m]=n:this._root=n),this):(this._root=i,this)}function Wg(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Gg(){return this._root}function qg(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Ug(t){var e=[],n,r=this._root,o,i,s,a,l;for(r&&e.push(new at(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,i=n.x0,s=n.y0,a=n.x1,l=n.y1)&&r.length){var c=(i+a)/2,f=(s+l)/2;(o=r[3])&&e.push(new at(o,c,f,a,l)),(o=r[2])&&e.push(new at(o,i,f,c,l)),(o=r[1])&&e.push(new at(o,c,s,a,f)),(o=r[0])&&e.push(new at(o,i,s,c,f))}return this}function Zg(t){var e=[],n=[],r;for(this._root&&e.push(new at(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var o=r.node;if(o.length){var i,s=r.x0,a=r.y0,l=r.x1,c=r.y1,f=(s+l)/2,u=(a+c)/2;(i=o[0])&&e.push(new at(i,s,a,f,u)),(i=o[1])&&e.push(new at(i,f,a,l,u)),(i=o[2])&&e.push(new at(i,s,u,f,c)),(i=o[3])&&e.push(new at(i,f,u,l,c))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Kg(t){return t[0]}function Qg(t){return arguments.length?(this._x=t,this):this._x}function Jg(t){return t[1]}function t0(t){return arguments.length?(this._y=t,this):this._y}function dr(t,e,n){var r=new hr(e??Kg,n??Jg,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function hr(t,e,n,r,o,i){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=o,this._y1=i,this._root=void 0}function Io(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var ct=dr.prototype=hr.prototype;ct.copy=function(){var t=new hr(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Io(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var o=0;o<4;++o)(r=e.source[o])&&(r.length?n.push({source:r,target:e.target[o]=new Array(4)}):e.target[o]=Io(r));return t};ct.add=Hg;ct.addAll=Vg;ct.cover=Bg;ct.data=Fg;ct.extent=Og;ct.find=Xg;ct.remove=Yg;ct.removeAll=Wg;ct.root=Gg;ct.size=qg;ct.visit=Ug;ct.visitAfter=Zg;ct.x=Qg;ct.y=t0;function jt(t){return function(){return t}}function $t(t){return(t()-.5)*1e-6}function e0(t){return t.x+t.vx}function n0(t){return t.y+t.vy}function r0(t){var e,n,r,o=1,i=1;typeof t!="function"&&(t=jt(t==null?1:+t));function s(){for(var c,f=e.length,u,d,h,g,y,p,m=0;m<i;++m)for(u=dr(e,e0,n0).visitAfter(a),c=0;c<f;++c)d=e[c],y=n[d.index],p=y*y,h=d.x+d.vx,g=d.y+d.vy,u.visit(v);function v(x,w,E,N,S){var I=x.data,T=x.r,j=y+T;if(I){if(I.index>d.index){var k=h-I.x-I.vx,L=g-I.y-I.vy,H=k*k+L*L;H<j*j&&(k===0&&(k=$t(r),H+=k*k),L===0&&(L=$t(r),H+=L*L),H=(j-(H=Math.sqrt(H)))/H*o,d.vx+=(k*=H)*(j=(T*=T)/(p+T)),d.vy+=(L*=H)*j,I.vx-=k*(j=1-j),I.vy-=L*j)}return}return w>h+j||N<h-j||E>g+j||S<g-j}}function a(c){if(c.data)return c.r=n[c.data.index];for(var f=c.r=0;f<4;++f)c[f]&&c[f].r>c.r&&(c.r=c[f].r)}function l(){if(e){var c,f=e.length,u;for(n=new Array(f),c=0;c<f;++c)u=e[c],n[u.index]=+t(u,c,e)}}return s.initialize=function(c,f){e=c,r=f,l()},s.iterations=function(c){return arguments.length?(i=+c,s):i},s.strength=function(c){return arguments.length?(o=+c,s):o},s.radius=function(c){return arguments.length?(t=typeof c=="function"?c:jt(+c),l(),s):t},s}function o0(t){return t.index}function Ao(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function i0(t){var e=o0,n=u,r,o=jt(30),i,s,a,l,c,f=1;t==null&&(t=[]);function u(p){return 1/Math.min(a[p.source.index],a[p.target.index])}function d(p){for(var m=0,v=t.length;m<f;++m)for(var x=0,w,E,N,S,I,T,j;x<v;++x)w=t[x],E=w.source,N=w.target,S=N.x+N.vx-E.x-E.vx||$t(c),I=N.y+N.vy-E.y-E.vy||$t(c),T=Math.sqrt(S*S+I*I),T=(T-i[x])/T*p*r[x],S*=T,I*=T,N.vx-=S*(j=l[x]),N.vy-=I*j,E.vx+=S*(j=1-j),E.vy+=I*j}function h(){if(s){var p,m=s.length,v=t.length,x=new Map(s.map((E,N)=>[e(E,N,s),E])),w;for(p=0,a=new Array(m);p<v;++p)w=t[p],w.index=p,typeof w.source!="object"&&(w.source=Ao(x,w.source)),typeof w.target!="object"&&(w.target=Ao(x,w.target)),a[w.source.index]=(a[w.source.index]||0)+1,a[w.target.index]=(a[w.target.index]||0)+1;for(p=0,l=new Array(v);p<v;++p)w=t[p],l[p]=a[w.source.index]/(a[w.source.index]+a[w.target.index]);r=new Array(v),g(),i=new Array(v),y()}}function g(){if(s)for(var p=0,m=t.length;p<m;++p)r[p]=+n(t[p],p,t)}function y(){if(s)for(var p=0,m=t.length;p<m;++p)i[p]=+o(t[p],p,t)}return d.initialize=function(p,m){s=p,c=m,h()},d.links=function(p){return arguments.length?(t=p,h(),d):t},d.id=function(p){return arguments.length?(e=p,d):e},d.iterations=function(p){return arguments.length?(f=+p,d):f},d.strength=function(p){return arguments.length?(n=typeof p=="function"?p:jt(+p),g(),d):n},d.distance=function(p){return arguments.length?(o=typeof p=="function"?p:jt(+p),y(),d):o},d}const s0=1664525,a0=1013904223,$o=4294967296;function c0(){let t=1;return()=>(t=(s0*t+a0)%$o)/$o}function l0(t){return t.x}function u0(t){return t.y}var f0=10,d0=Math.PI*(3-Math.sqrt(5));function h0(t){var e,n=1,r=.001,o=1-Math.pow(r,1/300),i=0,s=.6,a=new Map,l=Jn(u),c=Ne("tick","end"),f=c0();t==null&&(t=[]);function u(){d(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function d(y){var p,m=t.length,v;y===void 0&&(y=1);for(var x=0;x<y;++x)for(n+=(i-n)*o,a.forEach(function(w){w(n)}),p=0;p<m;++p)v=t[p],v.fx==null?v.x+=v.vx*=s:(v.x=v.fx,v.vx=0),v.fy==null?v.y+=v.vy*=s:(v.y=v.fy,v.vy=0);return e}function h(){for(var y=0,p=t.length,m;y<p;++y){if(m=t[y],m.index=y,m.fx!=null&&(m.x=m.fx),m.fy!=null&&(m.y=m.fy),isNaN(m.x)||isNaN(m.y)){var v=f0*Math.sqrt(.5+y),x=y*d0;m.x=v*Math.cos(x),m.y=v*Math.sin(x)}(isNaN(m.vx)||isNaN(m.vy))&&(m.vx=m.vy=0)}}function g(y){return y.initialize&&y.initialize(t,f),y}return h(),e={tick:d,restart:function(){return l.restart(u),e},stop:function(){return l.stop(),e},nodes:function(y){return arguments.length?(t=y,h(),a.forEach(g),e):t},alpha:function(y){return arguments.length?(n=+y,e):n},alphaMin:function(y){return arguments.length?(r=+y,e):r},alphaDecay:function(y){return arguments.length?(o=+y,e):+o},alphaTarget:function(y){return arguments.length?(i=+y,e):i},velocityDecay:function(y){return arguments.length?(s=1-y,e):1-s},randomSource:function(y){return arguments.length?(f=y,a.forEach(g),e):f},force:function(y,p){return arguments.length>1?(p==null?a.delete(y):a.set(y,g(p)),e):a.get(y)},find:function(y,p,m){var v=0,x=t.length,w,E,N,S,I;for(m==null?m=1/0:m*=m,v=0;v<x;++v)S=t[v],w=y-S.x,E=p-S.y,N=w*w+E*E,N<m&&(I=S,m=N);return I},on:function(y,p){return arguments.length>1?(c.on(y,p),e):c.on(y)}}}function g0(){var t,e,n,r,o=jt(-30),i,s=1,a=1/0,l=.81;function c(h){var g,y=t.length,p=dr(t,l0,u0).visitAfter(u);for(r=h,g=0;g<y;++g)e=t[g],p.visit(d)}function f(){if(t){var h,g=t.length,y;for(i=new Array(g),h=0;h<g;++h)y=t[h],i[y.index]=+o(y,h,t)}}function u(h){var g=0,y,p,m=0,v,x,w;if(h.length){for(v=x=w=0;w<4;++w)(y=h[w])&&(p=Math.abs(y.value))&&(g+=y.value,m+=p,v+=p*y.x,x+=p*y.y);h.x=v/m,h.y=x/m}else{y=h,y.x=y.data.x,y.y=y.data.y;do g+=i[y.data.index];while(y=y.next)}h.value=g}function d(h,g,y,p){if(!h.value)return!0;var m=h.x-e.x,v=h.y-e.y,x=p-g,w=m*m+v*v;if(x*x/l<w)return w<a&&(m===0&&(m=$t(n),w+=m*m),v===0&&(v=$t(n),w+=v*v),w<s&&(w=Math.sqrt(s*w)),e.vx+=m*h.value*r/w,e.vy+=v*h.value*r/w),!0;if(h.length||w>=a)return;(h.data!==e||h.next)&&(m===0&&(m=$t(n),w+=m*m),v===0&&(v=$t(n),w+=v*v),w<s&&(w=Math.sqrt(s*w)));do h.data!==e&&(x=i[h.data.index]*r/w,e.vx+=m*x,e.vy+=v*x);while(h=h.next)}return c.initialize=function(h,g){t=h,n=g,f()},c.strength=function(h){return arguments.length?(o=typeof h=="function"?h:jt(+h),f(),c):o},c.distanceMin=function(h){return arguments.length?(s=h*h,c):Math.sqrt(s)},c.distanceMax=function(h){return arguments.length?(a=h*h,c):Math.sqrt(a)},c.theta=function(h){return arguments.length?(l=h*h,c):Math.sqrt(l)},c}function Po(t){if(!t)return"—";const e=t.split("/");return e[e.length-1]??t}function p0({layout:t,onLayoutChange:e,depth:n,onDepthChange:r,nodeCount:o,edgeCount:i,truncated:s,onRelayout:a,langFilter:l,onLangFilterChange:c,availableLangs:f,clusterByDir:u,onClusterByDirChange:d,pathFrom:h,pathTo:g,selectingPath:y,onSelectPath:p,onFindPath:m,onClearPath:v,pathStatus:x}){const{zoomIn:w,zoomOut:E,fitView:N}=Ae();return b.jsxs("div",{"data-testid":"graph-controls",className:"flex flex-col gap-3 p-3 bg-gray-900 border border-gray-700 rounded-lg shadow-lg",style:{width:230},children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx("button",{type:"button",onClick:()=>w({duration:200}),className:"flex-1 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Zoom in",children:"+ Zoom In"}),b.jsx("button",{type:"button",onClick:()=>E({duration:200}),className:"flex-1 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Zoom out",children:"− Zoom Out"})]}),b.jsx("button",{type:"button",onClick:()=>N({duration:300,padding:.1}),className:"py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Fit to view",children:"Fit to View"}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Layout"}),b.jsxs("select",{value:t,onChange:S=>e(S.target.value),className:"w-full px-2 py-1 text-xs bg-gray-800 border border-gray-700 rounded text-gray-300 focus:outline-none focus:border-blue-500","aria-label":"Layout algorithm",children:[b.jsx("option",{value:"force",children:"Force-directed"}),b.jsx("option",{value:"hierarchical",children:"Hierarchical"}),b.jsx("option",{value:"radial",children:"Radial"})]})]}),b.jsxs("div",{children:[b.jsxs("label",{className:"flex items-center justify-between text-xs text-gray-500 mb-1",children:[b.jsx("span",{children:"Depth"}),b.jsx("span",{className:"text-gray-300",children:n})]}),b.jsx("input",{type:"range",min:1,max:10,value:n,onChange:S=>r(Number(S.target.value)),className:"w-full accent-blue-500","aria-label":"Traversal depth","data-testid":"depth-slider"}),b.jsxs("div",{className:"flex justify-between text-gray-600 mt-0.5",style:{fontSize:"0.6rem"},children:[b.jsx("span",{children:"1"}),b.jsx("span",{children:"10"})]})]}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Language"}),b.jsxs("select",{value:l,onChange:S=>c(S.target.value),className:"w-full px-2 py-1 text-xs bg-gray-800 border border-gray-700 rounded text-gray-300 focus:outline-none focus:border-blue-500","aria-label":"Language filter","data-testid":"lang-filter",children:[b.jsx("option",{value:"",children:"All languages"}),f.map(S=>b.jsxs("option",{value:S,children:[".",S]},S))]})]}),b.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[b.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked),className:"accent-blue-500","aria-label":"Cluster by directory","data-testid":"cluster-toggle"}),b.jsx("span",{className:"text-xs text-gray-400",children:"Cluster by directory"})]}),b.jsxs("div",{className:"border-t border-gray-800 pt-2",children:[b.jsx("div",{className:"text-xs text-gray-500 mb-1.5",children:"Highlight Path"}),b.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[b.jsx("button",{type:"button",onClick:()=>p("from"),className:`px-2 py-0.5 text-xs rounded border transition-colors ${y==="from"?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300"}`,"aria-label":"Select path start node","data-testid":"path-from-btn",children:"From"}),b.jsx("span",{className:"text-xs font-mono text-gray-300 truncate flex-1",title:h??"","data-testid":"path-from-label",children:y==="from"?b.jsx("span",{className:"text-blue-400 animate-pulse",children:"click a node…"}):Po(h)})]}),b.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[b.jsx("button",{type:"button",onClick:()=>p("to"),className:`px-2 py-0.5 text-xs rounded border transition-colors ${y==="to"?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300"}`,"aria-label":"Select path end node","data-testid":"path-to-btn",children:"To"}),b.jsx("span",{className:"text-xs font-mono text-gray-300 truncate flex-1",title:g??"","data-testid":"path-to-label",children:y==="to"?b.jsx("span",{className:"text-blue-400 animate-pulse",children:"click a node…"}):Po(g)})]}),b.jsxs("div",{className:"flex gap-1.5",children:[b.jsx("button",{type:"button",onClick:m,disabled:!h||!g,className:"flex-1 py-1 text-xs bg-blue-600 hover:bg-blue-500 disabled:bg-gray-800 disabled:text-gray-600 rounded text-white transition-colors","aria-label":"Find path","data-testid":"find-path-btn",children:"Find Path"}),b.jsx("button",{type:"button",onClick:v,disabled:!h&&!g&&x==="idle",className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:text-gray-700 border border-gray-700 rounded text-gray-400 transition-colors","aria-label":"Clear path","data-testid":"clear-path-btn",children:"Clear"})]}),x==="found"&&b.jsx("div",{className:"mt-1.5 text-xs text-green-400","data-testid":"path-status-found",children:"Path found — highlighted in blue"}),x==="not-found"&&b.jsx("div",{className:"mt-1.5 text-xs text-amber-400","data-testid":"path-status-not-found",children:"No path found between these nodes"})]}),b.jsx("button",{type:"button",onClick:a,className:"py-1 text-xs bg-blue-600 hover:bg-blue-500 rounded text-white transition-colors","aria-label":"Re-run layout",children:"Re-layout"}),b.jsxs("div",{className:"border-t border-gray-800 pt-2 text-gray-500",style:{fontSize:"0.65rem"},children:[b.jsxs("div",{children:[o," nodes · ",i," edges"]}),s&&b.jsx("div",{className:"text-amber-500 mt-0.5",children:"Graph truncated (limit reached)"})]})]})}function m0(t){if(t<.5){const e=t*2,n=Math.round(34+e*200),r=Math.round(197+e*-18),o=Math.round(94+e*-86);return`rgb(${n},${r},${o})`}else{const e=(t-.5)*2,n=Math.round(234+e*5),r=Math.round(179+e*-111),o=Math.round(8+e*60);return`rgb(${n},${r},${o})`}}function y0({ext:t}){const e=t==="ts"||t==="tsx"?"#3b82f6":t==="js"||t==="jsx"?"#eab308":t==="vue"?"#22c55e":t==="py"?"#a78bfa":"#9ca3af";return b.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",className:"shrink-0",children:[b.jsx("rect",{x:"1",y:"1",width:"8",height:"10",rx:"1",stroke:e,strokeWidth:"1.2"}),b.jsx("path",{d:"M7 1v3h3",stroke:e,strokeWidth:"1.2",strokeLinecap:"round"}),b.jsx("line",{x1:"3",y1:"6",x2:"9",y2:"6",stroke:e,strokeWidth:"1",strokeLinecap:"round"}),b.jsx("line",{x1:"3",y1:"8",x2:"7",y2:"8",stroke:e,strokeWidth:"1",strokeLinecap:"round"})]})}const x0=P.memo(function({data:e,selected:n}){const r=e.label??"",o=r.includes(".")?r.split(".").pop()??"":"",i=typeof e.heatmapScore=="number"?e.heatmapScore:void 0,s=!!e.isChurnHotspot;return b.jsxs("div",{"data-testid":"graph-file-node",className:`
|
|
22
|
+
`)),f=c.reduce((u,d)=>u.concat(...d),[]);return[c,f]}return[[],[]]},[t]);return P.useEffect(()=>{const l=(e==null?void 0:e.target)??uo,c=(e==null?void 0:e.actInsideInputWithModifier)??!0;if(t!==null){const f=h=>{var p,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!c)&&Si(h))return!1;const y=ho(h.code,a);if(i.current.add(h[y]),fo(s,i.current,!1)){const v=((m=(p=h.composedPath)==null?void 0:p.call(h))==null?void 0:m[0])||h.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";e.preventDefault!==!1&&(o.current||!x)&&h.preventDefault(),r(!0)}},u=h=>{const g=ho(h.code,a);fo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},d=()=>{i.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",f),l==null||l.addEventListener("keyup",u),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{l==null||l.removeEventListener("keydown",f),l==null||l.removeEventListener("keyup",u),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[t,r]),n}function fo(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(o=>e.has(o)))}function ho(t,e){return e.includes(t)?"code":"key"}const Fd=()=>{const t=ot();return P.useMemo(()=>({zoomIn:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,e):Promise.resolve(!1)},zoomOut:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,e):Promise.resolve(!1)},zoomTo:(e,n)=>{const{panZoom:r}=t.getState();return r?r.scaleTo(e,n):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,n)=>{const{transform:[r,o,i],panZoom:s}=t.getState();return s?(await s.setViewport({x:e.x??r,y:e.y??o,zoom:e.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},setCenter:async(e,n,r)=>t.getState().setCenter(e,n,r),fitBounds:async(e,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=t.getState(),l=or(e,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=t.getState();if(!s)return e;const{x:a,y:l}=s.getBoundingClientRect(),c={x:e.x-a,y:e.y-l},f=n.snapGrid??o,u=n.snapToGrid??i;return Ie(c,r,u,f)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:o,y:i}=r.getBoundingClientRect(),s=rn(e,n);return{x:s.x+o,y:s.y+i}}}),[])};function Gi(t,e){const n=[],r=new Map,o=[];for(const i of t)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of e){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const l of s)Od(l,a);n.push(a)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Od(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function qi(t,e){return Gi(t,e)}function Ui(t,e){return Gi(t,e)}function Tt(t,e){return{id:t,type:"select",selected:e}}function Yt(t,e=new Set,n=!1){const r=[];for(const[o,i]of t){const s=e.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(Tt(i.id,s)))}return r}function go({items:t=[],lookup:e}){var o;const n=[],r=new Map(t.map(i=>[i.id,i]));for(const[i,s]of t.entries()){const a=e.get(s.id),l=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;l!==void 0&&l!==s&&n.push({id:s.id,item:s,type:"replace"}),l===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of e)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function po(t){return{id:t.id,type:"remove"}}const mo=t=>hf(t),Xd=t=>yi(t);function Zi(t){return P.forwardRef(t)}function yo(t){const[e,n]=P.useState(BigInt(0)),[r]=P.useState(()=>Yd(()=>n(o=>o+BigInt(1))));return Wn(()=>{const o=r.get();o.length&&(t(o),r.reset())},[e]),r}function Yd(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:n=>{e.push(n),t()}}}const Ki=P.createContext(null);function Wd({children:t}){const e=ot(),n=P.useCallback(a=>{const{nodes:l=[],setNodes:c,hasDefaultNodes:f,onNodesChange:u,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=e.getState();let y=l;for(const m of a)y=typeof m=="function"?m(y):m;let p=go({items:y,lookup:d});for(const m of g.values())p=m(p);f&&c(y),p.length>0?u==null||u(p):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:v,setNodes:x}=e.getState();m&&x(v)})},[]),r=yo(n),o=P.useCallback(a=>{const{edges:l=[],setEdges:c,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:d}=e.getState();let h=l;for(const g of a)h=typeof g=="function"?g(h):g;f?c(h):u&&u(go({items:h,lookup:d}))},[]),i=yo(o),s=P.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return b.jsx(Ki.Provider,{value:s,children:t})}function Gd(){const t=P.useContext(Ki);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const qd=t=>!!t.panZoom;function Ae(){const t=Fd(),e=ot(),n=Gd(),r=J(qd),o=P.useMemo(()=>{const i=u=>e.getState().nodeLookup.get(u),s=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},l=u=>{var m,v;const{nodeLookup:d,nodeOrigin:h}=e.getState(),g=mo(u)?u:d.get(u.id),y=g.parentId?Ni(g.position,g.measured,g.parentId,d,h):g.position,p={...g,position:y,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return Jt(p)},c=(u,d,h={replace:!1})=>{s(g=>g.map(y=>{if(y.id===u){const p=typeof d=="function"?d(y):d;return h.replace&&mo(p)?p:{...y,...p}}return y}))},f=(u,d,h={replace:!1})=>{a(g=>g.map(y=>{if(y.id===u){const p=typeof d=="function"?d(y):d;return h.replace&&Xd(p)?p:{...y,...p}}return y}))};return{getNodes:()=>e.getState().nodes.map(u=>({...u})),getNode:u=>{var d;return(d=i(u))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=e.getState();return u.map(d=>({...d}))},getEdge:u=>e.getState().edgeLookup.get(u),setNodes:s,setEdges:a,addNodes:u=>{const d=Array.isArray(u)?u:[u];n.nodeQueue.push(h=>[...h,...d])},addEdges:u=>{const d=Array.isArray(u)?u:[u];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:u=[],edges:d=[],transform:h}=e.getState(),[g,y,p]=h;return{nodes:u.map(m=>({...m})),edges:d.map(m=>({...m})),viewport:{x:g,y,zoom:p}}},deleteElements:async({nodes:u=[],edges:d=[]})=>{const{nodes:h,edges:g,onNodesDelete:y,onEdgesDelete:p,triggerNodeChanges:m,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:w}=e.getState(),{nodes:E,edges:N}=await xf({nodesToRemove:u,edgesToRemove:d,nodes:h,edges:g,onBeforeDelete:w}),S=N.length>0,I=E.length>0;if(S){const T=N.map(po);p==null||p(N),v(T)}if(I){const T=E.map(po);y==null||y(E),m(T)}return(I||S)&&(x==null||x({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(u,d=!0,h)=>{const g=Br(u),y=g?u:l(u),p=h!==void 0;return y?(h||e.getState().nodes).filter(m=>{const v=e.getState().nodeLookup.get(m.id);if(v&&!g&&(m.id===u.id||!v.internals.positionAbsolute))return!1;const x=Jt(p?m:v),w=ve(x,y);return d&&w>0||w>=x.width*x.height||w>=y.width*y.height}):[]},isNodeIntersecting:(u,d,h=!0)=>{const y=Br(u)?u:l(u);if(!y)return!1;const p=ve(y,d);return h&&p>0||p>=d.width*d.height||p>=y.width*y.height},updateNode:c,updateNodeData:(u,d,h={replace:!1})=>{c(u,g=>{const y=typeof d=="function"?d(g):d;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},updateEdge:f,updateEdgeData:(u,d,h={replace:!1})=>{f(u,g=>{const y=typeof d=="function"?d(g):d;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},getNodesBounds:u=>{const{nodeLookup:d,nodeOrigin:h}=e.getState();return gf(u,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:u,id:d,nodeId:h})=>{var g;return Array.from(((g=e.getState().connectionLookup.get(`${h}-${u}${d?`-${d}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:d,nodeId:h})=>{var g;return Array.from(((g=e.getState().connectionLookup.get(`${h}${u?d?`-${u}-${d}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const d=e.getState().fitViewResolver??_f();return e.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return P.useMemo(()=>({...o,...t,viewportInitialized:r}),[r])}const xo=t=>t.selected,Ud=typeof window<"u"?window:void 0;function Zd({deleteKeyCode:t,multiSelectionKeyCode:e}){const n=ot(),{deleteElements:r}=Ae(),o=_e(t,{actInsideInputWithModifier:!1}),i=_e(e,{target:Ud});P.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(xo),edges:s.filter(xo)}),n.setState({nodesSelectionActive:!1})}},[o]),P.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Kd(t){const e=ot();P.useEffect(()=>{const n=()=>{var o,i,s,a;if(!t.current||!(((i=(o=t.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=ir(t.current);(r.height===0||r.width===0)&&((a=(s=e.getState()).onError)==null||a.call(s,"004",wt.error004())),e.setState({width:r.width||500,height:r.height||500})};if(t.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(t.current),()=>{window.removeEventListener("resize",n),r&&t.current&&r.unobserve(t.current)}}},[])}const pn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Qd=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Jd({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Lt.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:f,maxZoom:u,zoomActivationKeyCode:d,preventScrolling:h=!0,children:g,noWheelClassName:y,noPanClassName:p,onViewportChange:m,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:w}){const E=ot(),N=P.useRef(null),{userSelectionActive:S,lib:I,connectionInProgress:T}=J(Qd,rt),D=_e(d),k=P.useRef();Kd(N);const j=P.useCallback(H=>{m==null||m({x:H[0],y:H[1],zoom:H[2]}),v||E.setState({transform:H})},[m,v]);return P.useEffect(()=>{if(N.current){k.current=id({domNode:N.current,minZoom:f,maxZoom:u,translateExtent:c,viewport:l,onDraggingChange:C=>E.setState(z=>z.paneDragging===C?z:{paneDragging:C}),onPanZoomStart:(C,z)=>{const{onViewportChangeStart:A,onMoveStart:M}=E.getState();M==null||M(C,z),A==null||A(z)},onPanZoom:(C,z)=>{const{onViewportChange:A,onMove:M}=E.getState();M==null||M(C,z),A==null||A(z)},onPanZoomEnd:(C,z)=>{const{onViewportChangeEnd:A,onMoveEnd:M}=E.getState();M==null||M(C,z),A==null||A(z)}});const{x:H,y:_,zoom:$}=k.current.getViewport();return E.setState({panZoom:k.current,transform:[H,_,$],domNode:N.current.closest(".react-flow")}),()=>{var C;(C=k.current)==null||C.destroy()}}},[]),P.useEffect(()=>{var H;(H=k.current)==null||H.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:D,preventScrolling:h,noPanClassName:p,userSelectionActive:S,noWheelClassName:y,lib:I,onTransformChange:j,connectionInProgress:T,selectionOnDrag:w,paneClickDistance:x})},[t,e,n,r,o,i,s,a,D,h,p,S,y,I,j,T,w,x]),b.jsx("div",{className:"react-flow__renderer",ref:N,style:pn,children:g})}const th=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function eh(){const{userSelectionActive:t,userSelectionRect:e}=J(th,rt);return t&&e?b.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}const $n=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},nh=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});function rh({isSelecting:t,selectionKeyPressed:e,selectionMode:n=we.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:d,onPaneMouseLeave:h,children:g}){const y=ot(),{userSelectionActive:p,elementsSelectable:m,dragging:v,connectionInProgress:x}=J(nh,rt),w=m&&(t||p),E=P.useRef(null),N=P.useRef(),S=P.useRef(new Set),I=P.useRef(new Set),T=P.useRef(!1),D=A=>{if(T.current||x){T.current=!1;return}l==null||l(A),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},k=A=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){A.preventDefault();return}c==null||c(A)},j=f?A=>f(A):void 0,H=A=>{T.current&&(A.stopPropagation(),T.current=!1)},_=A=>{var W,q;const{domNode:M}=y.getState();if(N.current=M==null?void 0:M.getBoundingClientRect(),!N.current)return;const L=A.target===E.current;if(!L&&!!A.target.closest(".nokey")||!t||!(i&&L||e)||A.button!==0||!A.isPrimary)return;(q=(W=A.target)==null?void 0:W.setPointerCapture)==null||q.call(W,A.pointerId),T.current=!1;const{x:X,y:Y}=pt(A.nativeEvent,N.current);y.setState({userSelectionRect:{width:0,height:0,startX:X,startY:Y,x:X,y:Y}}),L||(A.stopPropagation(),A.preventDefault())},$=A=>{const{userSelectionRect:M,transform:L,nodeLookup:V,edgeLookup:R,connectionLookup:X,triggerNodeChanges:Y,triggerEdgeChanges:W,defaultEdgeOptions:q,resetSelectedElements:F}=y.getState();if(!N.current||!M)return;const{x:B,y:O}=pt(A.nativeEvent,N.current),{startX:Z,startY:Q}=M;if(!T.current){const tt=e?0:o;if(Math.hypot(B-Z,O-Q)<=tt)return;F(),s==null||s(A)}T.current=!0;const K={startX:Z,startY:Q,x:B<Z?B:Z,y:O<Q?O:Q,width:Math.abs(B-Z),height:Math.abs(O-Q)},U=S.current,et=I.current;S.current=new Set(rr(V,K,L,n===we.Partial,!0).map(tt=>tt.id)),I.current=new Set;const nt=(q==null?void 0:q.selectable)??!0;for(const tt of S.current){const st=X.get(tt);if(st)for(const{edgeId:Ct}of st.values()){const bt=R.get(Ct);bt&&(bt.selectable??nt)&&I.current.add(Ct)}}if(!Fr(U,S.current)){const tt=Yt(V,S.current,!0);Y(tt)}if(!Fr(et,I.current)){const tt=Yt(R,I.current);W(tt)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},C=A=>{var M,L;A.button===0&&((L=(M=A.target)==null?void 0:M.releasePointerCapture)==null||L.call(M,A.pointerId),!p&&A.target===E.current&&y.getState().userSelectionRect&&(D==null||D(A)),y.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(a==null||a(A),y.setState({nodesSelectionActive:S.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return b.jsxs("div",{className:it(["react-flow__pane",{draggable:z,dragging:v,selection:t}]),onClick:w?void 0:$n(D,E),onContextMenu:$n(k,E),onWheel:$n(j,E),onPointerEnter:w?void 0:u,onPointerMove:w?$:d,onPointerUp:w?C:void 0,onPointerDownCapture:w?_:void 0,onClickCapture:w?H:void 0,onPointerLeave:h,ref:E,style:pn,children:[g,b.jsx(eh,{})]})}function Gn({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=e.getState(),c=a.get(t);if(!c){l==null||l("012",wt.error012(t));return}e.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):o([t])}function Qi({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=ot(),[l,c]=P.useState(!1),f=P.useRef();return P.useEffect(()=>{f.current=Yf({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Gn({id:u,store:a,nodeRef:t})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),P.useEffect(()=>{if(!(e||!t.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:t.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,e,i,t,o,s]),l}const oh=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");function Ji(){const t=ot();return P.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:l,nodeLookup:c,nodeOrigin:f}=t.getState(),u=new Map,d=oh(s),h=o?i[0]:5,g=o?i[1]:5,y=n.direction.x*h*n.factor,p=n.direction.y*g*n.factor;for(const[,m]of c){if(!d(m))continue;let v={x:m.internals.positionAbsolute.x+y,y:m.internals.positionAbsolute.y+p};o&&(v=ke(v,i));const{position:x,positionAbsolute:w}=xi({nodeId:m.id,nextPosition:v,nodeLookup:c,nodeExtent:r,nodeOrigin:f,onError:a});m.position=x,m.internals.positionAbsolute=w,u.set(m.id,m)}l(u)},[])}const fr=P.createContext(null),ih=fr.Provider;fr.Consumer;const ts=()=>P.useContext(fr),sh=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),ah=(t,e,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:l,isValid:c}=s,f=(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===e&&(l==null?void 0:l.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===e&&(a==null?void 0:a.type)===n,connectingTo:f,clickConnecting:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.id)===e&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Zt.Strict?(a==null?void 0:a.type)!==n:t!==(a==null?void 0:a.nodeId)||e!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:f&&c}};function ch({type:t="source",position:e=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:l,className:c,onMouseDown:f,onTouchStart:u,...d},h){var $,C;const g=s||null,y=t==="target",p=ot(),m=ts(),{connectOnClick:v,noPanClassName:x,rfId:w}=J(sh,rt),{connectingFrom:E,connectingTo:N,clickConnecting:S,isPossibleEndHandle:I,connectionInProcess:T,clickConnectionInProcess:D,valid:k}=J(ah(m,g,t),rt);m||(C=($=p.getState()).onError)==null||C.call($,"010",wt.error010());const j=z=>{const{defaultEdgeOptions:A,onConnect:M,hasDefaultEdges:L}=p.getState(),V={...A,...z};if(L){const{edges:R,setEdges:X}=p.getState();X(If(V,R))}M==null||M(V),a==null||a(V)},H=z=>{if(!m)return;const A=Mi(z.nativeEvent);if(o&&(A&&z.button===0||!A)){const M=p.getState();Yn.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:y,handleId:g,nodeId:m,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...L)=>{var V,R;return(R=(V=p.getState()).onConnectEnd)==null?void 0:R.call(V,...L)},updateConnection:M.updateConnection,onConnect:j,isValidConnection:n||((...L)=>{var V,R;return((R=(V=p.getState()).isValidConnection)==null?void 0:R.call(V,...L))??!0}),getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}A?f==null||f(z):u==null||u(z)},_=z=>{const{onClickConnectStart:A,onClickConnectEnd:M,connectionClickStartHandle:L,connectionMode:V,isValidConnection:R,lib:X,rfId:Y,nodeLookup:W,connection:q}=p.getState();if(!m||!L&&!o)return;if(!L){A==null||A(z.nativeEvent,{nodeId:m,handleId:g,handleType:t}),p.setState({connectionClickStartHandle:{nodeId:m,type:t,id:g}});return}const F=Ei(z.target),B=n||R,{connection:O,isValid:Z}=Yn.isValid(z.nativeEvent,{handle:{nodeId:m,id:g,type:t},connectionMode:V,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:B,flowId:Y,doc:F,lib:X,nodeLookup:W});Z&&O&&j(O);const Q=structuredClone(q);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,M==null||M(z,Q),p.setState({connectionClickStartHandle:null})};return b.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":e,"data-id":`${w}-${m}-${g}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",x,c,{source:!y,target:y,connectable:r,connectablestart:o,connectableend:i,clickconnecting:S,connectingfrom:E,connectingto:N,valid:k,connectionindicator:r&&(!T||I)&&(T||D?i:o)}]),onMouseDown:H,onTouchStart:H,onClick:v?_:void 0,ref:h,...d,children:l})}const ne=P.memo(Zi(ch));function lh({data:t,isConnectable:e,sourcePosition:n=G.Bottom}){return b.jsxs(b.Fragment,{children:[t==null?void 0:t.label,b.jsx(ne,{type:"source",position:n,isConnectable:e})]})}function uh({data:t,isConnectable:e,targetPosition:n=G.Top,sourcePosition:r=G.Bottom}){return b.jsxs(b.Fragment,{children:[b.jsx(ne,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,b.jsx(ne,{type:"source",position:r,isConnectable:e})]})}function fh(){return null}function dh({data:t,isConnectable:e,targetPosition:n=G.Top}){return b.jsxs(b.Fragment,{children:[b.jsx(ne,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label]})}const on={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},wo={input:lh,default:uh,output:dh,group:fh};function hh(t){var e,n,r,o;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((e=t.style)==null?void 0:e.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((r=t.style)==null?void 0:r.width),height:t.height??((o=t.style)==null?void 0:o.height)}}const gh=t=>{const{width:e,height:n,x:r,y:o}=Ce(t.nodeLookup,{filter:i=>!!i.selected});return{width:gt(e)?e:null,height:gt(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${r}px,${o}px)`}};function ph({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ot(),{width:o,height:i,transformString:s,userSelectionActive:a}=J(gh,rt),l=Ji(),c=P.useRef(null);P.useEffect(()=>{var h;n||(h=c.current)==null||h.focus({preventScroll:!0})},[n]);const f=!a&&o!==null&&i!==null;if(Qi({nodeRef:c,disabled:!f}),!f)return null;const u=t?h=>{const g=r.getState().nodes.filter(y=>y.selected);t(h,g)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(on,h.key)&&(h.preventDefault(),l({direction:on[h.key],factor:h.shiftKey?4:1}))};return b.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",e]),style:{transform:s},children:b.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:o,height:i}})})}const vo=typeof window<"u"?window:void 0,mh=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function es({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:f,selectionMode:u,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:p,elementsSelectable:m,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:w,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:S,panOnDrag:I,defaultViewport:T,translateExtent:D,minZoom:k,maxZoom:j,preventScrolling:H,onSelectionContextMenu:_,noWheelClassName:$,noPanClassName:C,disableKeyboardA11y:z,onViewportChange:A,isControlledViewport:M}){const{nodesSelectionActive:L,userSelectionActive:V}=J(mh,rt),R=_e(c,{target:vo}),X=_e(y,{target:vo}),Y=X||I,W=X||w,q=f&&Y!==!0,F=R||V||q;return Zd({deleteKeyCode:l,multiSelectionKeyCode:g}),b.jsx(Jd,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:S,panOnDrag:!R&&Y,defaultViewport:T,translateExtent:D,minZoom:k,maxZoom:j,zoomActivationKeyCode:p,preventScrolling:H,noWheelClassName:$,noPanClassName:C,onViewportChange:A,isControlledViewport:M,paneClickDistance:a,selectionOnDrag:q,children:b.jsxs(rh,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:Y,isSelecting:!!F,selectionMode:u,selectionKeyPressed:R,paneClickDistance:a,selectionOnDrag:q,children:[t,L&&b.jsx(ph,{onSelectionContextMenu:_,noPanClassName:C,disableKeyboardA11y:z})]})})}es.displayName="FlowRenderer";const yh=P.memo(es),xh=t=>e=>t?rr(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(n=>n.id):Array.from(e.nodeLookup.keys());function wh(t){return J(P.useCallback(xh(t),[t]),rt)}const vh=t=>t.updateNodeInternals;function bh(){const t=J(vh),[e]=P.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),t(r)}));return P.useEffect(()=>()=>{e==null||e.disconnect()},[e]),e}function _h({node:t,nodeType:e,hasDimensions:n,resizeObserver:r}){const o=ot(),i=P.useRef(null),s=P.useRef(null),a=P.useRef(t.sourcePosition),l=P.useRef(t.targetPosition),c=P.useRef(e),f=n&&!!t.internals.handleBounds;return P.useEffect(()=>{i.current&&!t.hidden&&(!f||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[f,t.hidden]),P.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),P.useEffect(()=>{if(i.current){const u=c.current!==e,d=a.current!==t.sourcePosition,h=l.current!==t.targetPosition;(u||d||h)&&(c.current=e,a.current=t.sourcePosition,l.current=t.targetPosition,o.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:i.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),i}function Nh({id:t,onClick:e,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:f,resizeObserver:u,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:g,rfId:y,nodeTypes:p,nodeClickDistance:m,onError:v}){const{node:x,internals:w,isParent:E}=J(B=>{const O=B.nodeLookup.get(t),Z=B.parentLookup.has(t);return{node:O,internals:O.internals,isParent:Z}},rt);let N=x.type||"default",S=(p==null?void 0:p[N])||wo[N];S===void 0&&(v==null||v("003",wt.error003(N)),N="default",S=(p==null?void 0:p.default)||wo.default);const I=!!(x.draggable||a&&typeof x.draggable>"u"),T=!!(x.selectable||l&&typeof x.selectable>"u"),D=!!(x.connectable||c&&typeof x.connectable>"u"),k=!!(x.focusable||f&&typeof x.focusable>"u"),j=ot(),H=_i(x),_=_h({node:x,nodeType:N,hasDimensions:H,resizeObserver:u}),$=Qi({nodeRef:_,disabled:x.hidden||!I,noDragClassName:d,handleSelector:x.dragHandle,nodeId:t,isSelectable:T,nodeClickDistance:m}),C=Ji();if(x.hidden)return null;const z=Mt(x),A=hh(x),M=T||I||e||n||r||o,L=n?B=>n(B,{...w.userNode}):void 0,V=r?B=>r(B,{...w.userNode}):void 0,R=o?B=>o(B,{...w.userNode}):void 0,X=i?B=>i(B,{...w.userNode}):void 0,Y=s?B=>s(B,{...w.userNode}):void 0,W=B=>{const{selectNodesOnDrag:O,nodeDragThreshold:Z}=j.getState();T&&(!O||!I||Z>0)&&Gn({id:t,store:j,nodeRef:_}),e&&e(B,{...w.userNode})},q=B=>{if(!(Si(B.nativeEvent)||g)){if(hi.includes(B.key)&&T){const O=B.key==="Escape";Gn({id:t,store:j,unselect:O,nodeRef:_})}else if(I&&x.selected&&Object.prototype.hasOwnProperty.call(on,B.key)){B.preventDefault();const{ariaLabelConfig:O}=j.getState();j.setState({ariaLiveMessage:O["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),C({direction:on[B.key],factor:B.shiftKey?4:1})}}},F=()=>{var et;if(g||!((et=_.current)!=null&&et.matches(":focus-visible")))return;const{transform:B,width:O,height:Z,autoPanOnNodeFocus:Q,setCenter:K}=j.getState();if(!Q)return;rr(new Map([[t,x]]),{x:0,y:0,width:O,height:Z},B,!0).length>0||K(x.position.x+z.width/2,x.position.y+z.height/2,{zoom:B[2]})};return b.jsx("div",{className:it(["react-flow__node",`react-flow__node-${N}`,{[h]:I},x.className,{selected:x.selected,selectable:T,parent:E,draggable:I,dragging:$}]),ref:_,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:H?"visible":"hidden",...x.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:L,onMouseMove:V,onMouseLeave:R,onContextMenu:X,onClick:W,onDoubleClick:Y,onKeyDown:k?q:void 0,tabIndex:k?0:void 0,onFocus:k?F:void 0,role:x.ariaRole??(k?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Xi}-${y}`,"aria-label":x.ariaLabel,...x.domAttributes,children:b.jsx(ih,{value:t,children:b.jsx(S,{id:t,data:x.data,type:N,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:x.selected??!1,selectable:T,draggable:I,deletable:x.deletable??!0,isConnectable:D,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:$,dragHandle:x.dragHandle,zIndex:w.z,parentId:x.parentId,...z})})})}var Eh=P.memo(Nh);const Sh=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function ns(t){const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=J(Sh,rt),s=wh(t.onlyRenderVisibleElements),a=bh();return b.jsx("div",{className:"react-flow__nodes",style:pn,children:s.map(l=>b.jsx(Eh,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:a,nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}ns.displayName="NodeRenderer";const Mh=P.memo(ns);function Ch(t){return J(P.useCallback(n=>{if(!t)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&Mf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[t]),rt)}const kh=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t}};return b.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Ih=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t,fill:t}};return b.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bo={[Kt.Arrow]:kh,[Kt.ArrowClosed]:Ih};function Ah(t){const e=ot();return P.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(bo,t)?bo[t]:((i=(o=e.getState()).onError)==null||i.call(o,"009",wt.error009(t)),null)},[t])}const $h=({id:t,type:e,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const l=Ah(e);return l?b.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:b.jsx(l,{color:n,strokeWidth:s})}):null},rs=({defaultColor:t,rfId:e})=>{const n=J(i=>i.edges),r=J(i=>i.defaultEdgeOptions),o=P.useMemo(()=>zf(n,{id:e,defaultColor:t,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,e,t]);return o.length?b.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:b.jsx("defs",{children:o.map(i=>b.jsx($h,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};rs.displayName="MarkerDefinitions";var Ph=P.memo(rs);function os({x:t,y:e,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...f}){const[u,d]=P.useState({x:1,y:0,width:0,height:0}),h=it(["react-flow__edge-textwrapper",c]),g=P.useRef(null);return P.useEffect(()=>{if(g.current){const y=g.current.getBBox();d({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?b.jsxs("g",{transform:`translate(${t-u.width/2} ${e-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...f,children:[o&&b.jsx("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),b.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),l]}):null}os.displayName="EdgeText";const Th=P.memo(os);function mn({path:t,labelX:e,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...f}){return b.jsxs(b.Fragment,{children:[b.jsx("path",{...f,d:t,fill:"none",className:it(["react-flow__edge-path",f.className])}),c?b.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,r&>(e)&>(n)?b.jsx(Th,{x:e,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function _o({pos:t,x1:e,y1:n,x2:r,y2:o}){return t===G.Left||t===G.Right?[.5*(e+r),n]:[e,.5*(n+o)]}function is({sourceX:t,sourceY:e,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top}){const[s,a]=_o({pos:n,x1:t,y1:e,x2:r,y2:o}),[l,c]=_o({pos:i,x1:r,y1:o,x2:t,y2:e}),[f,u,d,h]=Ci({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${t},${e} C${s},${a} ${l},${c} ${r},${o}`,f,u,d,h]}function ss(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:m})=>{const[v,x,w]=is({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),E=t.isInternal?void 0:e;return b.jsx(mn,{id:E,path:v,labelX:x,labelY:w,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:m})})}const zh=ss({isInternal:!1}),as=ss({isInternal:!0});zh.displayName="SimpleBezierEdge";as.displayName="SimpleBezierEdgeInternal";function cs(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,sourcePosition:h=G.Bottom,targetPosition:g=G.Top,markerEnd:y,markerStart:p,pathOptions:m,interactionWidth:v})=>{const[x,w,E]=Fn({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:i,targetPosition:g,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),N=t.isInternal?void 0:e;return b.jsx(mn,{id:N,path:x,labelX:w,labelY:E,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:y,markerStart:p,interactionWidth:v})})}const ls=cs({isInternal:!1}),us=cs({isInternal:!0});ls.displayName="SmoothStepEdge";us.displayName="SmoothStepEdgeInternal";function fs(t){return P.memo(({id:e,...n})=>{var o;const r=t.isInternal?void 0:e;return b.jsx(ls,{...n,id:r,pathOptions:P.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const jh=fs({isInternal:!1}),ds=fs({isInternal:!0});jh.displayName="StepEdge";ds.displayName="StepEdgeInternal";function hs(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:g,interactionWidth:y})=>{const[p,m,v]=Ai({sourceX:n,sourceY:r,targetX:o,targetY:i}),x=t.isInternal?void 0:e;return b.jsx(mn,{id:x,path:p,labelX:m,labelY:v,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:g,interactionWidth:y})})}const Lh=hs({isInternal:!1}),gs=hs({isInternal:!0});Lh.displayName="StraightEdge";gs.displayName="StraightEdgeInternal";function ps(t){return P.memo(({id:e,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=G.Bottom,targetPosition:a=G.Top,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,pathOptions:m,interactionWidth:v})=>{const[x,w,E]=ki({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),N=t.isInternal?void 0:e;return b.jsx(mn,{id:N,path:x,labelX:w,labelY:E,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:p,interactionWidth:v})})}const Dh=ps({isInternal:!1}),ms=ps({isInternal:!0});Dh.displayName="BezierEdge";ms.displayName="BezierEdgeInternal";const No={default:ms,straight:gs,step:ds,smoothstep:us,simplebezier:as},Eo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Rh=(t,e,n)=>n===G.Left?t-e:n===G.Right?t+e:t,Hh=(t,e,n)=>n===G.Top?t-e:n===G.Bottom?t+e:t,So="react-flow__edgeupdater";function Mo({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return b.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:it([So,`${So}-${a}`]),cx:Rh(e,r,t),cy:Hh(n,r,t),r,stroke:"transparent",fill:"transparent"})}function Vh({isReconnectable:t,reconnectRadius:e,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:f,onReconnectEnd:u,setReconnecting:d,setUpdateHover:h}){const g=ot(),y=(w,E)=>{if(w.button!==0)return;const{autoPanOnConnect:N,domNode:S,connectionMode:I,connectionRadius:T,lib:D,onConnectStart:k,cancelConnection:j,nodeLookup:H,rfId:_,panBy:$,updateConnection:C}=g.getState(),z=E.type==="target",A=(V,R)=>{d(!1),u==null||u(V,n,E.type,R)},M=V=>c==null?void 0:c(n,V),L=(V,R)=>{d(!0),f==null||f(w,n,E.type),k==null||k(V,R)};Yn.onPointerDown(w.nativeEvent,{autoPanOnConnect:N,connectionMode:I,connectionRadius:T,domNode:S,handleId:E.id,nodeId:E.nodeId,nodeLookup:H,isTarget:z,edgeUpdaterType:E.type,lib:D,flowId:_,cancelConnection:j,panBy:$,isValidConnection:(...V)=>{var R,X;return((X=(R=g.getState()).isValidConnection)==null?void 0:X.call(R,...V))??!0},onConnect:M,onConnectStart:L,onConnectEnd:(...V)=>{var R,X;return(X=(R=g.getState()).onConnectEnd)==null?void 0:X.call(R,...V)},onReconnectEnd:A,updateConnection:C,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},p=w=>y(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>y(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>h(!0),x=()=>h(!1);return b.jsxs(b.Fragment,{children:[(t===!0||t==="source")&&b.jsx(Mo,{position:a,centerX:r,centerY:o,radius:e,onMouseDown:p,onMouseEnter:v,onMouseOut:x,type:"source"}),(t===!0||t==="target")&&b.jsx(Mo,{position:l,centerX:i,centerY:s,radius:e,onMouseDown:m,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function Bh({id:t,edgesFocusable:e,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:h,rfId:g,edgeTypes:y,noPanClassName:p,onError:m,disableKeyboardA11y:v}){let x=J(K=>K.edgeLookup.get(t));const w=J(K=>K.defaultEdgeOptions);x=w?{...w,...x}:x;let E=x.type||"default",N=(y==null?void 0:y[E])||No[E];N===void 0&&(m==null||m("011",wt.error011(E)),E="default",N=(y==null?void 0:y.default)||No.default);const S=!!(x.focusable||e&&typeof x.focusable>"u"),I=typeof u<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),T=!!(x.selectable||r&&typeof x.selectable>"u"),D=P.useRef(null),[k,j]=P.useState(!1),[H,_]=P.useState(!1),$=ot(),{zIndex:C,sourceX:z,sourceY:A,targetX:M,targetY:L,sourcePosition:V,targetPosition:R}=J(P.useCallback(K=>{const U=K.nodeLookup.get(x.source),et=K.nodeLookup.get(x.target);if(!U||!et)return{zIndex:x.zIndex,...Eo};const nt=Tf({id:t,sourceNode:U,targetNode:et,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:K.connectionMode,onError:m});return{zIndex:Sf({selected:x.selected,zIndex:x.zIndex,sourceNode:U,targetNode:et,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...nt||Eo}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),rt),X=P.useMemo(()=>x.markerStart?`url('#${On(x.markerStart,g)}')`:void 0,[x.markerStart,g]),Y=P.useMemo(()=>x.markerEnd?`url('#${On(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||z===null||A===null||M===null||L===null)return null;const W=K=>{var tt;const{addSelectedEdges:U,unselectNodesAndEdges:et,multiSelectionActive:nt}=$.getState();T&&($.setState({nodesSelectionActive:!1}),x.selected&&nt?(et({nodes:[],edges:[x]}),(tt=D.current)==null||tt.blur()):U([t])),o&&o(K,x)},q=i?K=>{i(K,{...x})}:void 0,F=s?K=>{s(K,{...x})}:void 0,B=a?K=>{a(K,{...x})}:void 0,O=l?K=>{l(K,{...x})}:void 0,Z=c?K=>{c(K,{...x})}:void 0,Q=K=>{var U;if(!v&&hi.includes(K.key)&&T){const{unselectNodesAndEdges:et,addSelectedEdges:nt}=$.getState();K.key==="Escape"?((U=D.current)==null||U.blur(),et({edges:[x]})):nt([t])}};return b.jsx("svg",{style:{zIndex:C},children:b.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${E}`,x.className,p,{selected:x.selected,animated:x.animated,inactive:!T&&!o,updating:k,selectable:T}]),onClick:W,onDoubleClick:q,onContextMenu:F,onMouseEnter:B,onMouseMove:O,onMouseLeave:Z,onKeyDown:S?Q:void 0,tabIndex:S?0:void 0,role:x.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":S?`${Yi}-${g}`:void 0,ref:D,...x.domAttributes,children:[!H&&b.jsx(N,{id:t,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:T,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:M,targetY:L,sourcePosition:V,targetPosition:R,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:X,markerEnd:Y,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),I&&b.jsx(Vh,{edge:x,isReconnectable:I,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:h,sourceX:z,sourceY:A,targetX:M,targetY:L,sourcePosition:V,targetPosition:R,setUpdateHover:j,setReconnecting:_})]})})}var Fh=P.memo(Bh);const Oh=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function ys({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:p,edgesReconnectable:m,elementsSelectable:v,onError:x}=J(Oh,rt),w=Ch(e);return b.jsxs("div",{className:"react-flow__edges",children:[b.jsx(Ph,{defaultColor:t,rfId:n}),w.map(E=>b.jsx(Fh,{id:E,edgesFocusable:p,edgesReconnectable:m,elementsSelectable:v,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:f,reconnectRadius:u,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:y},E))]})}ys.displayName="EdgeRenderer";const Xh=P.memo(ys),Yh=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function Wh({children:t}){const e=J(Yh);return b.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function Gh(t){const e=Ae(),n=P.useRef(!1);P.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const qh=t=>{var e;return(e=t.panZoom)==null?void 0:e.syncViewport};function Uh(t){const e=J(qh),n=ot();return P.useEffect(()=>{t&&(e==null||e(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function Zh(t){return t.connection.inProgress?{...t.connection,to:Ie(t.connection.to,t.transform)}:{...t.connection}}function Kh(t){return Zh}function Qh(t){const e=Kh();return J(e,rt)}const Jh=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function tg({containerStyle:t,style:e,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:l}=J(Jh,rt);return!(i&&o&&l)?null:b.jsx("svg",{style:t,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:b.jsx("g",{className:it(["react-flow__connection",mi(a)]),children:b.jsx(xs,{style:e,type:n,CustomComponent:r,isValid:a})})})}const xs=({style:t,type:e=At.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:l,to:c,toNode:f,toHandle:u,toPosition:d,pointer:h}=Qh();if(!o)return;if(n)return b.jsx(n,{connectionLineType:e,connectionLineStyle:t,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:d,connectionStatus:mi(r),toNode:f,toHandle:u,pointer:h});let g="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:d};switch(e){case At.Bezier:[g]=ki(y);break;case At.SimpleBezier:[g]=is(y);break;case At.Step:[g]=Fn({...y,borderRadius:0});break;case At.SmoothStep:[g]=Fn(y);break;default:[g]=Ai(y)}return b.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:t})};xs.displayName="ConnectionLine";const eg={};function Co(t=eg){P.useRef(t),ot(),P.useEffect(()=>{},[t])}function ng(){ot(),P.useRef(!1),P.useEffect(()=>{},[])}function ws({nodeTypes:t,edgeTypes:e,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:d,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:p,connectionLineContainerStyle:m,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:S,deleteKeyCode:I,onlyRenderVisibleElements:T,elementsSelectable:D,defaultViewport:k,translateExtent:j,minZoom:H,maxZoom:_,preventScrolling:$,defaultMarkerColor:C,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:M,panOnScrollSpeed:L,panOnScrollMode:V,zoomOnDoubleClick:R,panOnDrag:X,onPaneClick:Y,onPaneMouseEnter:W,onPaneMouseMove:q,onPaneMouseLeave:F,onPaneScroll:B,onPaneContextMenu:O,paneClickDistance:Z,nodeClickDistance:Q,onEdgeContextMenu:K,onEdgeMouseEnter:U,onEdgeMouseMove:et,onEdgeMouseLeave:nt,reconnectRadius:tt,onReconnect:st,onReconnectStart:Ct,onReconnectEnd:bt,noDragClassName:Pt,noWheelClassName:re,noPanClassName:oe,disableKeyboardA11y:ie,nodeExtent:yn,rfId:$e,viewport:Ft,onViewportChange:se}){return Co(t),Co(e),ng(),Gh(n),Uh(Ft),b.jsx(yh,{onPaneClick:Y,onPaneMouseEnter:W,onPaneMouseMove:q,onPaneMouseLeave:F,onPaneContextMenu:O,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:I,selectionKeyCode:v,selectionOnDrag:x,selectionMode:w,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:S,elementsSelectable:D,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:R,panOnScroll:M,panOnScrollSpeed:L,panOnScrollMode:V,panOnDrag:X,defaultViewport:k,translateExtent:j,minZoom:H,maxZoom:_,onSelectionContextMenu:u,preventScrolling:$,noDragClassName:Pt,noWheelClassName:re,noPanClassName:oe,disableKeyboardA11y:ie,onViewportChange:se,isControlledViewport:!!Ft,children:b.jsxs(Wh,{children:[b.jsx(Xh,{edgeTypes:e,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:st,onReconnectStart:Ct,onReconnectEnd:bt,onlyRenderVisibleElements:T,onEdgeContextMenu:K,onEdgeMouseEnter:U,onEdgeMouseMove:et,onEdgeMouseLeave:nt,reconnectRadius:tt,defaultMarkerColor:C,noPanClassName:oe,disableKeyboardA11y:ie,rfId:$e}),b.jsx(tg,{style:y,type:g,component:p,containerStyle:m}),b.jsx("div",{className:"react-flow__edgelabel-renderer"}),b.jsx(Mh,{nodeTypes:t,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,nodeClickDistance:Q,onlyRenderVisibleElements:T,noPanClassName:oe,noDragClassName:Pt,disableKeyboardA11y:ie,nodeExtent:yn,rfId:$e}),b.jsx("div",{className:"react-flow__viewport-portal"})]})})}ws.displayName="GraphView";const rg=P.memo(ws),ko=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:f,nodeExtent:u,zIndexMode:d="basic"}={})=>{const h=new Map,g=new Map,y=new Map,p=new Map,m=r??e??[],v=n??t??[],x=f??[0,0],w=u??xe;Ti(y,p,m);const{nodesInitialized:E}=Xn(v,h,g,{nodeOrigin:x,nodeExtent:w,zIndexMode:d});let N=[0,0,1];if(s&&o&&i){const S=Ce(h,{filter:k=>!!((k.width||k.initialWidth)&&(k.height||k.initialHeight))}),{x:I,y:T,zoom:D}=or(S,o,i,l,c,(a==null?void 0:a.padding)??.1);N=[I,T,D]}return{rfId:"1",width:o??0,height:i??0,transform:N,nodes:v,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:p,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:xe,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...pi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:wf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:gi,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},og=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d})=>Nd((h,g)=>{async function y(){const{nodeLookup:p,panZoom:m,fitViewOptions:v,fitViewResolver:x,width:w,height:E,minZoom:N,maxZoom:S}=g();m&&(await yf({nodes:p,width:w,height:E,panZoom:m,minZoom:N,maxZoom:S},v),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...ko({nodes:t,edges:e,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:p=>{const{nodeLookup:m,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:w,fitViewQueued:E,zIndexMode:N,nodesSelectionActive:S}=g(),{nodesInitialized:I,hasSelectedNodes:T}=Xn(p,m,v,{nodeOrigin:x,nodeExtent:u,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:N}),D=S&&T;E&&I?(y(),h({nodes:p,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):h({nodes:p,nodesInitialized:I,nodesSelectionActive:D})},setEdges:p=>{const{connectionLookup:m,edgeLookup:v}=g();Ti(m,v,p),h({edges:p})},setDefaultNodesAndEdges:(p,m)=>{if(p){const{setNodes:v}=g();v(p),h({hasDefaultNodes:!0})}if(m){const{setEdges:v}=g();v(m),h({hasDefaultEdges:!0})}},updateNodeInternals:p=>{const{triggerNodeChanges:m,nodeLookup:v,parentLookup:x,domNode:w,nodeOrigin:E,nodeExtent:N,debug:S,fitViewQueued:I,zIndexMode:T}=g(),{changes:D,updatedInternals:k}=Bf(p,v,x,w,E,N,T);k&&(Df(v,x,{nodeOrigin:E,nodeExtent:N,zIndexMode:T}),I?(y(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(D==null?void 0:D.length)>0&&(S&&console.log("React Flow: trigger node changes",D),m==null||m(D)))},updateNodePositions:(p,m=!1)=>{const v=[];let x=[];const{nodeLookup:w,triggerNodeChanges:E,connection:N,updateConnection:S,onNodesChangeMiddlewareMap:I}=g();for(const[T,D]of p){const k=w.get(T),j=!!(k!=null&&k.expandParent&&(k!=null&&k.parentId)&&(D!=null&&D.position)),H={id:T,type:"position",position:j?{x:Math.max(0,D.position.x),y:Math.max(0,D.position.y)}:D.position,dragging:m};if(k&&N.inProgress&&N.fromNode.id===k.id){const _=Bt(k,N.fromHandle,G.Left,!0);S({...N,from:_})}j&&k.parentId&&v.push({id:T,parentId:k.parentId,rect:{...D.internals.positionAbsolute,width:D.measured.width??0,height:D.measured.height??0}}),x.push(H)}if(v.length>0){const{parentLookup:T,nodeOrigin:D}=g(),k=ur(v,w,T,D);x.push(...k)}for(const T of I.values())x=T(x);E(x)},triggerNodeChanges:p=>{const{onNodesChange:m,setNodes:v,nodes:x,hasDefaultNodes:w,debug:E}=g();if(p!=null&&p.length){if(w){const N=qi(p,x);v(N)}E&&console.log("React Flow: trigger node changes",p),m==null||m(p)}},triggerEdgeChanges:p=>{const{onEdgesChange:m,setEdges:v,edges:x,hasDefaultEdges:w,debug:E}=g();if(p!=null&&p.length){if(w){const N=Ui(p,x);v(N)}E&&console.log("React Flow: trigger edge changes",p),m==null||m(p)}},addSelectedNodes:p=>{const{multiSelectionActive:m,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(m){const N=p.map(S=>Tt(S,!0));w(N);return}w(Yt(x,new Set([...p]),!0)),E(Yt(v))},addSelectedEdges:p=>{const{multiSelectionActive:m,edgeLookup:v,nodeLookup:x,triggerNodeChanges:w,triggerEdgeChanges:E}=g();if(m){const N=p.map(S=>Tt(S,!0));E(N);return}E(Yt(v,new Set([...p]))),w(Yt(x,new Set,!0))},unselectNodesAndEdges:({nodes:p,edges:m}={})=>{const{edges:v,nodes:x,nodeLookup:w,triggerNodeChanges:E,triggerEdgeChanges:N}=g(),S=p||x,I=m||v,T=[];for(const k of S){if(!k.selected)continue;const j=w.get(k.id);j&&(j.selected=!1),T.push(Tt(k.id,!1))}const D=[];for(const k of I)k.selected&&D.push(Tt(k.id,!1));E(T),N(D)},setMinZoom:p=>{const{panZoom:m,maxZoom:v}=g();m==null||m.setScaleExtent([p,v]),h({minZoom:p})},setMaxZoom:p=>{const{panZoom:m,minZoom:v}=g();m==null||m.setScaleExtent([v,p]),h({maxZoom:p})},setTranslateExtent:p=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(p),h({translateExtent:p})},resetSelectedElements:()=>{const{edges:p,nodes:m,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:w}=g();if(!w)return;const E=m.reduce((S,I)=>I.selected?[...S,Tt(I.id,!1)]:S,[]),N=p.reduce((S,I)=>I.selected?[...S,Tt(I.id,!1)]:S,[]);v(E),x(N)},setNodeExtent:p=>{const{nodes:m,nodeLookup:v,parentLookup:x,nodeOrigin:w,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:S}=g();p[0][0]===N[0][0]&&p[0][1]===N[0][1]&&p[1][0]===N[1][0]&&p[1][1]===N[1][1]||(Xn(m,v,x,{nodeOrigin:w,nodeExtent:p,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:S}),h({nodeExtent:p}))},panBy:p=>{const{transform:m,width:v,height:x,panZoom:w,translateExtent:E}=g();return Ff({delta:p,panZoom:w,transform:m,translateExtent:E,width:v,height:x})},setCenter:async(p,m,v)=>{const{width:x,height:w,maxZoom:E,panZoom:N}=g();if(!N)return Promise.resolve(!1);const S=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:E;return await N.setViewport({x:x/2-p*S,y:w/2-m*S,zoom:S},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...pi}})},updateConnection:p=>{h({connection:p})},reset:()=>h({...ko()})}},Object.is);function vs({initialNodes:t,initialEdges:e,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d,children:h}){const[g]=P.useState(()=>og({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:c,minZoom:s,maxZoom:a,fitViewOptions:l,nodeOrigin:f,nodeExtent:u,zIndexMode:d}));return b.jsx(Ed,{value:g,children:b.jsx(Wd,{children:h})})}function ig({children:t,nodes:e,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:h}){return P.useContext(hn)?b.jsx(b.Fragment,{children:t}):b.jsx(vs,{initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:h,children:t})}const sg={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ag({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:f,onMoveStart:u,onMoveEnd:d,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:p,onClickConnectEnd:m,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:S,onNodeDrag:I,onNodeDragStop:T,onNodesDelete:D,onEdgesDelete:k,onDelete:j,onSelectionChange:H,onSelectionDragStart:_,onSelectionDrag:$,onSelectionDragStop:C,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:M,onBeforeDelete:L,connectionMode:V,connectionLineType:R=At.Bezier,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:W,deleteKeyCode:q="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:B=!1,selectionMode:O=we.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:Q=be()?"Meta":"Control",zoomActivationKeyCode:K=be()?"Meta":"Control",snapToGrid:U,snapGrid:et,onlyRenderVisibleElements:nt=!1,selectNodesOnDrag:tt,nodesDraggable:st,autoPanOnNodeFocus:Ct,nodesConnectable:bt,nodesFocusable:Pt,nodeOrigin:re=Wi,edgesFocusable:oe,edgesReconnectable:ie,elementsSelectable:yn=!0,defaultViewport:$e=Dd,minZoom:Ft=.5,maxZoom:se=2,translateExtent:gr=xe,preventScrolling:Ss=!0,nodeExtent:xn,defaultMarkerColor:Ms="#b1b1b7",zoomOnScroll:Cs=!0,zoomOnPinch:ks=!0,panOnScroll:Is=!1,panOnScrollSpeed:As=.5,panOnScrollMode:$s=Lt.Free,zoomOnDoubleClick:Ps=!0,panOnDrag:Ts=!0,onPaneClick:zs,onPaneMouseEnter:js,onPaneMouseMove:Ls,onPaneMouseLeave:Ds,onPaneScroll:Rs,onPaneContextMenu:Hs,paneClickDistance:Vs=1,nodeClickDistance:Bs=0,children:Fs,onReconnect:Os,onReconnectStart:Xs,onReconnectEnd:Ys,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:qs,onEdgeMouseMove:Us,onEdgeMouseLeave:Zs,reconnectRadius:Ks=10,onNodesChange:Qs,onEdgesChange:Js,noDragClassName:ta="nodrag",noWheelClassName:ea="nowheel",noPanClassName:pr="nopan",fitView:mr,fitViewOptions:yr,connectOnClick:na,attributionPosition:ra,proOptions:oa,defaultEdgeOptions:ia,elevateNodesOnSelect:sa=!0,elevateEdgesOnSelect:aa=!1,disableKeyboardA11y:xr=!1,autoPanOnConnect:ca,autoPanOnNodeDrag:la,autoPanSpeed:ua,connectionRadius:fa,isValidConnection:da,onError:ha,style:ga,id:wr,nodeDragThreshold:pa,connectionDragThreshold:ma,viewport:ya,onViewportChange:xa,width:wa,height:va,colorMode:ba="light",debug:_a,onScroll:Pe,ariaLabelConfig:Na,zIndexMode:vr="basic",...Ea},Sa){const wn=wr||"1",Ma=Bd(ba),Ca=P.useCallback(br=>{br.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pe==null||Pe(br)},[Pe]);return b.jsx("div",{"data-testid":"rf__wrapper",...Ea,onScroll:Ca,style:{...ga,...sg},ref:Sa,className:it(["react-flow",o,Ma]),id:wr,role:"application",children:b.jsxs(ig,{nodes:t,edges:e,width:wa,height:va,fitView:mr,fitViewOptions:yr,minZoom:Ft,maxZoom:se,nodeOrigin:re,nodeExtent:xn,zIndexMode:vr,children:[b.jsx(Vd,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:p,onClickConnectEnd:m,nodesDraggable:st,autoPanOnNodeFocus:Ct,nodesConnectable:bt,nodesFocusable:Pt,edgesFocusable:oe,edgesReconnectable:ie,elementsSelectable:yn,elevateNodesOnSelect:sa,elevateEdgesOnSelect:aa,minZoom:Ft,maxZoom:se,nodeExtent:xn,onNodesChange:Qs,onEdgesChange:Js,snapToGrid:U,snapGrid:et,connectionMode:V,translateExtent:gr,connectOnClick:na,defaultEdgeOptions:ia,fitView:mr,fitViewOptions:yr,onNodesDelete:D,onEdgesDelete:k,onDelete:j,onNodeDragStart:S,onNodeDrag:I,onNodeDragStop:T,onSelectionDrag:$,onSelectionDragStart:_,onSelectionDragStop:C,onMove:f,onMoveStart:u,onMoveEnd:d,noPanClassName:pr,nodeOrigin:re,rfId:wn,autoPanOnConnect:ca,autoPanOnNodeDrag:la,autoPanSpeed:ua,onError:ha,connectionRadius:fa,isValidConnection:da,selectNodesOnDrag:tt,nodeDragThreshold:pa,connectionDragThreshold:ma,onBeforeDelete:L,debug:_a,ariaLabelConfig:Na,zIndexMode:vr}),b.jsx(rg,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:R,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:W,selectionKeyCode:F,selectionOnDrag:B,selectionMode:O,deleteKeyCode:q,multiSelectionKeyCode:Q,panActivationKeyCode:Z,zoomActivationKeyCode:K,onlyRenderVisibleElements:nt,defaultViewport:$e,translateExtent:gr,minZoom:Ft,maxZoom:se,preventScrolling:Ss,zoomOnScroll:Cs,zoomOnPinch:ks,zoomOnDoubleClick:Ps,panOnScroll:Is,panOnScrollSpeed:As,panOnScrollMode:$s,panOnDrag:Ts,onPaneClick:zs,onPaneMouseEnter:js,onPaneMouseMove:Ls,onPaneMouseLeave:Ds,onPaneScroll:Rs,onPaneContextMenu:Hs,paneClickDistance:Vs,nodeClickDistance:Bs,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:M,onReconnect:Os,onReconnectStart:Xs,onReconnectEnd:Ys,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:qs,onEdgeMouseMove:Us,onEdgeMouseLeave:Zs,reconnectRadius:Ks,defaultMarkerColor:Ms,noDragClassName:ta,noWheelClassName:ea,noPanClassName:pr,rfId:wn,disableKeyboardA11y:xr,nodeExtent:xn,viewport:ya,onViewportChange:xa}),b.jsx(Ld,{onSelectionChange:H}),Fs,b.jsx($d,{proOptions:oa,position:ra}),b.jsx(Ad,{rfId:wn,disableKeyboardA11y:xr})]})})}var cg=Zi(ag);function lg(t){const[e,n]=P.useState(t),r=P.useCallback(o=>n(i=>qi(o,i)),[]);return[e,n,r]}function ug(t){const[e,n]=P.useState(t),r=P.useCallback(o=>n(i=>Ui(o,i)),[]);return[e,n,r]}function fg({dimensions:t,lineWidth:e,variant:n,className:r}){return b.jsx("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",n,r])})}function dg({radius:t,className:e}){return b.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",e])})}var Et;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Et||(Et={}));const hg={[Et.Dots]:1,[Et.Lines]:1,[Et.Cross]:6},gg=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function bs({id:t,variant:e=Et.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:l,className:c,patternClassName:f}){const u=P.useRef(null),{transform:d,patternId:h}=J(gg,rt),g=r||hg[e],y=e===Et.Dots,p=e===Et.Cross,m=Array.isArray(n)?n:[n,n],v=[m[0]*d[2]||1,m[1]*d[2]||1],x=g*d[2],w=Array.isArray(i)?i:[i,i],E=p?[x,x]:v,N=[w[0]*d[2]||1+E[0]/2,w[1]*d[2]||1+E[1]/2],S=`${h}${t||""}`;return b.jsxs("svg",{className:it(["react-flow__background",c]),style:{...l,...pn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[b.jsx("pattern",{id:S,x:d[0]%v[0],y:d[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:y?b.jsx(dg,{radius:x/2,className:f}):b.jsx(fg,{dimensions:E,lineWidth:o,variant:e,className:f})}),b.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}bs.displayName="Background";const pg=P.memo(bs);function mg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:b.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function yg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:b.jsx("path",{d:"M0 0h32v4.2H0z"})})}function xg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:b.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function wg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:b.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function vg(){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:b.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Be({children:t,className:e,...n}){return b.jsx("button",{type:"button",className:it(["react-flow__controls-button",e]),...n,children:t})}const bg=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function _s({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:l,className:c,children:f,position:u="bottom-left",orientation:d="vertical","aria-label":h}){const g=ot(),{isInteractive:y,minZoomReached:p,maxZoomReached:m,ariaLabelConfig:v}=J(bg,rt),{zoomIn:x,zoomOut:w,fitView:E}=Ae(),N=()=>{x(),i==null||i()},S=()=>{w(),s==null||s()},I=()=>{E(o),a==null||a()},T=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l==null||l(!y)},D=d==="horizontal"?"horizontal":"vertical";return b.jsxs(gn,{className:it(["react-flow__controls",D,c]),position:u,style:t,"data-testid":"rf__controls","aria-label":h??v["controls.ariaLabel"],children:[e&&b.jsxs(b.Fragment,{children:[b.jsx(Be,{onClick:N,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:m,children:b.jsx(mg,{})}),b.jsx(Be,{onClick:S,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:p,children:b.jsx(yg,{})})]}),n&&b.jsx(Be,{className:"react-flow__controls-fitview",onClick:I,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:b.jsx(xg,{})}),r&&b.jsx(Be,{className:"react-flow__controls-interactive",onClick:T,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:y?b.jsx(vg,{}):b.jsx(wg,{})}),f]})}_s.displayName="Controls";P.memo(_s);function _g({id:t,x:e,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:l,className:c,borderRadius:f,shapeRendering:u,selected:d,onClick:h}){const{background:g,backgroundColor:y}=i||{},p=s||g||y;return b.jsx("rect",{className:it(["react-flow__minimap-node",{selected:d},c]),x:e,y:n,rx:f,ry:f,width:r,height:o,style:{fill:p,stroke:a,strokeWidth:l},shapeRendering:u,onClick:h?m=>h(m,t):void 0})}const Ng=P.memo(_g),Eg=t=>t.nodes.map(e=>e.id),Pn=t=>t instanceof Function?t:()=>t;function Sg({nodeStrokeColor:t,nodeColor:e,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Ng,onClick:s}){const a=J(Eg,rt),l=Pn(e),c=Pn(t),f=Pn(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return b.jsx(b.Fragment,{children:a.map(d=>b.jsx(Cg,{id:d,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:u},d))})}function Mg({id:t,nodeColorFunc:e,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:l}){const{node:c,x:f,y:u,width:d,height:h}=J(g=>{const y=g.nodeLookup.get(t);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const p=y.internals.userNode,{x:m,y:v}=y.internals.positionAbsolute,{width:x,height:w}=Mt(p);return{node:p,x:m,y:v,width:x,height:w}},rt);return!c||c.hidden||!_i(c)?null:b.jsx(a,{x:f,y:u,width:d,height:h,style:c.style,selected:!!c.selected,className:r(c),color:e(c),borderRadius:o,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:l,id:c.id})}const Cg=P.memo(Mg);var kg=P.memo(Sg);const Ig=200,Ag=150,$g=t=>!t.hidden,Pg=t=>{const e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?bi(Ce(t.nodeLookup,{filter:$g}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Tg="react-flow__minimap-desc";function Ns({style:t,className:e,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:f,maskStrokeWidth:u,position:d="bottom-right",onClick:h,onNodeClick:g,pannable:y=!1,zoomable:p=!1,ariaLabel:m,inversePan:v,zoomStep:x=1,offsetScale:w=5}){const E=ot(),N=P.useRef(null),{boundingRect:S,viewBB:I,rfId:T,panZoom:D,translateExtent:k,flowWidth:j,flowHeight:H,ariaLabelConfig:_}=J(Pg,rt),$=(t==null?void 0:t.width)??Ig,C=(t==null?void 0:t.height)??Ag,z=S.width/$,A=S.height/C,M=Math.max(z,A),L=M*$,V=M*C,R=w*M,X=S.x-(L-S.width)/2-R,Y=S.y-(V-S.height)/2-R,W=L+R*2,q=V+R*2,F=`${Tg}-${T}`,B=P.useRef(0),O=P.useRef();B.current=M,P.useEffect(()=>{if(N.current&&D)return O.current=Kf({domNode:N.current,panZoom:D,getTransform:()=>E.getState().transform,getViewScale:()=>B.current}),()=>{var U;(U=O.current)==null||U.destroy()}},[D]),P.useEffect(()=>{var U;(U=O.current)==null||U.update({translateExtent:k,width:j,height:H,inversePan:v,pannable:y,zoomStep:x,zoomable:p})},[y,p,v,x,k,j,H]);const Z=h?U=>{var tt;const[et,nt]=((tt=O.current)==null?void 0:tt.pointer(U))||[0,0];h(U,{x:et,y:nt})}:void 0,Q=g?P.useCallback((U,et)=>{const nt=E.getState().nodeLookup.get(et).internals.userNode;g(U,nt)},[]):void 0,K=m??_["minimap.ariaLabel"];return b.jsx(gn,{position:d,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:it(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:b.jsxs("svg",{width:$,height:C,viewBox:`${X} ${Y} ${W} ${q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":F,ref:N,onClick:Z,children:[K&&b.jsx("title",{id:F,children:K}),b.jsx(kg,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),b.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-R},${Y-R}h${W+R*2}v${q+R*2}h${-W-R*2}z
|
|
23
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ns.displayName="MiniMap";const zg=P.memo(Ns),jg=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,Lg={[ee.Line]:"right",[ee.Handle]:"bottom-right"};function Dg({nodeId:t,position:e,variant:n=ee.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:d,autoScale:h=!0,shouldResize:g,onResizeStart:y,onResize:p,onResizeEnd:m}){const v=ts(),x=typeof t=="string"?t:v,w=ot(),E=P.useRef(null),N=n===ee.Handle,S=J(P.useCallback(jg(N&&h),[N,h]),rt),I=P.useRef(null),T=e??Lg[n];P.useEffect(()=>{if(!(!E.current||!x))return I.current||(I.current=fd({domNode:E.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:k,transform:j,snapGrid:H,snapToGrid:_,nodeOrigin:$,domNode:C}=w.getState();return{nodeLookup:k,transform:j,snapGrid:H,snapToGrid:_,nodeOrigin:$,paneDomNode:C}},onChange:(k,j)=>{const{triggerNodeChanges:H,nodeLookup:_,parentLookup:$,nodeOrigin:C}=w.getState(),z=[],A={x:k.x,y:k.y},M=_.get(x);if(M&&M.expandParent&&M.parentId){const L=M.origin??C,V=k.width??M.measured.width??0,R=k.height??M.measured.height??0,X={id:M.id,parentId:M.parentId,rect:{width:V,height:R,...Ni({x:k.x??M.position.x,y:k.y??M.position.y},{width:V,height:R},M.parentId,_,L)}},Y=ur([X],_,$,C);z.push(...Y),A.x=k.x?Math.max(L[0]*V,k.x):void 0,A.y=k.y?Math.max(L[1]*R,k.y):void 0}if(A.x!==void 0&&A.y!==void 0){const L={id:x,type:"position",position:{...A}};z.push(L)}if(k.width!==void 0&&k.height!==void 0){const V={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:k.width,height:k.height}};z.push(V)}for(const L of j){const V={...L,type:"position"};z.push(V)}H(z)},onEnd:({width:k,height:j})=>{const H={id:x,type:"dimensions",resizing:!1,dimensions:{width:k,height:j}};w.getState().triggerNodeChanges([H])}})),I.current.update({controlPosition:T,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:f},keepAspectRatio:u,resizeDirection:d,onResizeStart:y,onResize:p,onResizeEnd:m,shouldResize:g}),()=>{var k;(k=I.current)==null||k.destroy()}},[T,a,l,c,f,u,y,p,m,g]);const D=T.split("-");return b.jsx("div",{className:it(["react-flow__resize-control","nodrag",...D,n,r]),ref:E,style:{...o,scale:S,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}P.memo(Dg);function Rg(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function o(){var i,s=n.length,a,l=0,c=0;for(i=0;i<s;++i)a=n[i],l+=a.x,c+=a.y;for(l=(l/s-t)*r,c=(c/s-e)*r,i=0;i<s;++i)a=n[i],a.x-=l,a.y-=c}return o.initialize=function(i){n=i},o.x=function(i){return arguments.length?(t=+i,o):t},o.y=function(i){return arguments.length?(e=+i,o):e},o.strength=function(i){return arguments.length?(r=+i,o):r},o}function Hg(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Es(this.cover(e,n),e,n,t)}function Es(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var o,i=t._root,s={data:r},a=t._x0,l=t._y0,c=t._x1,f=t._y1,u,d,h,g,y,p,m,v;if(!i)return t._root=s,t;for(;i.length;)if((y=e>=(u=(a+c)/2))?a=u:c=u,(p=n>=(d=(l+f)/2))?l=d:f=d,o=i,!(i=i[m=p<<1|y]))return o[m]=s,t;if(h=+t._x.call(null,i.data),g=+t._y.call(null,i.data),e===h&&n===g)return s.next=i,o?o[m]=s:t._root=s,t;do o=o?o[m]=new Array(4):t._root=new Array(4),(y=e>=(u=(a+c)/2))?a=u:c=u,(p=n>=(d=(l+f)/2))?l=d:f=d;while((m=p<<1|y)===(v=(g>=d)<<1|h>=u));return o[v]=i,o[m]=s,t}function Vg(t){var e,n,r=t.length,o,i,s=new Array(r),a=new Array(r),l=1/0,c=1/0,f=-1/0,u=-1/0;for(n=0;n<r;++n)isNaN(o=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(s[n]=o,a[n]=i,o<l&&(l=o),o>f&&(f=o),i<c&&(c=i),i>u&&(u=i));if(l>f||c>u)return this;for(this.cover(l,c).cover(f,u),n=0;n<r;++n)Es(this,s[n],a[n],t[n]);return this}function Bg(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,o=this._x1,i=this._y1;if(isNaN(n))o=(n=Math.floor(t))+1,i=(r=Math.floor(e))+1;else{for(var s=o-n||1,a=this._root,l,c;n>t||t>=o||r>e||e>=i;)switch(c=(e<r)<<1|t<n,l=new Array(4),l[c]=a,a=l,s*=2,c){case 0:o=n+s,i=r+s;break;case 1:n=o-s,i=r+s;break;case 2:o=n+s,r=i-s;break;case 3:n=o-s,r=i-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=n,this._y0=r,this._x1=o,this._y1=i,this}function Fg(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Og(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function at(t,e,n,r,o){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=o}function Xg(t,e,n){var r,o=this._x0,i=this._y0,s,a,l,c,f=this._x1,u=this._y1,d=[],h=this._root,g,y;for(h&&d.push(new at(h,o,i,f,u)),n==null?n=1/0:(o=t-n,i=e-n,f=t+n,u=e+n,n*=n);g=d.pop();)if(!(!(h=g.node)||(s=g.x0)>f||(a=g.y0)>u||(l=g.x1)<o||(c=g.y1)<i))if(h.length){var p=(s+l)/2,m=(a+c)/2;d.push(new at(h[3],p,m,l,c),new at(h[2],s,m,p,c),new at(h[1],p,a,l,m),new at(h[0],s,a,p,m)),(y=(e>=m)<<1|t>=p)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-y],d[d.length-1-y]=g)}else{var v=t-+this._x.call(null,h.data),x=e-+this._y.call(null,h.data),w=v*v+x*x;if(w<n){var E=Math.sqrt(n=w);o=t-E,i=e-E,f=t+E,u=e+E,r=h.data}}return r}function Yg(t){if(isNaN(f=+this._x.call(null,t))||isNaN(u=+this._y.call(null,t)))return this;var e,n=this._root,r,o,i,s=this._x0,a=this._y0,l=this._x1,c=this._y1,f,u,d,h,g,y,p,m;if(!n)return this;if(n.length)for(;;){if((g=f>=(d=(s+l)/2))?s=d:l=d,(y=u>=(h=(a+c)/2))?a=h:c=h,e=n,!(n=n[p=y<<1|g]))return this;if(!n.length)break;(e[p+1&3]||e[p+2&3]||e[p+3&3])&&(r=e,m=p)}for(;n.data!==t;)if(o=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,o?(i?o.next=i:delete o.next,this):e?(i?e[p]=i:delete e[p],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[m]=n:this._root=n),this):(this._root=i,this)}function Wg(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Gg(){return this._root}function qg(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Ug(t){var e=[],n,r=this._root,o,i,s,a,l;for(r&&e.push(new at(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,i=n.x0,s=n.y0,a=n.x1,l=n.y1)&&r.length){var c=(i+a)/2,f=(s+l)/2;(o=r[3])&&e.push(new at(o,c,f,a,l)),(o=r[2])&&e.push(new at(o,i,f,c,l)),(o=r[1])&&e.push(new at(o,c,s,a,f)),(o=r[0])&&e.push(new at(o,i,s,c,f))}return this}function Zg(t){var e=[],n=[],r;for(this._root&&e.push(new at(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var o=r.node;if(o.length){var i,s=r.x0,a=r.y0,l=r.x1,c=r.y1,f=(s+l)/2,u=(a+c)/2;(i=o[0])&&e.push(new at(i,s,a,f,u)),(i=o[1])&&e.push(new at(i,f,a,l,u)),(i=o[2])&&e.push(new at(i,s,u,f,c)),(i=o[3])&&e.push(new at(i,f,u,l,c))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Kg(t){return t[0]}function Qg(t){return arguments.length?(this._x=t,this):this._x}function Jg(t){return t[1]}function t0(t){return arguments.length?(this._y=t,this):this._y}function dr(t,e,n){var r=new hr(e??Kg,n??Jg,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function hr(t,e,n,r,o,i){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=o,this._y1=i,this._root=void 0}function Io(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var ct=dr.prototype=hr.prototype;ct.copy=function(){var t=new hr(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Io(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var o=0;o<4;++o)(r=e.source[o])&&(r.length?n.push({source:r,target:e.target[o]=new Array(4)}):e.target[o]=Io(r));return t};ct.add=Hg;ct.addAll=Vg;ct.cover=Bg;ct.data=Fg;ct.extent=Og;ct.find=Xg;ct.remove=Yg;ct.removeAll=Wg;ct.root=Gg;ct.size=qg;ct.visit=Ug;ct.visitAfter=Zg;ct.x=Qg;ct.y=t0;function Dt(t){return function(){return t}}function $t(t){return(t()-.5)*1e-6}function e0(t){return t.x+t.vx}function n0(t){return t.y+t.vy}function r0(t){var e,n,r,o=1,i=1;typeof t!="function"&&(t=Dt(t==null?1:+t));function s(){for(var c,f=e.length,u,d,h,g,y,p,m=0;m<i;++m)for(u=dr(e,e0,n0).visitAfter(a),c=0;c<f;++c)d=e[c],y=n[d.index],p=y*y,h=d.x+d.vx,g=d.y+d.vy,u.visit(v);function v(x,w,E,N,S){var I=x.data,T=x.r,D=y+T;if(I){if(I.index>d.index){var k=h-I.x-I.vx,j=g-I.y-I.vy,H=k*k+j*j;H<D*D&&(k===0&&(k=$t(r),H+=k*k),j===0&&(j=$t(r),H+=j*j),H=(D-(H=Math.sqrt(H)))/H*o,d.vx+=(k*=H)*(D=(T*=T)/(p+T)),d.vy+=(j*=H)*D,I.vx-=k*(D=1-D),I.vy-=j*D)}return}return w>h+D||N<h-D||E>g+D||S<g-D}}function a(c){if(c.data)return c.r=n[c.data.index];for(var f=c.r=0;f<4;++f)c[f]&&c[f].r>c.r&&(c.r=c[f].r)}function l(){if(e){var c,f=e.length,u;for(n=new Array(f),c=0;c<f;++c)u=e[c],n[u.index]=+t(u,c,e)}}return s.initialize=function(c,f){e=c,r=f,l()},s.iterations=function(c){return arguments.length?(i=+c,s):i},s.strength=function(c){return arguments.length?(o=+c,s):o},s.radius=function(c){return arguments.length?(t=typeof c=="function"?c:Dt(+c),l(),s):t},s}function o0(t){return t.index}function Ao(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function i0(t){var e=o0,n=u,r,o=Dt(30),i,s,a,l,c,f=1;t==null&&(t=[]);function u(p){return 1/Math.min(a[p.source.index],a[p.target.index])}function d(p){for(var m=0,v=t.length;m<f;++m)for(var x=0,w,E,N,S,I,T,D;x<v;++x)w=t[x],E=w.source,N=w.target,S=N.x+N.vx-E.x-E.vx||$t(c),I=N.y+N.vy-E.y-E.vy||$t(c),T=Math.sqrt(S*S+I*I),T=(T-i[x])/T*p*r[x],S*=T,I*=T,N.vx-=S*(D=l[x]),N.vy-=I*D,E.vx+=S*(D=1-D),E.vy+=I*D}function h(){if(s){var p,m=s.length,v=t.length,x=new Map(s.map((E,N)=>[e(E,N,s),E])),w;for(p=0,a=new Array(m);p<v;++p)w=t[p],w.index=p,typeof w.source!="object"&&(w.source=Ao(x,w.source)),typeof w.target!="object"&&(w.target=Ao(x,w.target)),a[w.source.index]=(a[w.source.index]||0)+1,a[w.target.index]=(a[w.target.index]||0)+1;for(p=0,l=new Array(v);p<v;++p)w=t[p],l[p]=a[w.source.index]/(a[w.source.index]+a[w.target.index]);r=new Array(v),g(),i=new Array(v),y()}}function g(){if(s)for(var p=0,m=t.length;p<m;++p)r[p]=+n(t[p],p,t)}function y(){if(s)for(var p=0,m=t.length;p<m;++p)i[p]=+o(t[p],p,t)}return d.initialize=function(p,m){s=p,c=m,h()},d.links=function(p){return arguments.length?(t=p,h(),d):t},d.id=function(p){return arguments.length?(e=p,d):e},d.iterations=function(p){return arguments.length?(f=+p,d):f},d.strength=function(p){return arguments.length?(n=typeof p=="function"?p:Dt(+p),g(),d):n},d.distance=function(p){return arguments.length?(o=typeof p=="function"?p:Dt(+p),y(),d):o},d}const s0=1664525,a0=1013904223,$o=4294967296;function c0(){let t=1;return()=>(t=(s0*t+a0)%$o)/$o}function l0(t){return t.x}function u0(t){return t.y}var f0=10,d0=Math.PI*(3-Math.sqrt(5));function h0(t){var e,n=1,r=.001,o=1-Math.pow(r,1/300),i=0,s=.6,a=new Map,l=Jn(u),c=Ne("tick","end"),f=c0();t==null&&(t=[]);function u(){d(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function d(y){var p,m=t.length,v;y===void 0&&(y=1);for(var x=0;x<y;++x)for(n+=(i-n)*o,a.forEach(function(w){w(n)}),p=0;p<m;++p)v=t[p],v.fx==null?v.x+=v.vx*=s:(v.x=v.fx,v.vx=0),v.fy==null?v.y+=v.vy*=s:(v.y=v.fy,v.vy=0);return e}function h(){for(var y=0,p=t.length,m;y<p;++y){if(m=t[y],m.index=y,m.fx!=null&&(m.x=m.fx),m.fy!=null&&(m.y=m.fy),isNaN(m.x)||isNaN(m.y)){var v=f0*Math.sqrt(.5+y),x=y*d0;m.x=v*Math.cos(x),m.y=v*Math.sin(x)}(isNaN(m.vx)||isNaN(m.vy))&&(m.vx=m.vy=0)}}function g(y){return y.initialize&&y.initialize(t,f),y}return h(),e={tick:d,restart:function(){return l.restart(u),e},stop:function(){return l.stop(),e},nodes:function(y){return arguments.length?(t=y,h(),a.forEach(g),e):t},alpha:function(y){return arguments.length?(n=+y,e):n},alphaMin:function(y){return arguments.length?(r=+y,e):r},alphaDecay:function(y){return arguments.length?(o=+y,e):+o},alphaTarget:function(y){return arguments.length?(i=+y,e):i},velocityDecay:function(y){return arguments.length?(s=1-y,e):1-s},randomSource:function(y){return arguments.length?(f=y,a.forEach(g),e):f},force:function(y,p){return arguments.length>1?(p==null?a.delete(y):a.set(y,g(p)),e):a.get(y)},find:function(y,p,m){var v=0,x=t.length,w,E,N,S,I;for(m==null?m=1/0:m*=m,v=0;v<x;++v)S=t[v],w=y-S.x,E=p-S.y,N=w*w+E*E,N<m&&(I=S,m=N);return I},on:function(y,p){return arguments.length>1?(c.on(y,p),e):c.on(y)}}}function g0(){var t,e,n,r,o=Dt(-30),i,s=1,a=1/0,l=.81;function c(h){var g,y=t.length,p=dr(t,l0,u0).visitAfter(u);for(r=h,g=0;g<y;++g)e=t[g],p.visit(d)}function f(){if(t){var h,g=t.length,y;for(i=new Array(g),h=0;h<g;++h)y=t[h],i[y.index]=+o(y,h,t)}}function u(h){var g=0,y,p,m=0,v,x,w;if(h.length){for(v=x=w=0;w<4;++w)(y=h[w])&&(p=Math.abs(y.value))&&(g+=y.value,m+=p,v+=p*y.x,x+=p*y.y);h.x=v/m,h.y=x/m}else{y=h,y.x=y.data.x,y.y=y.data.y;do g+=i[y.data.index];while(y=y.next)}h.value=g}function d(h,g,y,p){if(!h.value)return!0;var m=h.x-e.x,v=h.y-e.y,x=p-g,w=m*m+v*v;if(x*x/l<w)return w<a&&(m===0&&(m=$t(n),w+=m*m),v===0&&(v=$t(n),w+=v*v),w<s&&(w=Math.sqrt(s*w)),e.vx+=m*h.value*r/w,e.vy+=v*h.value*r/w),!0;if(h.length||w>=a)return;(h.data!==e||h.next)&&(m===0&&(m=$t(n),w+=m*m),v===0&&(v=$t(n),w+=v*v),w<s&&(w=Math.sqrt(s*w)));do h.data!==e&&(x=i[h.data.index]*r/w,e.vx+=m*x,e.vy+=v*x);while(h=h.next)}return c.initialize=function(h,g){t=h,n=g,f()},c.strength=function(h){return arguments.length?(o=typeof h=="function"?h:Dt(+h),f(),c):o},c.distanceMin=function(h){return arguments.length?(s=h*h,c):Math.sqrt(s)},c.distanceMax=function(h){return arguments.length?(a=h*h,c):Math.sqrt(a)},c.theta=function(h){return arguments.length?(l=h*h,c):Math.sqrt(l)},c}function Po(t){if(!t)return"—";const e=t.split("/");return e[e.length-1]??t}function p0({layout:t,onLayoutChange:e,depth:n,onDepthChange:r,nodeCount:o,edgeCount:i,truncated:s,onRelayout:a,langFilter:l,onLangFilterChange:c,availableLangs:f,clusterByDir:u,onClusterByDirChange:d,pathFrom:h,pathTo:g,selectingPath:y,onSelectPath:p,onFindPath:m,onClearPath:v,pathStatus:x}){const{zoomIn:w,zoomOut:E,fitView:N}=Ae();return b.jsxs("div",{"data-testid":"graph-controls",className:"flex flex-col gap-3 p-3 bg-gray-900 border border-gray-700 rounded-lg shadow-lg",style:{width:230},children:[b.jsxs("div",{className:"flex items-center gap-1.5",children:[b.jsx("button",{type:"button",onClick:()=>w({duration:200}),className:"flex-1 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Zoom in",children:"+ Zoom In"}),b.jsx("button",{type:"button",onClick:()=>E({duration:200}),className:"flex-1 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Zoom out",children:"− Zoom Out"})]}),b.jsx("button",{type:"button",onClick:()=>N({duration:300,padding:.1}),className:"py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Fit to view",children:"Fit to View"}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Layout"}),b.jsxs("select",{value:t,onChange:S=>e(S.target.value),className:"w-full px-2 py-1 text-xs bg-gray-800 border border-gray-700 rounded text-gray-300 focus:outline-none focus:border-blue-500","aria-label":"Layout algorithm",children:[b.jsx("option",{value:"force",children:"Force-directed"}),b.jsx("option",{value:"hierarchical",children:"Hierarchical"}),b.jsx("option",{value:"radial",children:"Radial"})]})]}),b.jsxs("div",{children:[b.jsxs("label",{className:"flex items-center justify-between text-xs text-gray-500 mb-1",children:[b.jsx("span",{children:"Depth"}),b.jsx("span",{className:"text-gray-300",children:n})]}),b.jsx("input",{type:"range",min:1,max:10,value:n,onChange:S=>r(Number(S.target.value)),className:"w-full accent-blue-500","aria-label":"Traversal depth","data-testid":"depth-slider"}),b.jsxs("div",{className:"flex justify-between text-gray-600 mt-0.5",style:{fontSize:"0.6rem"},children:[b.jsx("span",{children:"1"}),b.jsx("span",{children:"10"})]})]}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Language"}),b.jsxs("select",{value:l,onChange:S=>c(S.target.value),className:"w-full px-2 py-1 text-xs bg-gray-800 border border-gray-700 rounded text-gray-300 focus:outline-none focus:border-blue-500","aria-label":"Language filter","data-testid":"lang-filter",children:[b.jsx("option",{value:"",children:"All languages"}),f.map(S=>b.jsxs("option",{value:S,children:[".",S]},S))]})]}),b.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[b.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked),className:"accent-blue-500","aria-label":"Cluster by directory","data-testid":"cluster-toggle"}),b.jsx("span",{className:"text-xs text-gray-400",children:"Cluster by directory"})]}),b.jsxs("div",{className:"border-t border-gray-800 pt-2",children:[b.jsx("div",{className:"text-xs text-gray-500 mb-1.5",children:"Highlight Path"}),b.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[b.jsx("button",{type:"button",onClick:()=>p("from"),className:`px-2 py-0.5 text-xs rounded border transition-colors ${y==="from"?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300"}`,"aria-label":"Select path start node","data-testid":"path-from-btn",children:"From"}),b.jsx("span",{className:"text-xs font-mono text-gray-300 truncate flex-1",title:h??"","data-testid":"path-from-label",children:y==="from"?b.jsx("span",{className:"text-blue-400 animate-pulse",children:"click a node…"}):Po(h)})]}),b.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[b.jsx("button",{type:"button",onClick:()=>p("to"),className:`px-2 py-0.5 text-xs rounded border transition-colors ${y==="to"?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300"}`,"aria-label":"Select path end node","data-testid":"path-to-btn",children:"To"}),b.jsx("span",{className:"text-xs font-mono text-gray-300 truncate flex-1",title:g??"","data-testid":"path-to-label",children:y==="to"?b.jsx("span",{className:"text-blue-400 animate-pulse",children:"click a node…"}):Po(g)})]}),b.jsxs("div",{className:"flex gap-1.5",children:[b.jsx("button",{type:"button",onClick:m,disabled:!h||!g,className:"flex-1 py-1 text-xs bg-blue-600 hover:bg-blue-500 disabled:bg-gray-800 disabled:text-gray-600 rounded text-white transition-colors","aria-label":"Find path","data-testid":"find-path-btn",children:"Find Path"}),b.jsx("button",{type:"button",onClick:v,disabled:!h&&!g&&x==="idle",className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:text-gray-700 border border-gray-700 rounded text-gray-400 transition-colors","aria-label":"Clear path","data-testid":"clear-path-btn",children:"Clear"})]}),x==="found"&&b.jsx("div",{className:"mt-1.5 text-xs text-green-400","data-testid":"path-status-found",children:"Path found — highlighted in blue"}),x==="not-found"&&b.jsx("div",{className:"mt-1.5 text-xs text-amber-400","data-testid":"path-status-not-found",children:"No path found between these nodes"})]}),b.jsx("button",{type:"button",onClick:a,className:"py-1 text-xs bg-blue-600 hover:bg-blue-500 rounded text-white transition-colors","aria-label":"Re-run layout",children:"Re-layout"}),b.jsxs("div",{className:"border-t border-gray-800 pt-2 text-gray-500",style:{fontSize:"0.65rem"},children:[b.jsxs("div",{children:[o," nodes · ",i," edges"]}),s&&b.jsx("div",{className:"text-amber-500 mt-0.5",children:"Graph truncated (limit reached)"})]})]})}function m0(t){if(t<.5){const e=t*2,n=Math.round(34+e*200),r=Math.round(197+e*-18),o=Math.round(94+e*-86);return`rgb(${n},${r},${o})`}else{const e=(t-.5)*2,n=Math.round(234+e*5),r=Math.round(179+e*-111),o=Math.round(8+e*60);return`rgb(${n},${r},${o})`}}function y0({ext:t}){const e=t==="ts"||t==="tsx"?"#3b82f6":t==="js"||t==="jsx"?"#eab308":t==="vue"?"#22c55e":t==="py"?"#a78bfa":"#9ca3af";return b.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",className:"shrink-0",children:[b.jsx("rect",{x:"1",y:"1",width:"8",height:"10",rx:"1",stroke:e,strokeWidth:"1.2"}),b.jsx("path",{d:"M7 1v3h3",stroke:e,strokeWidth:"1.2",strokeLinecap:"round"}),b.jsx("line",{x1:"3",y1:"6",x2:"9",y2:"6",stroke:e,strokeWidth:"1",strokeLinecap:"round"}),b.jsx("line",{x1:"3",y1:"8",x2:"7",y2:"8",stroke:e,strokeWidth:"1",strokeLinecap:"round"})]})}const x0=P.memo(function({data:e,selected:n}){const r=e.label??"",o=r.includes(".")?r.split(".").pop()??"":"",i=typeof e.heatmapScore=="number"?e.heatmapScore:void 0,s=!!e.isChurnHotspot;return b.jsxs("div",{"data-testid":"graph-file-node",className:`
|
|
24
24
|
relative rounded border px-2.5 py-1.5 text-xs font-mono select-none
|
|
25
25
|
bg-gray-900 text-gray-200 transition-colors
|
|
26
26
|
${n?"border-blue-500 shadow-lg shadow-blue-500/20":"border-gray-700 hover:border-gray-500"}
|
|
27
|
-
`,style:{minWidth:120,maxWidth:200},children:[b.jsx(ne,{type:"target",position:G.Top,style:{background:"#4b5563",width:6,height:6}}),i!==void 0&&b.jsx("div",{className:"absolute -top-1.5 -right-1.5 w-3 h-3 rounded-full border-2 border-gray-950",style:{background:m0(i)},title:`Quality score: ${Math.round((1-i)*100)}%`,"aria-label":"quality-indicator"}),s&&b.jsx("div",{className:"absolute -top-1.5 -left-1.5 w-3 h-3 rounded-full bg-orange-500 animate-ping opacity-75","aria-label":"churn-indicator"}),b.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[b.jsx(y0,{ext:o}),b.jsx("span",{className:"truncate",title:e.path,children:r})]}),e.symbolCount>0&&b.jsxs("div",{className:"mt-0.5 text-gray-500",style:{fontSize:"0.65rem"},children:[e.symbolCount," symbol",e.symbolCount!==1?"s":""]}),b.jsx(ne,{type:"source",position:G.Bottom,style:{background:"#4b5563",width:6,height:6}})]})});function w0({data:t}){return b.jsx("div",{className:"w-full h-full rounded border border-gray-700",style:{background:"rgba(31, 41, 55, 0.5)"},"data-testid":"dir-group-node",children:b.jsx("div",{className:"px-2 py-1 text-xs text-gray-500 font-mono truncate border-b border-gray-700/50",children:t.label})})}const v0={file:x0,dirGroup:w0};function b0(t,e){return e?t.filter(n=>{const r=n.data.path;return(r.includes(".")?r.split(".").pop()??"":"")===e}):t}function _0(t,e,n){if(t===e)return[t];const r=new Map;for(const s of n)r.has(s.source)||r.set(s.source,[]),r.has(s.target)||r.set(s.target,[]),r.get(s.source).push(s.target),r.get(s.target).push(s.source);const o=new Set([t]),i=[[t]];for(;i.length>0;){const s=i.shift(),a=s[s.length-1];for(const l of r.get(a)??[]){if(l===e)return[...s,e];o.has(l)||(o.add(l),i.push([...s,l]))}}return null}function N0(t,e){if(t.length<2)return new Set;const n=new Map;for(const o of e)n.set(`${o.source}|${o.target}`,o.id),n.set(`${o.target}|${o.source}`,o.id);const r=new Set;for(let o=0;o<t.length-1;o++){const i=n.get(`${t[o]}|${t[o+1]}`);i&&r.add(i)}return r}function E0(t){const e=new Map;for(const n of t){const r=n.data.path,o=r.lastIndexOf("/"),i=o>=0?r.slice(0,o):".";e.has(i)||e.set(i,[]),e.get(i).push(n)}return e}function S0(t,e,n,r){const o=t.map((a,l)=>({id:a.id,x:(Math.random()-.5)*n,y:(Math.random()-.5)*r,index:l})),i=new Map(o.map(a=>[a.id,a])),s=e.map(a=>({source:i.get(a.source),target:i.get(a.target)})).filter(a=>!!a.source&&!!a.target);return h0(o).force("link",i0(s).id(a=>a.id).distance(120).strength(.8)).force("charge",g0().strength(-400)).force("center",Rg(0,0)).force("collide",r0(70)).stop().tick(200),new Map(o.map(a=>[a.id,{x:a.x,y:a.y}]))}function M0(t,e){var c;const n=new Map(t.map(f=>[f.id,0]));for(const f of e)n.set(f.target,(n.get(f.target)??0)+1);const r=new Map(t.map(f=>[f.id,[]]));for(const f of e)(c=r.get(f.source))==null||c.push(f.target);const o=new Map,i=[];for(const[f,u]of n)u===0&&(o.set(f,0),i.push(f));i.length===0&&t.length>0&&(o.set(t[0].id,0),i.push(t[0].id));for(let f=0;f<i.length;f++){const u=i[f],d=o.get(u)??0;for(const h of r.get(u)??[])o.has(h)||(o.set(h,d+1),i.push(h))}const s=new Map;for(const[f,u]of o)s.has(u)||s.set(u,[]),s.get(u).push(f);const a=new Map;for(const[f,u]of s){const d=u.length*180;u.forEach((h,g)=>{a.set(h,{x:g*180-d/2,y:f*140})})}let l=0;for(const f of t)a.has(f.id)||(a.set(f.id,{x:l,y:0}),l+=180);return a}function C0(t,e){if(t.length===0)return new Map;const n=new Map(t.map(c=>[c.id,0]));for(const c of e)n.set(c.source,(n.get(c.source)??0)+1),n.set(c.target,(n.get(c.target)??0)+1);const r=[...t].sort((c,f)=>(n.get(f.id)??0)-(n.get(c.id)??0)),o=new Map,i=r[0];o.set(i.id,{x:0,y:0});const s=r.slice(1),a=[s.slice(0,8),s.slice(8,24),s.slice(24)],l=[200,380,560];for(let c=0;c<a.length;c++){const f=a[c];if(f.length===0)continue;const u=l[c];f.forEach((d,h)=>{const g=2*Math.PI*h/f.length;o.set(d.id,{x:u*Math.cos(g),y:u*Math.sin(g)})})}return o}const Fe=20,To=200,zo=60,Lo=24,Oe=10,le=2;function k0(t,e){const n=E0(t),r=[];for(const[o,i]of n){const s=Math.ceil(i.length/le),a=le*To+(le-1)*Oe+Fe*2,l=s*zo+(s-1)*Oe+Fe*2+Lo;let c=0,f=0;for(const d of i){const h=e.get(d.id)??{x:0,y:0};c+=h.x,f+=h.y}c/=i.length,f/=i.length;const u=`__dir_${o}`;r.push({id:u,type:"dirGroup",position:{x:c-a/2,y:f-l/2},style:{width:a,height:l},data:{label:o,path:"",symbolCount:0,__isGroup:!0}}),i.forEach((d,h)=>{const g=h%le,y=Math.floor(h/le);r.push({id:d.id,type:"file",parentId:u,extent:"parent",position:{x:Fe+g*(To+Oe),y:Fe+Lo+y*(zo+Oe)},data:d.data})})}return r}function I0(t,e,n){return t.map(r=>{const o=e.get(r.id)??{x:0,y:0};return{id:r.id,type:"file",position:o,data:r.data,style:n&&r.id===n?{filter:"drop-shadow(0 0 8px rgba(59,130,246,0.8))"}:void 0}})}function A0(t){return t.map(e=>({id:e.id,source:e.source,target:e.target,markerEnd:{type:Kt.ArrowClosed,color:"#4b5563",width:12,height:12},style:{stroke:"#4b5563",strokeWidth:1.5},data:e.data,type:"smoothstep"}))}function $0({apiNodes:t,apiEdges:e,focusFile:n,layout:r,depth:o,onDepthChange:i,onLayoutChange:s,truncated:a,onNodeClick:l}){const{fitView:c}=Ae(),[f,u,d]=lg([]),[h,g,y]=ug([]),p=P.useRef(null),m=P.useRef(0),[v,x]=P.useState(""),[w,E]=P.useState(!1),[N,S]=P.useState(null),[I,T]=P.useState(null),[j,k]=P.useState(new Set),[L,H]=P.useState(new Set),[_,$]=P.useState(null),[C,z]=P.useState("idle"),A=P.useMemo(()=>{const F=new Set;for(const B of t){const O=B.data.path,Z=O.includes(".")?O.split(".").pop():void 0;Z&&F.add(Z)}return[...F].sort()},[t]),M=P.useMemo(()=>b0(t,v),[t,v]),D=P.useMemo(()=>{if(!v)return e;const F=new Set(M.map(B=>B.id));return e.filter(B=>F.has(B.source)&&F.has(B.target))},[e,M,v]),V=P.useMemo(()=>({nodeCount:M.length,edgeCount:D.length}),[M,D]),R=P.useCallback(()=>{if(!N||!I)return;const F=_0(N,I,D);F?(k(new Set(F)),H(N0(F,D)),z("found")):(k(new Set),H(new Set),z("not-found"))},[N,I,D]),X=P.useCallback(()=>{S(null),T(null),k(new Set),H(new Set),z("idle"),$(null)},[]),Y=P.useCallback(F=>{$(B=>B===F?null:F)},[]),W=P.useCallback(()=>{var Z,Q;if(M.length===0){u([]),g([]);return}const F=((Z=p.current)==null?void 0:Z.clientWidth)??800,B=((Q=p.current)==null?void 0:Q.clientHeight)??600;let O;r==="force"?O=S0(M,D,F,B):r==="hierarchical"?O=M0(M,D):O=C0(M,D),u(w?k0(M,O):I0(M,O,n)),g(A0(D)),m.current++,setTimeout(()=>c({duration:300,padding:.1}),50)},[M,D,n,r,w,u,g,c]);P.useEffect(()=>{W()},[W]),P.useEffect(()=>{const F=j.size>0;u(B=>B.map(O=>O.data.__isGroup?O:{...O,style:{...O.style??{},opacity:F&&!j.has(O.id)?.2:1}})),g(B=>B.map(O=>{const Z=!F||L.has(O.id);return{...O,markerEnd:{type:Kt.ArrowClosed,color:F&&Z?"#3b82f6":"#4b5563",width:12,height:12},style:{stroke:F&&Z?"#3b82f6":"#4b5563",strokeWidth:F&&Z?2.5:1.5,opacity:Z?1:.2}}}))},[j,L,u,g]);const q=P.useCallback((F,B)=>{const O=B.data.path;if(O){if(_==="from"){S(O),$(null);return}if(_==="to"){T(O),$(null);return}l==null||l(O)}},[l,_]);return b.jsxs("div",{ref:p,className:"relative w-full h-full","data-testid":"graph-viewer",style:{cursor:_?"crosshair":void 0},children:[b.jsxs(cg,{nodes:f,edges:h,onNodesChange:d,onEdgesChange:y,onNodeClick:q,nodeTypes:v0,minZoom:.05,maxZoom:3,fitView:!0,attributionPosition:"bottom-right",className:"bg-gray-950",children:[b.jsx(pg,{variant:Et.Dots,gap:24,size:1,color:"#1f2937"}),b.jsx(zg,{nodeColor:F=>F.data.__isGroup?"transparent":"#374151",maskColor:"rgba(17, 24, 39, 0.7)",style:{background:"#111827"},"data-testid":"graph-minimap"})]}),b.jsx("div",{className:"absolute top-3 right-3 z-10",children:b.jsx(p0,{layout:r,onLayoutChange:s,depth:o,onDepthChange:i,nodeCount:V.nodeCount,edgeCount:V.edgeCount,truncated:a,onRelayout:W,langFilter:v,onLangFilterChange:x,availableLangs:A,clusterByDir:w,onClusterByDirChange:E,pathFrom:N,pathTo:I,selectingPath:_,onSelectPath:Y,onFindPath:R,onClearPath:X,pathStatus:C})})]})}function P0(t){return b.jsx(ws,{children:b.jsx($0,{...t})})}function T0(){return b.jsxs("div",{className:"flex items-center justify-center h-full text-gray-500 gap-2",children:[b.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-500 animate-pulse"}),b.jsx("span",{className:"text-sm",children:"Loading graph…"})]})}function z0({message:t}){return b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsxs("div",{className:"text-center max-w-sm",children:[b.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Failed to load graph"}),b.jsx("div",{className:"text-sm text-gray-500",children:t})]})})}function L0(){return b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsxs("div",{className:"text-center text-gray-500",children:[b.jsx("div",{className:"text-lg mb-1",children:"No dependency data"}),b.jsx("div",{className:"text-sm",children:"Index this repository first to see dependency edges."})]})})}function j0(){const{id:t}=Aa(),[e,n]=P.useState(null),[r,o]=P.useState(!0),[i,s]=P.useState(null),[a,l]=P.useState(void 0),[c,f]=P.useState(3),[u,d]=P.useState("force"),h=P.useCallback(async()=>{if(t){o(!0),s(null);try{const p=await $a.getGraph(t,{filePath:a,depth:c,limit:200});n(p)}catch(p){s(p instanceof Error?p.message:String(p))}finally{o(!1)}}},[t,a,c]);P.useEffect(()=>{h()},[h]);const g=P.useCallback(p=>{l(m=>m===p?void 0:p)},[]),y=P.useCallback(p=>{f(p)},[]);return b.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[b.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-gray-800 shrink-0 bg-gray-900",children:[t&&b.jsx(Pa,{to:`/repos/${encodeURIComponent(t)}`,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"← Back to repo"}),b.jsx("h1",{className:"text-sm font-semibold text-gray-200",children:"Dependency Graph"}),a&&b.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[b.jsx("span",{className:"text-xs text-gray-500",children:"Focus:"}),b.jsx("code",{className:"text-xs text-blue-400 font-mono truncate max-w-xs",children:a}),b.jsx("button",{type:"button",onClick:()=>l(void 0),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Clear focus",children:"✕"})]}),!a&&b.jsx("span",{className:"text-xs text-gray-600 ml-auto",children:"Click a node to focus on its neighborhood"}),b.jsx("button",{type:"button",onClick:()=>void h(),className:"ml-2 px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Refresh graph",children:"Refresh"})]}),b.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[r&&b.jsx(T0,{}),!r&&i&&b.jsx(z0,{message:i}),!r&&!i&&e&&e.nodes.length===0&&b.jsx(L0,{}),!r&&!i&&e&&e.nodes.length>0&&b.jsx(P0,{apiNodes:e.nodes,apiEdges:e.edges,focusFile:a,layout:u,depth:c,onDepthChange:y,onLayoutChange:d,truncated:e.truncated,onNodeClick:g})]})]})}export{j0 as default};
|
|
27
|
+
`,style:{minWidth:120,maxWidth:200},children:[b.jsx(ne,{type:"target",position:G.Top,style:{background:"#4b5563",width:6,height:6}}),i!==void 0&&b.jsx("div",{className:"absolute -top-1.5 -right-1.5 w-3 h-3 rounded-full border-2 border-gray-950",style:{background:m0(i)},title:`Quality score: ${Math.round((1-i)*100)}%`,"aria-label":"quality-indicator"}),s&&b.jsx("div",{className:"absolute -top-1.5 -left-1.5 w-3 h-3 rounded-full bg-orange-500 animate-ping opacity-75","aria-label":"churn-indicator"}),b.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[b.jsx(y0,{ext:o}),b.jsx("span",{className:"truncate",title:e.path,children:r})]}),e.symbolCount>0&&b.jsxs("div",{className:"mt-0.5 text-gray-500",style:{fontSize:"0.65rem"},children:[e.symbolCount," symbol",e.symbolCount!==1?"s":""]}),b.jsx(ne,{type:"source",position:G.Bottom,style:{background:"#4b5563",width:6,height:6}})]})});function w0({data:t}){return b.jsx("div",{className:"w-full h-full rounded border border-gray-700",style:{background:"rgba(31, 41, 55, 0.5)"},"data-testid":"dir-group-node",children:b.jsx("div",{className:"px-2 py-1 text-xs text-gray-500 font-mono truncate border-b border-gray-700/50",children:t.label})})}const v0={file:x0,dirGroup:w0};function b0(t,e){return e?t.filter(n=>{const r=n.data.path;return(r.includes(".")?r.split(".").pop()??"":"")===e}):t}function _0(t,e,n){if(t===e)return[t];const r=new Map;for(const s of n)r.has(s.source)||r.set(s.source,[]),r.has(s.target)||r.set(s.target,[]),r.get(s.source).push(s.target),r.get(s.target).push(s.source);const o=new Set([t]),i=[[t]];for(;i.length>0;){const s=i.shift(),a=s[s.length-1];for(const l of r.get(a)??[]){if(l===e)return[...s,e];o.has(l)||(o.add(l),i.push([...s,l]))}}return null}function N0(t,e){if(t.length<2)return new Set;const n=new Map;for(const o of e)n.set(`${o.source}|${o.target}`,o.id),n.set(`${o.target}|${o.source}`,o.id);const r=new Set;for(let o=0;o<t.length-1;o++){const i=n.get(`${t[o]}|${t[o+1]}`);i&&r.add(i)}return r}function E0(t){const e=new Map;for(const n of t){const r=n.data.path,o=r.lastIndexOf("/"),i=o>=0?r.slice(0,o):".";e.has(i)||e.set(i,[]),e.get(i).push(n)}return e}function S0(t,e,n,r){const o=t.map((a,l)=>({id:a.id,x:(Math.random()-.5)*n,y:(Math.random()-.5)*r,index:l})),i=new Map(o.map(a=>[a.id,a])),s=e.map(a=>({source:i.get(a.source),target:i.get(a.target)})).filter(a=>!!a.source&&!!a.target);return h0(o).force("link",i0(s).id(a=>a.id).distance(120).strength(.8)).force("charge",g0().strength(-400)).force("center",Rg(0,0)).force("collide",r0(70)).stop().tick(200),new Map(o.map(a=>[a.id,{x:a.x,y:a.y}]))}function M0(t,e){var c;const n=new Map(t.map(f=>[f.id,0]));for(const f of e)n.set(f.target,(n.get(f.target)??0)+1);const r=new Map(t.map(f=>[f.id,[]]));for(const f of e)(c=r.get(f.source))==null||c.push(f.target);const o=new Map,i=[];for(const[f,u]of n)u===0&&(o.set(f,0),i.push(f));i.length===0&&t.length>0&&(o.set(t[0].id,0),i.push(t[0].id));for(let f=0;f<i.length;f++){const u=i[f],d=o.get(u)??0;for(const h of r.get(u)??[])o.has(h)||(o.set(h,d+1),i.push(h))}const s=new Map;for(const[f,u]of o)s.has(u)||s.set(u,[]),s.get(u).push(f);const a=new Map;for(const[f,u]of s){const d=u.length*180;u.forEach((h,g)=>{a.set(h,{x:g*180-d/2,y:f*140})})}let l=0;for(const f of t)a.has(f.id)||(a.set(f.id,{x:l,y:0}),l+=180);return a}function C0(t,e){if(t.length===0)return new Map;const n=new Map(t.map(c=>[c.id,0]));for(const c of e)n.set(c.source,(n.get(c.source)??0)+1),n.set(c.target,(n.get(c.target)??0)+1);const r=[...t].sort((c,f)=>(n.get(f.id)??0)-(n.get(c.id)??0)),o=new Map,i=r[0];o.set(i.id,{x:0,y:0});const s=r.slice(1),a=[s.slice(0,8),s.slice(8,24),s.slice(24)],l=[200,380,560];for(let c=0;c<a.length;c++){const f=a[c];if(f.length===0)continue;const u=l[c];f.forEach((d,h)=>{const g=2*Math.PI*h/f.length;o.set(d.id,{x:u*Math.cos(g),y:u*Math.sin(g)})})}return o}const Fe=20,To=200,zo=60,jo=24,Oe=10,le=2;function k0(t,e){const n=E0(t),r=[];for(const[o,i]of n){const s=Math.ceil(i.length/le),a=le*To+(le-1)*Oe+Fe*2,l=s*zo+(s-1)*Oe+Fe*2+jo;let c=0,f=0;for(const d of i){const h=e.get(d.id)??{x:0,y:0};c+=h.x,f+=h.y}c/=i.length,f/=i.length;const u=`__dir_${o}`;r.push({id:u,type:"dirGroup",position:{x:c-a/2,y:f-l/2},style:{width:a,height:l},data:{label:o,path:"",symbolCount:0,__isGroup:!0}}),i.forEach((d,h)=>{const g=h%le,y=Math.floor(h/le);r.push({id:d.id,type:"file",parentId:u,extent:"parent",position:{x:Fe+g*(To+Oe),y:Fe+jo+y*(zo+Oe)},data:d.data})})}return r}function I0(t,e,n){return t.map(r=>{const o=e.get(r.id)??{x:0,y:0};return{id:r.id,type:"file",position:o,data:r.data,style:n&&r.id===n?{filter:"drop-shadow(0 0 8px rgba(59,130,246,0.8))"}:void 0}})}function A0(t){return t.map(e=>({id:e.id,source:e.source,target:e.target,markerEnd:{type:Kt.ArrowClosed,color:"#4b5563",width:12,height:12},style:{stroke:"#4b5563",strokeWidth:1.5},data:e.data,type:"smoothstep"}))}function $0({apiNodes:t,apiEdges:e,focusFile:n,layout:r,depth:o,onDepthChange:i,onLayoutChange:s,truncated:a,onNodeClick:l}){const{fitView:c}=Ae(),[f,u,d]=lg([]),[h,g,y]=ug([]),p=P.useRef(null),m=P.useRef(0),[v,x]=P.useState(""),[w,E]=P.useState(!1),[N,S]=P.useState(null),[I,T]=P.useState(null),[D,k]=P.useState(new Set),[j,H]=P.useState(new Set),[_,$]=P.useState(null),[C,z]=P.useState("idle"),A=P.useMemo(()=>{const F=new Set;for(const B of t){const O=B.data.path,Z=O.includes(".")?O.split(".").pop():void 0;Z&&F.add(Z)}return[...F].sort()},[t]),M=P.useMemo(()=>b0(t,v),[t,v]),L=P.useMemo(()=>{if(!v)return e;const F=new Set(M.map(B=>B.id));return e.filter(B=>F.has(B.source)&&F.has(B.target))},[e,M,v]),V=P.useMemo(()=>({nodeCount:M.length,edgeCount:L.length}),[M,L]),R=P.useCallback(()=>{if(!N||!I)return;const F=_0(N,I,L);F?(k(new Set(F)),H(N0(F,L)),z("found")):(k(new Set),H(new Set),z("not-found"))},[N,I,L]),X=P.useCallback(()=>{S(null),T(null),k(new Set),H(new Set),z("idle"),$(null)},[]),Y=P.useCallback(F=>{$(B=>B===F?null:F)},[]),W=P.useCallback(()=>{var Z,Q;if(M.length===0){u([]),g([]);return}const F=((Z=p.current)==null?void 0:Z.clientWidth)??800,B=((Q=p.current)==null?void 0:Q.clientHeight)??600;let O;r==="force"?O=S0(M,L,F,B):r==="hierarchical"?O=M0(M,L):O=C0(M,L),u(w?k0(M,O):I0(M,O,n)),g(A0(L)),m.current++,setTimeout(()=>c({duration:300,padding:.1}),50)},[M,L,n,r,w,u,g,c]);P.useEffect(()=>{W()},[W]),P.useEffect(()=>{const F=D.size>0;u(B=>B.map(O=>O.data.__isGroup?O:{...O,style:{...O.style??{},opacity:F&&!D.has(O.id)?.2:1}})),g(B=>B.map(O=>{const Z=!F||j.has(O.id);return{...O,markerEnd:{type:Kt.ArrowClosed,color:F&&Z?"#3b82f6":"#4b5563",width:12,height:12},style:{stroke:F&&Z?"#3b82f6":"#4b5563",strokeWidth:F&&Z?2.5:1.5,opacity:Z?1:.2}}}))},[D,j,u,g]);const q=P.useCallback((F,B)=>{const O=B.data.path;if(O){if(_==="from"){S(O),$(null);return}if(_==="to"){T(O),$(null);return}l==null||l(O)}},[l,_]);return b.jsxs("div",{ref:p,className:"relative w-full h-full","data-testid":"graph-viewer",style:{cursor:_?"crosshair":void 0},children:[b.jsxs(cg,{nodes:f,edges:h,onNodesChange:d,onEdgesChange:y,onNodeClick:q,nodeTypes:v0,minZoom:.05,maxZoom:3,fitView:!0,attributionPosition:"bottom-right",className:"bg-gray-950",children:[b.jsx(pg,{variant:Et.Dots,gap:24,size:1,color:"#1f2937"}),b.jsx(zg,{nodeColor:F=>F.data.__isGroup?"transparent":"#374151",maskColor:"rgba(17, 24, 39, 0.7)",style:{background:"#111827"},"data-testid":"graph-minimap"})]}),b.jsx("div",{className:"absolute top-3 right-3 z-10",children:b.jsx(p0,{layout:r,onLayoutChange:s,depth:o,onDepthChange:i,nodeCount:V.nodeCount,edgeCount:V.edgeCount,truncated:a,onRelayout:W,langFilter:v,onLangFilterChange:x,availableLangs:A,clusterByDir:w,onClusterByDirChange:E,pathFrom:N,pathTo:I,selectingPath:_,onSelectPath:Y,onFindPath:R,onClearPath:X,pathStatus:C})})]})}function P0(t){return b.jsx(vs,{children:b.jsx($0,{...t})})}function T0(){return b.jsxs("div",{className:"flex items-center justify-center h-full text-gray-500 gap-2",children:[b.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-500 animate-pulse"}),b.jsx("span",{className:"text-sm",children:"Loading graph…"})]})}function z0({message:t}){return b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsxs("div",{className:"text-center max-w-sm",children:[b.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Failed to load graph"}),b.jsx("div",{className:"text-sm text-gray-500",children:t})]})})}function j0(){return b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsxs("div",{className:"text-center text-gray-500",children:[b.jsx("div",{className:"text-lg mb-1",children:"No dependency data"}),b.jsx("div",{className:"text-sm",children:"Index this repository first to see dependency edges."})]})})}function L0(){return b.jsx("div",{className:"flex items-center justify-center h-full",children:b.jsxs("div",{className:"text-center text-gray-500",children:[b.jsx("div",{className:"text-lg mb-1",children:"No repository selected"}),b.jsx("div",{className:"text-sm mb-3",children:"Open a repository first, then navigate to its graph."}),b.jsx(Do,{to:"/",className:"text-sm text-blue-400 hover:text-blue-300 transition-colors",children:"← Go to repositories"})]})})}function R0(){const{id:t}=$a(),[e,n]=P.useState(null),[r,o]=P.useState(!0),[i,s]=P.useState(null),[a,l]=P.useState(void 0),[c,f]=P.useState(3),[u,d]=P.useState("force"),h=P.useCallback(async()=>{if(!t){o(!1);return}o(!0),s(null);try{const p=await Pa.getGraph(t,{filePath:a,depth:c,limit:200});n(p)}catch(p){s(p instanceof Error?p.message:String(p))}finally{o(!1)}},[t,a,c]);P.useEffect(()=>{h()},[h]);const g=P.useCallback(p=>{l(m=>m===p?void 0:p)},[]),y=P.useCallback(p=>{f(p)},[]);return b.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[b.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-gray-800 shrink-0 bg-gray-900",children:[t&&b.jsx(Do,{to:`/repos/${encodeURIComponent(t)}`,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"← Back to repo"}),b.jsx("h1",{className:"text-sm font-semibold text-gray-200",children:"Dependency Graph"}),a&&b.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[b.jsx("span",{className:"text-xs text-gray-500",children:"Focus:"}),b.jsx("code",{className:"text-xs text-blue-400 font-mono truncate max-w-xs",children:a}),b.jsx("button",{type:"button",onClick:()=>l(void 0),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Clear focus",children:"✕"})]}),!a&&b.jsx("span",{className:"text-xs text-gray-600 ml-auto",children:"Click a node to focus on its neighborhood"}),b.jsx("button",{type:"button",onClick:()=>void h(),className:"ml-2 px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-gray-300 transition-colors","aria-label":"Refresh graph",children:"Refresh"})]}),b.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[!t&&b.jsx(L0,{}),t&&r&&b.jsx(T0,{}),t&&!r&&i&&b.jsx(z0,{message:i}),t&&!r&&!i&&e&&e.nodes.length===0&&b.jsx(j0,{}),t&&!r&&!i&&e&&e.nodes.length>0&&b.jsx(P0,{apiNodes:e.nodes,apiEdges:e.edges,focusFile:a,layout:u,depth:c,onDepthChange:y,onLayoutChange:d,truncated:e.truncated,onNodeClick:g})]})]})}export{R0 as default};
|