@owox/web 0.35.0 → 0.36.0
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/assets/ModelCanvas-BIPDBSA2.js +12 -0
- package/dist/assets/RelationshipCanvas-BoamwL_P.js +1 -0
- package/dist/assets/{erd-fields-section-w0MuCbrx.js → erd-fields-section-BDlFV3FN.js} +7 -7
- package/dist/assets/index-C5zthIAZ.css +1 -0
- package/dist/assets/index-D5dI1sj2.js +46 -0
- package/dist/assets/index-DbpdnvsV.js +1757 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ModelCanvas-BmvwRtKX.js +0 -2
- package/dist/assets/RelationshipCanvas-BJwnmPDj.js +0 -1
- package/dist/assets/index-BobN8jFh.js +0 -46
- package/dist/assets/index-CHid1y1x.js +0 -1457
- package/dist/assets/index-OJoOSyiH.css +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as or,$ as Lc,a0 as Dc,r as L,j as E,P as Rc,o as Hc,c as zc,a1 as Fc,q as Bc,a2 as Dr,a3 as Vc,a4 as Yc,a5 as Xc,z as Wc,a6 as Gc,a7 as qc,a8 as Kc,T as Zc,a as Uc,I as Qc,b as Jc,a9 as el,aa as tl,ab as nl}from"./index-DbpdnvsV.js";/**
|
|
2
2
|
* @license lucide-react v0.475.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const rl=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]],ex=or("Locate",rl);/**
|
|
7
7
|
* @license lucide-react v0.475.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const ol=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],tx=or("ZoomIn",ol);/**
|
|
12
12
|
* @license lucide-react v0.475.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const tl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Gy=ir("ZoomOut",tl);function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var nl={value:()=>{}};function dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Yt(n)}function Yt(e){this._=e}function rl(e,t){return e.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&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Yt.prototype=dn.prototype={constructor:Yt,on:function(e,t){var n=this._,r=rl(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=ol(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=Fr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Fr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Yt(e)},call:function(e,t){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(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function ol(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Fr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=nl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yn="http://www.w3.org/1999/xhtml";const Br={svg:"http://www.w3.org/2000/svg",xhtml:Yn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Br.hasOwnProperty(t)?{space:Br[t],local:e}:e}function il(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Yn&&t.documentElement.namespaceURI===Yn?t.createElement(e):t.createElementNS(n,e)}}function sl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pi(e){var t=fn(e);return(t.local?sl:il)(t)}function al(){}function sr(e){return e==null?al:function(){return this.querySelector(e)}}function cl(e){typeof e!="function"&&(e=sr(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new le(r,this._parents)}function ll(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ul(){return[]}function mi(e){return e==null?ul:function(){return this.querySelectorAll(e)}}function dl(e){return function(){return ll(e.apply(this,arguments))}}function fl(e){typeof e=="function"?e=dl(e):e=mi(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(r.push(e.call(c,c.__data__,l,s)),o.push(c));return new le(r,o)}function yi(e){return function(){return this.matches(e)}}function xi(e){return function(t){return t.matches(e)}}var hl=Array.prototype.find;function gl(e){return function(){return hl.call(this.children,e)}}function pl(){return this.firstElementChild}function ml(e){return this.select(e==null?pl:gl(typeof e=="function"?e:xi(e)))}var yl=Array.prototype.filter;function xl(){return Array.from(this.children)}function wl(e){return function(){return yl.call(this.children,e)}}function vl(e){return this.selectAll(e==null?xl:wl(typeof e=="function"?e:xi(e)))}function bl(e){typeof e!="function"&&(e=yi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function wi(e){return new Array(e.length)}function El(){return new le(this._enter||this._groups.map(wi),this._parents)}function Kt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kt.prototype={constructor:Kt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _l(e){return function(){return e}}function Nl(e,t,n,r,o,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Kt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Sl(e,t,n,r,o,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(r[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new Kt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function kl(e){return e.__data__}function Cl(e,t){if(!arguments.length)return Array.from(this,kl);var n=t?Sl:Nl,r=this._parents,o=this._groups;typeof e!="function"&&(e=_l(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],d=o[l],f=d.length,h=Ml(e.call(u,u&&u.__data__,l,r)),g=h.length,v=a[l]=new Array(g),w=s[l]=new Array(g),m=c[l]=new Array(f);n(u,d,v,w,m,h,t);for(var b=0,p=0,x,E;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(E=w[p])&&++p<g;);x._next=E||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Ml(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new le(this._exit||this._groups.map(wi),this._parents)}function Al(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function Tl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var l=n[c],u=r[c],d=l.length,f=a[c]=new Array(d),h,g=0;g<d;++g)(h=l[g]||u[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new le(a,this._parents)}function Ol(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],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 Pl(e){e||(e=$l);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}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,c=o[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new le(o,this._parents).order()}function $l(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ll(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function jl(){return Array.from(this)}function Dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function Rl(){let e=0;for(const t of this)++e;return e}function Hl(){return!this.node()}function zl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function Fl(e){return function(){this.removeAttribute(e)}}function Bl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vl(e,t){return function(){this.setAttribute(e,t)}}function Yl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Wl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Gl(e,t){var n=fn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Bl:Fl:typeof t=="function"?n.local?Wl:Xl:n.local?Yl:Vl)(n,t))}function vi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ql(e){return function(){this.style.removeProperty(e)}}function Kl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Zl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Ul(e,t,n){return arguments.length>1?this.each((t==null?ql:typeof t=="function"?Zl:Kl)(e,t,n??"")):et(this.node(),e)}function et(e,t){return e.style.getPropertyValue(t)||vi(e).getComputedStyle(e,null).getPropertyValue(t)}function Ql(e){return function(){delete this[e]}}function Jl(e,t){return function(){this[e]=t}}function eu(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function tu(e,t){return arguments.length>1?this.each((t==null?Ql:typeof t=="function"?eu:Jl)(e,t)):this.node()[e]}function bi(e){return e.trim().split(/^|\s+/)}function ar(e){return e.classList||new Ei(e)}function Ei(e){this._node=e,this._names=bi(e.getAttribute("class")||"")}Ei.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function _i(e,t){for(var n=ar(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ni(e,t){for(var n=ar(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function nu(e){return function(){_i(this,e)}}function ru(e){return function(){Ni(this,e)}}function ou(e,t){return function(){(t.apply(this,arguments)?_i:Ni)(this,e)}}function iu(e,t){var n=bi(e+"");if(arguments.length<2){for(var r=ar(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?ou:t?nu:ru)(n,t))}function su(){this.textContent=""}function au(e){return function(){this.textContent=e}}function cu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function lu(e){return arguments.length?this.each(e==null?su:(typeof e=="function"?cu:au)(e)):this.node().textContent}function uu(){this.innerHTML=""}function du(e){return function(){this.innerHTML=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hu(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:du)(e)):this.node().innerHTML}function gu(){this.nextSibling&&this.parentNode.appendChild(this)}function pu(){return this.each(gu)}function mu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yu(){return this.each(mu)}function xu(e){var t=typeof e=="function"?e:pi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wu(){return null}function vu(e,t){var n=typeof e=="function"?e:pi(e),r=t==null?wu:typeof t=="function"?t:sr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function bu(){var e=this.parentNode;e&&e.removeChild(this)}function Eu(){return this.each(bu)}function _u(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Su(e){return this.select(e?Nu:_u)}function ku(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Cu(e){return function(t){e.call(this,t,this.__data__)}}function Mu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Iu(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Au(e,t,n){return function(){var r=this.__on,o,i=Cu(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function Tu(e,t,n){var r=Mu(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(o=0,u=a[c];o<i;++o)if((s=r[o]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Au:Iu,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function Si(e,t,n){var r=vi(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Ou(e,t){return function(){return Si(this,e,t)}}function Pu(e,t){return function(){return Si(this,e,t.apply(this,arguments))}}function $u(e,t){return this.each((typeof t=="function"?Pu:Ou)(e,t))}function*Lu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var ki=[null];function le(e,t){this._groups=e,this._parents=t}function kt(){return new le([[document.documentElement]],ki)}function ju(){return this}le.prototype=kt.prototype={constructor:le,select:cl,selectAll:fl,selectChild:ml,selectChildren:vl,filter:bl,data:Cl,enter:El,exit:Il,join:Al,merge:Tl,selection:ju,order:Ol,sort:Pl,call:Ll,nodes:jl,node:Dl,size:Rl,empty:Hl,each:zl,attr:Gl,style:Ul,property:tu,classed:iu,text:lu,html:hu,raise:pu,lower:yu,append:xu,insert:vu,remove:Eu,clone:Su,datum:ku,on:Tu,dispatch:$u,[Symbol.iterator]:Lu};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],ki)}function Du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Du(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ru={passive:!1},mt={capture:!0,passive:!1};function In(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Ci(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,mt);"onselectstart"in t?n.on("selectstart.drag",Qe,mt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Mi(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Qe,mt),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 Lt=e=>()=>e;function Xn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Xn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Hu(e){return!e.ctrlKey&&!e.button}function zu(){return this.parentNode}function Fu(e,t){return t??{x:e.x,y:e.y}}function Bu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ii(){var e=Hu,t=zu,n=Fu,r=Bu,o={},i=dn("start","drag","end"),s=0,a,c,l,u,d=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",m,Ru).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,E){if(!(u||!e.call(this,x,E))){var S=p(this,t.call(this,x,E),x,E,"mouse");S&&(ce(x.view).on("mousemove.drag",g,mt).on("mouseup.drag",v,mt),Ci(x.view),In(x),l=!1,a=x.clientX,c=x.clientY,S("start",x))}}function g(x){if(Qe(x),!l){var E=x.clientX-a,S=x.clientY-c;l=E*E+S*S>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Mi(x.view,l),Qe(x),o.mouse("end",x)}function w(x,E){if(e.call(this,x,E)){var S=x.changedTouches,C=t.call(this,x,E),M=S.length,I,z;for(I=0;I<M;++I)(z=p(this,C,x,E,S[I].identifier,S[I]))&&(In(x),z("start",x,S[I]))}}function m(x){var E=x.changedTouches,S=E.length,C,M;for(C=0;C<S;++C)(M=o[E[C].identifier])&&(Qe(x),M("drag",x,E[C]))}function b(x){var E=x.changedTouches,S=E.length,C,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<S;++C)(M=o[E[C].identifier])&&(In(x),M("end",x,E[C]))}function p(x,E,S,C,M,I){var z=i.copy(),O=fe(I||S,E),$,P,y;if((y=n.call(x,new Xn("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:z}),C))!=null)return $=y.x-O[0]||0,P=y.y-O[1]||0,function _(k,A,L){var T=O,D;switch(k){case"start":o[M]=_,D=s++;break;case"end":delete o[M],--s;case"drag":O=fe(L||A,E),D=s;break}z.call(k,x,new Xn(k,{sourceEvent:A,subject:y,target:f,identifier:M,active:D,x:O[0]+$,y:O[1]+P,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:z}),C)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Lt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Lt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Lt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:Lt(!!x),f):r},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(d=(x=+x)*x,f):Math.sqrt(d)},f}function cr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ai(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Ct(){}var yt=.7,Zt=1/yt,Je="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vu=/^#([0-9a-f]{3,8})$/,Yu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Xu=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Wu=new RegExp(`^rgba\\(${Je},${Je},${Je},${xt}\\)$`),Gu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${xt}\\)$`),qu=new RegExp(`^hsl\\(${xt},${Ne},${Ne}\\)$`),Ku=new RegExp(`^hsla\\(${xt},${Ne},${Ne},${xt}\\)$`),Vr={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};cr(Ct,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Yr,formatHex:Yr,formatHex8:Zu,formatHsl:Uu,formatRgb:Xr,toString:Xr});function Yr(){return this.rgb().formatHex()}function Zu(){return this.rgb().formatHex8()}function Uu(){return Ti(this).formatHsl()}function Xr(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Vu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Wr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yu.exec(e))?new ae(t[1],t[2],t[3],1):(t=Xu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wu.exec(e))?jt(t[1],t[2],t[3],t[4]):(t=Gu.exec(e))?jt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qu.exec(e))?Kr(t[1],t[2]/100,t[3]/100,1):(t=Ku.exec(e))?Kr(t[1],t[2]/100,t[3]/100,t[4]):Vr.hasOwnProperty(e)?Wr(Vr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Wr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function jt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Qu(e){return e instanceof Ct||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Wn(e,t,n,r){return arguments.length===1?Qu(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}cr(ae,Wn,Ai(Ct,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Ut(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:Gr,formatHex:Gr,formatHex8:Ju,formatRgb:qr,toString:qr}));function Gr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function Ju(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function qr(){const e=Ut(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Ut(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fe(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function Kr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Ti(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof Ct||(e=Ye(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function ed(e,t,n,r){return arguments.length===1?Ti(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}cr(he,ed,Ai(Ct,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(An(e>=240?e-240:e+120,o,r),An(e,o,r),An(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Zr(this.h),Dt(this.s),Dt(this.l),Ut(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 e=Ut(this.opacity);return`${e===1?"hsl(":"hsla("}${Zr(this.h)}, ${Dt(this.s)*100}%, ${Dt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zr(e){return e=(e||0)%360,e<0?e+360:e}function Dt(e){return Math.max(0,Math.min(1,e||0))}function An(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const lr=e=>()=>e;function td(e,t){return function(n){return e+n*t}}function nd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function rd(e){return(e=+e)==1?Oi:function(t,n){return n-t?nd(t,n,e):lr(isNaN(t)?n:t)}}function Oi(e,t){var n=t-e;return n?td(e,n):lr(isNaN(e)?t:e)}const Qt=(function e(t){var n=rd(t);function r(o,i){var s=n((o=Wn(o)).r,(i=Wn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Oi(o.opacity,i.opacity);return function(u){return o.r=s(u),o.g=a(u),o.b=c(u),o.opacity=l(u),o+""}}return r.gamma=e,r})(1);function od(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function id(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sd(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=gt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function ad(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ee(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function cd(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=gt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Gn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Tn=new RegExp(Gn.source,"g");function ld(e){return function(){return e}}function ud(e){return function(t){return e(t)+""}}function Pi(e,t){var n=Gn.lastIndex=Tn.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Gn.exec(e))&&(o=Tn.exec(t));)(i=o.index)>n&&(i=t.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,c.push({i:s,x:Ee(r,o)})),n=Tn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?ud(c[0].x):ld(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function gt(e,t){var n=typeof t,r;return t==null||n==="boolean"?lr(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Qt):Pi:t instanceof Ye?Qt:t instanceof Date?ad:id(t)?od:Array.isArray(t)?sd:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?cd:Ee)(e,t)}var Ur=180/Math.PI,qn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $i(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Ur,skewX:Math.atan(c)*Ur,scaleX:s,scaleY:a}}var Rt;function dd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?qn:$i(t.a,t.b,t.c,t.d,t.e,t.f)}function fd(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?qn:(e=e.matrix,$i(e.a,e.b,e.c,e.d,e.e,e.f))}function Li(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(o(d)+"rotate(",null,r)-2,x:Ee(l,u)})):u&&d.push(o(d)+"rotate("+u+r)}function a(l,u,d,f){l!==u?f.push({i:d.push(o(d)+"skewX(",null,r)-2,x:Ee(l,u)}):u&&d.push(o(d)+"skewX("+u+r)}function c(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push(o(h)+"scale(",null,",",null,")");g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d!==1||f!==1)&&h.push(o(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var g=-1,v=f.length,w;++g<v;)d[(w=f[g]).i]=w.x(h);return d.join("")}}}var hd=Li(dd,"px, ","px)","deg)"),gd=Li(fd,", ",")",")"),pd=1e-12;function Qr(e){return((e=Math.exp(e))+1/e)/2}function md(e){return((e=Math.exp(e))-1/e)/2}function yd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xt=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,g=d-c,v=h*h+g*g,w,m;if(v<pd)m=Math.log(f/l)/t,w=function(C){return[a+C*h,c+C*g,l*Math.exp(t*C*m)]};else{var b=Math.sqrt(v),p=(f*f-l*l+r*v)/(2*l*n*b),x=(f*f-l*l-r*v)/(2*f*n*b),E=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(x*x+1)-x);m=(S-E)/t,w=function(C){var M=C*m,I=Qr(E),z=l/(n*b)*(I*yd(t*M+E)-md(E));return[a+z*h,c+z*g,l*I/Qr(t*M+E)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var tt=0,dt=0,lt=0,ji=1e3,Jt,ft,en=0,Xe=0,hn=0,wt=typeof performance=="object"&&performance.now?performance:Date,Di=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ur(){return Xe||(Di(xd),Xe=wt.now()+hn)}function xd(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=Ri.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ur():+n)+(t==null?0:+t),!this._next&&ft!==this&&(ft?ft._next=this:Jt=this,ft=this),this._call=e,this._time=n,Kn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Kn())}};function Ri(e,t,n){var r=new tn;return r.restart(e,t,n),r}function wd(){ur(),++tt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}function Jr(){Xe=(en=wt.now())+hn,tt=dt=0;try{wd()}finally{tt=0,bd(),Xe=0}}function vd(){var e=wt.now(),t=e-en;t>ji&&(hn-=t,en=e)}function bd(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ft=e,Kn(r)}function Kn(e){if(!tt){dt&&(dt=clearTimeout(dt));var t=e-Xe;t>24?(e<1/0&&(dt=setTimeout(Jr,e-wt.now()-hn)),lt&&(lt=clearInterval(lt))):(lt||(en=wt.now(),lt=setInterval(vd,ji)),tt=1,Di(Jr))}}function eo(e,t,n){var r=new tn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Ed=dn("start","end","cancel","interrupt"),_d=[],Hi=0,to=1,Zn=2,Wt=3,no=4,Un=5,Gt=6;function gn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Nd(e,n,{name:t,index:r,group:o,on:Ed,tween:_d,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Hi})}function dr(e,t){var n=ye(e,t);if(n.state>Hi)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Wt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Nd(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Ri(i,0,n.time);function i(l){n.state=to,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==to)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Wt)return eo(s);h.state===no?(h.state=Gt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=Gt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(eo(function(){n.state===Wt&&(n.state=no,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Zn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Zn){for(n.state=Wt,o=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Un,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Un&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Gt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function qt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Zn&&r.state<Un,r.state=Gt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Sd(e){return this.each(function(){qt(this,e)})}function kd(e,t){var n,r;return function(){var o=Se(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function Cd(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}i.tween=o}}function Md(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?kd:Cd)(n,e,t))}function fr(e,t,n){var r=e._id;return e.each(function(){var o=Se(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function zi(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):Pi)(e,t)}function Id(e){return function(){this.removeAttribute(e)}}function Ad(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Td(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Od(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Pd(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function $d(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Ld(e,t){var n=fn(e),r=n==="transform"?gd:zi;return this.attrTween(e,typeof t=="function"?(n.local?$d:Pd)(n,r,fr(this,"attr."+e,t)):t==null?(n.local?Ad:Id)(n):(n.local?Od:Td)(n,r,t))}function jd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Rd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dd(e,i)),n}return o._value=t,o}function Hd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&jd(e,i)),n}return o._value=t,o}function zd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=fn(e);return this.tween(n,(r.local?Rd:Hd)(r,t))}function Fd(e,t){return function(){dr(this,e).delay=+t.apply(this,arguments)}}function Bd(e,t){return t=+t,function(){dr(this,e).delay=t}}function Vd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fd:Bd)(t,e)):ye(this.node(),t).delay}function Yd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Xd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Wd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yd:Xd)(t,e)):ye(this.node(),t).duration}function Gd(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function qd(e){var t=this._id;return arguments.length?this.each(Gd(t,e)):ye(this.node(),t).ease}function Kd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function Zd(e){if(typeof e!="function")throw new Error;return this.each(Kd(this._id,e))}function Ud(e){typeof e!="function"&&(e=yi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Te(r,this._parents,this._name,this._id)}function Qd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<r;++a)s[a]=t[a];return new Te(s,this._parents,this._name,this._id)}function Jd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ef(e,t,n){var r,o,i=Jd(t)?dr:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function tf(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(ef(n,e,t))}function nf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function rf(){return this.on("end.remove",nf(this._id))}function of(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sr(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,gn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function sf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mi(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,g=ye(u,n),v=0,w=f.length;v<w;++v)(h=f[v])&&gn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var af=kt.prototype.constructor;function cf(){return new af(this._groups,this._parents)}function lf(e,t){var n,r,o;return function(){var i=et(this,e),s=(this.style.removeProperty(e),et(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Fi(e){return function(){this.style.removeProperty(e)}}function uf(e,t,n){var r,o=n+"",i;return function(){var s=et(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function df(e,t,n){var r,o,i;return function(){var s=et(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),et(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function ff(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=Fi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function hf(e,t,n){var r=(e+="")=="transform"?hd:zi;return t==null?this.styleTween(e,lf(e,r)).on("end.style."+e,Fi(e)):typeof t=="function"?this.styleTween(e,df(e,r,fr(this,"style."+e,t))).each(ff(this._id,e)):this.styleTween(e,uf(e,r,t),n).on("end.style."+e,null)}function gf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function pf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&gf(e,s,n)),r}return i._value=t,i}function mf(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,pf(e,t,n??""))}function yf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e(this);this.textContent=t??""}}function wf(e){return this.tween("text",typeof e=="function"?xf(fr(this,"text",e)):yf(e==null?"":e+""))}function vf(e){return function(t){this.textContent=e.call(this,t)}}function bf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&vf(o)),t}return r._value=e,r}function Ef(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,bf(e))}function _f(){for(var e=this._name,t=this._id,n=Bi(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=ye(c,t);gn(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Te(r,this._parents,e,n)}function Nf(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var l=Se(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&i()})}var Sf=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Bi(){return++Sf}var Ie=kt.prototype;Te.prototype={constructor:Te,select:of,selectAll:sf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:Ud,merge:Qd,selection:cf,transition:_f,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:tf,attr:Ld,attrTween:zd,style:hf,styleTween:mf,text:wf,textTween:Ef,remove:rf,tween:Md,delay:Vd,duration:Wd,ease:qd,easeVarying:Zd,end:Nf,[Symbol.iterator]:Ie[Symbol.iterator]};function kf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Cf={time:null,delay:0,duration:250,ease:kf};function Mf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function If(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=Bi(),(n=Cf).time=ur(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&gn(c,e,t,l,s,n||Mf(c,t));return new Te(r,this._parents,e,t)}kt.prototype.interrupt=Sd;kt.prototype.transition=If;const Ht=e=>()=>e;function Af(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ae(e,t,n){this.k=e,this.x=t,this.y=n}Ae.prototype={constructor:Ae,scale:function(e){return e===1?this:new Ae(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ae(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var pn=new Ae(1,0,0);Vi.prototype=Ae.prototype;function Vi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return pn;return e.__zoom}function On(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Tf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Of(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ro(){return this.__zoom||pn}function Pf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $f(){return navigator.maxTouchPoints||"ontouchstart"in this}function Lf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.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 Yi(){var e=Tf,t=Of,n=Lf,r=Pf,o=$f,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xt,l=dn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",ro).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,_,k,A){var L=y.selection?y.selection():y;L.property("__zoom",ro),y!==L?E(y,_,k,A):L.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},m.scaleBy=function(y,_,k,A){m.scaleTo(y,function(){var L=this.__zoom.k,T=typeof _=="function"?_.apply(this,arguments):_;return L*T},k,A)},m.scaleTo=function(y,_,k,A){m.transform(y,function(){var L=t.apply(this,arguments),T=this.__zoom,D=k==null?x(L):typeof k=="function"?k.apply(this,arguments):k,F=T.invert(D),H=typeof _=="function"?_.apply(this,arguments):_;return n(p(b(T,H),D,F),L,s)},k,A)},m.translateBy=function(y,_,k,A){m.transform(y,function(){return n(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,_,k,A,L){m.transform(y,function(){var T=t.apply(this,arguments),D=this.__zoom,F=A==null?x(T):typeof A=="function"?A.apply(this,arguments):A;return n(pn.translate(F[0],F[1]).scale(D.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof k=="function"?-k.apply(this,arguments):-k),T,s)},A,L)};function b(y,_){return _=Math.max(i[0],Math.min(i[1],_)),_===y.k?y:new Ae(_,y.x,y.y)}function p(y,_,k){var A=_[0]-k[0]*y.k,L=_[1]-k[1]*y.k;return A===y.x&&L===y.y?y:new Ae(y.k,A,L)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function E(y,_,k,A){y.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var L=this,T=arguments,D=S(L,T).event(A),F=t.apply(L,T),H=k==null?x(F):typeof k=="function"?k.apply(L,T):k,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=L.__zoom,q=typeof _=="function"?_.apply(L,T):_,J=c(Y.invert(H).concat(V/Y.k),q.invert(H).concat(V/q.k));return function(G){if(G===1)G=q;else{var R=J(G),B=V/R[2];G=new Ae(B,H[0]-R[0]*B,H[1]-R[1]*B)}D.zoom(null,G)}})}function S(y,_,k){return!k&&y.__zooming||new C(y,_)}function C(y,_){this.that=y,this.args=_,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,_),this.taps=0}C.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,_){return this.mouse&&y!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&y!=="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(y){var _=ce(this.that).datum();l.call(y,this.that,new Af(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),_)}};function M(y,..._){if(!e.apply(this,arguments))return;var k=S(this,_).event(y),A=this.__zoom,L=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),T=fe(y);if(k.wheel)(k.mouse[0][0]!==T[0]||k.mouse[0][1]!==T[1])&&(k.mouse[1]=A.invert(k.mouse[0]=T)),clearTimeout(k.wheel);else{if(A.k===L)return;k.mouse=[T,A.invert(T)],qt(this),k.start()}ut(y),k.wheel=setTimeout(D,g),k.zoom("mouse",n(p(b(A,L),k.mouse[0],k.mouse[1]),k.extent,s));function D(){k.wheel=null,k.end()}}function I(y,..._){if(f||!e.apply(this,arguments))return;var k=y.currentTarget,A=S(this,_,!0).event(y),L=ce(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",V,!0),T=fe(y,k),D=y.clientX,F=y.clientY;Ci(y.view),On(y),A.mouse=[T,this.__zoom.invert(T)],qt(this),A.start();function H(Y){if(ut(Y),!A.moved){var q=Y.clientX-D,J=Y.clientY-F;A.moved=q*q+J*J>v}A.event(Y).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=fe(Y,k),A.mouse[1]),A.extent,s))}function V(Y){L.on("mousemove.zoom mouseup.zoom",null),Mi(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(y,..._){if(e.apply(this,arguments)){var k=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),L=k.invert(A),T=k.k*(y.shiftKey?.5:2),D=n(p(b(k,T),A,L),t.apply(this,_),s);ut(y),a>0?ce(this).transition().duration(a).call(E,D,A,y):ce(this).call(m.transform,D,A,y)}}function O(y,..._){if(e.apply(this,arguments)){var k=y.touches,A=k.length,L=S(this,_,y.changedTouches.length===A).event(y),T,D,F,H;for(On(y),D=0;D<A;++D)F=k[D],H=fe(F,this),H=[H,this.__zoom.invert(H),F.identifier],L.touch0?!L.touch1&&L.touch0[2]!==H[2]&&(L.touch1=H,L.taps=0):(L.touch0=H,T=!0,L.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(L.taps<2&&(d=H[0],u=setTimeout(function(){u=null},h)),qt(this),L.start())}}function $(y,..._){if(this.__zooming){var k=S(this,_).event(y),A=y.changedTouches,L=A.length,T,D,F,H;for(ut(y),T=0;T<L;++T)D=A[T],F=fe(D,this),k.touch0&&k.touch0[2]===D.identifier?k.touch0[0]=F:k.touch1&&k.touch1[2]===D.identifier&&(k.touch1[0]=F);if(D=k.that.__zoom,k.touch1){var V=k.touch0[0],Y=k.touch0[1],q=k.touch1[0],J=k.touch1[1],G=(G=q[0]-V[0])*G+(G=q[1]-V[1])*G,R=(R=J[0]-Y[0])*R+(R=J[1]-Y[1])*R;D=b(D,Math.sqrt(G/R)),F=[(V[0]+q[0])/2,(V[1]+q[1])/2],H=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(k.touch0)F=k.touch0[0],H=k.touch0[1];else return;k.zoom("touch",n(p(D,F,H),k.extent,s))}}function P(y,..._){if(this.__zooming){var k=S(this,_).event(y),A=y.changedTouches,L=A.length,T,D;for(On(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<L;++T)D=A[T],k.touch0&&k.touch0[2]===D.identifier?delete k.touch0:k.touch1&&k.touch1[2]===D.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(D=fe(D,this),Math.hypot(d[0]-D[0],d[1]-D[1])<w)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:Ht(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ht(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Ht(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:Ht([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=l.on.apply(l,arguments);return y===l?m:y},m.clickDistance=function(y){return arguments.length?(v=(y=+y)*y,m):Math.sqrt(v)},m.tapDistance=function(y){return arguments.length?(w=+y,m):w},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Xi=["Enter"," ","Escape"],Wi={"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:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, 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 nt;(function(e){e.Strict="strict",e.Loose="loose"})(nt||(nt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));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 Le;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Le||(Le={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const oo={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},qi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,jf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),hr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Df=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):hr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,mn(o,rn(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?yn(r):{x:0,y:0,width:0,height:0}},It=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=mn(n,rn(o)),r=!0)}),r?yn(n):{x:0,y:0,width:0,height:0}},gr=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,l=t.width/o,u=t.height/o,d=[];for(const f of e.values()){const{measured:h,selectable:g=!0,hidden:v=!1}=f;if(s&&!g||v)continue;const w=h.width??f.width??f.initialWidth??0,m=h.height??f.height??f.initialHeight??0,{x:b,y:p}=f.internals.positionAbsolute,x=Qi(a,c,l,u,b,p,w,m),E=w*m,S=i&&x>0;(!f.internals.handleBounds||S||x>=E||f.dragging)&&d.push(f)}return d},Rf=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Hf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function zf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Hf(e,s),c=It(a),l=mr(c,t,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(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function Ki({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,l],[c+h,l+g]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?We(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Ff({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(v=>v.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),u=Rf(s,c);for(const f of c)a.has(f.id)&&!u.find(g=>g.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:s};const d=await o({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const rt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:rt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:rt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Zi(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return We(e,[[i,s],[i+r,s+o]],t)}const io=(e,t,n)=>e<t?rt(Math.abs(e-t),1,t)/t:e>n?-rt(Math.abs(e-n),1,t)/t:0,pr=(e,t,n=15,r=40)=>{const o=io(e.x,r,t.width-r)*n,i=io(e.y,r,t.height-r)*n;return[o,i]},mn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Qn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),yn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Et=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=hr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},rn=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=hr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Ui=(e,t)=>yn(mn(Qn(e),Qn(t))),Qi=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),l=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*l)},on=(e,t)=>Qi(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),so=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Ji=(e,t)=>(n,r)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?At(a,s):a},ot=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ze(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Bf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ze(e,n),o=Ze(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ze(e.top??e.y??0,n),o=Ze(e.bottom??e.y??0,n),i=Ze(e.left??e.x??0,t),s=Ze(e.right??e.x??0,t);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 Vf(e,t,n,r,o,i){const{x:s,y:a}=ot(e,[t,n,r]),{x:c,y:l}=ot({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=o-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const mr=(e,t,n,r,o,i)=>{const s=Bf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=rt(l,r,o),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,g=n/2-f*u,v=Vf(e,h,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},_t=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ge(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function es(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ts(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ao(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Yf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Xf(e){return{...Wi,...e||{}}}function ns(e){return e===null?null:e?"valid":"invalid"}function pt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Tt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const yr=e=>({width:e.offsetWidth,height:e.offsetHeight}),rs=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Wf=["INPUT","SELECT","TEXTAREA"];function os(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Wf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const is=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=is(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},co=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...yr(s)}})};function ss({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function zt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function lo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-zt(t-r,i),n];case W.Right:return[t+zt(r-t,i),n];case W.Top:return[t,n-zt(n-o,i)];case W.Bottom:return[t,n+zt(o-n,i)]}}function as({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=lo({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=lo({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=ss({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${r},${o}`,d,f,h,g]}function cs({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function Gf({sourceNode:e,targetNode:t,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(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function qf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=mn(rn(e),rn(t));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 on(s,yn(i))>0}const Kf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Zf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Uf=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||Kf;let o;return qi(e)?o={...e}:o={...e,id:r(e)},Zf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function ls({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=cs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const uo={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Qf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},fo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Jf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=uo[t],c=uo[r],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=Qf({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let g=[],v,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=cs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(v=o.x??l.x+(u.x-l.x)*s,w=o.y??(l.y+u.y)/2):(v=o.x??(l.x+u.x)/2,w=o.y??l.y+(u.y-l.y)*s);const M=[{x:v,y:l.y},{x:v,y:u.y}],I=[{x:l.x,y:w},{x:u.x,y:w}];a[f]===h?g=f==="x"?M:I:g=f==="x"?I:M}else{const M=[{x:l.x,y:u.y}],I=[{x:u.x,y:l.y}];if(f==="x"?g=a.x===h?I:M:g=a.y===h?M:I,t===r){const y=Math.abs(e[f]-n[f]);if(y<=i){const _=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*_:b[f]=(u[f]>n[f]?-1:1)*_}}if(t!==r){const y=f==="x"?"y":"x",_=a[f]===c[y],k=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!_&&k||_&&A)||a[f]!==1&&(!_&&A||_&&k))&&(g=f==="x"?M:I)}const z={x:l.x+m.x,y:l.y+m.y},O={x:u.x+b.x,y:u.y+b.y},$=Math.max(Math.abs(z.x-g[0].x),Math.abs(O.x-g[0].x)),P=Math.max(Math.abs(z.y-g[0].y),Math.abs(O.y-g[0].y));$>=P?(v=(z.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(z.y+O.y)/2)}const E={x:l.x+m.x,y:l.y+m.y},S={x:u.x+b.x,y:u.y+b.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],v,w,p,x]}function eh(e,t,n,r){const o=Math.min(fo(e,t)/2,fo(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+o*l},${s}Q ${i},${s} ${i},${s+o*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Jn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,g,v]=Jf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)w+=eh(d[m-1],d[m],d[m+1],s);return w+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[w,f,h,g,v]}function ho(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function th(e){var d;const{sourceNode:t,targetNode:n}=e;if(!ho(t)||!ho(n))return null;const r=t.internals.handleBounds||go(t.handles),o=n.internals.handleBounds||go(n.handles),i=po((r==null?void 0:r.source)??[],e.sourceHandle),s=po(e.connectionMode===nt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function go(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function qe(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function po(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function er(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function nh(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=er(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const us=1e3,rh=10,xr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oh={...xr,checkEquality:!0};function wr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ih(e,t,n){const r=wr(xr,n);for(const o of e.values())if(o.parentId)br(o,e,t,r);else{const i=Mt(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function sh(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.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 vr(e){return e==="manual"}function tr(e,t,n,r={}){var u,d;const o=wr(oh,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!vr(o.zIndexMode)?us:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Mt(f,o.nodeOrigin),v=Ge(f.extent)?f.extent:o.nodeExtent,w=We(g,v,xe(f));h={...o.defaults,...f,measured:{width:(u=f.measured)==null?void 0:u.width,height:(d=f.measured)==null?void 0:d.height},internals:{positionAbsolute:w,handleBounds:sh(f,h),z:ds(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&br(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function ah(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function br(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=wr(xr,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}ah(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*rh),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!vr(c)?us:0,{x:f,y:h,z:g}=ch(e,u,s,a,d,c),{positionAbsolute:v}=e.internals,w=f!==v.x||h!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:v,z:g}})}function ds(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return vr(n)?r:r+(e.selected?t:0)}function ch(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=Mt(e,n),u=Ge(e.extent)?We(l,e.extent,c):l;let d=We({x:s+u.x,y:a+u.y},r,c);e.extent==="parent"&&(d=Zi(d,c,t));const f=ds(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function Er(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Et(c),u=Ui(l,a.rect);i.set(a.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const u=c.internals.positionAbsolute,d=xe(c),f=c.origin??r,h=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,g=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(d.width,Math.round(a.width)),w=Math.max(d.height,Math.round(a.height)),m=(v-d.width)*f[0],b=(w-d.height)*f[1];(h>0||g>0||m||b)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(l))==null||p.forEach(x=>{e.some(E=>E.id===x.id)||o.push({id:x.id,type:"position",position:{x:x.position.x+h,y:x.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-m:0),height:w+(g?f[1]*g-b:0)}})}),o}function lh(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=yr(h.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ge(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;if(g.parentId&&g.extent==="parent"){const S=t.get(g.parentId);S&&(x=Zi(x,v,S))}else p&&(x=We(x,p,v));const E={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:co("source",h.nodeElement,b,d,g.id),target:co("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,E),g.parentId&&br(E,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:Et(E,o)}))}}if(f.length>0){const h=Er(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function uh({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function mo(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const l=r.get(s)||new Map;r.set(s,l.set(n,t))}}function fs(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},l=`${o}-${s}--${i}-${a}`,u=`${i}-${a}--${o}-${s}`;mo("source",c,u,e,o,s),mo("target",c,l,e,i,a),t.set(r.id,r)}}function hs(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:hs(n,t):!1}function yo(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function dh(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!hs(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.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 Pn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[l,u]of t){const d=(s=n.get(l))==null?void 0:s.internals.userNode;d&&o.push({...d,position:u.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function fh({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function hh({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,g=!1,v=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:E,nodeId:S,nodeClickDistance:C=0}){f=ce(x);function M({x:$,y:P}){const{nodeLookup:y,nodeExtent:_,snapGrid:k,snapToGrid:A,nodeOrigin:L,onNodeDrag:T,onSelectionDrag:D,onError:F,updateNodePositions:H}=t();i={x:$,y:P};let V=!1;const Y=a.size>1,q=Y&&_?Qn(It(a)):null,J=Y&&A?fh({dragItems:a,snapGrid:k,x:$,y:P}):null;for(const[G,R]of a){if(!y.has(G))continue;let B={x:$-R.distance.x,y:P-R.distance.y};A&&(B=J?{x:Math.round(B.x+J.x),y:Math.round(B.y+J.y)}:At(B,k));let K=null;if(Y&&_&&!R.extent&&q){const{positionAbsolute:U}=R.internals,Q=U.x-q.x+_[0][0],ee=U.x+R.measured.width-q.x2+_[1][0],ne=U.y-q.y+_[0][1],re=U.y+R.measured.height-q.y2+_[1][1];K=[[Q,ne],[ee,re]]}const{position:Z,positionAbsolute:X}=Ki({nodeId:G,nextPosition:B,nodeLookup:y,nodeExtent:K||_,nodeOrigin:L,onError:F});V=V||R.position.x!==Z.x||R.position.y!==Z.y,R.position=Z,R.internals.positionAbsolute=X}if(g=g||V,!!V&&(H(a,!0),v&&(r||T||!S&&D))){const[G,R]=Pn({nodeId:S,dragItems:a,nodeLookup:y});r==null||r(v,a,G,R),T==null||T(v,G,R),S||D==null||D(v,R)}}async function I(){if(!u)return;const{transform:$,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:_}=t();if(!_){c=!1,cancelAnimationFrame(s);return}const[k,A]=pr(l,u,y);(k!==0||A!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-A/$[2],await P({x:k,y:A})&&M(i)),s=requestAnimationFrame(I)}function z($){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:_,transform:k,snapGrid:A,snapToGrid:L,selectNodesOnDrag:T,onNodeDragStart:D,onSelectionDragStart:F,unselectNodesAndEdges:H}=t();d=!0,(!T||!E)&&!y&&S&&((Y=P.get(S))!=null&&Y.selected||H()),E&&T&&S&&(e==null||e(S));const V=pt($.sourceEvent,{transform:k,snapGrid:A,snapToGrid:L,containerBounds:u});if(i=V,a=dh(P,_,V,S),a.size>0&&(n||D||!S&&F)){const[q,J]=Pn({nodeId:S,dragItems:a,nodeLookup:P});n==null||n($.sourceEvent,a,q,J),D==null||D($.sourceEvent,q,J),S||F==null||F($.sourceEvent,J)}}const O=Ii().clickDistance(C).on("start",$=>{const{domNode:P,nodeDragThreshold:y,transform:_,snapGrid:k,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=$.sourceEvent,y===0&&z($),i=pt($.sourceEvent,{transform:_,snapGrid:k,snapToGrid:A,containerBounds:u}),l=pe($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:_,snapToGrid:k,nodeDragThreshold:A,nodeLookup:L}=t(),T=pt($.sourceEvent,{transform:y,snapGrid:_,snapToGrid:k,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!L.has(S))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const D=pe($.sourceEvent,u),F=D.x-l.x,H=D.y-l.y;Math.sqrt(F*F+H*H)>A&&z($)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe($.sourceEvent,u),M(T))}}).on("end",$=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:P,updateNodePositions:y,onNodeDragStop:_,onSelectionDragStop:k}=t();if(g&&(y(a,!1),g=!1),o||_||!S&&k){const[A,L]=Pn({nodeId:S,dragItems:a,nodeLookup:P,dragging:!1});o==null||o($.sourceEvent,a,A,L),_==null||_($.sourceEvent,A,L),S||k==null||k($.sourceEvent,L)}}}).filter($=>{const P=$.target;return!$.button&&(!b||!yo(P,`.${b}`,x))&&(!p||yo(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function gh(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())on(o,Et(i))>0&&r.push(i);return r}const ph=250;function mh(e,t,n,r){var a,c;let o=[],i=1/0;const s=gh(e,n,t+ph);for(const l of s){const u=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of u){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:f,y:h}=qe(l,d,d.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:f,y:h}],i=g):g===i&&o.push({...d,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(u=>u.type===l)??o[0]}return o[0]}function gs(e,t,n,r,o,i=!1){var l,u,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((u=s.internals.handleBounds)==null?void 0:u.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function ps(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function yh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ms=()=>!0;function xh(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:m=ms,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:E,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:M}){const I=rs(e.target);let z=0,O;const{x:$,y:P}=pe(e),y=ps(i,M),_=a==null?void 0:a.getBoundingClientRect();let k=!1;if(!_||!y)return;const A=gs(o,y,r,c,t);if(!A)return;let L=pe(e,_),T=!1,D=null,F=!1,H=null;function V(){if(!u||!_)return;const[Z,X]=pr(L,_,S);f({x:Z,y:X}),z=requestAnimationFrame(V)}const Y={...A,nodeId:o,type:y,position:A.position},q=c.get(o);let G={inProgress:!0,isValid:null,from:qe(q,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:q,to:L,toHandle:null,toPosition:oo[Y.position],toNode:null,pointer:L};function R(){k=!0,p(G),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}C===0&&R();function B(Z){if(!k){const{x:re,y:ue}=pe(Z),ve=re-$,be=ue-P;if(!(ve*ve+be*be>C*C))return;R()}if(!E()||!Y){K(Z);return}const X=x();L=pe(Z,_),O=mh(Tt(L,X,!1,[1,1]),n,c,Y),T||(V(),T=!0);const U=ys(Z,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:I,lib:l,flowId:d,nodeLookup:c});H=U.handleDomNode,D=U.connection,F=yh(!!O,U.isValid);const Q=c.get(o),ee=Q?qe(Q,Y,W.Left,!0):G.from,ne={...G,from:ee,isValid:F,to:U.toHandle&&F?ot({x:U.toHandle.x,y:U.toHandle.y},X):L,toHandle:U.toHandle,toPosition:F&&U.toHandle?U.toHandle.position:oo[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:L};p(ne),G=ne}function K(Z){if(!("touches"in Z&&Z.touches.length>0)){if(k){(O||H)&&D&&F&&(v==null||v(D));const{inProgress:X,...U}=G,Q={...U,toPosition:G.toHandle?G.toPosition:null};w==null||w(Z,Q),i&&(b==null||b(Z,Q))}h(),cancelAnimationFrame(z),T=!1,F=!1,D=null,H=null,I.removeEventListener("mousemove",B),I.removeEventListener("mouseup",K),I.removeEventListener("touchmove",B),I.removeEventListener("touchend",K)}}I.addEventListener("mousemove",B),I.addEventListener("mouseup",K),I.addEventListener("touchmove",B),I.addEventListener("touchend",K)}function ys(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=ms,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),v=s.elementFromPoint(h,g),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=ps(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),E=w.classList.contains("connectable"),S=w.classList.contains("connectableend");if(!p||!b)return m;const C={source:d?p:r,sourceHandle:d?x:o,target:d?r:p,targetHandle:d?o:x};m.connection=C;const I=E&&S&&(n===nt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(C),m.toHandle=gs(p,b,x,u,n,!0)}return m}const nr={onPointerDown:xh,isValid:ys};function wh({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),E=p.sourceEvent.ctrlKey&&_t()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,C=x[2]*Math.pow(2,S*E);t.scaleTo(C)};let v=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[E[0]-v[0],E[1]-v[1]];v=E;const C=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),M={x:x[0]-S[0]*C,y:x[1]-S[1]*C},I=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:x[2]},I,a)},b=Yi().on("start",w).on("zoom",d?m:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const xn=e=>({x:e.x,y:e.y,zoom:e.k}),$n=({x:e,y:t,zoom:n})=>pn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),xs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ln=(e,t=0,n=vh,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ws=e=>{const t=e.ctrlKey&&_t()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function bh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=fe(u),m=ws(u),b=d*Math.pow(2,m);r.scaleTo(n,b,w,u);return}const f=u.deltaMode===1?20:1;let h=o===Ve.Vertical?0:u.deltaX*f,g=o===Ve.Horizontal?0:u.deltaY*f;!_t()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=xn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(u,v):(e.isPanScrolling=!0,a==null||a(u,v)),e.panScrollTimeout=setTimeout(()=>{l==null||l(u,v),e.isPanScrolling=!1},150)}}function Eh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=$e(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function _h({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=xn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Nh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&xs(t,e.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,xn(i.transform)))}}function Sh({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&xs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=xn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function kh({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{var m;const h=t||n,g=r&&f.ctrlKey,v=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&($e(f,`${u}-flow__node`)||$e(f,`${u}-flow__edge`)||$e(f,`${u}-flow__selection`)||$e(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||$e(f,c)&&v||$e(f,l)&&(!v||i&&v&&!t)||!r&&f.ctrlKey&&v)return!1;if(!r&&f.type==="touchstart"&&((m=f.touches)==null?void 0:m.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!g&&v||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||v||e)&&w}}function Ch({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];const f=typeof ResizeObserver<"u"?new ResizeObserver(P=>{const y=P[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;f==null||f.observe(e);const h=Yi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:rt(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(ws);async function m(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).transform(Ln(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:_,userSelectionActive:k,panOnScroll:A,panOnDrag:L,panOnScrollMode:T,panOnScrollSpeed:D,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:Y,panActivationKeyPressed:q=!1,zoomActivationKeyPressed:J,lib:G,onTransformChange:R,connectionInProgress:B,paneClickDistance:K,selectionOnDrag:Z}){k&&!l.isZoomingOrPanning&&p();const X=A&&!J&&!k;h.clickDistance(Z?1/0:!ge(K)||K<0?0:K);const U=X?bh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:D,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Eh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",U,{passive:!1});const Q=_h({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Nh({zoomPanValues:l,panOnDrag:L,onPaneContextMenu:!!_,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Sh({zoomPanValues:l,panOnDrag:L,panOnScroll:A,onPaneContextMenu:_,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=kh({panActivationKeyPressed:q,zoomActivationKeyPressed:J,panOnDrag:L,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:k,noPanClassName:y,noWheelClassName:P,lib:G,connectionInProgress:B});h.filter(re),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function x(P,y,_){const k=$n(P),A=h==null?void 0:h.constrain()(k,y,_);return A&&await m(A),A}async function E(P,y){const _=$n(P);return await m(_,y),_}function S(P){if(g){const y=$n(P),_=g.property("__zoom");(_.k!==P.zoom||_.x!==P.x||_.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function C(){const P=g?Vi(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function M(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleTo(Ln(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}async function I(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleBy(Ln(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function z(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function $(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:E,setViewportConstrained:x,getViewport:C,scaleTo:M,scaleBy:I,setScaleExtent:z,setTranslateExtent:O,syncViewport:S,setClickDistance:$}}var it;(function(e){e.Line="line",e.Handle="handle"})(it||(it={}));function Mh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function xo(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Oe(e,t){return Math.max(0,t-e)}function Pe(e,t){return Math.max(0,e-t)}function Ft(e,t,n){return Math.max(0,t-e,e-n)}function wo(e,t){return e?!t:t}function Ih(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:m,maxHeight:b}=r,{x:p,y:x,width:E,height:S,aspectRatio:C}=e;let M=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const z=E+(c?-M:M),O=S+(l?-I:I),$=-i[0]*E,P=-i[1]*S;let y=Ft(z,v,w),_=Ft(O,m,b);if(s){let L=0,T=0;c&&M<0?L=Oe(p+M+$,s[0][0]):!c&&M>0&&(L=Pe(p+z+$,s[1][0])),l&&I<0?T=Oe(x+I+P,s[0][1]):!l&&I>0&&(T=Pe(x+O+P,s[1][1])),y=Math.max(y,L),_=Math.max(_,T)}if(a){let L=0,T=0;c&&M>0?L=Pe(p+M,a[0][0]):!c&&M<0&&(L=Oe(p+z,a[1][0])),l&&I>0?T=Pe(x+I,a[0][1]):!l&&I<0&&(T=Oe(x+O,a[1][1])),y=Math.max(y,L),_=Math.max(_,T)}if(o){if(u){const L=Ft(z/C,m,b)*C;if(y=Math.max(y,L),s){let T=0;!c&&!l||c&&!l&&f?T=Pe(x+P+z/C,s[1][1])*C:T=Oe(x+P+(c?M:-M)/C,s[0][1])*C,y=Math.max(y,T)}if(a){let T=0;!c&&!l||c&&!l&&f?T=Oe(x+z/C,a[1][1])*C:T=Pe(x+(c?M:-M)/C,a[0][1])*C,y=Math.max(y,T)}}if(d){const L=Ft(O*C,v,w)/C;if(_=Math.max(_,L),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*C+$,s[1][0])/C:T=Oe(p+(l?I:-I)*C+$,s[0][0])/C,_=Math.max(_,T)}if(a){let T=0;!c&&!l||l&&!c&&f?T=Oe(p+O*C,a[1][0])/C:T=Pe(p+(l?I:-I)*C,a[0][0])/C,_=Math.max(_,T)}}}I=I+(I<0?_:-_),M=M+(M<0?y:-y),o&&(f?z>O*C?I=(wo(c,l)?-M:M)/C:M=(wo(c,l)?-I:I)*C:u?(I=M/C,l=c):(M=I*C,c=l));const k=c?p+M:p,A=l?x+I:x;return{width:E+(c?-M:M),height:S+(l?-I:I),x:i[0]*M*(c?-1:1)+k,y:i[1]*I*(l?-1:1)+A}}const vs={width:0,height:0,x:0,y:0},Ah={...vs,pointerX:0,pointerY:0,aspectRatio:1};function Th(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Oh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:xo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:w}){let m={...vs},b={...Ah};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:xo(l)};let p,x=null,E=[],S,C,M,I=!1;const z=Ii().on("start",O=>{const{nodeLookup:$,transform:P,snapGrid:y,snapToGrid:_,nodeOrigin:k,paneDomNode:A}=n();if(p=$.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:L,ySnapped:T}=pt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:_,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:L,pointerY:T,aspectRatio:m.width/m.height},S=void 0,C=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId)),S&&p.extent==="parent"&&(C=[[0,0],[S.measured.width,S.measured.height]]),E=[],M=void 0;for(const[D,F]of $)if(F.parentId===t&&(E.push({id:D,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=Th(F,p,F.origin??k);M?M=[[Math.min(H[0][0],M[0][0]),Math.min(H[0][1],M[0][1])],[Math.max(H[1][0],M[1][0]),Math.max(H[1][1],M[1][1])]]:M=H}h==null||h(O,{...m})}).on("drag",O=>{const{transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:_}=n(),k=pt(O.sourceEvent,{transform:$,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:L,y:T,width:D,height:F}=m,H={},V=p.origin??_,{width:Y,height:q,x:J,y:G}=Ih(b,s.controlDirection,k,s.boundaries,s.keepAspectRatio,V,C,M),R=Y!==D,B=q!==F,K=J!==L&&R,Z=G!==T&&B;if(!K&&!Z&&!R&&!B)return;if((K||Z||V[0]===1||V[1]===1)&&(H.x=K?J:m.x,H.y=Z?G:m.y,m.x=H.x,m.y=H.y,E.length>0)){const ee=J-L,ne=G-T;for(const re of E)re.position={x:re.position.x-ee+V[0]*(Y-D),y:re.position.y-ne+V[1]*(q-F)},A.push(re)}if((R||B)&&(H.width=R&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,H.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?q:m.height,m.width=H.width,m.height=H.height),S&&p.expandParent){const ee=V[0]*(H.width??0);H.x&&H.x<ee&&(m.x=ee,b.x=b.x-(H.x-ee));const ne=V[1]*(H.height??0);H.y&&H.y<ne&&(m.y=ne,b.y=b.y-(H.y-ne))}const X=Mh({width:m.width,prevWidth:D,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:X};(w==null?void 0:w(O,U))!==!1&&(I=!0,g==null||g(O,U),r(H,A))}).on("end",O=>{I&&(v==null||v(O,{...m}),o==null||o({...m}),I=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const Ph={},vo=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Ph?"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()}},l=t=e(r,o,c);return c},$h=e=>e?vo(e):vo,{useDebugValue:Lh}=Lc,{useSyncExternalStoreWithSelector:jh}=$c,Dh=e=>e;function bs(e,t=Dh,n){const r=jh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Lh(r),r}const bo=(e,t)=>{const n=$h(e),r=(o,i=t)=>bs(n,o,i);return Object.assign(r,n),r},Rh=(e,t)=>e?bo(e,t):bo;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const wn=j.createContext(null),Hh=wn.Provider,Es=me.error001("react");function te(e,t){const n=j.useContext(wn);if(n===null)throw new Error(Es);return bs(n,e,t)}function oe(){const e=j.useContext(wn);if(e===null)throw new Error(Es);return j.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Eo={display:"none"},zh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_s="react-flow__node-desc",Ns="react-flow__edge-desc",Fh="react-flow__aria-live",Bh=e=>e.ariaLiveMessage,Vh=e=>e.ariaLabelConfig;function Yh({rfId:e}){const t=te(Bh);return N.jsx("div",{id:`${Fh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:zh,children:t})}function Xh({rfId:e,disableKeyboardA11y:t}){const n=te(Vh);return N.jsxs(N.Fragment,{children:[N.jsx("div",{id:`${_s}-${e}`,style:Eo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),N.jsx("div",{id:`${Ns}-${e}`,style:Eo,children:n["edge.a11yDescription.default"]}),!t&&N.jsx(Yh,{rfId:e})]})}const vn=j.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return N.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});vn.displayName="Panel";const _o="https://reactflow.dev?utm_source=attribution";function Wh({proOptions:e,position:t="bottom-right"}){return j.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:N.jsx(vn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${_o}`,children:N.jsx("a",{href:_o,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Gh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Bt=e=>e.id;function qh(e,t){return ie(e.selectedNodes.map(Bt),t.selectedNodes.map(Bt))&&ie(e.selectedEdges.map(Bt),t.selectedEdges.map(Bt))}function Kh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(Gh,qh);return j.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Zh=e=>!!e.onSelectionChangeHandlers;function Uh({onSelectionChange:e}){const t=te(Zh);return e||t?N.jsx(Kh,{onSelectionChange:e}):null}const Ss=[0,0],Qh={x:0,y:0,zoom:1},Jh=["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"],No=[...Jh,"rfId"],eg=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),So={translateExtent:vt,nodeOrigin:Ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function tg(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(eg,ie),l=oe();j.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=So,a()}),[]);const u=j.useRef(So);return j.useEffect(()=>{for(const d of No){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?r(f):d==="maxZoom"?o(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Xf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},No.map(d=>e[d])),null}function ko(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ng(e){var r;const[t,n]=j.useState(e==="system"?null:e);return j.useEffect(()=>{if(e!=="system"){n(e);return}const o=ko(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=ko())!=null&&r.matches?"dark":"light"}const Co=typeof document<"u"?document:null;function Nt(e=null,t={target:Co,actInsideInputWithModifier:!0}){const[n,r]=j.useState(!1),o=j.useRef(!1),i=j.useRef(new Set([])),[s,a]=j.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
16
|
+
*/const il=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],nx=or("ZoomOut",il);function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var sl={value:()=>{}};function dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Yt(n)}function Yt(e){this._=e}function al(e,t){return e.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&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Yt.prototype=dn.prototype={constructor:Yt,on:function(e,t){var n=this._,r=al(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=cl(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=Rr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Rr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Yt(e)},call:function(e,t){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(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function cl(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Rr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=sl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Vn="http://www.w3.org/1999/xhtml";const Hr={svg:"http://www.w3.org/2000/svg",xhtml:Vn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Hr.hasOwnProperty(t)?{space:Hr[t],local:e}:e}function ll(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Vn&&t.documentElement.namespaceURI===Vn?t.createElement(e):t.createElementNS(n,e)}}function ul(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function gi(e){var t=fn(e);return(t.local?ul:ll)(t)}function dl(){}function ir(e){return e==null?dl:function(){return this.querySelector(e)}}function fl(e){typeof e!="function"&&(e=ir(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new le(r,this._parents)}function hl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gl(){return[]}function pi(e){return e==null?gl:function(){return this.querySelectorAll(e)}}function pl(e){return function(){return hl(e.apply(this,arguments))}}function ml(e){typeof e=="function"?e=pl(e):e=pi(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(r.push(e.call(c,c.__data__,l,s)),o.push(c));return new le(r,o)}function mi(e){return function(){return this.matches(e)}}function yi(e){return function(t){return t.matches(e)}}var yl=Array.prototype.find;function xl(e){return function(){return yl.call(this.children,e)}}function wl(){return this.firstElementChild}function vl(e){return this.select(e==null?wl:xl(typeof e=="function"?e:yi(e)))}var bl=Array.prototype.filter;function El(){return Array.from(this.children)}function _l(e){return function(){return bl.call(this.children,e)}}function Nl(e){return this.selectAll(e==null?El:_l(typeof e=="function"?e:yi(e)))}function Sl(e){typeof e!="function"&&(e=mi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function xi(e){return new Array(e.length)}function kl(){return new le(this._enter||this._groups.map(xi),this._parents)}function Kt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kt.prototype={constructor:Kt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Cl(e){return function(){return e}}function Ml(e,t,n,r,o,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Kt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Il(e,t,n,r,o,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(r[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new Kt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Al(e){return e.__data__}function Tl(e,t){if(!arguments.length)return Array.from(this,Al);var n=t?Il:Ml,r=this._parents,o=this._groups;typeof e!="function"&&(e=Cl(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],d=o[l],f=d.length,h=Ol(e.call(u,u&&u.__data__,l,r)),g=h.length,v=a[l]=new Array(g),w=s[l]=new Array(g),m=c[l]=new Array(f);n(u,d,v,w,m,h,t);for(var b=0,p=0,x,_;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(_=w[p])&&++p<g;);x._next=_||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Ol(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Pl(){return new le(this._exit||this._groups.map(xi),this._parents)}function $l(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function jl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var l=n[c],u=r[c],d=l.length,f=a[c]=new Array(d),h,g=0;g<d;++g)(h=l[g]||u[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new le(a,this._parents)}function Ll(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],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 Dl(e){e||(e=Rl);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}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,c=o[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new le(o,this._parents).order()}function Rl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Hl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function zl(){return Array.from(this)}function Fl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function Bl(){let e=0;for(const t of this)++e;return e}function Vl(){return!this.node()}function Yl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function Xl(e){return function(){this.removeAttribute(e)}}function Wl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Gl(e,t){return function(){this.setAttribute(e,t)}}function ql(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Kl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Zl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ul(e,t){var n=fn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Wl:Xl:typeof t=="function"?n.local?Zl:Kl:n.local?ql:Gl)(n,t))}function wi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ql(e){return function(){this.style.removeProperty(e)}}function Jl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function eu(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function tu(e,t,n){return arguments.length>1?this.each((t==null?Ql:typeof t=="function"?eu:Jl)(e,t,n??"")):et(this.node(),e)}function et(e,t){return e.style.getPropertyValue(t)||wi(e).getComputedStyle(e,null).getPropertyValue(t)}function nu(e){return function(){delete this[e]}}function ru(e,t){return function(){this[e]=t}}function ou(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function iu(e,t){return arguments.length>1?this.each((t==null?nu:typeof t=="function"?ou:ru)(e,t)):this.node()[e]}function vi(e){return e.trim().split(/^|\s+/)}function sr(e){return e.classList||new bi(e)}function bi(e){this._node=e,this._names=vi(e.getAttribute("class")||"")}bi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ei(e,t){for(var n=sr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function _i(e,t){for(var n=sr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function su(e){return function(){Ei(this,e)}}function au(e){return function(){_i(this,e)}}function cu(e,t){return function(){(t.apply(this,arguments)?Ei:_i)(this,e)}}function lu(e,t){var n=vi(e+"");if(arguments.length<2){for(var r=sr(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?cu:t?su:au)(n,t))}function uu(){this.textContent=""}function du(e){return function(){this.textContent=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function hu(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:du)(e)):this.node().textContent}function gu(){this.innerHTML=""}function pu(e){return function(){this.innerHTML=e}}function mu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function yu(e){return arguments.length?this.each(e==null?gu:(typeof e=="function"?mu:pu)(e)):this.node().innerHTML}function xu(){this.nextSibling&&this.parentNode.appendChild(this)}function wu(){return this.each(xu)}function vu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bu(){return this.each(vu)}function Eu(e){var t=typeof e=="function"?e:gi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function _u(){return null}function Nu(e,t){var n=typeof e=="function"?e:gi(e),r=t==null?_u:typeof t=="function"?t:ir(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Su(){var e=this.parentNode;e&&e.removeChild(this)}function ku(){return this.each(Su)}function Cu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Iu(e){return this.select(e?Mu:Cu)}function Au(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Tu(e){return function(t){e.call(this,t,this.__data__)}}function Ou(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Pu(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function $u(e,t,n){return function(){var r=this.__on,o,i=Tu(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function ju(e,t,n){var r=Ou(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(o=0,u=a[c];o<i;++o)if((s=r[o]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?$u:Pu,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function Ni(e,t,n){var r=wi(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Lu(e,t){return function(){return Ni(this,e,t)}}function Du(e,t){return function(){return Ni(this,e,t.apply(this,arguments))}}function Ru(e,t){return this.each((typeof t=="function"?Du:Lu)(e,t))}function*Hu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Si=[null];function le(e,t){this._groups=e,this._parents=t}function kt(){return new le([[document.documentElement]],Si)}function zu(){return this}le.prototype=kt.prototype={constructor:le,select:fl,selectAll:ml,selectChild:vl,selectChildren:Nl,filter:Sl,data:Tl,enter:kl,exit:Pl,join:$l,merge:jl,selection:zu,order:Ll,sort:Dl,call:Hl,nodes:zl,node:Fl,size:Bl,empty:Vl,each:Yl,attr:Ul,style:tu,property:iu,classed:lu,text:hu,html:yu,raise:wu,lower:bu,append:Eu,insert:Nu,remove:ku,clone:Iu,datum:Au,on:ju,dispatch:Ru,[Symbol.iterator]:Hu};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Si)}function Fu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Fu(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Bu={passive:!1},mt={capture:!0,passive:!1};function Mn(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function ki(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,mt);"onselectstart"in t?n.on("selectstart.drag",Qe,mt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ci(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Qe,mt),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 jt=e=>()=>e;function Yn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Yn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Vu(e){return!e.ctrlKey&&!e.button}function Yu(){return this.parentNode}function Xu(e,t){return t??{x:e.x,y:e.y}}function Wu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mi(){var e=Vu,t=Yu,n=Xu,r=Wu,o={},i=dn("start","drag","end"),s=0,a,c,l,u,d=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",m,Bu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,_){if(!(u||!e.call(this,x,_))){var S=p(this,t.call(this,x,_),x,_,"mouse");S&&(ce(x.view).on("mousemove.drag",g,mt).on("mouseup.drag",v,mt),ki(x.view),Mn(x),l=!1,a=x.clientX,c=x.clientY,S("start",x))}}function g(x){if(Qe(x),!l){var _=x.clientX-a,S=x.clientY-c;l=_*_+S*S>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Ci(x.view,l),Qe(x),o.mouse("end",x)}function w(x,_){if(e.call(this,x,_)){var S=x.changedTouches,C=t.call(this,x,_),M=S.length,I,z;for(I=0;I<M;++I)(z=p(this,C,x,_,S[I].identifier,S[I]))&&(Mn(x),z("start",x,S[I]))}}function m(x){var _=x.changedTouches,S=_.length,C,M;for(C=0;C<S;++C)(M=o[_[C].identifier])&&(Qe(x),M("drag",x,_[C]))}function b(x){var _=x.changedTouches,S=_.length,C,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<S;++C)(M=o[_[C].identifier])&&(Mn(x),M("end",x,_[C]))}function p(x,_,S,C,M,I){var z=i.copy(),O=fe(I||S,_),$,P,y;if((y=n.call(x,new Yn("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:z}),C))!=null)return $=y.x-O[0]||0,P=y.y-O[1]||0,function N(k,A,j){var T=O,D;switch(k){case"start":o[M]=N,D=s++;break;case"end":delete o[M],--s;case"drag":O=fe(j||A,_),D=s;break}z.call(k,x,new Yn(k,{sourceEvent:A,subject:y,target:f,identifier:M,active:D,x:O[0]+$,y:O[1]+P,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:z}),C)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:jt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:jt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:jt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:jt(!!x),f):r},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(d=(x=+x)*x,f):Math.sqrt(d)},f}function ar(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ii(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Ct(){}var yt=.7,Zt=1/yt,Je="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gu=/^#([0-9a-f]{3,8})$/,qu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Ku=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Zu=new RegExp(`^rgba\\(${Je},${Je},${Je},${xt}\\)$`),Uu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${xt}\\)$`),Qu=new RegExp(`^hsl\\(${xt},${Ne},${Ne}\\)$`),Ju=new RegExp(`^hsla\\(${xt},${Ne},${Ne},${xt}\\)$`),zr={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};ar(Ct,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fr,formatHex:Fr,formatHex8:ed,formatHsl:td,formatRgb:Br,toString:Br});function Fr(){return this.rgb().formatHex()}function ed(){return this.rgb().formatHex8()}function td(){return Ai(this).formatHsl()}function Br(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Gu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Vr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=qu.exec(e))?new ae(t[1],t[2],t[3],1):(t=Ku.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Zu.exec(e))?Lt(t[1],t[2],t[3],t[4]):(t=Uu.exec(e))?Lt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qu.exec(e))?Wr(t[1],t[2]/100,t[3]/100,1):(t=Ju.exec(e))?Wr(t[1],t[2]/100,t[3]/100,t[4]):zr.hasOwnProperty(e)?Vr(zr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Vr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Lt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function nd(e){return e instanceof Ct||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Xn(e,t,n,r){return arguments.length===1?nd(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ar(ae,Xn,Ii(Ct,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Ut(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:Yr,formatHex:Yr,formatHex8:rd,formatRgb:Xr,toString:Xr}));function Yr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function rd(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Xr(){const e=Ut(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Ut(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fe(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function Wr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Ai(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof Ct||(e=Ye(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function od(e,t,n,r){return arguments.length===1?Ai(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ar(he,od,Ii(Ct,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(In(e>=240?e-240:e+120,o,r),In(e,o,r),In(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Gr(this.h),Dt(this.s),Dt(this.l),Ut(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 e=Ut(this.opacity);return`${e===1?"hsl(":"hsla("}${Gr(this.h)}, ${Dt(this.s)*100}%, ${Dt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Gr(e){return e=(e||0)%360,e<0?e+360:e}function Dt(e){return Math.max(0,Math.min(1,e||0))}function In(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const cr=e=>()=>e;function id(e,t){return function(n){return e+n*t}}function sd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function ad(e){return(e=+e)==1?Ti:function(t,n){return n-t?sd(t,n,e):cr(isNaN(t)?n:t)}}function Ti(e,t){var n=t-e;return n?id(e,n):cr(isNaN(e)?t:e)}const Qt=(function e(t){var n=ad(t);function r(o,i){var s=n((o=Xn(o)).r,(i=Xn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Ti(o.opacity,i.opacity);return function(u){return o.r=s(u),o.g=a(u),o.b=c(u),o.opacity=l(u),o+""}}return r.gamma=e,r})(1);function cd(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function ld(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ud(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=gt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function dd(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ee(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function fd(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=gt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,An=new RegExp(Wn.source,"g");function hd(e){return function(){return e}}function gd(e){return function(t){return e(t)+""}}function Oi(e,t){var n=Wn.lastIndex=An.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Wn.exec(e))&&(o=An.exec(t));)(i=o.index)>n&&(i=t.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,c.push({i:s,x:Ee(r,o)})),n=An.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?gd(c[0].x):hd(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function gt(e,t){var n=typeof t,r;return t==null||n==="boolean"?cr(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Qt):Oi:t instanceof Ye?Qt:t instanceof Date?dd:ld(t)?cd:Array.isArray(t)?ud:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?fd:Ee)(e,t)}var qr=180/Math.PI,Gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pi(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*qr,skewX:Math.atan(c)*qr,scaleX:s,scaleY:a}}var Rt;function pd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Gn:Pi(t.a,t.b,t.c,t.d,t.e,t.f)}function md(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Gn:(e=e.matrix,Pi(e.a,e.b,e.c,e.d,e.e,e.f))}function $i(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(o(d)+"rotate(",null,r)-2,x:Ee(l,u)})):u&&d.push(o(d)+"rotate("+u+r)}function a(l,u,d,f){l!==u?f.push({i:d.push(o(d)+"skewX(",null,r)-2,x:Ee(l,u)}):u&&d.push(o(d)+"skewX("+u+r)}function c(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push(o(h)+"scale(",null,",",null,")");g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d!==1||f!==1)&&h.push(o(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var g=-1,v=f.length,w;++g<v;)d[(w=f[g]).i]=w.x(h);return d.join("")}}}var yd=$i(pd,"px, ","px)","deg)"),xd=$i(md,", ",")",")"),wd=1e-12;function Kr(e){return((e=Math.exp(e))+1/e)/2}function vd(e){return((e=Math.exp(e))-1/e)/2}function bd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xt=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,g=d-c,v=h*h+g*g,w,m;if(v<wd)m=Math.log(f/l)/t,w=function(C){return[a+C*h,c+C*g,l*Math.exp(t*C*m)]};else{var b=Math.sqrt(v),p=(f*f-l*l+r*v)/(2*l*n*b),x=(f*f-l*l-r*v)/(2*f*n*b),_=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(x*x+1)-x);m=(S-_)/t,w=function(C){var M=C*m,I=Kr(_),z=l/(n*b)*(I*bd(t*M+_)-vd(_));return[a+z*h,c+z*g,l*I/Kr(t*M+_)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var tt=0,dt=0,lt=0,ji=1e3,Jt,ft,en=0,Xe=0,hn=0,wt=typeof performance=="object"&&performance.now?performance:Date,Li=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lr(){return Xe||(Li(Ed),Xe=wt.now()+hn)}function Ed(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=Di.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?lr():+n)+(t==null?0:+t),!this._next&&ft!==this&&(ft?ft._next=this:Jt=this,ft=this),this._call=e,this._time=n,qn()},stop:function(){this._call&&(this._call=null,this._time=1/0,qn())}};function Di(e,t,n){var r=new tn;return r.restart(e,t,n),r}function _d(){lr(),++tt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}function Zr(){Xe=(en=wt.now())+hn,tt=dt=0;try{_d()}finally{tt=0,Sd(),Xe=0}}function Nd(){var e=wt.now(),t=e-en;t>ji&&(hn-=t,en=e)}function Sd(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ft=e,qn(r)}function qn(e){if(!tt){dt&&(dt=clearTimeout(dt));var t=e-Xe;t>24?(e<1/0&&(dt=setTimeout(Zr,e-wt.now()-hn)),lt&&(lt=clearInterval(lt))):(lt||(en=wt.now(),lt=setInterval(Nd,ji)),tt=1,Li(Zr))}}function Ur(e,t,n){var r=new tn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var kd=dn("start","end","cancel","interrupt"),Cd=[],Ri=0,Qr=1,Kn=2,Wt=3,Jr=4,Zn=5,Gt=6;function gn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Md(e,n,{name:t,index:r,group:o,on:kd,tween:Cd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ri})}function ur(e,t){var n=ye(e,t);if(n.state>Ri)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Wt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Md(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Di(i,0,n.time);function i(l){n.state=Qr,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==Qr)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Wt)return Ur(s);h.state===Jr?(h.state=Gt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=Gt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(Ur(function(){n.state===Wt&&(n.state=Jr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Wt,o=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Zn,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Zn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Gt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function qt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Kn&&r.state<Zn,r.state=Gt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Id(e){return this.each(function(){qt(this,e)})}function Ad(e,t){var n,r;return function(){var o=Se(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function Td(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}i.tween=o}}function Od(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Ad:Td)(n,e,t))}function dr(e,t,n){var r=e._id;return e.each(function(){var o=Se(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Hi(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):Oi)(e,t)}function Pd(e){return function(){this.removeAttribute(e)}}function $d(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jd(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Ld(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Dd(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Rd(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Hd(e,t){var n=fn(e),r=n==="transform"?xd:Hi;return this.attrTween(e,typeof t=="function"?(n.local?Rd:Dd)(n,r,dr(this,"attr."+e,t)):t==null?(n.local?$d:Pd)(n):(n.local?Ld:jd)(n,r,t))}function zd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Fd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Bd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Fd(e,i)),n}return o._value=t,o}function Vd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zd(e,i)),n}return o._value=t,o}function Yd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=fn(e);return this.tween(n,(r.local?Bd:Vd)(r,t))}function Xd(e,t){return function(){ur(this,e).delay=+t.apply(this,arguments)}}function Wd(e,t){return t=+t,function(){ur(this,e).delay=t}}function Gd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Xd:Wd)(t,e)):ye(this.node(),t).delay}function qd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Kd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Zd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qd:Kd)(t,e)):ye(this.node(),t).duration}function Ud(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function Qd(e){var t=this._id;return arguments.length?this.each(Ud(t,e)):ye(this.node(),t).ease}function Jd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function ef(e){if(typeof e!="function")throw new Error;return this.each(Jd(this._id,e))}function tf(e){typeof e!="function"&&(e=mi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Te(r,this._parents,this._name,this._id)}function nf(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<r;++a)s[a]=t[a];return new Te(s,this._parents,this._name,this._id)}function rf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function of(e,t,n){var r,o,i=rf(t)?ur:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function sf(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(of(n,e,t))}function af(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function cf(){return this.on("end.remove",af(this._id))}function lf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ir(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,gn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function uf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pi(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,g=ye(u,n),v=0,w=f.length;v<w;++v)(h=f[v])&&gn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var df=kt.prototype.constructor;function ff(){return new df(this._groups,this._parents)}function hf(e,t){var n,r,o;return function(){var i=et(this,e),s=(this.style.removeProperty(e),et(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function zi(e){return function(){this.style.removeProperty(e)}}function gf(e,t,n){var r,o=n+"",i;return function(){var s=et(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function pf(e,t,n){var r,o,i;return function(){var s=et(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),et(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function mf(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=zi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function yf(e,t,n){var r=(e+="")=="transform"?yd:Hi;return t==null?this.styleTween(e,hf(e,r)).on("end.style."+e,zi(e)):typeof t=="function"?this.styleTween(e,pf(e,r,dr(this,"style."+e,t))).each(mf(this._id,e)):this.styleTween(e,gf(e,r,t),n).on("end.style."+e,null)}function xf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function wf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&xf(e,s,n)),r}return i._value=t,i}function vf(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,wf(e,t,n??""))}function bf(e){return function(){this.textContent=e}}function Ef(e){return function(){var t=e(this);this.textContent=t??""}}function _f(e){return this.tween("text",typeof e=="function"?Ef(dr(this,"text",e)):bf(e==null?"":e+""))}function Nf(e){return function(t){this.textContent=e.call(this,t)}}function Sf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Nf(o)),t}return r._value=e,r}function kf(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Sf(e))}function Cf(){for(var e=this._name,t=this._id,n=Fi(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=ye(c,t);gn(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Te(r,this._parents,e,n)}function Mf(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var l=Se(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&i()})}var If=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fi(){return++If}var Ie=kt.prototype;Te.prototype={constructor:Te,select:lf,selectAll:uf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:tf,merge:nf,selection:ff,transition:Cf,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:sf,attr:Hd,attrTween:Yd,style:yf,styleTween:vf,text:_f,textTween:kf,remove:cf,tween:Od,delay:Gd,duration:Zd,ease:Qd,easeVarying:ef,end:Mf,[Symbol.iterator]:Ie[Symbol.iterator]};function Af(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Tf={time:null,delay:0,duration:250,ease:Af};function Of(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Pf(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=Fi(),(n=Tf).time=lr(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&gn(c,e,t,l,s,n||Of(c,t));return new Te(r,this._parents,e,t)}kt.prototype.interrupt=Id;kt.prototype.transition=Pf;const Ht=e=>()=>e;function $f(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ae(e,t,n){this.k=e,this.x=t,this.y=n}Ae.prototype={constructor:Ae,scale:function(e){return e===1?this:new Ae(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ae(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var pn=new Ae(1,0,0);Bi.prototype=Ae.prototype;function Bi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return pn;return e.__zoom}function Tn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function jf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Lf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function eo(){return this.__zoom||pn}function Df(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Rf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.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 Vi(){var e=jf,t=Lf,n=Hf,r=Df,o=Rf,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xt,l=dn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",eo).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,N,k,A){var j=y.selection?y.selection():y;j.property("__zoom",eo),y!==j?_(y,N,k,A):j.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},m.scaleBy=function(y,N,k,A){m.scaleTo(y,function(){var j=this.__zoom.k,T=typeof N=="function"?N.apply(this,arguments):N;return j*T},k,A)},m.scaleTo=function(y,N,k,A){m.transform(y,function(){var j=t.apply(this,arguments),T=this.__zoom,D=k==null?x(j):typeof k=="function"?k.apply(this,arguments):k,F=T.invert(D),H=typeof N=="function"?N.apply(this,arguments):N;return n(p(b(T,H),D,F),j,s)},k,A)},m.translateBy=function(y,N,k,A){m.transform(y,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,N,k,A,j){m.transform(y,function(){var T=t.apply(this,arguments),D=this.__zoom,F=A==null?x(T):typeof A=="function"?A.apply(this,arguments):A;return n(pn.translate(F[0],F[1]).scale(D.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof k=="function"?-k.apply(this,arguments):-k),T,s)},A,j)};function b(y,N){return N=Math.max(i[0],Math.min(i[1],N)),N===y.k?y:new Ae(N,y.x,y.y)}function p(y,N,k){var A=N[0]-k[0]*y.k,j=N[1]-k[1]*y.k;return A===y.x&&j===y.y?y:new Ae(y.k,A,j)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function _(y,N,k,A){y.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var j=this,T=arguments,D=S(j,T).event(A),F=t.apply(j,T),H=k==null?x(F):typeof k=="function"?k.apply(j,T):k,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=j.__zoom,q=typeof N=="function"?N.apply(j,T):N,J=c(Y.invert(H).concat(V/Y.k),q.invert(H).concat(V/q.k));return function(G){if(G===1)G=q;else{var R=J(G),B=V/R[2];G=new Ae(B,H[0]-R[0]*B,H[1]-R[1]*B)}D.zoom(null,G)}})}function S(y,N,k){return!k&&y.__zooming||new C(y,N)}function C(y,N){this.that=y,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,N),this.taps=0}C.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,N){return this.mouse&&y!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var N=ce(this.that).datum();l.call(y,this.that,new $f(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),N)}};function M(y,...N){if(!e.apply(this,arguments))return;var k=S(this,N).event(y),A=this.__zoom,j=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),T=fe(y);if(k.wheel)(k.mouse[0][0]!==T[0]||k.mouse[0][1]!==T[1])&&(k.mouse[1]=A.invert(k.mouse[0]=T)),clearTimeout(k.wheel);else{if(A.k===j)return;k.mouse=[T,A.invert(T)],qt(this),k.start()}ut(y),k.wheel=setTimeout(D,g),k.zoom("mouse",n(p(b(A,j),k.mouse[0],k.mouse[1]),k.extent,s));function D(){k.wheel=null,k.end()}}function I(y,...N){if(f||!e.apply(this,arguments))return;var k=y.currentTarget,A=S(this,N,!0).event(y),j=ce(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",V,!0),T=fe(y,k),D=y.clientX,F=y.clientY;ki(y.view),Tn(y),A.mouse=[T,this.__zoom.invert(T)],qt(this),A.start();function H(Y){if(ut(Y),!A.moved){var q=Y.clientX-D,J=Y.clientY-F;A.moved=q*q+J*J>v}A.event(Y).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=fe(Y,k),A.mouse[1]),A.extent,s))}function V(Y){j.on("mousemove.zoom mouseup.zoom",null),Ci(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(y,...N){if(e.apply(this,arguments)){var k=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),j=k.invert(A),T=k.k*(y.shiftKey?.5:2),D=n(p(b(k,T),A,j),t.apply(this,N),s);ut(y),a>0?ce(this).transition().duration(a).call(_,D,A,y):ce(this).call(m.transform,D,A,y)}}function O(y,...N){if(e.apply(this,arguments)){var k=y.touches,A=k.length,j=S(this,N,y.changedTouches.length===A).event(y),T,D,F,H;for(Tn(y),D=0;D<A;++D)F=k[D],H=fe(F,this),H=[H,this.__zoom.invert(H),F.identifier],j.touch0?!j.touch1&&j.touch0[2]!==H[2]&&(j.touch1=H,j.taps=0):(j.touch0=H,T=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(j.taps<2&&(d=H[0],u=setTimeout(function(){u=null},h)),qt(this),j.start())}}function $(y,...N){if(this.__zooming){var k=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D,F,H;for(ut(y),T=0;T<j;++T)D=A[T],F=fe(D,this),k.touch0&&k.touch0[2]===D.identifier?k.touch0[0]=F:k.touch1&&k.touch1[2]===D.identifier&&(k.touch1[0]=F);if(D=k.that.__zoom,k.touch1){var V=k.touch0[0],Y=k.touch0[1],q=k.touch1[0],J=k.touch1[1],G=(G=q[0]-V[0])*G+(G=q[1]-V[1])*G,R=(R=J[0]-Y[0])*R+(R=J[1]-Y[1])*R;D=b(D,Math.sqrt(G/R)),F=[(V[0]+q[0])/2,(V[1]+q[1])/2],H=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(k.touch0)F=k.touch0[0],H=k.touch0[1];else return;k.zoom("touch",n(p(D,F,H),k.extent,s))}}function P(y,...N){if(this.__zooming){var k=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D;for(Tn(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<j;++T)D=A[T],k.touch0&&k.touch0[2]===D.identifier?delete k.touch0:k.touch1&&k.touch1[2]===D.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(D=fe(D,this),Math.hypot(d[0]-D[0],d[1]-D[1])<w)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:Ht(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ht(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Ht(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:Ht([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=l.on.apply(l,arguments);return y===l?m:y},m.clickDistance=function(y){return arguments.length?(v=(y=+y)*y,m):Math.sqrt(v)},m.tapDistance=function(y){return arguments.length?(w=+y,m):w},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yi=["Enter"," ","Escape"],Xi={"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:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, 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 nt;(function(e){e.Strict="strict",e.Loose="loose"})(nt||(nt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Wi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(je||(je={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const to={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Gi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,zf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),fr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Ff=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):fr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,mn(o,rn(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?yn(r):{x:0,y:0,width:0,height:0}},It=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=mn(n,rn(o)),r=!0)}),r?yn(n):{x:0,y:0,width:0,height:0}},hr=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,l=t.width/o,u=t.height/o,d=[];for(const f of e.values()){const{measured:h,selectable:g=!0,hidden:v=!1}=f;if(s&&!g||v)continue;const w=h.width??f.width??f.initialWidth??0,m=h.height??f.height??f.initialHeight??0,{x:b,y:p}=f.internals.positionAbsolute,x=Ui(a,c,l,u,b,p,w,m),_=w*m,S=i&&x>0;(!f.internals.handleBounds||S||x>=_||f.dragging)&&d.push(f)}return d},Bf=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Vf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function Yf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Vf(e,s),c=It(a),l=pr(c,t,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(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function qi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,l],[c+h,l+g]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?We(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Xf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(v=>v.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),u=Bf(s,c);for(const f of c)a.has(f.id)&&!u.find(g=>g.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:s};const d=await o({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const rt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:rt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:rt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ki(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return We(e,[[i,s],[i+r,s+o]],t)}const no=(e,t,n)=>e<t?rt(Math.abs(e-t),1,t)/t:e>n?-rt(Math.abs(e-n),1,t)/t:0,gr=(e,t,n=15,r=40)=>{const o=no(e.x,r,t.width-r)*n,i=no(e.y,r,t.height-r)*n;return[o,i]},mn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Un=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),yn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Et=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},rn=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Zi=(e,t)=>yn(mn(Un(e),Un(t))),Ui=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),l=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*l)},on=(e,t)=>Ui(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),ro=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Qi=(e,t)=>(n,r)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?At(a,s):a},ot=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ze(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Wf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ze(e,n),o=Ze(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ze(e.top??e.y??0,n),o=Ze(e.bottom??e.y??0,n),i=Ze(e.left??e.x??0,t),s=Ze(e.right??e.x??0,t);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 Gf(e,t,n,r,o,i){const{x:s,y:a}=ot(e,[t,n,r]),{x:c,y:l}=ot({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=o-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const pr=(e,t,n,r,o,i)=>{const s=Wf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=rt(l,r,o),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,g=n/2-f*u,v=Gf(e,h,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},_t=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ge(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Ji(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function es(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function oo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function qf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Kf(e){return{...Xi,...e||{}}}function ts(e){return e===null?null:e?"valid":"invalid"}function pt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Tt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const mr=e=>({width:e.offsetWidth,height:e.offsetHeight}),ns=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Zf=["INPUT","SELECT","TEXTAREA"];function rs(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Zf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const os=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=os(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},io=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...mr(s)}})};function is({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function zt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function so({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-zt(t-r,i),n];case W.Right:return[t+zt(r-t,i),n];case W.Top:return[t,n-zt(n-o,i)];case W.Bottom:return[t,n+zt(o-n,i)]}}function ss({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=so({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=so({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=is({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${r},${o}`,d,f,h,g]}function as({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function Uf({sourceNode:e,targetNode:t,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(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function Qf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=mn(rn(e),rn(t));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 on(s,yn(i))>0}const Jf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,eh=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),th=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||Jf;let o;return Gi(e)?o={...e}:o={...e,id:r(e)},eh(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function cs({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=as({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const ao={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},nh=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},co=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function rh({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=ao[t],c=ao[r],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=nh({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let g=[],v,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=as({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(v=o.x??l.x+(u.x-l.x)*s,w=o.y??(l.y+u.y)/2):(v=o.x??(l.x+u.x)/2,w=o.y??l.y+(u.y-l.y)*s);const M=[{x:v,y:l.y},{x:v,y:u.y}],I=[{x:l.x,y:w},{x:u.x,y:w}];a[f]===h?g=f==="x"?M:I:g=f==="x"?I:M}else{const M=[{x:l.x,y:u.y}],I=[{x:u.x,y:l.y}];if(f==="x"?g=a.x===h?I:M:g=a.y===h?M:I,t===r){const y=Math.abs(e[f]-n[f]);if(y<=i){const N=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*N:b[f]=(u[f]>n[f]?-1:1)*N}}if(t!==r){const y=f==="x"?"y":"x",N=a[f]===c[y],k=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!N&&k||N&&A)||a[f]!==1&&(!N&&A||N&&k))&&(g=f==="x"?M:I)}const z={x:l.x+m.x,y:l.y+m.y},O={x:u.x+b.x,y:u.y+b.y},$=Math.max(Math.abs(z.x-g[0].x),Math.abs(O.x-g[0].x)),P=Math.max(Math.abs(z.y-g[0].y),Math.abs(O.y-g[0].y));$>=P?(v=(z.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(z.y+O.y)/2)}const _={x:l.x+m.x,y:l.y+m.y},S={x:u.x+b.x,y:u.y+b.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],v,w,p,x]}function oh(e,t,n,r){const o=Math.min(co(e,t)/2,co(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+o*l},${s}Q ${i},${s} ${i},${s+o*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Qn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,g,v]=rh({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)w+=oh(d[m-1],d[m],d[m+1],s);return w+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[w,f,h,g,v]}function lo(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ih(e){var d;const{sourceNode:t,targetNode:n}=e;if(!lo(t)||!lo(n))return null;const r=t.internals.handleBounds||uo(t.handles),o=n.internals.handleBounds||uo(n.handles),i=fo((r==null?void 0:r.source)??[],e.sourceHandle),s=fo(e.connectionMode===nt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function uo(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function qe(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function fo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function sh(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Jn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const ls=1e3,ah=10,yr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ch={...yr,checkEquality:!0};function xr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function lh(e,t,n){const r=xr(yr,n);for(const o of e.values())if(o.parentId)vr(o,e,t,r);else{const i=Mt(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function uh(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.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 wr(e){return e==="manual"}function er(e,t,n,r={}){var u,d;const o=xr(ch,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!wr(o.zIndexMode)?ls:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Mt(f,o.nodeOrigin),v=Ge(f.extent)?f.extent:o.nodeExtent,w=We(g,v,xe(f));h={...o.defaults,...f,measured:{width:(u=f.measured)==null?void 0:u.width,height:(d=f.measured)==null?void 0:d.height},internals:{positionAbsolute:w,handleBounds:uh(f,h),z:us(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&vr(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function dh(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function vr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=xr(yr,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}dh(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*ah),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!wr(c)?ls:0,{x:f,y:h,z:g}=fh(e,u,s,a,d,c),{positionAbsolute:v}=e.internals,w=f!==v.x||h!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:v,z:g}})}function us(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return wr(n)?r:r+(e.selected?t:0)}function fh(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=Mt(e,n),u=Ge(e.extent)?We(l,e.extent,c):l;let d=We({x:s+u.x,y:a+u.y},r,c);e.extent==="parent"&&(d=Ki(d,c,t));const f=us(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function br(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Et(c),u=Zi(l,a.rect);i.set(a.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const u=c.internals.positionAbsolute,d=xe(c),f=c.origin??r,h=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,g=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(d.width,Math.round(a.width)),w=Math.max(d.height,Math.round(a.height)),m=(v-d.width)*f[0],b=(w-d.height)*f[1];(h>0||g>0||m||b)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(l))==null||p.forEach(x=>{e.some(_=>_.id===x.id)||o.push({id:x.id,type:"position",position:{x:x.position.x+h,y:x.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-m:0),height:w+(g?f[1]*g-b:0)}})}),o}function hh(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=mr(h.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ge(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;if(g.parentId&&g.extent==="parent"){const S=t.get(g.parentId);S&&(x=Ki(x,v,S))}else p&&(x=We(x,p,v));const _={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:io("source",h.nodeElement,b,d,g.id),target:io("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,_),g.parentId&&vr(_,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:Et(_,o)}))}}if(f.length>0){const h=br(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function gh({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ho(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const l=r.get(s)||new Map;r.set(s,l.set(n,t))}}function ds(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},l=`${o}-${s}--${i}-${a}`,u=`${i}-${a}--${o}-${s}`;ho("source",c,u,e,o,s),ho("target",c,l,e,i,a),t.set(r.id,r)}}function fs(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:fs(n,t):!1}function go(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function ph(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!fs(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.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 On({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[l,u]of t){const d=(s=n.get(l))==null?void 0:s.internals.userNode;d&&o.push({...d,position:u.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function mh({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function yh({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,g=!1,v=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:_,nodeId:S,nodeClickDistance:C=0}){f=ce(x);function M({x:$,y:P}){const{nodeLookup:y,nodeExtent:N,snapGrid:k,snapToGrid:A,nodeOrigin:j,onNodeDrag:T,onSelectionDrag:D,onError:F,updateNodePositions:H}=t();i={x:$,y:P};let V=!1;const Y=a.size>1,q=Y&&N?Un(It(a)):null,J=Y&&A?mh({dragItems:a,snapGrid:k,x:$,y:P}):null;for(const[G,R]of a){if(!y.has(G))continue;let B={x:$-R.distance.x,y:P-R.distance.y};A&&(B=J?{x:Math.round(B.x+J.x),y:Math.round(B.y+J.y)}:At(B,k));let K=null;if(Y&&N&&!R.extent&&q){const{positionAbsolute:U}=R.internals,Q=U.x-q.x+N[0][0],ee=U.x+R.measured.width-q.x2+N[1][0],ne=U.y-q.y+N[0][1],re=U.y+R.measured.height-q.y2+N[1][1];K=[[Q,ne],[ee,re]]}const{position:Z,positionAbsolute:X}=qi({nodeId:G,nextPosition:B,nodeLookup:y,nodeExtent:K||N,nodeOrigin:j,onError:F});V=V||R.position.x!==Z.x||R.position.y!==Z.y,R.position=Z,R.internals.positionAbsolute=X}if(g=g||V,!!V&&(H(a,!0),v&&(r||T||!S&&D))){const[G,R]=On({nodeId:S,dragItems:a,nodeLookup:y});r==null||r(v,a,G,R),T==null||T(v,G,R),S||D==null||D(v,R)}}async function I(){if(!u)return;const{transform:$,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:N}=t();if(!N){c=!1,cancelAnimationFrame(s);return}const[k,A]=gr(l,u,y);(k!==0||A!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-A/$[2],await P({x:k,y:A})&&M(i)),s=requestAnimationFrame(I)}function z($){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:N,transform:k,snapGrid:A,snapToGrid:j,selectNodesOnDrag:T,onNodeDragStart:D,onSelectionDragStart:F,unselectNodesAndEdges:H}=t();d=!0,(!T||!_)&&!y&&S&&((Y=P.get(S))!=null&&Y.selected||H()),_&&T&&S&&(e==null||e(S));const V=pt($.sourceEvent,{transform:k,snapGrid:A,snapToGrid:j,containerBounds:u});if(i=V,a=ph(P,N,V,S),a.size>0&&(n||D||!S&&F)){const[q,J]=On({nodeId:S,dragItems:a,nodeLookup:P});n==null||n($.sourceEvent,a,q,J),D==null||D($.sourceEvent,q,J),S||F==null||F($.sourceEvent,J)}}const O=Mi().clickDistance(C).on("start",$=>{const{domNode:P,nodeDragThreshold:y,transform:N,snapGrid:k,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=$.sourceEvent,y===0&&z($),i=pt($.sourceEvent,{transform:N,snapGrid:k,snapToGrid:A,containerBounds:u}),l=pe($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:N,snapToGrid:k,nodeDragThreshold:A,nodeLookup:j}=t(),T=pt($.sourceEvent,{transform:y,snapGrid:N,snapToGrid:k,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!j.has(S))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const D=pe($.sourceEvent,u),F=D.x-l.x,H=D.y-l.y;Math.sqrt(F*F+H*H)>A&&z($)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe($.sourceEvent,u),M(T))}}).on("end",$=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:P,updateNodePositions:y,onNodeDragStop:N,onSelectionDragStop:k}=t();if(g&&(y(a,!1),g=!1),o||N||!S&&k){const[A,j]=On({nodeId:S,dragItems:a,nodeLookup:P,dragging:!1});o==null||o($.sourceEvent,a,A,j),N==null||N($.sourceEvent,A,j),S||k==null||k($.sourceEvent,j)}}}).filter($=>{const P=$.target;return!$.button&&(!b||!go(P,`.${b}`,x))&&(!p||go(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function xh(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())on(o,Et(i))>0&&r.push(i);return r}const wh=250;function vh(e,t,n,r){var a,c;let o=[],i=1/0;const s=xh(e,n,t+wh);for(const l of s){const u=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of u){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:f,y:h}=qe(l,d,d.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:f,y:h}],i=g):g===i&&o.push({...d,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(u=>u.type===l)??o[0]}return o[0]}function hs(e,t,n,r,o,i=!1){var l,u,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((u=s.internals.handleBounds)==null?void 0:u.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function gs(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function bh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ps=()=>!0;function Eh(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:m=ps,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:_,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:M}){const I=ns(e.target);let z=0,O;const{x:$,y:P}=pe(e),y=gs(i,M),N=a==null?void 0:a.getBoundingClientRect();let k=!1;if(!N||!y)return;const A=hs(o,y,r,c,t);if(!A)return;let j=pe(e,N),T=!1,D=null,F=!1,H=null;function V(){if(!u||!N)return;const[Z,X]=gr(j,N,S);f({x:Z,y:X}),z=requestAnimationFrame(V)}const Y={...A,nodeId:o,type:y,position:A.position},q=c.get(o);let G={inProgress:!0,isValid:null,from:qe(q,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:q,to:j,toHandle:null,toPosition:to[Y.position],toNode:null,pointer:j};function R(){k=!0,p(G),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}C===0&&R();function B(Z){if(!k){const{x:re,y:ue}=pe(Z),ve=re-$,be=ue-P;if(!(ve*ve+be*be>C*C))return;R()}if(!_()||!Y){K(Z);return}const X=x();j=pe(Z,N),O=vh(Tt(j,X,!1,[1,1]),n,c,Y),T||(V(),T=!0);const U=ms(Z,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:I,lib:l,flowId:d,nodeLookup:c});H=U.handleDomNode,D=U.connection,F=bh(!!O,U.isValid);const Q=c.get(o),ee=Q?qe(Q,Y,W.Left,!0):G.from,ne={...G,from:ee,isValid:F,to:U.toHandle&&F?ot({x:U.toHandle.x,y:U.toHandle.y},X):j,toHandle:U.toHandle,toPosition:F&&U.toHandle?U.toHandle.position:to[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:j};p(ne),G=ne}function K(Z){if(!("touches"in Z&&Z.touches.length>0)){if(k){(O||H)&&D&&F&&(v==null||v(D));const{inProgress:X,...U}=G,Q={...U,toPosition:G.toHandle?G.toPosition:null};w==null||w(Z,Q),i&&(b==null||b(Z,Q))}h(),cancelAnimationFrame(z),T=!1,F=!1,D=null,H=null,I.removeEventListener("mousemove",B),I.removeEventListener("mouseup",K),I.removeEventListener("touchmove",B),I.removeEventListener("touchend",K)}}I.addEventListener("mousemove",B),I.addEventListener("mouseup",K),I.addEventListener("touchmove",B),I.addEventListener("touchend",K)}function ms(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=ps,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),v=s.elementFromPoint(h,g),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=gs(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),_=w.classList.contains("connectable"),S=w.classList.contains("connectableend");if(!p||!b)return m;const C={source:d?p:r,sourceHandle:d?x:o,target:d?r:p,targetHandle:d?o:x};m.connection=C;const I=_&&S&&(n===nt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(C),m.toHandle=hs(p,b,x,u,n,!0)}return m}const tr={onPointerDown:Eh,isValid:ms};function _h({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),_=p.sourceEvent.ctrlKey&&_t()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,C=x[2]*Math.pow(2,S*_);t.scaleTo(C)};let v=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const _=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[_[0]-v[0],_[1]-v[1]];v=_;const C=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),M={x:x[0]-S[0]*C,y:x[1]-S[1]*C},I=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:x[2]},I,a)},b=Vi().on("start",w).on("zoom",d?m:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const xn=e=>({x:e.x,y:e.y,zoom:e.k}),Pn=({x:e,y:t,zoom:n})=>pn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),ys=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Nh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,$n=(e,t=0,n=Nh,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},xs=e=>{const t=e.ctrlKey&&_t()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Sh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=fe(u),m=xs(u),b=d*Math.pow(2,m);r.scaleTo(n,b,w,u);return}const f=u.deltaMode===1?20:1;let h=o===Ve.Vertical?0:u.deltaX*f,g=o===Ve.Horizontal?0:u.deltaY*f;!_t()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=xn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(u,v):(e.isPanScrolling=!0,a==null||a(u,v)),e.panScrollTimeout=setTimeout(()=>{l==null||l(u,v),e.isPanScrolling=!1},150)}}function kh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=$e(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Ch({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=xn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Mh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&ys(t,e.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,xn(i.transform)))}}function Ih({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&ys(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=xn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ah({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{var m;const h=t||n,g=r&&f.ctrlKey,v=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&($e(f,`${u}-flow__node`)||$e(f,`${u}-flow__edge`)||$e(f,`${u}-flow__selection`)||$e(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||$e(f,c)&&v||$e(f,l)&&(!v||i&&v&&!t)||!r&&f.ctrlKey&&v)return!1;if(!r&&f.type==="touchstart"&&((m=f.touches)==null?void 0:m.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!g&&v||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||v||e)&&w}}function Th({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];const f=typeof ResizeObserver<"u"?new ResizeObserver(P=>{const y=P[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;f==null||f.observe(e);const h=Vi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:rt(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(xs);async function m(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).transform($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:N,userSelectionActive:k,panOnScroll:A,panOnDrag:j,panOnScrollMode:T,panOnScrollSpeed:D,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:Y,panActivationKeyPressed:q=!1,zoomActivationKeyPressed:J,lib:G,onTransformChange:R,connectionInProgress:B,paneClickDistance:K,selectionOnDrag:Z}){k&&!l.isZoomingOrPanning&&p();const X=A&&!J&&!k;h.clickDistance(Z?1/0:!ge(K)||K<0?0:K);const U=X?Sh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:D,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):kh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",U,{passive:!1});const Q=Ch({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Mh({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!N,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Ih({zoomPanValues:l,panOnDrag:j,panOnScroll:A,onPaneContextMenu:N,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Ah({panActivationKeyPressed:q,zoomActivationKeyPressed:J,panOnDrag:j,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:k,noPanClassName:y,noWheelClassName:P,lib:G,connectionInProgress:B});h.filter(re),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function x(P,y,N){const k=Pn(P),A=h==null?void 0:h.constrain()(k,y,N);return A&&await m(A),A}async function _(P,y){const N=Pn(P);return await m(N,y),N}function S(P){if(g){const y=Pn(P),N=g.property("__zoom");(N.k!==P.zoom||N.x!==P.x||N.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function C(){const P=g?Bi(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function M(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleTo($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}async function I(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleBy($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function z(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function $(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:_,setViewportConstrained:x,getViewport:C,scaleTo:M,scaleBy:I,setScaleExtent:z,setTranslateExtent:O,syncViewport:S,setClickDistance:$}}var it;(function(e){e.Line="line",e.Handle="handle"})(it||(it={}));function Oh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function po(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Oe(e,t){return Math.max(0,t-e)}function Pe(e,t){return Math.max(0,e-t)}function Ft(e,t,n){return Math.max(0,t-e,e-n)}function mo(e,t){return e?!t:t}function Ph(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:m,maxHeight:b}=r,{x:p,y:x,width:_,height:S,aspectRatio:C}=e;let M=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const z=_+(c?-M:M),O=S+(l?-I:I),$=-i[0]*_,P=-i[1]*S;let y=Ft(z,v,w),N=Ft(O,m,b);if(s){let j=0,T=0;c&&M<0?j=Oe(p+M+$,s[0][0]):!c&&M>0&&(j=Pe(p+z+$,s[1][0])),l&&I<0?T=Oe(x+I+P,s[0][1]):!l&&I>0&&(T=Pe(x+O+P,s[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(a){let j=0,T=0;c&&M>0?j=Pe(p+M,a[0][0]):!c&&M<0&&(j=Oe(p+z,a[1][0])),l&&I>0?T=Pe(x+I,a[0][1]):!l&&I<0&&(T=Oe(x+O,a[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(o){if(u){const j=Ft(z/C,m,b)*C;if(y=Math.max(y,j),s){let T=0;!c&&!l||c&&!l&&f?T=Pe(x+P+z/C,s[1][1])*C:T=Oe(x+P+(c?M:-M)/C,s[0][1])*C,y=Math.max(y,T)}if(a){let T=0;!c&&!l||c&&!l&&f?T=Oe(x+z/C,a[1][1])*C:T=Pe(x+(c?M:-M)/C,a[0][1])*C,y=Math.max(y,T)}}if(d){const j=Ft(O*C,v,w)/C;if(N=Math.max(N,j),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*C+$,s[1][0])/C:T=Oe(p+(l?I:-I)*C+$,s[0][0])/C,N=Math.max(N,T)}if(a){let T=0;!c&&!l||l&&!c&&f?T=Oe(p+O*C,a[1][0])/C:T=Pe(p+(l?I:-I)*C,a[0][0])/C,N=Math.max(N,T)}}}I=I+(I<0?N:-N),M=M+(M<0?y:-y),o&&(f?z>O*C?I=(mo(c,l)?-M:M)/C:M=(mo(c,l)?-I:I)*C:u?(I=M/C,l=c):(M=I*C,c=l));const k=c?p+M:p,A=l?x+I:x;return{width:_+(c?-M:M),height:S+(l?-I:I),x:i[0]*M*(c?-1:1)+k,y:i[1]*I*(l?-1:1)+A}}const ws={width:0,height:0,x:0,y:0},$h={...ws,pointerX:0,pointerY:0,aspectRatio:1};function jh(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Lh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:po("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:w}){let m={...ws},b={...$h};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:po(l)};let p,x=null,_=[],S,C,M,I=!1;const z=Mi().on("start",O=>{const{nodeLookup:$,transform:P,snapGrid:y,snapToGrid:N,nodeOrigin:k,paneDomNode:A}=n();if(p=$.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:j,ySnapped:T}=pt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:N,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:j,pointerY:T,aspectRatio:m.width/m.height},S=void 0,C=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId)),S&&p.extent==="parent"&&(C=[[0,0],[S.measured.width,S.measured.height]]),_=[],M=void 0;for(const[D,F]of $)if(F.parentId===t&&(_.push({id:D,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=jh(F,p,F.origin??k);M?M=[[Math.min(H[0][0],M[0][0]),Math.min(H[0][1],M[0][1])],[Math.max(H[1][0],M[1][0]),Math.max(H[1][1],M[1][1])]]:M=H}h==null||h(O,{...m})}).on("drag",O=>{const{transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:N}=n(),k=pt(O.sourceEvent,{transform:$,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:j,y:T,width:D,height:F}=m,H={},V=p.origin??N,{width:Y,height:q,x:J,y:G}=Ph(b,s.controlDirection,k,s.boundaries,s.keepAspectRatio,V,C,M),R=Y!==D,B=q!==F,K=J!==j&&R,Z=G!==T&&B;if(!K&&!Z&&!R&&!B)return;if((K||Z||V[0]===1||V[1]===1)&&(H.x=K?J:m.x,H.y=Z?G:m.y,m.x=H.x,m.y=H.y,_.length>0)){const ee=J-j,ne=G-T;for(const re of _)re.position={x:re.position.x-ee+V[0]*(Y-D),y:re.position.y-ne+V[1]*(q-F)},A.push(re)}if((R||B)&&(H.width=R&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,H.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?q:m.height,m.width=H.width,m.height=H.height),S&&p.expandParent){const ee=V[0]*(H.width??0);H.x&&H.x<ee&&(m.x=ee,b.x=b.x-(H.x-ee));const ne=V[1]*(H.height??0);H.y&&H.y<ne&&(m.y=ne,b.y=b.y-(H.y-ne))}const X=Oh({width:m.width,prevWidth:D,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:X};(w==null?void 0:w(O,U))!==!1&&(I=!0,g==null||g(O,U),r(H,A))}).on("end",O=>{I&&(v==null||v(O,{...m}),o==null||o({...m}),I=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const Dh={},yo=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Dh?"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()}},l=t=e(r,o,c);return c},Rh=e=>e?yo(e):yo,{useDebugValue:Hh}=Dc,{useSyncExternalStoreWithSelector:zh}=Lc,Fh=e=>e;function vs(e,t=Fh,n){const r=zh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hh(r),r}const xo=(e,t)=>{const n=Rh(e),r=(o,i=t)=>vs(n,o,i);return Object.assign(r,n),r},Bh=(e,t)=>e?xo(e,t):xo;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const wn=L.createContext(null),Vh=wn.Provider,bs=me.error001("react");function te(e,t){const n=L.useContext(wn);if(n===null)throw new Error(bs);return vs(n,e,t)}function oe(){const e=L.useContext(wn);if(e===null)throw new Error(bs);return L.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const wo={display:"none"},Yh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Es="react-flow__node-desc",_s="react-flow__edge-desc",Xh="react-flow__aria-live",Wh=e=>e.ariaLiveMessage,Gh=e=>e.ariaLabelConfig;function qh({rfId:e}){const t=te(Wh);return E.jsx("div",{id:`${Xh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Yh,children:t})}function Kh({rfId:e,disableKeyboardA11y:t}){const n=te(Gh);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${Es}-${e}`,style:wo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${_s}-${e}`,style:wo,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(qh,{rfId:e})]})}const vn=L.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});vn.displayName="Panel";const vo="https://reactflow.dev?utm_source=attribution";function Zh({proOptions:e,position:t="bottom-right"}){return L.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:E.jsx(vn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${vo}`,children:E.jsx("a",{href:vo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Uh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Bt=e=>e.id;function Qh(e,t){return ie(e.selectedNodes.map(Bt),t.selectedNodes.map(Bt))&&ie(e.selectedEdges.map(Bt),t.selectedEdges.map(Bt))}function Jh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(Uh,Qh);return L.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const eg=e=>!!e.onSelectionChangeHandlers;function tg({onSelectionChange:e}){const t=te(eg);return e||t?E.jsx(Jh,{onSelectionChange:e}):null}const Ns=[0,0],ng={x:0,y:0,zoom:1},rg=["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"],bo=[...rg,"rfId"],og=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Eo={translateExtent:vt,nodeOrigin:Ns,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ig(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(og,ie),l=oe();L.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Eo,a()}),[]);const u=L.useRef(Eo);return L.useEffect(()=>{for(const d of bo){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?r(f):d==="maxZoom"?o(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Kf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},bo.map(d=>e[d])),null}function _o(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function sg(e){var r;const[t,n]=L.useState(e==="system"?null:e);return L.useEffect(()=>{if(e!=="system"){n(e);return}const o=_o(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=_o())!=null&&r.matches?"dark":"light"}const No=typeof document<"u"?document:null;function Nt(e=null,t={target:No,actInsideInputWithModifier:!0}){const[n,r]=L.useState(!1),o=L.useRef(!1),i=L.useRef(new Set([])),[s,a]=L.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
17
17
|
`).replace(`
|
|
18
18
|
|
|
19
19
|
`,`
|
|
20
20
|
+`).split(`
|
|
21
|
-
`)),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return j.useEffect(()=>{const c=(t==null?void 0:t.target)??Co,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var w,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!l)&&os(h))return!1;const v=Io(h.code,a);if(i.current.add(h[v]),Mo(s,i.current,!1)){const b=((m=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:m[0])||h.target,p=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&h.preventDefault(),r(!0)}},d=h=>{const g=Io(h.code,a);Mo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Mo(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function Io(e,t){return t.includes(e)?"code":"key"}const rg=()=>{const e=oe();return j.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=mr(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},u=n.snapGrid??o,d=n.snapToGrid??i;return Tt(l,r,d,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=ot(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function ks(e,t){const n=[],r=new Map,o=[];for(const i of e)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 t){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 c of s)og(c,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 og(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function ig(e,t){return ks(e,t)}function sg(e,t){return ks(e,t)}function ze(e,t){return{id:e,type:"select",selected:t}}function Ue(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(ze(i.id,s)))}return r}function Ao({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function To(e){return{id:e.id,type:"remove"}}const ag=Ji();function cg(e,t,n={}){return Uf(e,t,{...n,onError:n.onError??ag})}const Oo=e=>jf(e),lg=e=>qi(e);function Cs(e){return j.forwardRef(e)}const Ms=typeof window<"u"?j.useLayoutEffect:j.useEffect;function Po(e){const[t,n]=j.useState(BigInt(0)),[r]=j.useState(()=>ug(()=>n(o=>o+BigInt(1))));return Ms(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function ug(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Is=j.createContext(null);function dg({children:e}){const t=oe(),n=j.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:d,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let v=c;for(const m of a)v=typeof m=="function"?m(v):m;let w=Ao({items:v,lookup:f});for(const m of g.values())w=m(w);u&&l(v),w.length>0?d==null||d(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=Po(n),o=j.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:d,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;u?l(h):d&&d(Ao({items:h,lookup:f}))},[]),i=Po(o),s=j.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return N.jsx(Is.Provider,{value:s,children:e})}function fg(){const e=j.useContext(Is);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const hg=e=>!!e.panZoom;function _r(){const e=rg(),t=oe(),n=fg(),r=te(hg),o=j.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var m,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=Oo(d)?d:f.get(d.id),v=g.parentId?ts(g.position,g.measured,g.parentId,f,h):g.position,w={...g,position:v,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Et(w)},l=(d,f,h={replace:!1})=>{s(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&Oo(w)?w:{...v,...w}}return v}))},u=(d,f,h={replace:!1})=>{a(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&lg(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(h=>[...h,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:h}=t.getState(),[g,v,w]=h;return{nodes:d.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y:v,zoom:w}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:E,edges:S}=await Ff({nodesToRemove:d,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:x}),C=S.length>0,M=E.length>0;if(C){const I=S.map(To);w==null||w(S),b(I)}if(M){const I=E.map(To);v==null||v(E),m(I)}return(M||C)&&(p==null||p({nodes:E,edges:S})),{deletedNodes:E,deletedEdges:S}},getIntersectingNodes:(d,f=!0,h)=>{const g=so(d),v=g?d:c(d),w=h!==void 0;return v?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===d.id||!b.internals.positionAbsolute))return!1;const p=Et(w?m:b),x=on(p,v);return f&&x>0||x>=p.width*p.height||x>=v.width*v.height}):[]},isNodeIntersecting:(d,f,h=!0)=>{const v=so(d)?d:c(d);if(!v)return!1;const w=on(v,f);return h&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(d,f,h={replace:!1})=>{l(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},updateEdge:u,updateEdgeData:(d,f,h={replace:!1})=>{u(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Df(d,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:d,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${d}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??Yf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return j.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const $o=e=>e.selected,gg=typeof window<"u"?window:void 0;function pg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=_r(),o=Nt(e,{actInsideInputWithModifier:!1}),i=Nt(t,{target:gg});j.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter($o),edges:s.filter($o)}),n.setState({nodesSelectionActive:!1})}},[o]),j.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function mg(e){const t=oe();j.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=yr(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",me.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const bn={position:"absolute",width:"100%",height:"100%",top:0,left:0},yg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function xg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:s=Ve.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:g=!0,children:v,noWheelClassName:w,noPanClassName:m,onViewportChange:b,isControlledViewport:p,paneClickDistance:x,selectionOnDrag:E}){const S=oe(),C=j.useRef(null),{userSelectionActive:M,lib:I,connectionInProgress:z}=te(yg,ie),O=Nt(h),$=j.useRef();mg(C);const P=j.useCallback(y=>{b==null||b({x:y[0],y:y[1],zoom:y[2]}),p||S.setState({transform:y})},[b,p]);return j.useEffect(()=>{if(C.current){$.current=Ch({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:A=>S.setState(L=>L.paneDragging===A?L:{paneDragging:A}),onPanZoomStart:(A,L)=>{const{onViewportChangeStart:T,onMoveStart:D}=S.getState();D==null||D(A,L),T==null||T(L)},onPanZoom:(A,L)=>{const{onViewportChange:T,onMove:D}=S.getState();D==null||D(A,L),T==null||T(L)},onPanZoomEnd:(A,L)=>{const{onViewportChangeEnd:T,onMoveEnd:D}=S.getState();D==null||D(A,L),T==null||T(L)}});const{x:y,y:_,zoom:k}=$.current.getViewport();return S.setState({panZoom:$.current,transform:[y,_,k],domNode:C.current.closest(".react-flow")}),()=>{var A;(A=$.current)==null||A.destroy()}}},[]),j.useEffect(()=>{var y;(y=$.current)==null||y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:m,userSelectionActive:M,noWheelClassName:w,lib:I,onTransformChange:P,connectionInProgress:z,selectionOnDrag:E,paneClickDistance:x})},[e,t,n,r,o,i,s,a,c,O,g,m,M,w,I,P,z,E,x]),N.jsx("div",{className:"react-flow__renderer",ref:C,style:bn,children:v})}const wg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function vg(){const{userSelectionActive:e,userSelectionRect:t}=te(wg,ie);return e&&t?N.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const jn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},bg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Eg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:v}){const w=j.useRef(0),m=oe(),{userSelectionActive:b,elementsSelectable:p,dragging:x,panBy:E,autoPanSpeed:S}=te(bg,ie),C=p&&(e||b),M=j.useRef(null),I=j.useRef(),z=j.useRef(new Set),O=j.useRef(new Set),$=j.useRef(!1),P=j.useRef(!1),y=j.useRef({x:0,y:0}),_=j.useRef(!1),k=R=>{if(P.current||$.current||m.getState().connection.inProgress){P.current=!1,$.current=!1;return}l==null||l(R),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},A=R=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){R.preventDefault();return}u==null||u(R)},L=d?R=>d(R):void 0,T=R=>{P.current&&(R.stopPropagation(),P.current=!1)},D=R=>{var re,ue;if(R.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:B,transform:K}=m.getState();if(I.current=B==null?void 0:B.getBoundingClientRect(),!I.current)return;const Z=R.target===M.current;if(!Z&&!!R.target.closest(".nokey")||!e||!(s&&Z||t)||R.button!==0||!R.isPrimary)return;(ue=(re=R.target)==null?void 0:re.setPointerCapture)==null||ue.call(re,R.pointerId),P.current=!1;const{x:Q,y:ee}=pe(R.nativeEvent,I.current),ne=Tt({x:Q,y:ee},K);m.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:Q,y:ee}}),Z||(R.stopPropagation(),R.preventDefault())};function F(R,B){const{userSelectionRect:K}=m.getState();if(!K)return;const{transform:Z,nodeLookup:X,edgeLookup:U,connectionLookup:Q,triggerNodeChanges:ee,triggerEdgeChanges:ne,defaultEdgeOptions:re}=m.getState(),ue={x:K.startX,y:K.startY},{x:ve,y:be}=ot(ue,Z),ke={startX:ue.x,startY:ue.y,x:R<ve?R:ve,y:B<be?B:be,width:Math.abs(R-ve),height:Math.abs(B-be)},ct=z.current,De=O.current;z.current=new Set(gr(X,ke,Z,n===bt.Partial,!0).map(de=>de.id)),O.current=new Set;const Re=(re==null?void 0:re.selectable)??!0;for(const de of z.current){const Ce=Q.get(de);if(Ce)for(const{edgeId:Me}of Ce.values()){const He=U.get(Me);He&&(He.selectable??Re)&&O.current.add(Me)}}if(!ao(ct,z.current)){const de=Ue(X,z.current,!0);ee(de)}if(!ao(De,O.current)){const de=Ue(U,O.current);ne(de)}m.setState({userSelectionRect:ke,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!o||!I.current)return;const[R,B]=pr(y.current,I.current,S);E({x:R,y:B}).then(K=>{if(!P.current||!K){w.current=requestAnimationFrame(H);return}const{x:Z,y:X}=y.current;F(Z,X),w.current=requestAnimationFrame(H)})}const V=()=>{cancelAnimationFrame(w.current),w.current=0,_.current=!1};j.useEffect(()=>()=>V(),[]);const Y=R=>{const{userSelectionRect:B,transform:K,resetSelectedElements:Z}=m.getState();if(!I.current||!B)return;const{x:X,y:U}=pe(R.nativeEvent,I.current);y.current={x:X,y:U};const Q=ot({x:B.startX,y:B.startY},K);if(!P.current){const ee=t?0:i;if(Math.hypot(X-Q.x,U-Q.y)<=ee)return;Z(),a==null||a(R)}P.current=!0,_.current||(H(),_.current=!0),F(X,U)},q=R=>{var B,K;if(!C){R.target===M.current&&m.getState().connection.inProgress&&($.current=!0);return}R.button===0&&((K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),!b&&R.target===M.current&&m.getState().userSelectionRect&&(k==null||k(R)),m.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(R),m.setState({nodesSelectionActive:z.current.size>0})),V())},J=R=>{var B,K;(K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),V()},G=r===!0||Array.isArray(r)&&r.includes(0);return N.jsxs("div",{className:se(["react-flow__pane",{draggable:G,dragging:x,selection:e}]),onClick:C?void 0:jn(k,M),onContextMenu:jn(A,M),onWheel:jn(L,M),onPointerEnter:C?void 0:f,onPointerMove:C?Y:h,onPointerUp:q,onPointerCancel:C?J:void 0,onPointerDownCapture:C?D:void 0,onClickCapture:C?T:void 0,onPointerLeave:g,ref:M,style:bn,children:[v,N.jsx(vg,{})]})}function rr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function As({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,l]=j.useState(!1),u=j.useRef();return j.useEffect(()=>{if(!t)return u.current=hh({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{rr({id:d,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{var d;(d=u.current)==null||d.destroy(),u.current=void 0}},[t,a,e]),j.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s})},[n,r,t,i,e,o,s]),c}const _g=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ts(){const e=oe();return j.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),d=new Map,f=_g(s),h=o?i[0]:5,g=o?i[1]:5,v=n.direction.x*h*n.factor,w=n.direction.y*g*n.factor;for(const[,m]of l){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+w};o&&(b=At(b,i));const{position:p,positionAbsolute:x}=Ki({nodeId:m.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:a});m.position=p,m.internals.positionAbsolute=x,d.set(m.id,m)}c(d)},[])}const Nr=j.createContext(null),Ng=Nr.Provider;Nr.Consumer;const Os=()=>j.useContext(Nr),Sg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Ps=j.createContext(null);function kg({children:e}){const t=te(Sg,ie);return N.jsx(Ps.Provider,{value:t,children:e})}function Cg(){const e=j.useContext(Ps);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Mg={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Ig=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:l}=s;if(!a&&!o)return Mg;const u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:u,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===nt.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:u&&l}};function Ag({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h){var _,k;const g=s||null,v=e==="target",w=oe(),m=Os(),{connectOnClick:b,noPanClassName:p,rfId:x}=Cg(),{connectingFrom:E,connectingTo:S,clickConnecting:C,isPossibleEndHandle:M,connectionInProcess:I,clickConnectionInProcess:z,valid:O}=te(Ig(m,g,e),ie);m||(k=(_=w.getState()).onError)==null||k.call(_,"010",me.error010());const $=A=>{const{defaultEdgeOptions:L,onConnect:T,hasDefaultEdges:D}=w.getState(),F={...L,...A};if(D){const{edges:H,setEdges:V,onError:Y}=w.getState();V(cg(F,H,{onError:Y}))}T==null||T(F),a==null||a(F)},P=A=>{if(!m)return;const L=is(A.nativeEvent);if(o&&(L&&A.button===0||!L)){const T=w.getState();nr.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:v,handleId:g,nodeId:m,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...D)=>{var F,H;return(H=(F=w.getState()).onConnectEnd)==null?void 0:H.call(F,...D)},updateConnection:T.updateConnection,onConnect:$,isValidConnection:n||((...D)=>{var F,H;return((H=(F=w.getState()).isValidConnection)==null?void 0:H.call(F,...D))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}L?u==null||u(A):d==null||d(A)},y=A=>{const{onClickConnectStart:L,onClickConnectEnd:T,connectionClickStartHandle:D,connectionMode:F,isValidConnection:H,lib:V,rfId:Y,nodeLookup:q,connection:J}=w.getState();if(!m||!D&&!o)return;if(!D){L==null||L(A.nativeEvent,{nodeId:m,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const G=rs(A.target),R=n||H,{connection:B,isValid:K}=nr.isValid(A.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:F,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:R,flowId:Y,doc:G,lib:V,nodeLookup:q});K&&B&&$(B);const Z=structuredClone(J);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,T==null||T(A,Z),w.setState({connectionClickStartHandle:null})};return N.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:C,connectingfrom:E,connectingto:S,valid:O,connectionindicator:r&&(!I||M)&&(I||z?i:o)}]),onMouseDown:P,onTouchStart:P,onClick:b?y:void 0,ref:h,...f,children:c})}const sn=j.memo(Cs(Ag));function Tg({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return N.jsxs(N.Fragment,{children:[e==null?void 0:e.label,N.jsx(sn,{type:"source",position:n,isConnectable:t})]})}function Og({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return N.jsxs(N.Fragment,{children:[N.jsx(sn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,N.jsx(sn,{type:"source",position:r,isConnectable:t})]})}function Pg(){return null}function $g({data:e,isConnectable:t,targetPosition:n=W.Top}){return N.jsxs(N.Fragment,{children:[N.jsx(sn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const an={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Lo={input:Tg,default:Og,output:$g,group:Pg};function Lg(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const jg=e=>{const{width:t,height:n,x:r,y:o}=It(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function Dg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=te(jg,ie),c=Ts(),l=j.useRef(null);j.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const u=!a&&o!==null&&i!==null;if(As({nodeRef:l,disabled:!u}),!u)return null;const d=e?h=>{const g=r.getState().nodes.filter(v=>v.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(an,h.key)&&(h.preventDefault(),c({direction:an[h.key],factor:h.shiftKey?4:1}))};return N.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:N.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const jo=typeof window<"u"?window:void 0,Rg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function $s({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:M,autoPanOnSelection:I,defaultViewport:z,translateExtent:O,minZoom:$,maxZoom:P,preventScrolling:y,onSelectionContextMenu:_,noWheelClassName:k,noPanClassName:A,disableKeyboardA11y:L,onViewportChange:T,isControlledViewport:D}){const{nodesSelectionActive:F,userSelectionActive:H}=te(Rg,ie),V=Nt(l,{target:jo}),Y=Nt(v,{target:jo}),q=Y||M,J=Y||x,G=u&&q!==!0,R=V||H||G;return pg({deleteKeyCode:c,multiSelectionKeyCode:g}),N.jsx(xg,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:Y,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!V&&q,defaultViewport:z,translateExtent:O,minZoom:$,maxZoom:P,zoomActivationKeyCode:w,preventScrolling:y,noWheelClassName:k,noPanClassName:A,onViewportChange:T,isControlledViewport:D,paneClickDistance:a,selectionOnDrag:G,children:N.jsxs(Eg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:q,autoPanOnSelection:I,isSelecting:!!R,selectionMode:d,selectionKeyPressed:V,paneClickDistance:a,selectionOnDrag:G,children:[e,F&&N.jsx(Dg,{onSelectionContextMenu:_,noPanClassName:A,disableKeyboardA11y:L})]})})}$s.displayName="FlowRenderer";const Hg=j.memo($s),zg=e=>t=>e?gr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Fg(e){return te(j.useCallback(zg(e),[e]),ie)}const Bg=e=>e.updateNodeInternals;function Vg(){const e=te(Bg),[t]=j.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})}),e(r)}));return j.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Yg({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=j.useRef(null),s=j.useRef(null),a=j.useRef(e.sourcePosition),c=j.useRef(e.targetPosition),l=j.useRef(t),u=n&&!!e.internals.handleBounds;return j.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[u,e.hidden]),j.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),j.useEffect(()=>{if(i.current){const d=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(d||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Xg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:v,nodeTypes:w,nodeClickDistance:m,onError:b}){const{node:p,internals:x,isParent:E}=te(R=>{const B=R.nodeLookup.get(e),K=R.parentLookup.has(e);return{node:B,internals:B.internals,isParent:K}},ie);let S=p.type||"default",C=(w==null?void 0:w[S])||Lo[S];C===void 0&&(b==null||b("003",me.error003(S)),S="default",C=(w==null?void 0:w.default)||Lo.default);const M=!!(p.draggable||a&&typeof p.draggable>"u"),I=!!(p.selectable||c&&typeof p.selectable>"u"),z=!!(p.connectable||l&&typeof p.connectable>"u"),O=!!(p.focusable||u&&typeof p.focusable>"u"),$=oe(),P=es(p),y=Yg({node:p,nodeType:S,hasDimensions:P,resizeObserver:d}),_=As({nodeRef:y,disabled:p.hidden||!M,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:m}),k=Ts();if(p.hidden)return null;const A=xe(p),L=Lg(p),T=I||M||t||n||r||o,D=n?R=>n(R,{...x.userNode}):void 0,F=r?R=>r(R,{...x.userNode}):void 0,H=o?R=>o(R,{...x.userNode}):void 0,V=i?R=>i(R,{...x.userNode}):void 0,Y=s?R=>s(R,{...x.userNode}):void 0,q=R=>{const{selectNodesOnDrag:B,nodeDragThreshold:K}=$.getState();I&&(!B||!M||K>0)&&rr({id:e,store:$,nodeRef:y}),t&&t(R,{...x.userNode})},J=R=>{if(!(os(R.nativeEvent)||g)){if(Xi.includes(R.key)&&I){const B=R.key==="Escape";rr({id:e,store:$,unselect:B,nodeRef:y})}else if(M&&p.selected&&Object.prototype.hasOwnProperty.call(an,R.key)){R.preventDefault();const{ariaLabelConfig:B}=$.getState();$.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:R.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),k({direction:an[R.key],factor:R.shiftKey?4:1})}}},G=()=>{var Q;if(g||!((Q=y.current)!=null&&Q.matches(":focus-visible")))return;const{transform:R,width:B,height:K,autoPanOnNodeFocus:Z,setCenter:X}=$.getState();if(!Z)return;gr(new Map([[e,p]]),{x:0,y:0,width:B,height:K},R,!0).length>0||X(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:R[2]})};return N.jsx("div",{className:se(["react-flow__node",`react-flow__node-${S}`,{[h]:M},p.className,{selected:p.selected,selectable:I,parent:E,draggable:M,dragging:_}]),ref:y,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:P?"visible":"hidden",...p.style,...L},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:F,onMouseLeave:H,onContextMenu:V,onClick:q,onDoubleClick:Y,onKeyDown:O?J:void 0,tabIndex:O?0:void 0,onFocus:O?G:void 0,role:p.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${_s}-${v}`,"aria-label":p.ariaLabel,...p.domAttributes,children:N.jsx(Ng,{value:e,children:N.jsx(C,{id:e,data:p.data,type:S,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:I,draggable:M,deletable:p.deletable??!0,isConnectable:z,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:_,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...A})})})}var Wg=j.memo(Xg);const Gg=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ls(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=te(Gg,ie),i=Fg(e.onlyRenderVisibleElements),s=Vg();return N.jsx("div",{className:"react-flow__nodes",style:bn,children:i.map(a=>N.jsx(Wg,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}Ls.displayName="NodeRenderer";const qg=j.memo(Ls);function Kg(e){return te(j.useCallback(n=>{if(!e)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&&qf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),ie)}const Zg=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return N.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Ug=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return N.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Do={[nn.Arrow]:Zg,[nn.ArrowClosed]:Ug};function Qg(e){const t=oe();return j.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Do,e)?Do[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",me.error009(e)),null)},[e])}const Jg=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Qg(t);return c?N.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:N.jsx(c,{color:n,strokeWidth:s})}):null},js=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),r=te(i=>i.defaultEdgeOptions),o=j.useMemo(()=>nh(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?N.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:N.jsx("defs",{children:o.map(i=>N.jsx(Jg,{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};js.displayName="MarkerDefinitions";var ep=j.memo(js);function Ds({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[d,f]=j.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",l]),g=j.useRef(null);return j.useEffect(()=>{if(g.current){const v=g.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?N.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:h,visibility:d.width?"visible":"hidden",...u,children:[o&&N.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),N.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}Ds.displayName="EdgeText";const tp=j.memo(Ds);function En({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return N.jsxs(N.Fragment,{children:[N.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l?N.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?N.jsx(tp,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Ro({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===W.Left||e===W.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Rs({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top}){const[s,a]=Ro({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=Ro({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,h]=ss({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${r},${o}`,u,d,f,h]}function Hs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})=>{const[b,p,x]=Rs({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),E=e.isInternal?void 0:t;return N.jsx(En,{id:E,path:b,labelX:p,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})})}const np=Hs({isInternal:!1}),zs=Hs({isInternal:!0});np.displayName="SimpleBezierEdge";zs.displayName="SimpleBezierEdgeInternal";function Fs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=Jn({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}),S=e.isInternal?void 0:t;return N.jsx(En,{id:S,path:p,labelX:x,labelY:E,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:v,markerStart:w,interactionWidth:b})})}const Bs=Fs({isInternal:!1}),Vs=Fs({isInternal:!0});Bs.displayName="SmoothStepEdge";Vs.displayName="SmoothStepEdgeInternal";function Ys(e){return j.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return N.jsx(Bs,{...n,id:r,pathOptions:j.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const rp=Ys({isInternal:!1}),Xs=Ys({isInternal:!0});rp.displayName="StepEdge";Xs.displayName="StepEdgeInternal";function Ws(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})=>{const[w,m,b]=ls({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return N.jsx(En,{id:p,path:w,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}const op=Ws({isInternal:!1}),Gs=Ws({isInternal:!0});op.displayName="StraightEdge";Gs.displayName="StraightEdgeInternal";function qs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=as({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),S=e.isInternal?void 0:t;return N.jsx(En,{id:S,path:p,labelX:x,labelY:E,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:b})})}const ip=qs({isInternal:!1}),Ks=qs({isInternal:!0});ip.displayName="BezierEdge";Ks.displayName="BezierEdgeInternal";const Ho={default:Ks,straight:Gs,step:Xs,smoothstep:Vs,simplebezier:zs},zo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},sp=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,ap=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,Fo="react-flow__edgeupdater";function Bo({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return N.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([Fo,`${Fo}-${a}`]),cx:sp(t,r,e),cy:ap(n,r,e),r,stroke:"transparent",fill:"transparent"})}function cp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:h}){const g=oe(),v=(x,E)=>{if(x.button!==0)return;const{autoPanOnConnect:S,domNode:C,connectionMode:M,connectionRadius:I,lib:z,onConnectStart:O,cancelConnection:$,nodeLookup:P,rfId:y,panBy:_,updateConnection:k}=g.getState(),A=E.type==="target",L=(F,H)=>{f(!1),d==null||d(F,n,E.type,H)},T=F=>l==null?void 0:l(n,F),D=(F,H)=>{f(!0),u==null||u(x,n,E.type),O==null||O(F,H)};nr.onPointerDown(x.nativeEvent,{autoPanOnConnect:S,connectionMode:M,connectionRadius:I,domNode:C,handleId:E.id,nodeId:E.nodeId,nodeLookup:P,isTarget:A,edgeUpdaterType:E.type,lib:z,flowId:y,cancelConnection:$,panBy:_,isValidConnection:(...F)=>{var H,V;return((V=(H=g.getState()).isValidConnection)==null?void 0:V.call(H,...F))??!0},onConnect:T,onConnectStart:D,onConnectEnd:(...F)=>{var H,V;return(V=(H=g.getState()).onConnectEnd)==null?void 0:V.call(H,...F)},onReconnectEnd:L,updateConnection:k,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return N.jsxs(N.Fragment,{children:[(e===!0||e==="source")&&N.jsx(Bo,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&N.jsx(Bo,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function lp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:v,noPanClassName:w,onError:m,disableKeyboardA11y:b}){let p=te(X=>X.edgeLookup.get(e));const x=te(X=>X.defaultEdgeOptions);p=x?{...x,...p}:p;let E=p.type||"default",S=(v==null?void 0:v[E])||Ho[E];S===void 0&&(m==null||m("011",me.error011(E)),E="default",S=(v==null?void 0:v.default)||Ho.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),M=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),I=!!(p.selectable||r&&typeof p.selectable>"u"),z=j.useRef(null),[O,$]=j.useState(!1),[P,y]=j.useState(!1),_=oe(),{zIndex:k=p.zIndex,sourceX:A,sourceY:L,targetX:T,targetY:D,sourcePosition:F,targetPosition:H}=te(j.useCallback(X=>{const U=X.nodeLookup.get(p.source),Q=X.nodeLookup.get(p.target);if(!U||!Q)return zo;const ee=th({id:e,sourceNode:U,targetNode:Q,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:m}),ne=Gf({selected:p.selected,zIndex:p.zIndex,sourceNode:U,targetNode:Q,elevateOnSelect:X.elevateEdgesOnSelect,zIndexMode:X.zIndexMode});return{...ee||zo,zIndex:ne}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,m]),ie),V=j.useMemo(()=>p.markerStart?`url('#${er(p.markerStart,g)}')`:void 0,[p.markerStart,g]),Y=j.useMemo(()=>p.markerEnd?`url('#${er(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||A===null||L===null||T===null||D===null)return null;const q=X=>{var ne;const{addSelectedEdges:U,unselectNodesAndEdges:Q,multiSelectionActive:ee}=_.getState();I&&(_.setState({nodesSelectionActive:!1}),p.selected&&ee?(Q({nodes:[],edges:[p]}),(ne=z.current)==null||ne.blur()):U([e])),o&&o(X,p)},J=i?X=>{i(X,{...p})}:void 0,G=s?X=>{s(X,{...p})}:void 0,R=a?X=>{a(X,{...p})}:void 0,B=c?X=>{c(X,{...p})}:void 0,K=l?X=>{l(X,{...p})}:void 0,Z=X=>{var U;if(!b&&Xi.includes(X.key)&&I){const{unselectNodesAndEdges:Q,addSelectedEdges:ee}=_.getState();X.key==="Escape"?((U=z.current)==null||U.blur(),Q({edges:[p]})):ee([e])}};return N.jsx("svg",{style:{zIndex:k},children:N.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${E}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!I&&!o,updating:O,selectable:I}]),onClick:q,onDoubleClick:J,onContextMenu:G,onMouseEnter:R,onMouseMove:B,onMouseLeave:K,onKeyDown:C?Z:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${Ns}-${g}`:void 0,ref:z,...p.domAttributes,children:[!P&&N.jsx(S,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:I,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:L,targetX:T,targetY:D,sourcePosition:F,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:Y,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),M&&N.jsx(cp,{edge:p,isReconnectable:M,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:L,targetX:T,targetY:D,sourcePosition:F,targetPosition:H,setUpdateHover:$,setReconnecting:y})]})})}var up=j.memo(lp);const dp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Zs({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,onError:p}=te(dp,ie),x=Kg(t);return N.jsxs("div",{className:"react-flow__edges",children:[N.jsx(ep,{defaultColor:e,rfId:n}),x.map(E=>N.jsx(up,{id:E,edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:v},E))]})}Zs.displayName="EdgeRenderer";const fp=j.memo(Zs),Vo=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function hp({children:e}){const t=oe(),n=j.useRef(null),[r]=j.useState(()=>t.getState().transform);return Ms(()=>{let o=null;const i=()=>{const s=t.getState().transform;o&&s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]||(o=s,n.current&&(n.current.style.transform=Vo(s)))};return i(),t.subscribe(i)},[t]),N.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Vo(r)},children:e})}function gp(e){const t=_r(),n=j.useRef(!1);j.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const pp=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function mp(e){const t=te(pp),n=oe();return j.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function yp(e){return e.connection.inProgress?{...e.connection,to:Tt(e.connection.to,e.transform)}:{...e.connection}}function xp(e){return yp}function wp(e){const t=xp();return te(t,ie)}const vp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function bp({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=te(vp,ie);return!(i&&o&&c)?null:N.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:N.jsx("g",{className:se(["react-flow__connection",ns(a)]),children:N.jsx(Us,{style:t,type:n,CustomComponent:r,isValid:a})})})}const Us=({style:e,type:t=Le.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:h}=wp();if(!o)return;if(n)return N.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:ns(r),toNode:u,toHandle:d,pointer:h});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Le.Bezier:[g]=as(v);break;case Le.SimpleBezier:[g]=Rs(v);break;case Le.Step:[g]=Jn({...v,borderRadius:0});break;case Le.SmoothStep:[g]=Jn(v);break;default:[g]=ls(v)}return N.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Us.displayName="ConnectionLine";const Ep={};function Yo(e=Ep){j.useRef(e),oe(),j.useEffect(()=>{},[e])}function _p(){oe(),j.useRef(!1),j.useEffect(()=>{},[])}function Qs({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:M,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:O,translateExtent:$,minZoom:P,maxZoom:y,preventScrolling:_,defaultMarkerColor:k,zoomOnScroll:A,zoomOnPinch:L,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,zoomOnDoubleClick:H,panOnDrag:V,autoPanOnSelection:Y,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneScroll:B,onPaneContextMenu:K,paneClickDistance:Z,nodeClickDistance:X,onEdgeContextMenu:U,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,noDragClassName:ke,noWheelClassName:ct,noPanClassName:De,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,viewport:Me,onViewportChange:He,nodesDraggable:Sn}){return Yo(e),Yo(t),_p(),gp(n),mp(Me),N.jsx(Hg,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneContextMenu:K,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:M,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:z,zoomOnScroll:A,zoomOnPinch:L,zoomOnDoubleClick:H,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,panOnDrag:V,autoPanOnSelection:Y,defaultViewport:O,translateExtent:$,minZoom:P,maxZoom:y,onSelectionContextMenu:d,preventScrolling:_,noDragClassName:ke,noWheelClassName:ct,noPanClassName:De,disableKeyboardA11y:Re,onViewportChange:He,isControlledViewport:!!Me,children:N.jsxs(hp,{children:[N.jsx(fp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,onlyRenderVisibleElements:I,onEdgeContextMenu:U,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,defaultMarkerColor:k,noPanClassName:De,disableKeyboardA11y:Re,rfId:Ce}),N.jsx(bp,{style:v,type:g,component:w,containerStyle:m}),N.jsx("div",{className:"react-flow__edgelabel-renderer"}),N.jsx(qg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:X,onlyRenderVisibleElements:I,noPanClassName:De,noDragClassName:ke,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,nodesDraggable:Sn}),N.jsx("div",{className:"react-flow__viewport-portal"})]})})}Qs.displayName="GraphView";const Np=j.memo(Qs),Sp=Ji(),Xo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,v=new Map,w=new Map,m=r??t??[],b=n??e??[],p=u??[0,0],x=d??vt;fs(v,w,m);const{nodesInitialized:E}=tr(b,h,g,{nodeOrigin:p,nodeExtent:x,zIndexMode:f});let S=[0,0,1];if(s&&o&&i){const C=It(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:M,y:I,zoom:z}=mr(C,o,i,c,l,(a==null?void 0:a.padding)??.1);S=[M,I,z]}return{rfId:"1",width:o??0,height:i??0,transform:S,nodes:b,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:vt,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:nt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,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:Sp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Wi,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},kp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Rh((h,g)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:x,height:E,minZoom:S,maxZoom:C}=g();m&&(await zf({nodes:w,width:x,height:E,panZoom:m,minZoom:S,maxZoom:C},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...Xo({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,fitViewQueued:S,zIndexMode:C,nodesSelectionActive:M}=g(),{nodesInitialized:I,hasSelectedNodes:z}=tr(w,m,b,{nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:C}),O=M&&z;S&&I?(v(),h({nodes:w,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):h({nodes:w,nodesInitialized:I,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:m,edgeLookup:b}=g();fs(m,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,m)=>{if(w){const{setNodes:b}=g();b(w),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:x,nodeOrigin:E,nodeExtent:S,debug:C,fitViewQueued:M,zIndexMode:I}=g(),{changes:z,updatedInternals:O}=lh(w,b,p,x,E,S,I);O&&(ih(b,p,{nodeOrigin:E,nodeExtent:S,zIndexMode:I}),M?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(z==null?void 0:z.length)>0&&(C&&console.log("React Flow: trigger node changes",z),m==null||m(z)))},updateNodePositions:(w,m=!1)=>{const b=[];let p=[];const{nodeLookup:x,triggerNodeChanges:E,connection:S,updateConnection:C,onNodesChangeMiddlewareMap:M}=g();for(const[I,z]of w){const O=x.get(I),$=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(z!=null&&z.position)),P={id:I,type:"position",position:$?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:m};if(O&&S.inProgress&&S.fromNode.id===O.id){const y=qe(O,S.fromHandle,W.Left,!0);C({...S,from:y})}$&&O.parentId&&b.push({id:I,parentId:O.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),p.push(P)}if(b.length>0){const{parentLookup:I,nodeOrigin:z}=g(),O=Er(b,x,I,z);p.push(...O)}for(const I of M.values())p=I(p);E(p)},triggerNodeChanges:w=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:x,debug:E}=g();if(w!=null&&w.length){if(x){const S=ig(w,p);b(S)}E&&console.log("React Flow: trigger node changes",w),m==null||m(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:x,debug:E}=g();if(w!=null&&w.length){if(x){const S=sg(w,p);b(S)}E&&console.log("React Flow: trigger edge changes",w),m==null||m(w)}},addSelectedNodes:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const S=w.map(C=>ze(C,!0));x(S);return}x(Ue(p,new Set([...w]),!0)),E(Ue(b))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const S=w.map(C=>ze(C,!0));E(S);return}E(Ue(b,new Set([...w]))),x(Ue(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:x,triggerNodeChanges:E,triggerEdgeChanges:S}=g(),C=w||p,M=m||b,I=[];for(const O of C){if(!O.selected)continue;const $=x.get(O.id);$&&($.selected=!1),I.push(ze(O.id,!1))}const z=[];for(const O of M)O.selected&&z.push(ze(O.id,!1));E(I),S(z)},setMinZoom:w=>{const{panZoom:m,maxZoom:b}=g();m==null||m.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:m,minZoom:b}=g();m==null||m.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:x}=g();if(!x)return;const E=m.reduce((C,M)=>M.selected?[...C,ze(M.id,!1)]:C,[]),S=w.reduce((C,M)=>M.selected?[...C,ze(M.id,!1)]:C,[]);b(E),p(S)},setNodeExtent:w=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:x,elevateNodesOnSelect:E,nodeExtent:S,zIndexMode:C}=g();w[0][0]===S[0][0]&&w[0][1]===S[0][1]&&w[1][0]===S[1][0]&&w[1][1]===S[1][1]||(tr(m,b,p,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:C}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:b,height:p,panZoom:x,translateExtent:E}=g();return uh({delta:w,panZoom:x,transform:m,translateExtent:E,width:b,height:p})},setCenter:async(w,m,b)=>{const{width:p,height:x,maxZoom:E,panZoom:S}=g();if(!S)return!1;const C=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:E;return await S.setViewport({x:p/2-w*C,y:x/2-m*C,zoom:C},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{h({connection:{...Gi}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Xo()})}},Object.is);function Cp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:h}){const[g]=j.useState(()=>kp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return N.jsx(Hh,{value:g,children:N.jsx(dg,{children:N.jsx(kg,{children:h})})})}function Mp({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h}){return j.useContext(wn)?N.jsx(N.Fragment,{children:e}):N.jsx(Cp,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:e})}const Ip={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Ap({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:M,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:O,onDelete:$,onSelectionChange:P,onSelectionDragStart:y,onSelectionDrag:_,onSelectionDragStop:k,onSelectionContextMenu:A,onSelectionStart:L,onSelectionEnd:T,onBeforeDelete:D,connectionMode:F,connectionLineType:H=Le.Bezier,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,deleteKeyCode:J="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:R=!1,selectionMode:B=bt.Full,panActivationKeyCode:K="Space",multiSelectionKeyCode:Z=_t()?"Meta":"Control",zoomActivationKeyCode:X=_t()?"Meta":"Control",snapToGrid:U,snapGrid:Q,onlyRenderVisibleElements:ee=!1,selectNodesOnDrag:ne,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,nodeOrigin:ke=Ss,edgesFocusable:ct,edgesReconnectable:De,elementsSelectable:Re=!0,defaultViewport:de=Qh,minZoom:Ce=.5,maxZoom:Me=2,translateExtent:He=vt,preventScrolling:Sn=!0,nodeExtent:kn,defaultMarkerColor:Ta="#b1b1b7",zoomOnScroll:Oa=!0,zoomOnPinch:Pa=!0,panOnScroll:$a=!1,panOnScrollSpeed:La=.5,panOnScrollMode:ja=Ve.Free,zoomOnDoubleClick:Da=!0,panOnDrag:Ra=!0,onPaneClick:Ha,onPaneMouseEnter:za,onPaneMouseMove:Fa,onPaneMouseLeave:Ba,onPaneScroll:Va,onPaneContextMenu:Ya,paneClickDistance:Xa=1,nodeClickDistance:Wa=0,children:Ga,onReconnect:qa,onReconnectStart:Ka,onReconnectEnd:Za,onEdgeContextMenu:Ua,onEdgeDoubleClick:Qa,onEdgeMouseEnter:Ja,onEdgeMouseMove:ec,onEdgeMouseLeave:tc,reconnectRadius:nc=10,onNodesChange:rc,onEdgesChange:oc,noDragClassName:ic="nodrag",noWheelClassName:sc="nowheel",noPanClassName:Tr="nopan",fitView:Or,fitViewOptions:Pr,connectOnClick:ac,attributionPosition:cc,proOptions:lc,defaultEdgeOptions:uc,elevateNodesOnSelect:dc=!0,elevateEdgesOnSelect:fc=!1,disableKeyboardA11y:$r=!1,autoPanOnConnect:hc,autoPanOnNodeDrag:gc,autoPanOnSelection:pc=!0,autoPanSpeed:mc,connectionRadius:yc,isValidConnection:xc,onError:wc,style:vc,id:Lr,nodeDragThreshold:bc,connectionDragThreshold:Ec,viewport:_c,onViewportChange:Nc,width:Sc,height:kc,colorMode:Cc="light",debug:Mc,onScroll:$t,ariaLabelConfig:Ic,zIndexMode:jr="basic",...Ac},Tc){const Cn=Lr||"1",Oc=ng(Cc),Pc=j.useCallback(Dr=>{Dr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t==null||$t(Dr)},[$t]);return N.jsx("div",{"data-testid":"rf__wrapper",...Ac,onScroll:Pc,style:{...vc,...Ip},ref:Tc,className:se(["react-flow",o,Oc]),id:Lr,role:"application",children:N.jsxs(Mp,{nodes:e,edges:t,width:Sc,height:kc,fitView:Or,fitViewOptions:Pr,minZoom:Ce,maxZoom:Me,nodeOrigin:ke,nodeExtent:kn,zIndexMode:jr,children:[N.jsx(tg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,edgesFocusable:ct,edgesReconnectable:De,elementsSelectable:Re,elevateNodesOnSelect:dc,elevateEdgesOnSelect:fc,minZoom:Ce,maxZoom:Me,nodeExtent:kn,onNodesChange:rc,onEdgesChange:oc,snapToGrid:U,snapGrid:Q,connectionMode:F,translateExtent:He,connectOnClick:ac,defaultEdgeOptions:uc,fitView:Or,fitViewOptions:Pr,onNodesDelete:z,onEdgesDelete:O,onDelete:$,onNodeDragStart:C,onNodeDrag:M,onNodeDragStop:I,onSelectionDrag:_,onSelectionDragStart:y,onSelectionDragStop:k,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Tr,nodeOrigin:ke,rfId:Cn,autoPanOnConnect:hc,autoPanOnNodeDrag:gc,autoPanSpeed:mc,onError:wc,connectionRadius:yc,isValidConnection:xc,selectNodesOnDrag:ne,nodeDragThreshold:bc,connectionDragThreshold:Ec,onBeforeDelete:D,debug:Mc,ariaLabelConfig:Ic,zIndexMode:jr}),N.jsx(Np,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:H,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,selectionKeyCode:G,selectionOnDrag:R,selectionMode:B,deleteKeyCode:J,multiSelectionKeyCode:Z,panActivationKeyCode:K,zoomActivationKeyCode:X,onlyRenderVisibleElements:ee,defaultViewport:de,translateExtent:He,minZoom:Ce,maxZoom:Me,preventScrolling:Sn,zoomOnScroll:Oa,zoomOnPinch:Pa,zoomOnDoubleClick:Da,panOnScroll:$a,panOnScrollSpeed:La,panOnScrollMode:ja,panOnDrag:Ra,autoPanOnSelection:pc,onPaneClick:Ha,onPaneMouseEnter:za,onPaneMouseMove:Fa,onPaneMouseLeave:Ba,onPaneScroll:Va,onPaneContextMenu:Ya,paneClickDistance:Xa,nodeClickDistance:Wa,onSelectionContextMenu:A,onSelectionStart:L,onSelectionEnd:T,onReconnect:qa,onReconnectStart:Ka,onReconnectEnd:Za,onEdgeContextMenu:Ua,onEdgeDoubleClick:Qa,onEdgeMouseEnter:Ja,onEdgeMouseMove:ec,onEdgeMouseLeave:tc,reconnectRadius:nc,defaultMarkerColor:Ta,noDragClassName:ic,noWheelClassName:sc,noPanClassName:Tr,rfId:Cn,disableKeyboardA11y:$r,nodeExtent:kn,viewport:_c,onViewportChange:Nc,nodesDraggable:re}),N.jsx(Uh,{onSelectionChange:P}),Ga,N.jsx(Wh,{proOptions:lc,position:cc}),N.jsx(Xh,{rfId:Cn,disableKeyboardA11y:$r})]})})}var qy=Cs(Ap);function Ky(){const e=oe();return j.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),o=Array.isArray(t)?t:[t],i=new Map;o.forEach(s=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${s}"]`);a&&i.set(s,{id:s,nodeElement:a,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function Tp({dimensions:e,lineWidth:t,variant:n,className:r}){return N.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function Op({radius:e,className:t}){return N.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var je;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(je||(je={}));const Pp={[je.Dots]:1,[je.Lines]:1,[je.Cross]:6},$p=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Js({id:e,variant:t=je.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:u}){const d=j.useRef(null),{transform:f,patternId:h}=te($p,ie),g=r||Pp[t],v=t===je.Dots,w=t===je.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],x=Array.isArray(i)?i:[i,i],E=w?[p,p]:b,S=[x[0]*f[2]+E[0]/2,x[1]*f[2]+E[1]/2],C=`${h}${e||""}`;return N.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...bn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[N.jsx("pattern",{id:C,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:v?N.jsx(Op,{radius:p/2,className:u}):N.jsx(Tp,{dimensions:E,lineWidth:o,variant:t,className:u})}),N.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}Js.displayName="Background";j.memo(Js);function Lp(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:N.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function jp(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:N.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Dp(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:N.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 Rp(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:N.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 Hp(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:N.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 Vt({children:e,className:t,...n}){return N.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const zp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ea({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:u,position:d="bottom-left",orientation:f="vertical","aria-label":h}){const g=oe(),{isInteractive:v,minZoomReached:w,maxZoomReached:m,ariaLabelConfig:b}=te(zp,ie),{zoomIn:p,zoomOut:x,fitView:E}=_r(),S=()=>{p(),i==null||i()},C=()=>{x(),s==null||s()},M=()=>{E(o),a==null||a()},I=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},z=f==="horizontal"?"horizontal":"vertical";return N.jsxs(vn,{className:se(["react-flow__controls",z,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&N.jsxs(N.Fragment,{children:[N.jsx(Vt,{onClick:S,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:N.jsx(Lp,{})}),N.jsx(Vt,{onClick:C,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:N.jsx(jp,{})})]}),n&&N.jsx(Vt,{className:"react-flow__controls-fitview",onClick:M,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:N.jsx(Dp,{})}),r&&N.jsx(Vt,{className:"react-flow__controls-interactive",onClick:I,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?N.jsx(Hp,{}):N.jsx(Rp,{})}),u]})}ea.displayName="Controls";j.memo(ea);function Fp({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:h}){const{background:g,backgroundColor:v}=i||{},w=s||g||v;return N.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:o,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:d,onClick:h?m=>h(m,e):void 0})}const Bp=j.memo(Fp),Vp=e=>e.nodes.map(t=>t.id),Dn=e=>e instanceof Function?e:()=>e;function Yp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Bp,onClick:s}){const a=te(Vp,ie),c=Dn(t),l=Dn(e),u=Dn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return N.jsx(N.Fragment,{children:a.map(f=>N.jsx(Wp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},f))})}function Xp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:u,y:d,width:f,height:h}=te(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:m,y:b}=v.internals.positionAbsolute,{width:p,height:x}=xe(w);return{node:w,x:m,y:b,width:p,height:x}},ie);return!l||l.hidden||!es(l)?null:N.jsx(a,{x:u,y:d,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const Wp=j.memo(Xp);var Gp=j.memo(Yp);const qp=200,Kp=150,Zp=e=>!e.hidden,Up=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Ui(It(e.nodeLookup,{filter:Zp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Wo=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Qp=(e,t)=>Wo(e.viewBB,t.viewBB)&&Wo(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Jp="react-flow__minimap-desc";function ta({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:v=!1,zoomable:w=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const E=oe(),S=j.useRef(null),{boundingRect:C,panZoom:M,viewBB:I,rfId:z,translateExtent:O,flowWidth:$,flowHeight:P,ariaLabelConfig:y}=te(Up,Qp),_=(e==null?void 0:e.width)??qp,k=(e==null?void 0:e.height)??Kp,A=C.width/_,L=C.height/k,T=Math.max(A,L),D=T*_,F=T*k,H=x*T,V=C.x-(D-C.width)/2-H,Y=C.y-(F-C.height)/2-H,q=D+H*2,J=F+H*2,G=`${Jp}-${z}`,R=j.useRef(0),B=j.useRef();R.current=T,j.useEffect(()=>{const Q=E.getState().panZoom;if(S.current&&Q)return B.current=wh({domNode:S.current,panZoom:Q,getTransform:()=>E.getState().transform,getViewScale:()=>R.current}),()=>{var ee;(ee=B.current)==null||ee.destroy()}},[M]),j.useEffect(()=>{var Q;(Q=B.current)==null||Q.update({translateExtent:O,width:$,height:P,inversePan:b,pannable:v,zoomStep:p,zoomable:w})},[v,w,b,p,O,$,P]);const K=h?Q=>{var re;const[ee,ne]=((re=B.current)==null?void 0:re.pointer(Q))||[0,0];h(Q,{x:ee,y:ne})}:void 0,Z=j.useCallback((Q,ee)=>{const ne=E.getState().nodeLookup.get(ee).internals.userNode;g==null||g(Q,ne)},[g]),X=g?Z:void 0,U=m??y["minimap.ariaLabel"];return N.jsx(vn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T: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:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:N.jsxs("svg",{width:_,height:k,viewBox:`${V} ${Y} ${q} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:S,onClick:K,children:[U&&N.jsx("title",{id:G,children:U}),N.jsx(Gp,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),N.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-H},${Y-H}h${q+H*2}v${J+H*2}h${-q-H*2}z
|
|
22
|
-
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ta.displayName="MiniMap";const Zy=j.memo(ta),e0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,t0={[it.Line]:"right",[it.Handle]:"bottom-right"};function n0({nodeId:e,position:t,variant:n=it.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:v,onResize:w,onResizeEnd:m}){const b=Os(),p=typeof e=="string"?e:b,x=oe(),E=j.useRef(null),S=n===it.Handle,C=te(j.useCallback(e0(S&&h),[S,h]),ie),M=j.useRef(null),I=t??t0[n];j.useEffect(()=>{if(!(!E.current||!p))return M.current||(M.current=Oh({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:O,transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:_,domNode:k}=x.getState();return{nodeLookup:O,transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:_,paneDomNode:k}},onChange:(O,$)=>{const{triggerNodeChanges:P,nodeLookup:y,parentLookup:_,nodeOrigin:k}=x.getState(),A=[],L={x:O.x,y:O.y},T=y.get(p);if(T&&T.expandParent&&T.parentId){const D=T.origin??k,F=O.width??T.measured.width??0,H=O.height??T.measured.height??0,V={id:T.id,parentId:T.parentId,rect:{width:F,height:H,...ts({x:O.x??T.position.x,y:O.y??T.position.y},{width:F,height:H},T.parentId,y,D)}},Y=Er([V],y,_,k);A.push(...Y),L.x=O.x?Math.max(D[0]*F,O.x):void 0,L.y=O.y?Math.max(D[1]*H,O.y):void 0}if(L.x!==void 0&&L.y!==void 0){const D={id:p,type:"position",position:{...L}};A.push(D)}if(O.width!==void 0&&O.height!==void 0){const F={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};A.push(F)}for(const D of $){const F={...D,type:"position"};A.push(F)}P(A)},onEnd:({width:O,height:$})=>{const P={id:p,type:"dimensions",resizing:!1,dimensions:{width:O,height:$}};x.getState().triggerNodeChanges([P])}})),M.current.update({controlPosition:I,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:m,shouldResize:g}),()=>{var O;(O=M.current)==null||O.destroy()}},[I,a,c,l,u,d,v,w,m,g]);const z=I.split("-");return N.jsx("div",{className:se(["react-flow__resize-control","nodrag",...z,n,r]),ref:E,style:{...o,scale:C,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}j.memo(n0);const r0={source:{label:"Input source",helper:"The source badge (VIEW / TABLE / SQL / PATTERN / CONNECTOR)"},fields:{label:"Field count",helper:"The field count shown on each object"},status:{label:"Status",helper:"The published/draft indicator"}};function o0({viewMode:e,onViewModeChange:t,direction:n,onDirectionChange:r,showJoinFields:o,onShowJoinFieldsChange:i,joinFieldsSwitchId:s,objectLabels:a,onObjectLabelsChange:c}){return N.jsxs(N.Fragment,{children:[N.jsx(Mn,{children:"View"}),N.jsx("div",{role:"radiogroup","aria-label":"Card view mode",className:"bg-muted mt-2 grid grid-cols-2 gap-0.5 rounded-md p-0.5",children:Fc.map(l=>N.jsx("button",{type:"button",role:"radio","aria-checked":e===l.value,className:`rounded px-2 py-1 text-sm transition-colors ${e===l.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{t(l.value)},children:l.label},l.value))}),N.jsx(Mn,{className:"mt-3 border-t pt-3",children:"Layout algorithm"}),N.jsx("div",{role:"radiogroup","aria-label":"Layout algorithm",className:"mt-2 space-y-0.5",children:Bc.map(l=>N.jsxs("button",{type:"button",role:"radio","aria-checked":n===l.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{r(l.value)},children:[N.jsx("span",{children:l.label}),n===l.value&&N.jsx(Rr,{className:"h-4 w-4"})]},l.value))}),N.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[N.jsx("label",{htmlFor:s,className:"text-sm",children:"Show join fields"}),N.jsx(Vc,{id:s,checked:o,onCheckedChange:i})]}),N.jsx(Mn,{className:"mt-3 border-t pt-3",children:"Object labels"}),N.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-snug",children:"Tick what every object shows — untick to hide it."}),N.jsx("div",{className:"mt-2 space-y-0.5",children:Yc.map(l=>{const u=r0[l],d=!a[l];return N.jsxs("button",{type:"button",role:"checkbox","aria-checked":d,className:"hover:bg-muted flex w-full items-start gap-2 rounded px-2 py-1.5 text-left",onClick:()=>{c(Xc(a,l))},children:[N.jsx("span",{className:`mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border transition-colors ${d?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-transparent"}`,"aria-hidden":"true",children:N.jsx(Rr,{className:"h-2.5 w-2.5",strokeWidth:3.5})}),N.jsxs("span",{className:"flex min-w-0 flex-col",children:[N.jsx("span",{className:`text-sm font-medium ${d?"text-foreground":"text-muted-foreground"}`,children:u.label}),N.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:u.helper})]})]},l)})}),N.jsxs("div",{className:"mt-1 space-y-0.5 border-t pt-1",children:[N.jsxs("button",{type:"button","aria-pressed":Hr(a),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${Hr(a)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{c(Wc)},children:[N.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"≡"}),"Check all — show everything"]}),N.jsxs("button",{type:"button","aria-pressed":zr(a),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${zr(a)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{c(Gc)},children:[N.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"⊘"}),"Uncheck all — title only"]})]})]})}function Uy(e){const t=j.useId();return N.jsxs(jc,{children:[N.jsx(Dc,{asChild:!0,children:N.jsx(Rc,{variant:"outline",size:"icon",className:"h-12 w-12","aria-label":"Canvas settings",children:N.jsx(Hc,{className:"h-6 w-6"})})}),N.jsx(zc,{align:"end",side:"left",className:"w-56",children:N.jsx(o0,{...e,joinFieldsSwitchId:t})})]})}const Ot={gray:["#000000","#2C2C2C","#606060","#C5C5C5","#E6E6E6","#F7F7F7"],blue:["#4286DE","#609DE4","#86B5EA","#CEE2F7","#E6F0FA","#F2F7FC"],green:["#6ABA5C","#84C77A","#A0D49A","#D9EED7","#ECF7EA","#F5FBF5"],yellow:["#F5C344","#F7CF58","#F9DA7B","#FCF1C9","#FEF7E3","#FEFBF1"],orange:["#E9883C","#ED9F5C","#F0B782","#F8E1CA","#FBEFE3","#FDF6F0"]},i0=Ot.blue[0],s0=Ot.green[0],na=Ot.yellow[0],a0=Ot.orange[0],c0=Ot.gray[2],ra=c0,Qy=i0,Jy=a0,ex="#0084ff",tx=ra,nx=1.5,rx=2.5,ox="8 4",l0=.15,ix="var(--muted-foreground)",sx={width:10,height:10,borderRadius:"50%",background:ra,border:"2px solid var(--background)"},ax={pointerEvents:"all",cursor:"default"},cx=`
|
|
21
|
+
`)),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return L.useEffect(()=>{const c=(t==null?void 0:t.target)??No,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var w,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!l)&&rs(h))return!1;const v=ko(h.code,a);if(i.current.add(h[v]),So(s,i.current,!1)){const b=((m=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:m[0])||h.target,p=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&h.preventDefault(),r(!0)}},d=h=>{const g=ko(h.code,a);So(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function So(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function ko(e,t){return t.includes(e)?"code":"key"}const ag=()=>{const e=oe();return L.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=pr(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},u=n.snapGrid??o,d=n.snapToGrid??i;return Tt(l,r,d,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=ot(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Ss(e,t){const n=[],r=new Map,o=[];for(const i of e)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 t){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 c of s)cg(c,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 cg(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function lg(e,t){return Ss(e,t)}function ug(e,t){return Ss(e,t)}function ze(e,t){return{id:e,type:"select",selected:t}}function Ue(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(ze(i.id,s)))}return r}function Co({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Mo(e){return{id:e.id,type:"remove"}}const dg=Qi();function fg(e,t,n={}){return th(e,t,{...n,onError:n.onError??dg})}const Io=e=>zf(e),hg=e=>Gi(e);function ks(e){return L.forwardRef(e)}const Cs=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Ao(e){const[t,n]=L.useState(BigInt(0)),[r]=L.useState(()=>gg(()=>n(o=>o+BigInt(1))));return Cs(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function gg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ms=L.createContext(null);function pg({children:e}){const t=oe(),n=L.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:d,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let v=c;for(const m of a)v=typeof m=="function"?m(v):m;let w=Co({items:v,lookup:f});for(const m of g.values())w=m(w);u&&l(v),w.length>0?d==null||d(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=Ao(n),o=L.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:d,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;u?l(h):d&&d(Co({items:h,lookup:f}))},[]),i=Ao(o),s=L.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return E.jsx(Ms.Provider,{value:s,children:e})}function mg(){const e=L.useContext(Ms);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const yg=e=>!!e.panZoom;function Er(){const e=ag(),t=oe(),n=mg(),r=te(yg),o=L.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var m,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=Io(d)?d:f.get(d.id),v=g.parentId?es(g.position,g.measured,g.parentId,f,h):g.position,w={...g,position:v,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Et(w)},l=(d,f,h={replace:!1})=>{s(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&Io(w)?w:{...v,...w}}return v}))},u=(d,f,h={replace:!1})=>{a(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&hg(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(h=>[...h,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:h}=t.getState(),[g,v,w]=h;return{nodes:d.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y:v,zoom:w}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:_,edges:S}=await Xf({nodesToRemove:d,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:x}),C=S.length>0,M=_.length>0;if(C){const I=S.map(Mo);w==null||w(S),b(I)}if(M){const I=_.map(Mo);v==null||v(_),m(I)}return(M||C)&&(p==null||p({nodes:_,edges:S})),{deletedNodes:_,deletedEdges:S}},getIntersectingNodes:(d,f=!0,h)=>{const g=ro(d),v=g?d:c(d),w=h!==void 0;return v?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===d.id||!b.internals.positionAbsolute))return!1;const p=Et(w?m:b),x=on(p,v);return f&&x>0||x>=p.width*p.height||x>=v.width*v.height}):[]},isNodeIntersecting:(d,f,h=!0)=>{const v=ro(d)?d:c(d);if(!v)return!1;const w=on(v,f);return h&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(d,f,h={replace:!1})=>{l(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},updateEdge:u,updateEdgeData:(d,f,h={replace:!1})=>{u(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Ff(d,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:d,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${d}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??qf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return L.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const To=e=>e.selected,xg=typeof window<"u"?window:void 0;function wg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=Er(),o=Nt(e,{actInsideInputWithModifier:!1}),i=Nt(t,{target:xg});L.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(To),edges:s.filter(To)}),n.setState({nodesSelectionActive:!1})}},[o]),L.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function vg(e){const t=oe();L.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=mr(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",me.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const bn={position:"absolute",width:"100%",height:"100%",top:0,left:0},bg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Eg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:s=Ve.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:g=!0,children:v,noWheelClassName:w,noPanClassName:m,onViewportChange:b,isControlledViewport:p,paneClickDistance:x,selectionOnDrag:_}){const S=oe(),C=L.useRef(null),{userSelectionActive:M,lib:I,connectionInProgress:z}=te(bg,ie),O=Nt(h),$=L.useRef();vg(C);const P=L.useCallback(y=>{b==null||b({x:y[0],y:y[1],zoom:y[2]}),p||S.setState({transform:y})},[b,p]);return L.useEffect(()=>{if(C.current){$.current=Th({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:A=>S.setState(j=>j.paneDragging===A?j:{paneDragging:A}),onPanZoomStart:(A,j)=>{const{onViewportChangeStart:T,onMoveStart:D}=S.getState();D==null||D(A,j),T==null||T(j)},onPanZoom:(A,j)=>{const{onViewportChange:T,onMove:D}=S.getState();D==null||D(A,j),T==null||T(j)},onPanZoomEnd:(A,j)=>{const{onViewportChangeEnd:T,onMoveEnd:D}=S.getState();D==null||D(A,j),T==null||T(j)}});const{x:y,y:N,zoom:k}=$.current.getViewport();return S.setState({panZoom:$.current,transform:[y,N,k],domNode:C.current.closest(".react-flow")}),()=>{var A;(A=$.current)==null||A.destroy()}}},[]),L.useEffect(()=>{var y;(y=$.current)==null||y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:m,userSelectionActive:M,noWheelClassName:w,lib:I,onTransformChange:P,connectionInProgress:z,selectionOnDrag:_,paneClickDistance:x})},[e,t,n,r,o,i,s,a,c,O,g,m,M,w,I,P,z,_,x]),E.jsx("div",{className:"react-flow__renderer",ref:C,style:bn,children:v})}const _g=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ng(){const{userSelectionActive:e,userSelectionRect:t}=te(_g,ie);return e&&t?E.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const jn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Sg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function kg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:v}){const w=L.useRef(0),m=oe(),{userSelectionActive:b,elementsSelectable:p,dragging:x,panBy:_,autoPanSpeed:S}=te(Sg,ie),C=p&&(e||b),M=L.useRef(null),I=L.useRef(),z=L.useRef(new Set),O=L.useRef(new Set),$=L.useRef(!1),P=L.useRef(!1),y=L.useRef({x:0,y:0}),N=L.useRef(!1),k=R=>{if(P.current||$.current||m.getState().connection.inProgress){P.current=!1,$.current=!1;return}l==null||l(R),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},A=R=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){R.preventDefault();return}u==null||u(R)},j=d?R=>d(R):void 0,T=R=>{P.current&&(R.stopPropagation(),P.current=!1)},D=R=>{var re,ue;if(R.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:B,transform:K}=m.getState();if(I.current=B==null?void 0:B.getBoundingClientRect(),!I.current)return;const Z=R.target===M.current;if(!Z&&!!R.target.closest(".nokey")||!e||!(s&&Z||t)||R.button!==0||!R.isPrimary)return;(ue=(re=R.target)==null?void 0:re.setPointerCapture)==null||ue.call(re,R.pointerId),P.current=!1;const{x:Q,y:ee}=pe(R.nativeEvent,I.current),ne=Tt({x:Q,y:ee},K);m.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:Q,y:ee}}),Z||(R.stopPropagation(),R.preventDefault())};function F(R,B){const{userSelectionRect:K}=m.getState();if(!K)return;const{transform:Z,nodeLookup:X,edgeLookup:U,connectionLookup:Q,triggerNodeChanges:ee,triggerEdgeChanges:ne,defaultEdgeOptions:re}=m.getState(),ue={x:K.startX,y:K.startY},{x:ve,y:be}=ot(ue,Z),ke={startX:ue.x,startY:ue.y,x:R<ve?R:ve,y:B<be?B:be,width:Math.abs(R-ve),height:Math.abs(B-be)},ct=z.current,De=O.current;z.current=new Set(hr(X,ke,Z,n===bt.Partial,!0).map(de=>de.id)),O.current=new Set;const Re=(re==null?void 0:re.selectable)??!0;for(const de of z.current){const Ce=Q.get(de);if(Ce)for(const{edgeId:Me}of Ce.values()){const He=U.get(Me);He&&(He.selectable??Re)&&O.current.add(Me)}}if(!oo(ct,z.current)){const de=Ue(X,z.current,!0);ee(de)}if(!oo(De,O.current)){const de=Ue(U,O.current);ne(de)}m.setState({userSelectionRect:ke,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!o||!I.current)return;const[R,B]=gr(y.current,I.current,S);_({x:R,y:B}).then(K=>{if(!P.current||!K){w.current=requestAnimationFrame(H);return}const{x:Z,y:X}=y.current;F(Z,X),w.current=requestAnimationFrame(H)})}const V=()=>{cancelAnimationFrame(w.current),w.current=0,N.current=!1};L.useEffect(()=>()=>V(),[]);const Y=R=>{const{userSelectionRect:B,transform:K,resetSelectedElements:Z}=m.getState();if(!I.current||!B)return;const{x:X,y:U}=pe(R.nativeEvent,I.current);y.current={x:X,y:U};const Q=ot({x:B.startX,y:B.startY},K);if(!P.current){const ee=t?0:i;if(Math.hypot(X-Q.x,U-Q.y)<=ee)return;Z(),a==null||a(R)}P.current=!0,N.current||(H(),N.current=!0),F(X,U)},q=R=>{var B,K;if(!C){R.target===M.current&&m.getState().connection.inProgress&&($.current=!0);return}R.button===0&&((K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),!b&&R.target===M.current&&m.getState().userSelectionRect&&(k==null||k(R)),m.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(R),m.setState({nodesSelectionActive:z.current.size>0})),V())},J=R=>{var B,K;(K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),V()},G=r===!0||Array.isArray(r)&&r.includes(0);return E.jsxs("div",{className:se(["react-flow__pane",{draggable:G,dragging:x,selection:e}]),onClick:C?void 0:jn(k,M),onContextMenu:jn(A,M),onWheel:jn(j,M),onPointerEnter:C?void 0:f,onPointerMove:C?Y:h,onPointerUp:q,onPointerCancel:C?J:void 0,onPointerDownCapture:C?D:void 0,onClickCapture:C?T:void 0,onPointerLeave:g,ref:M,style:bn,children:[v,E.jsx(Ng,{})]})}function nr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function Is({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,l]=L.useState(!1),u=L.useRef();return L.useEffect(()=>{if(!t)return u.current=yh({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{nr({id:d,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{var d;(d=u.current)==null||d.destroy(),u.current=void 0}},[t,a,e]),L.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s})},[n,r,t,i,e,o,s]),c}const Cg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function As(){const e=oe();return L.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),d=new Map,f=Cg(s),h=o?i[0]:5,g=o?i[1]:5,v=n.direction.x*h*n.factor,w=n.direction.y*g*n.factor;for(const[,m]of l){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+w};o&&(b=At(b,i));const{position:p,positionAbsolute:x}=qi({nodeId:m.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:a});m.position=p,m.internals.positionAbsolute=x,d.set(m.id,m)}c(d)},[])}const _r=L.createContext(null),Mg=_r.Provider;_r.Consumer;const Ts=()=>L.useContext(_r),Ig=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Os=L.createContext(null);function Ag({children:e}){const t=te(Ig,ie);return E.jsx(Os.Provider,{value:t,children:e})}function Tg(){const e=L.useContext(Os);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Og={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Pg=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:l}=s;if(!a&&!o)return Og;const u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:u,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===nt.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:u&&l}};function $g({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h){var N,k;const g=s||null,v=e==="target",w=oe(),m=Ts(),{connectOnClick:b,noPanClassName:p,rfId:x}=Tg(),{connectingFrom:_,connectingTo:S,clickConnecting:C,isPossibleEndHandle:M,connectionInProcess:I,clickConnectionInProcess:z,valid:O}=te(Pg(m,g,e),ie);m||(k=(N=w.getState()).onError)==null||k.call(N,"010",me.error010());const $=A=>{const{defaultEdgeOptions:j,onConnect:T,hasDefaultEdges:D}=w.getState(),F={...j,...A};if(D){const{edges:H,setEdges:V,onError:Y}=w.getState();V(fg(F,H,{onError:Y}))}T==null||T(F),a==null||a(F)},P=A=>{if(!m)return;const j=os(A.nativeEvent);if(o&&(j&&A.button===0||!j)){const T=w.getState();tr.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:v,handleId:g,nodeId:m,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...D)=>{var F,H;return(H=(F=w.getState()).onConnectEnd)==null?void 0:H.call(F,...D)},updateConnection:T.updateConnection,onConnect:$,isValidConnection:n||((...D)=>{var F,H;return((H=(F=w.getState()).isValidConnection)==null?void 0:H.call(F,...D))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}j?u==null||u(A):d==null||d(A)},y=A=>{const{onClickConnectStart:j,onClickConnectEnd:T,connectionClickStartHandle:D,connectionMode:F,isValidConnection:H,lib:V,rfId:Y,nodeLookup:q,connection:J}=w.getState();if(!m||!D&&!o)return;if(!D){j==null||j(A.nativeEvent,{nodeId:m,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const G=ns(A.target),R=n||H,{connection:B,isValid:K}=tr.isValid(A.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:F,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:R,flowId:Y,doc:G,lib:V,nodeLookup:q});K&&B&&$(B);const Z=structuredClone(J);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,T==null||T(A,Z),w.setState({connectionClickStartHandle:null})};return E.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:C,connectingfrom:_,connectingto:S,valid:O,connectionindicator:r&&(!I||M)&&(I||z?i:o)}]),onMouseDown:P,onTouchStart:P,onClick:b?y:void 0,ref:h,...f,children:c})}const sn=L.memo(ks($g));function jg({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return E.jsxs(E.Fragment,{children:[e==null?void 0:e.label,E.jsx(sn,{type:"source",position:n,isConnectable:t})]})}function Lg({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return E.jsxs(E.Fragment,{children:[E.jsx(sn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,E.jsx(sn,{type:"source",position:r,isConnectable:t})]})}function Dg(){return null}function Rg({data:e,isConnectable:t,targetPosition:n=W.Top}){return E.jsxs(E.Fragment,{children:[E.jsx(sn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const an={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Oo={input:jg,default:Lg,output:Rg,group:Dg};function Hg(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const zg=e=>{const{width:t,height:n,x:r,y:o}=It(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function Fg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=te(zg,ie),c=As(),l=L.useRef(null);L.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const u=!a&&o!==null&&i!==null;if(Is({nodeRef:l,disabled:!u}),!u)return null;const d=e?h=>{const g=r.getState().nodes.filter(v=>v.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(an,h.key)&&(h.preventDefault(),c({direction:an[h.key],factor:h.shiftKey?4:1}))};return E.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:E.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const Po=typeof window<"u"?window:void 0,Bg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ps({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:M,autoPanOnSelection:I,defaultViewport:z,translateExtent:O,minZoom:$,maxZoom:P,preventScrolling:y,onSelectionContextMenu:N,noWheelClassName:k,noPanClassName:A,disableKeyboardA11y:j,onViewportChange:T,isControlledViewport:D}){const{nodesSelectionActive:F,userSelectionActive:H}=te(Bg,ie),V=Nt(l,{target:Po}),Y=Nt(v,{target:Po}),q=Y||M,J=Y||x,G=u&&q!==!0,R=V||H||G;return wg({deleteKeyCode:c,multiSelectionKeyCode:g}),E.jsx(Eg,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:Y,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!V&&q,defaultViewport:z,translateExtent:O,minZoom:$,maxZoom:P,zoomActivationKeyCode:w,preventScrolling:y,noWheelClassName:k,noPanClassName:A,onViewportChange:T,isControlledViewport:D,paneClickDistance:a,selectionOnDrag:G,children:E.jsxs(kg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:q,autoPanOnSelection:I,isSelecting:!!R,selectionMode:d,selectionKeyPressed:V,paneClickDistance:a,selectionOnDrag:G,children:[e,F&&E.jsx(Fg,{onSelectionContextMenu:N,noPanClassName:A,disableKeyboardA11y:j})]})})}Ps.displayName="FlowRenderer";const Vg=L.memo(Ps),Yg=e=>t=>e?hr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Xg(e){return te(L.useCallback(Yg(e),[e]),ie)}const Wg=e=>e.updateNodeInternals;function Gg(){const e=te(Wg),[t]=L.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})}),e(r)}));return L.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function qg({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=L.useRef(null),s=L.useRef(null),a=L.useRef(e.sourcePosition),c=L.useRef(e.targetPosition),l=L.useRef(t),u=n&&!!e.internals.handleBounds;return L.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[u,e.hidden]),L.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),L.useEffect(()=>{if(i.current){const d=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(d||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Kg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:v,nodeTypes:w,nodeClickDistance:m,onError:b}){const{node:p,internals:x,isParent:_}=te(R=>{const B=R.nodeLookup.get(e),K=R.parentLookup.has(e);return{node:B,internals:B.internals,isParent:K}},ie);let S=p.type||"default",C=(w==null?void 0:w[S])||Oo[S];C===void 0&&(b==null||b("003",me.error003(S)),S="default",C=(w==null?void 0:w.default)||Oo.default);const M=!!(p.draggable||a&&typeof p.draggable>"u"),I=!!(p.selectable||c&&typeof p.selectable>"u"),z=!!(p.connectable||l&&typeof p.connectable>"u"),O=!!(p.focusable||u&&typeof p.focusable>"u"),$=oe(),P=Ji(p),y=qg({node:p,nodeType:S,hasDimensions:P,resizeObserver:d}),N=Is({nodeRef:y,disabled:p.hidden||!M,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:m}),k=As();if(p.hidden)return null;const A=xe(p),j=Hg(p),T=I||M||t||n||r||o,D=n?R=>n(R,{...x.userNode}):void 0,F=r?R=>r(R,{...x.userNode}):void 0,H=o?R=>o(R,{...x.userNode}):void 0,V=i?R=>i(R,{...x.userNode}):void 0,Y=s?R=>s(R,{...x.userNode}):void 0,q=R=>{const{selectNodesOnDrag:B,nodeDragThreshold:K}=$.getState();I&&(!B||!M||K>0)&&nr({id:e,store:$,nodeRef:y}),t&&t(R,{...x.userNode})},J=R=>{if(!(rs(R.nativeEvent)||g)){if(Yi.includes(R.key)&&I){const B=R.key==="Escape";nr({id:e,store:$,unselect:B,nodeRef:y})}else if(M&&p.selected&&Object.prototype.hasOwnProperty.call(an,R.key)){R.preventDefault();const{ariaLabelConfig:B}=$.getState();$.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:R.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),k({direction:an[R.key],factor:R.shiftKey?4:1})}}},G=()=>{var Q;if(g||!((Q=y.current)!=null&&Q.matches(":focus-visible")))return;const{transform:R,width:B,height:K,autoPanOnNodeFocus:Z,setCenter:X}=$.getState();if(!Z)return;hr(new Map([[e,p]]),{x:0,y:0,width:B,height:K},R,!0).length>0||X(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:R[2]})};return E.jsx("div",{className:se(["react-flow__node",`react-flow__node-${S}`,{[h]:M},p.className,{selected:p.selected,selectable:I,parent:_,draggable:M,dragging:N}]),ref:y,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:P?"visible":"hidden",...p.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:F,onMouseLeave:H,onContextMenu:V,onClick:q,onDoubleClick:Y,onKeyDown:O?J:void 0,tabIndex:O?0:void 0,onFocus:O?G:void 0,role:p.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Es}-${v}`,"aria-label":p.ariaLabel,...p.domAttributes,children:E.jsx(Mg,{value:e,children:E.jsx(C,{id:e,data:p.data,type:S,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:I,draggable:M,deletable:p.deletable??!0,isConnectable:z,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:N,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...A})})})}var Zg=L.memo(Kg);const Ug=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function $s(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=te(Ug,ie),i=Xg(e.onlyRenderVisibleElements),s=Gg();return E.jsx("div",{className:"react-flow__nodes",style:bn,children:i.map(a=>E.jsx(Zg,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}$s.displayName="NodeRenderer";const Qg=L.memo($s);function Jg(e){return te(L.useCallback(n=>{if(!e)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&&Qf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),ie)}const ep=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return E.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},tp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return E.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},$o={[nn.Arrow]:ep,[nn.ArrowClosed]:tp};function np(e){const t=oe();return L.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call($o,e)?$o[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",me.error009(e)),null)},[e])}const rp=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=np(t);return c?E.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:E.jsx(c,{color:n,strokeWidth:s})}):null},js=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),r=te(i=>i.defaultEdgeOptions),o=L.useMemo(()=>sh(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?E.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:E.jsx("defs",{children:o.map(i=>E.jsx(rp,{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};js.displayName="MarkerDefinitions";var op=L.memo(js);function Ls({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[d,f]=L.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",l]),g=L.useRef(null);return L.useEffect(()=>{if(g.current){const v=g.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?E.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:h,visibility:d.width?"visible":"hidden",...u,children:[o&&E.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),E.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}Ls.displayName="EdgeText";const ip=L.memo(Ls);function En({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return E.jsxs(E.Fragment,{children:[E.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l?E.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?E.jsx(ip,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function jo({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===W.Left||e===W.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Ds({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top}){const[s,a]=jo({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=jo({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,h]=is({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${r},${o}`,u,d,f,h]}function Rs(e){return L.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})=>{const[b,p,x]=Ds({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),_=e.isInternal?void 0:t;return E.jsx(En,{id:_,path:b,labelX:p,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})})}const sp=Rs({isInternal:!1}),Hs=Rs({isInternal:!0});sp.displayName="SimpleBezierEdge";Hs.displayName="SimpleBezierEdgeInternal";function zs(e){return L.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,_]=Qn({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}),S=e.isInternal?void 0:t;return E.jsx(En,{id:S,path:p,labelX:x,labelY:_,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:v,markerStart:w,interactionWidth:b})})}const Fs=zs({isInternal:!1}),Bs=zs({isInternal:!0});Fs.displayName="SmoothStepEdge";Bs.displayName="SmoothStepEdgeInternal";function Vs(e){return L.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return E.jsx(Fs,{...n,id:r,pathOptions:L.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const ap=Vs({isInternal:!1}),Ys=Vs({isInternal:!0});ap.displayName="StepEdge";Ys.displayName="StepEdgeInternal";function Xs(e){return L.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})=>{const[w,m,b]=cs({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return E.jsx(En,{id:p,path:w,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}const cp=Xs({isInternal:!1}),Ws=Xs({isInternal:!0});cp.displayName="StraightEdge";Ws.displayName="StraightEdgeInternal";function Gs(e){return L.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,_]=ss({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),S=e.isInternal?void 0:t;return E.jsx(En,{id:S,path:p,labelX:x,labelY:_,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:b})})}const lp=Gs({isInternal:!1}),qs=Gs({isInternal:!0});lp.displayName="BezierEdge";qs.displayName="BezierEdgeInternal";const Lo={default:qs,straight:Ws,step:Ys,smoothstep:Bs,simplebezier:Hs},Do={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},up=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,dp=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,Ro="react-flow__edgeupdater";function Ho({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return E.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([Ro,`${Ro}-${a}`]),cx:up(t,r,e),cy:dp(n,r,e),r,stroke:"transparent",fill:"transparent"})}function fp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:h}){const g=oe(),v=(x,_)=>{if(x.button!==0)return;const{autoPanOnConnect:S,domNode:C,connectionMode:M,connectionRadius:I,lib:z,onConnectStart:O,cancelConnection:$,nodeLookup:P,rfId:y,panBy:N,updateConnection:k}=g.getState(),A=_.type==="target",j=(F,H)=>{f(!1),d==null||d(F,n,_.type,H)},T=F=>l==null?void 0:l(n,F),D=(F,H)=>{f(!0),u==null||u(x,n,_.type),O==null||O(F,H)};tr.onPointerDown(x.nativeEvent,{autoPanOnConnect:S,connectionMode:M,connectionRadius:I,domNode:C,handleId:_.id,nodeId:_.nodeId,nodeLookup:P,isTarget:A,edgeUpdaterType:_.type,lib:z,flowId:y,cancelConnection:$,panBy:N,isValidConnection:(...F)=>{var H,V;return((V=(H=g.getState()).isValidConnection)==null?void 0:V.call(H,...F))??!0},onConnect:T,onConnectStart:D,onConnectEnd:(...F)=>{var H,V;return(V=(H=g.getState()).onConnectEnd)==null?void 0:V.call(H,...F)},onReconnectEnd:j,updateConnection:k,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return E.jsxs(E.Fragment,{children:[(e===!0||e==="source")&&E.jsx(Ho,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&E.jsx(Ho,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function hp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:v,noPanClassName:w,onError:m,disableKeyboardA11y:b}){let p=te(X=>X.edgeLookup.get(e));const x=te(X=>X.defaultEdgeOptions);p=x?{...x,...p}:p;let _=p.type||"default",S=(v==null?void 0:v[_])||Lo[_];S===void 0&&(m==null||m("011",me.error011(_)),_="default",S=(v==null?void 0:v.default)||Lo.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),M=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),I=!!(p.selectable||r&&typeof p.selectable>"u"),z=L.useRef(null),[O,$]=L.useState(!1),[P,y]=L.useState(!1),N=oe(),{zIndex:k=p.zIndex,sourceX:A,sourceY:j,targetX:T,targetY:D,sourcePosition:F,targetPosition:H}=te(L.useCallback(X=>{const U=X.nodeLookup.get(p.source),Q=X.nodeLookup.get(p.target);if(!U||!Q)return Do;const ee=ih({id:e,sourceNode:U,targetNode:Q,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:m}),ne=Uf({selected:p.selected,zIndex:p.zIndex,sourceNode:U,targetNode:Q,elevateOnSelect:X.elevateEdgesOnSelect,zIndexMode:X.zIndexMode});return{...ee||Do,zIndex:ne}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,m]),ie),V=L.useMemo(()=>p.markerStart?`url('#${Jn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),Y=L.useMemo(()=>p.markerEnd?`url('#${Jn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||A===null||j===null||T===null||D===null)return null;const q=X=>{var ne;const{addSelectedEdges:U,unselectNodesAndEdges:Q,multiSelectionActive:ee}=N.getState();I&&(N.setState({nodesSelectionActive:!1}),p.selected&&ee?(Q({nodes:[],edges:[p]}),(ne=z.current)==null||ne.blur()):U([e])),o&&o(X,p)},J=i?X=>{i(X,{...p})}:void 0,G=s?X=>{s(X,{...p})}:void 0,R=a?X=>{a(X,{...p})}:void 0,B=c?X=>{c(X,{...p})}:void 0,K=l?X=>{l(X,{...p})}:void 0,Z=X=>{var U;if(!b&&Yi.includes(X.key)&&I){const{unselectNodesAndEdges:Q,addSelectedEdges:ee}=N.getState();X.key==="Escape"?((U=z.current)==null||U.blur(),Q({edges:[p]})):ee([e])}};return E.jsx("svg",{style:{zIndex:k},children:E.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${_}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!I&&!o,updating:O,selectable:I}]),onClick:q,onDoubleClick:J,onContextMenu:G,onMouseEnter:R,onMouseMove:B,onMouseLeave:K,onKeyDown:C?Z:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${_s}-${g}`:void 0,ref:z,...p.domAttributes,children:[!P&&E.jsx(S,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:I,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:j,targetX:T,targetY:D,sourcePosition:F,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:Y,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),M&&E.jsx(fp,{edge:p,isReconnectable:M,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:j,targetX:T,targetY:D,sourcePosition:F,targetPosition:H,setUpdateHover:$,setReconnecting:y})]})})}var gp=L.memo(hp);const pp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ks({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,onError:p}=te(pp,ie),x=Jg(t);return E.jsxs("div",{className:"react-flow__edges",children:[E.jsx(op,{defaultColor:e,rfId:n}),x.map(_=>E.jsx(gp,{id:_,edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:v},_))]})}Ks.displayName="EdgeRenderer";const mp=L.memo(Ks),zo=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function yp({children:e}){const t=oe(),n=L.useRef(null),[r]=L.useState(()=>t.getState().transform);return Cs(()=>{let o=null;const i=()=>{const s=t.getState().transform;o&&s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]||(o=s,n.current&&(n.current.style.transform=zo(s)))};return i(),t.subscribe(i)},[t]),E.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:zo(r)},children:e})}function xp(e){const t=Er(),n=L.useRef(!1);L.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const wp=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function vp(e){const t=te(wp),n=oe();return L.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function bp(e){return e.connection.inProgress?{...e.connection,to:Tt(e.connection.to,e.transform)}:{...e.connection}}function Ep(e){return bp}function _p(e){const t=Ep();return te(t,ie)}const Np=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Sp({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=te(Np,ie);return!(i&&o&&c)?null:E.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:E.jsx("g",{className:se(["react-flow__connection",ts(a)]),children:E.jsx(Zs,{style:t,type:n,CustomComponent:r,isValid:a})})})}const Zs=({style:e,type:t=je.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:h}=_p();if(!o)return;if(n)return E.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:ts(r),toNode:u,toHandle:d,pointer:h});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case je.Bezier:[g]=ss(v);break;case je.SimpleBezier:[g]=Ds(v);break;case je.Step:[g]=Qn({...v,borderRadius:0});break;case je.SmoothStep:[g]=Qn(v);break;default:[g]=cs(v)}return E.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Zs.displayName="ConnectionLine";const kp={};function Fo(e=kp){L.useRef(e),oe(),L.useEffect(()=>{},[e])}function Cp(){oe(),L.useRef(!1),L.useEffect(()=>{},[])}function Us({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:M,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:O,translateExtent:$,minZoom:P,maxZoom:y,preventScrolling:N,defaultMarkerColor:k,zoomOnScroll:A,zoomOnPinch:j,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,zoomOnDoubleClick:H,panOnDrag:V,autoPanOnSelection:Y,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneScroll:B,onPaneContextMenu:K,paneClickDistance:Z,nodeClickDistance:X,onEdgeContextMenu:U,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,noDragClassName:ke,noWheelClassName:ct,noPanClassName:De,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,viewport:Me,onViewportChange:He,nodesDraggable:Sn}){return Fo(e),Fo(t),Cp(),xp(n),vp(Me),E.jsx(Vg,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneContextMenu:K,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:M,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:z,zoomOnScroll:A,zoomOnPinch:j,zoomOnDoubleClick:H,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,panOnDrag:V,autoPanOnSelection:Y,defaultViewport:O,translateExtent:$,minZoom:P,maxZoom:y,onSelectionContextMenu:d,preventScrolling:N,noDragClassName:ke,noWheelClassName:ct,noPanClassName:De,disableKeyboardA11y:Re,onViewportChange:He,isControlledViewport:!!Me,children:E.jsxs(yp,{children:[E.jsx(mp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,onlyRenderVisibleElements:I,onEdgeContextMenu:U,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,defaultMarkerColor:k,noPanClassName:De,disableKeyboardA11y:Re,rfId:Ce}),E.jsx(Sp,{style:v,type:g,component:w,containerStyle:m}),E.jsx("div",{className:"react-flow__edgelabel-renderer"}),E.jsx(Qg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:X,onlyRenderVisibleElements:I,noPanClassName:De,noDragClassName:ke,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,nodesDraggable:Sn}),E.jsx("div",{className:"react-flow__viewport-portal"})]})})}Us.displayName="GraphView";const Mp=L.memo(Us),Ip=Qi(),Bo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,v=new Map,w=new Map,m=r??t??[],b=n??e??[],p=u??[0,0],x=d??vt;ds(v,w,m);const{nodesInitialized:_}=er(b,h,g,{nodeOrigin:p,nodeExtent:x,zIndexMode:f});let S=[0,0,1];if(s&&o&&i){const C=It(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:M,y:I,zoom:z}=pr(C,o,i,c,l,(a==null?void 0:a.padding)??.1);S=[M,I,z]}return{rfId:"1",width:o??0,height:i??0,transform:S,nodes:b,nodesInitialized:_,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:vt,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:nt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,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:{...Wi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ip,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Xi,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},Ap=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Bh((h,g)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:x,height:_,minZoom:S,maxZoom:C}=g();m&&(await Yf({nodes:w,width:x,height:_,panZoom:m,minZoom:S,maxZoom:C},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...Bo({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:_,fitViewQueued:S,zIndexMode:C,nodesSelectionActive:M}=g(),{nodesInitialized:I,hasSelectedNodes:z}=er(w,m,b,{nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:C}),O=M&&z;S&&I?(v(),h({nodes:w,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):h({nodes:w,nodesInitialized:I,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:m,edgeLookup:b}=g();ds(m,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,m)=>{if(w){const{setNodes:b}=g();b(w),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:x,nodeOrigin:_,nodeExtent:S,debug:C,fitViewQueued:M,zIndexMode:I}=g(),{changes:z,updatedInternals:O}=hh(w,b,p,x,_,S,I);O&&(lh(b,p,{nodeOrigin:_,nodeExtent:S,zIndexMode:I}),M?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(z==null?void 0:z.length)>0&&(C&&console.log("React Flow: trigger node changes",z),m==null||m(z)))},updateNodePositions:(w,m=!1)=>{const b=[];let p=[];const{nodeLookup:x,triggerNodeChanges:_,connection:S,updateConnection:C,onNodesChangeMiddlewareMap:M}=g();for(const[I,z]of w){const O=x.get(I),$=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(z!=null&&z.position)),P={id:I,type:"position",position:$?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:m};if(O&&S.inProgress&&S.fromNode.id===O.id){const y=qe(O,S.fromHandle,W.Left,!0);C({...S,from:y})}$&&O.parentId&&b.push({id:I,parentId:O.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),p.push(P)}if(b.length>0){const{parentLookup:I,nodeOrigin:z}=g(),O=br(b,x,I,z);p.push(...O)}for(const I of M.values())p=I(p);_(p)},triggerNodeChanges:w=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:x,debug:_}=g();if(w!=null&&w.length){if(x){const S=lg(w,p);b(S)}_&&console.log("React Flow: trigger node changes",w),m==null||m(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:x,debug:_}=g();if(w!=null&&w.length){if(x){const S=ug(w,p);b(S)}_&&console.log("React Flow: trigger edge changes",w),m==null||m(w)}},addSelectedNodes:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:_}=g();if(m){const S=w.map(C=>ze(C,!0));x(S);return}x(Ue(p,new Set([...w]),!0)),_(Ue(b))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:_}=g();if(m){const S=w.map(C=>ze(C,!0));_(S);return}_(Ue(b,new Set([...w]))),x(Ue(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=g(),C=w||p,M=m||b,I=[];for(const O of C){if(!O.selected)continue;const $=x.get(O.id);$&&($.selected=!1),I.push(ze(O.id,!1))}const z=[];for(const O of M)O.selected&&z.push(ze(O.id,!1));_(I),S(z)},setMinZoom:w=>{const{panZoom:m,maxZoom:b}=g();m==null||m.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:m,minZoom:b}=g();m==null||m.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:x}=g();if(!x)return;const _=m.reduce((C,M)=>M.selected?[...C,ze(M.id,!1)]:C,[]),S=w.reduce((C,M)=>M.selected?[...C,ze(M.id,!1)]:C,[]);b(_),p(S)},setNodeExtent:w=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:x,elevateNodesOnSelect:_,nodeExtent:S,zIndexMode:C}=g();w[0][0]===S[0][0]&&w[0][1]===S[0][1]&&w[1][0]===S[1][0]&&w[1][1]===S[1][1]||(er(m,b,p,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:C}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:b,height:p,panZoom:x,translateExtent:_}=g();return gh({delta:w,panZoom:x,transform:m,translateExtent:_,width:b,height:p})},setCenter:async(w,m,b)=>{const{width:p,height:x,maxZoom:_,panZoom:S}=g();if(!S)return!1;const C=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:_;return await S.setViewport({x:p/2-w*C,y:x/2-m*C,zoom:C},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{h({connection:{...Wi}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Bo()})}},Object.is);function Tp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:h}){const[g]=L.useState(()=>Ap({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return E.jsx(Vh,{value:g,children:E.jsx(pg,{children:E.jsx(Ag,{children:h})})})}function Op({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h}){return L.useContext(wn)?E.jsx(E.Fragment,{children:e}):E.jsx(Tp,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:e})}const Pp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function $p({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:_,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:M,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:O,onDelete:$,onSelectionChange:P,onSelectionDragStart:y,onSelectionDrag:N,onSelectionDragStop:k,onSelectionContextMenu:A,onSelectionStart:j,onSelectionEnd:T,onBeforeDelete:D,connectionMode:F,connectionLineType:H=je.Bezier,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,deleteKeyCode:J="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:R=!1,selectionMode:B=bt.Full,panActivationKeyCode:K="Space",multiSelectionKeyCode:Z=_t()?"Meta":"Control",zoomActivationKeyCode:X=_t()?"Meta":"Control",snapToGrid:U,snapGrid:Q,onlyRenderVisibleElements:ee=!1,selectNodesOnDrag:ne,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,nodeOrigin:ke=Ns,edgesFocusable:ct,edgesReconnectable:De,elementsSelectable:Re=!0,defaultViewport:de=ng,minZoom:Ce=.5,maxZoom:Me=2,translateExtent:He=vt,preventScrolling:Sn=!0,nodeExtent:kn,defaultMarkerColor:Pa="#b1b1b7",zoomOnScroll:$a=!0,zoomOnPinch:ja=!0,panOnScroll:La=!1,panOnScrollSpeed:Da=.5,panOnScrollMode:Ra=Ve.Free,zoomOnDoubleClick:Ha=!0,panOnDrag:za=!0,onPaneClick:Fa,onPaneMouseEnter:Ba,onPaneMouseMove:Va,onPaneMouseLeave:Ya,onPaneScroll:Xa,onPaneContextMenu:Wa,paneClickDistance:Ga=1,nodeClickDistance:qa=0,children:Ka,onReconnect:Za,onReconnectStart:Ua,onReconnectEnd:Qa,onEdgeContextMenu:Ja,onEdgeDoubleClick:ec,onEdgeMouseEnter:tc,onEdgeMouseMove:nc,onEdgeMouseLeave:rc,reconnectRadius:oc=10,onNodesChange:ic,onEdgesChange:sc,noDragClassName:ac="nodrag",noWheelClassName:cc="nowheel",noPanClassName:Ar="nopan",fitView:Tr,fitViewOptions:Or,connectOnClick:lc,attributionPosition:uc,proOptions:dc,defaultEdgeOptions:fc,elevateNodesOnSelect:hc=!0,elevateEdgesOnSelect:gc=!1,disableKeyboardA11y:Pr=!1,autoPanOnConnect:pc,autoPanOnNodeDrag:mc,autoPanOnSelection:yc=!0,autoPanSpeed:xc,connectionRadius:wc,isValidConnection:vc,onError:bc,style:Ec,id:$r,nodeDragThreshold:_c,connectionDragThreshold:Nc,viewport:Sc,onViewportChange:kc,width:Cc,height:Mc,colorMode:Ic="light",debug:Ac,onScroll:$t,ariaLabelConfig:Tc,zIndexMode:jr="basic",...Oc},Pc){const Cn=$r||"1",$c=sg(Ic),jc=L.useCallback(Lr=>{Lr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t==null||$t(Lr)},[$t]);return E.jsx("div",{"data-testid":"rf__wrapper",...Oc,onScroll:jc,style:{...Ec,...Pp},ref:Pc,className:se(["react-flow",o,$c]),id:$r,role:"application",children:E.jsxs(Op,{nodes:e,edges:t,width:Cc,height:Mc,fitView:Tr,fitViewOptions:Or,minZoom:Ce,maxZoom:Me,nodeOrigin:ke,nodeExtent:kn,zIndexMode:jr,children:[E.jsx(ig,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,edgesFocusable:ct,edgesReconnectable:De,elementsSelectable:Re,elevateNodesOnSelect:hc,elevateEdgesOnSelect:gc,minZoom:Ce,maxZoom:Me,nodeExtent:kn,onNodesChange:ic,onEdgesChange:sc,snapToGrid:U,snapGrid:Q,connectionMode:F,translateExtent:He,connectOnClick:lc,defaultEdgeOptions:fc,fitView:Tr,fitViewOptions:Or,onNodesDelete:z,onEdgesDelete:O,onDelete:$,onNodeDragStart:C,onNodeDrag:M,onNodeDragStop:I,onSelectionDrag:N,onSelectionDragStart:y,onSelectionDragStop:k,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ar,nodeOrigin:ke,rfId:Cn,autoPanOnConnect:pc,autoPanOnNodeDrag:mc,autoPanSpeed:xc,onError:bc,connectionRadius:wc,isValidConnection:vc,selectNodesOnDrag:ne,nodeDragThreshold:_c,connectionDragThreshold:Nc,onBeforeDelete:D,debug:Ac,ariaLabelConfig:Tc,zIndexMode:jr}),E.jsx(Mp,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:_,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:H,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,selectionKeyCode:G,selectionOnDrag:R,selectionMode:B,deleteKeyCode:J,multiSelectionKeyCode:Z,panActivationKeyCode:K,zoomActivationKeyCode:X,onlyRenderVisibleElements:ee,defaultViewport:de,translateExtent:He,minZoom:Ce,maxZoom:Me,preventScrolling:Sn,zoomOnScroll:$a,zoomOnPinch:ja,zoomOnDoubleClick:Ha,panOnScroll:La,panOnScrollSpeed:Da,panOnScrollMode:Ra,panOnDrag:za,autoPanOnSelection:yc,onPaneClick:Fa,onPaneMouseEnter:Ba,onPaneMouseMove:Va,onPaneMouseLeave:Ya,onPaneScroll:Xa,onPaneContextMenu:Wa,paneClickDistance:Ga,nodeClickDistance:qa,onSelectionContextMenu:A,onSelectionStart:j,onSelectionEnd:T,onReconnect:Za,onReconnectStart:Ua,onReconnectEnd:Qa,onEdgeContextMenu:Ja,onEdgeDoubleClick:ec,onEdgeMouseEnter:tc,onEdgeMouseMove:nc,onEdgeMouseLeave:rc,reconnectRadius:oc,defaultMarkerColor:Pa,noDragClassName:ac,noWheelClassName:cc,noPanClassName:Ar,rfId:Cn,disableKeyboardA11y:Pr,nodeExtent:kn,viewport:Sc,onViewportChange:kc,nodesDraggable:re}),E.jsx(tg,{onSelectionChange:P}),Ka,E.jsx(Zh,{proOptions:dc,position:uc}),E.jsx(Kh,{rfId:Cn,disableKeyboardA11y:Pr})]})})}var rx=ks($p);function ox(){const e=oe();return L.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),o=Array.isArray(t)?t:[t],i=new Map;o.forEach(s=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${s}"]`);a&&i.set(s,{id:s,nodeElement:a,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function jp({dimensions:e,lineWidth:t,variant:n,className:r}){return E.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function Lp({radius:e,className:t}){return E.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var Le;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Le||(Le={}));const Dp={[Le.Dots]:1,[Le.Lines]:1,[Le.Cross]:6},Rp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Qs({id:e,variant:t=Le.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:u}){const d=L.useRef(null),{transform:f,patternId:h}=te(Rp,ie),g=r||Dp[t],v=t===Le.Dots,w=t===Le.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],x=Array.isArray(i)?i:[i,i],_=w?[p,p]:b,S=[x[0]*f[2]+_[0]/2,x[1]*f[2]+_[1]/2],C=`${h}${e||""}`;return E.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...bn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[E.jsx("pattern",{id:C,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:v?E.jsx(Lp,{radius:p/2,className:u}):E.jsx(jp,{dimensions:_,lineWidth:o,variant:t,className:u})}),E.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}Qs.displayName="Background";L.memo(Qs);function Hp(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:E.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function zp(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:E.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Fp(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:E.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 Bp(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.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 Vp(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.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 Vt({children:e,className:t,...n}){return E.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const Yp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Js({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:u,position:d="bottom-left",orientation:f="vertical","aria-label":h}){const g=oe(),{isInteractive:v,minZoomReached:w,maxZoomReached:m,ariaLabelConfig:b}=te(Yp,ie),{zoomIn:p,zoomOut:x,fitView:_}=Er(),S=()=>{p(),i==null||i()},C=()=>{x(),s==null||s()},M=()=>{_(o),a==null||a()},I=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},z=f==="horizontal"?"horizontal":"vertical";return E.jsxs(vn,{className:se(["react-flow__controls",z,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&E.jsxs(E.Fragment,{children:[E.jsx(Vt,{onClick:S,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:E.jsx(Hp,{})}),E.jsx(Vt,{onClick:C,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:E.jsx(zp,{})})]}),n&&E.jsx(Vt,{className:"react-flow__controls-fitview",onClick:M,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:E.jsx(Fp,{})}),r&&E.jsx(Vt,{className:"react-flow__controls-interactive",onClick:I,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?E.jsx(Vp,{}):E.jsx(Bp,{})}),u]})}Js.displayName="Controls";L.memo(Js);function Xp({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:h}){const{background:g,backgroundColor:v}=i||{},w=s||g||v;return E.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:o,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:d,onClick:h?m=>h(m,e):void 0})}const Wp=L.memo(Xp),Gp=e=>e.nodes.map(t=>t.id),Ln=e=>e instanceof Function?e:()=>e;function qp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Wp,onClick:s}){const a=te(Gp,ie),c=Ln(t),l=Ln(e),u=Ln(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return E.jsx(E.Fragment,{children:a.map(f=>E.jsx(Zp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},f))})}function Kp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:u,y:d,width:f,height:h}=te(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:m,y:b}=v.internals.positionAbsolute,{width:p,height:x}=xe(w);return{node:w,x:m,y:b,width:p,height:x}},ie);return!l||l.hidden||!Ji(l)?null:E.jsx(a,{x:u,y:d,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const Zp=L.memo(Kp);var Up=L.memo(qp);const Qp=200,Jp=150,e0=e=>!e.hidden,t0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Zi(It(e.nodeLookup,{filter:e0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Vo=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,n0=(e,t)=>Vo(e.viewBB,t.viewBB)&&Vo(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,r0="react-flow__minimap-desc";function ea({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:v=!1,zoomable:w=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const _=oe(),S=L.useRef(null),{boundingRect:C,panZoom:M,viewBB:I,rfId:z,translateExtent:O,flowWidth:$,flowHeight:P,ariaLabelConfig:y}=te(t0,n0),N=(e==null?void 0:e.width)??Qp,k=(e==null?void 0:e.height)??Jp,A=C.width/N,j=C.height/k,T=Math.max(A,j),D=T*N,F=T*k,H=x*T,V=C.x-(D-C.width)/2-H,Y=C.y-(F-C.height)/2-H,q=D+H*2,J=F+H*2,G=`${r0}-${z}`,R=L.useRef(0),B=L.useRef();R.current=T,L.useEffect(()=>{const Q=_.getState().panZoom;if(S.current&&Q)return B.current=_h({domNode:S.current,panZoom:Q,getTransform:()=>_.getState().transform,getViewScale:()=>R.current}),()=>{var ee;(ee=B.current)==null||ee.destroy()}},[M]),L.useEffect(()=>{var Q;(Q=B.current)==null||Q.update({translateExtent:O,width:$,height:P,inversePan:b,pannable:v,zoomStep:p,zoomable:w})},[v,w,b,p,O,$,P]);const K=h?Q=>{var re;const[ee,ne]=((re=B.current)==null?void 0:re.pointer(Q))||[0,0];h(Q,{x:ee,y:ne})}:void 0,Z=L.useCallback((Q,ee)=>{const ne=_.getState().nodeLookup.get(ee).internals.userNode;g==null||g(Q,ne)},[g]),X=g?Z:void 0,U=m??y["minimap.ariaLabel"];return E.jsx(vn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T: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:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:E.jsxs("svg",{width:N,height:k,viewBox:`${V} ${Y} ${q} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:S,onClick:K,children:[U&&E.jsx("title",{id:G,children:U}),E.jsx(Up,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),E.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-H},${Y-H}h${q+H*2}v${J+H*2}h${-q-H*2}z
|
|
22
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ea.displayName="MiniMap";const ix=L.memo(ea),o0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,i0={[it.Line]:"right",[it.Handle]:"bottom-right"};function s0({nodeId:e,position:t,variant:n=it.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:v,onResize:w,onResizeEnd:m}){const b=Ts(),p=typeof e=="string"?e:b,x=oe(),_=L.useRef(null),S=n===it.Handle,C=te(L.useCallback(o0(S&&h),[S,h]),ie),M=L.useRef(null),I=t??i0[n];L.useEffect(()=>{if(!(!_.current||!p))return M.current||(M.current=Lh({domNode:_.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:O,transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:N,domNode:k}=x.getState();return{nodeLookup:O,transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:N,paneDomNode:k}},onChange:(O,$)=>{const{triggerNodeChanges:P,nodeLookup:y,parentLookup:N,nodeOrigin:k}=x.getState(),A=[],j={x:O.x,y:O.y},T=y.get(p);if(T&&T.expandParent&&T.parentId){const D=T.origin??k,F=O.width??T.measured.width??0,H=O.height??T.measured.height??0,V={id:T.id,parentId:T.parentId,rect:{width:F,height:H,...es({x:O.x??T.position.x,y:O.y??T.position.y},{width:F,height:H},T.parentId,y,D)}},Y=br([V],y,N,k);A.push(...Y),j.x=O.x?Math.max(D[0]*F,O.x):void 0,j.y=O.y?Math.max(D[1]*H,O.y):void 0}if(j.x!==void 0&&j.y!==void 0){const D={id:p,type:"position",position:{...j}};A.push(D)}if(O.width!==void 0&&O.height!==void 0){const F={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};A.push(F)}for(const D of $){const F={...D,type:"position"};A.push(F)}P(A)},onEnd:({width:O,height:$})=>{const P={id:p,type:"dimensions",resizing:!1,dimensions:{width:O,height:$}};x.getState().triggerNodeChanges([P])}})),M.current.update({controlPosition:I,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:m,shouldResize:g}),()=>{var O;(O=M.current)==null||O.destroy()}},[I,a,c,l,u,d,v,w,m,g]);const z=I.split("-");return E.jsx("div",{className:se(["react-flow__resize-control","nodrag",...z,n,r]),ref:_,style:{...o,scale:C,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}L.memo(s0);const a0={compact:"Data Marts and joins",erd:"Data Marts with their fields"};function c0({viewMode:e}){return e==="erd"?E.jsxs("svg",{width:"140",height:"56",viewBox:"0 0 140 56",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[E.jsx("rect",{x:"6",y:"5",width:"40",height:"46",rx:"4"}),E.jsx("path",{d:"M6 15h40"}),E.jsx("path",{d:"M12 23h24M12 31h18M12 39h26",strokeWidth:"1"}),E.jsx("rect",{x:"94",y:"5",width:"40",height:"46",rx:"4"}),E.jsx("path",{d:"M94 15h40"}),E.jsx("path",{d:"M100 23h22M100 31h26M100 39h16",strokeWidth:"1"}),E.jsx("path",{d:"M46 23 C70 23 70 31 94 31"}),E.jsx("circle",{cx:"46",cy:"23",r:"2",fill:"currentColor"}),E.jsx("circle",{cx:"94",cy:"31",r:"2",fill:"currentColor"})]}):E.jsxs("svg",{width:"140",height:"56",viewBox:"0 0 140 56",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:[E.jsx("rect",{x:"6",y:"18",width:"36",height:"20",rx:"4"}),E.jsx("rect",{x:"98",y:"5",width:"36",height:"18",rx:"4"}),E.jsx("rect",{x:"98",y:"33",width:"36",height:"18",rx:"4"}),E.jsx("path",{d:"M42 28 C70 28 70 14 98 14"}),E.jsx("path",{d:"M42 28 C70 28 70 42 98 42"})]})}function l0({direction:e}){return E.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="horizontal"?E.jsxs(E.Fragment,{children:[E.jsx("rect",{x:"2",y:"9",width:"6",height:"6",rx:"1.5"}),E.jsx("rect",{x:"16",y:"3",width:"6",height:"6",rx:"1.5"}),E.jsx("rect",{x:"16",y:"15",width:"6",height:"6",rx:"1.5"}),E.jsx("path",{d:"M8 12h4M12 6v12M12 6h4M12 18h4"})]}):E.jsxs(E.Fragment,{children:[E.jsx("rect",{x:"9",y:"2",width:"6",height:"6",rx:"1.5"}),E.jsx("rect",{x:"3",y:"16",width:"6",height:"6",rx:"1.5"}),E.jsx("rect",{x:"15",y:"16",width:"6",height:"6",rx:"1.5"}),E.jsx("path",{d:"M12 8v4M6 12h12M6 12v4M18 12v4"})]})})}function Yo({children:e,muted:t}){return E.jsx("span",{className:`flex min-h-[22px] items-center gap-1.5 text-xs font-semibold tracking-[0.04em] uppercase ${t?"text-muted-foreground/70":"text-muted-foreground"}`,children:e})}function u0({viewMode:e,onViewModeChange:t,direction:n,onDirectionChange:r,showJoinFields:o,onShowJoinFieldsChange:i,joinFieldsSwitchId:s,objectLabels:a,onObjectLabelsChange:c,objectLabelOptions:l}){const u=l.filter(h=>!Dr.includes(h.part)),d=l.filter(h=>Dr.includes(h.part)),f=e!=="erd";return E.jsxs("div",{className:"flex flex-col gap-4",children:[E.jsx("div",{role:"radiogroup","aria-label":"Card view mode",className:"grid grid-cols-2 gap-2",children:Vc.map(h=>{const g=e===h.value,v=`${s}-view-${h.value}`;return E.jsxs("button",{type:"button",role:"radio","aria-checked":g,"aria-label":h.label,"aria-describedby":v,className:`flex cursor-pointer flex-col gap-2 rounded-[10px] border-2 p-2.5 text-left transition-colors ${g?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,onClick:()=>{t(h.value)},children:[E.jsx("span",{className:`bg-background flex h-[60px] items-center justify-center rounded-md border ${g?"text-primary":"text-muted-foreground/60"}`,children:E.jsx(c0,{viewMode:h.value})}),E.jsxs("span",{className:"flex flex-col gap-0.5",children:[E.jsx("span",{className:"text-foreground text-sm font-semibold",children:h.label}),E.jsx("span",{id:v,className:"text-muted-foreground text-xs",children:a0[h.value]})]})]},h.value)})}),E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("div",{role:"radiogroup","aria-label":"Layout algorithm",className:"bg-muted flex gap-0.5 rounded-lg p-0.5",children:Yc.map(h=>{const g=n===h.value;return E.jsxs("button",{type:"button",role:"radio","aria-checked":g,className:`flex h-8 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-[13px] transition-colors ${g?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{r(h.value)},children:[E.jsx(l0,{direction:h.value}),h.label]},h.value)})}),E.jsx("span",{className:"grow"}),E.jsxs("button",{type:"button",role:"switch","aria-checked":o,className:`inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border px-3 text-[13px] transition-colors ${o?"border-primary/40 bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-muted/50"}`,onClick:()=>{i(!o)},children:[E.jsx(Xc,{className:"h-[15px] w-[15px]","aria-hidden":"true"}),"Show join fields"]})]}),E.jsx("div",{className:"bg-border h-px"}),E.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[E.jsx(Xo,{heading:E.jsx(Yo,{children:"Card content"}),label:"Card content",idPrefix:`${s}-card`,options:u,objectLabels:a,onObjectLabelsChange:c}),d.length>0&&E.jsx(Xo,{heading:E.jsxs(Yo,{muted:f,children:["Field rows",f&&E.jsx("span",{className:"bg-muted text-muted-foreground rounded-lg px-1.5 py-px text-[10.5px] font-normal tracking-normal normal-case",children:"ERD only"})]}),label:"Field rows",idPrefix:`${s}-rows`,options:d,disabled:f,objectLabels:a,onObjectLabelsChange:c})]}),E.jsxs("div",{className:"flex gap-2 border-t pt-2.5",children:[E.jsx("button",{type:"button",className:"text-primary hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 text-[13px]",onClick:()=>{c(Wc)},children:"Show all"}),E.jsx("button",{type:"button",className:"text-primary hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 text-[13px]",onClick:()=>{c(Gc)},children:"Title only"})]})]})}function d0({label:e,text:t}){return E.jsxs(Zc,{children:[E.jsx(Uc,{asChild:!0,children:E.jsx("button",{type:"button","aria-label":`About ${e}`,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 inline-flex h-6 w-6 shrink-0 cursor-default items-center justify-center rounded opacity-0 transition-opacity outline-none group-hover/row:opacity-100 focus-visible:opacity-100 focus-visible:ring-[3px]",children:E.jsx(Qc,{className:"size-3.5","aria-hidden":"true"})})}),E.jsx(Jc,{side:"top",className:"max-w-xs",children:t})]})}function Xo({heading:e,label:t,idPrefix:n,options:r,disabled:o=!1,objectLabels:i,onObjectLabelsChange:s}){return E.jsxs("div",{role:"group","aria-label":t,className:"flex min-w-0 flex-col gap-0.5",children:[e,r.map(({part:a,label:c,helper:l})=>{const u=`${n}-${a}`;return E.jsxs("div",{className:`group/row -mx-1.5 flex min-h-[34px] items-center rounded-md pr-0.5 pl-1.5 transition-colors ${o?"":"hover:bg-muted/60"}`,children:[E.jsxs("label",{htmlFor:u,className:`flex min-w-0 flex-1 items-center gap-2 self-stretch text-[13.5px] ${o?"text-muted-foreground/70 cursor-not-allowed":"text-foreground cursor-pointer"}`,children:[E.jsx(qc,{id:u,checked:!i[a],disabled:o,onCheckedChange:()=>{s(Kc(i,a))}}),E.jsx("span",{className:"min-w-0 truncate",children:c})]}),E.jsx(d0,{label:c,text:l})]},a)})]})}function sx(e){const t=L.useId();return E.jsxs(Rc,{children:[E.jsx(Hc,{asChild:!0,children:E.jsx(zc,{variant:"outline",size:"icon",className:"h-12 w-12","aria-label":"Canvas settings",children:E.jsx(Fc,{className:"h-6 w-6"})})}),E.jsx(Bc,{align:"end",side:"left",collisionPadding:8,className:"max-h-(--radix-popover-content-available-height) w-[400px] max-w-[calc(100vw-16px)] overflow-y-auto rounded-[14px] p-4",children:E.jsx(u0,{...e,joinFieldsSwitchId:t})})]})}const Ot={gray:["#000000","#2C2C2C","#606060","#C5C5C5","#E6E6E6","#F7F7F7"],blue:["#4286DE","#609DE4","#86B5EA","#CEE2F7","#E6F0FA","#F2F7FC"],green:["#6ABA5C","#84C77A","#A0D49A","#D9EED7","#ECF7EA","#F5FBF5"],yellow:["#F5C344","#F7CF58","#F9DA7B","#FCF1C9","#FEF7E3","#FEFBF1"],orange:["#E9883C","#ED9F5C","#F0B782","#F8E1CA","#FBEFE3","#FDF6F0"]},f0=Ot.blue[0],ax=Ot.green[0],h0=Ot.yellow[0],g0=Ot.orange[0],p0=Ot.gray[2],ta=p0,cx=f0,lx=g0,ux="#0084ff",dx=ta,fx=1.5,hx=2.5,gx="8 4",m0=.15,px="var(--muted-foreground)",mx={width:10,height:10,borderRadius:"50%",background:ta,border:"2px solid var(--background)"},yx={pointerEvents:"all",cursor:"default"},xx=`
|
|
23
23
|
@keyframes node-pulse {
|
|
24
24
|
0%, 100% { box-shadow: 0 0 0 3px rgba(66, 134, 222, 0.25), 0 0 12px rgba(66, 134, 222, 0.4); }
|
|
25
25
|
50% { box-shadow: 0 0 0 6px rgba(66, 134, 222, 0.15), 0 0 20px rgba(66, 134, 222, 0.5); }
|
|
26
26
|
}
|
|
27
|
-
`,lx={highlighted:!1,dimmed:!1};function ux(e,t,n,r){const o=t.trim().toLowerCase(),i=new Map;for(const s of e){const a=o!==""&&r(s).toLowerCase().includes(o);i.set(n(s),{highlighted:a,dimmed:o!==""&&!a})}return i}function dx(e){if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.position.x),n=Math.min(n,i.position.y),r=Math.max(r,i.position.x+(i.width??0)),o=Math.max(o,i.position.y+(i.height??0));return{minX:t,minY:n,maxX:r,maxY:o}}function fx(e,t,n,r,o){const i=o-t.maxX*e.zoom,s=n-o-t.minX*e.zoom,a=o-t.maxY*e.zoom,c=r-o-t.minY*e.zoom;return{x:Math.min(Math.max(e.x,i),s),y:Math.min(Math.max(e.y,a),c),zoom:e.zoom}}var oa=Object.defineProperty,u0=(e,t,n)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d0=(e,t)=>{for(var n in t)oa(e,n,{get:t[n],enumerable:!0})},f0=(e,t,n)=>u0(e,t+"",n),ia={};d0(ia,{Graph:()=>we,alg:()=>kr});var h0=Object.defineProperty,sa=(e,t)=>{for(var n in t)h0(e,n,{get:t[n],enumerable:!0})},Sr=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let o of r)n.add(o);return Array.from(n.values())}}isLeaf(e){var t;let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),((t=n==null?void 0:n.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=ht(this._isDirected,o,i,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,i,s);let u=g0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Go(this._preds[i],o),Go(this._sucs[o],i),this._in[i][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Rn(this._isDirected,e):ht(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"||r===null?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Rn(this._isDirected,e):ht(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Rn(this._isDirected,e):ht(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],qo(this._preds[s],i),qo(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function Go(e,t){e[t]?e[t]++:e[t]=1}function qo(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function ht(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function g0(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function Rn(e,t){return ht(e,t.v,t.w,t.name)}var p0={};sa(p0,{read:()=>w0,write:()=>m0});function m0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:y0(e),edges:x0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function y0(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function x0(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function w0(e){let t=new Sr(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var kr={};sa(kr,{CycleException:()=>ln,bellmanFord:()=>aa,components:()=>E0,dijkstra:()=>cn,dijkstraAll:()=>S0,findCycles:()=>k0,floydWarshall:()=>M0,isAcyclic:()=>A0,postorder:()=>O0,preorder:()=>P0,prim:()=>$0,shortestPaths:()=>L0,tarjan:()=>la,topsort:()=>ua});var v0=()=>1;function aa(e,t,n,r){return b0(e,String(t),n||v0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function b0(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(d){let f=o[d.v],h=o[d.w];if(!f||!h)return;let g=n(d);f.distance+g<h.distance&&(o[d.w]={distance:f.distance+g,predecessor:d.v},i=!0)},l=function(){a.forEach(function(d){r(d).forEach(function(f){let h=f.v===d?f.v:f.w,g=h===f.v?f.w:f.v;c({v:h,w:g})})})};a.forEach(function(d){let f=d===t?0:Number.POSITIVE_INFINITY;o[d]={distance:f,predecessor:""}});let u=a.length;for(let d=1;d<u&&(i=!1,s++,l(),!!i);d++);if(s===u-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function E0(e){let t={},n=[],r;function o(i){var s,a;i in t||(t[i]=!0,r.push(i),(s=e.successors(i))==null||s.forEach(o),(a=e.predecessors(i))==null||a.forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var ca=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},_0=()=>1;function cn(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return N0(e,String(t),n||_0,r||o)}function N0(e,t,n,r){let o={},i=new ca,s,a,c=function(l){let u=l.v!==s?l.v:l.w,d=o[u];if(!d)return;let f=n(l),h=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+f);h<d.distance&&(d.distance=h,d.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(l){let u=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},i.add(l,u)});i.size()>0;){s=i.removeMin();let l=o[s];if(!l||l.distance===Number.POSITIVE_INFINITY)break;a=l,r(s).forEach(c)}return o}function S0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=cn(e,o,t,n),r},{})}function la(e){let t=0,n=[],r={},o=[];function i(s){var a;let c=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),(a=e.successors(s))==null||a.forEach(function(l){if(l in r){let u=r[l];u!=null&&u.onStack&&(c.lowlink=Math.min(c.lowlink,u.index))}else{i(l);let u=r[l];u&&(c.lowlink=Math.min(c.lowlink,u.lowlink))}}),c.lowlink===c.index){let l=[],u;do{u=n.pop();let d=r[u];d&&(d.onStack=!1),l.push(u)}while(s!==u);o.push(l)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function k0(e){return la(e).filter(function(t){var n;let r=t[0];return r?t.length>1||t.length===1&&((n=e.outEdges(r,r))!=null?n:[]).length>0:!1})}var C0=()=>1;function M0(e,t,n){return I0(e,t||C0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function I0(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){let s={};r[i]=s,s[i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(s[a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let c=a.v===i?a.w:a.v,l=t(a);s[c]={distance:l,predecessor:i}})}),o.forEach(function(i){let s=r[i];s&&o.forEach(function(a){let c=r[a];c&&o.forEach(function(l){let u=c[i],d=s[l],f=c[l];if(u&&d&&f){let h=u.distance+d.distance;h<f.distance&&(f.distance=h,f.predecessor=d.predecessor)}})})}),r}var ln=class extends Error{constructor(e){super(e),this.name="CycleException"}};function ua(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new ln;i in t||(n[i]=!0,t[i]=!0,(s=e.predecessors(i))==null||s.forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new ln;return r}function A0(e){try{ua(e)}catch(t){if(t instanceof ln)return!1;throw t}return!0}function T0(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=da(e,a,n==="post",s,i,r,o)}),o}function da(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=da(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function fa(e,t,n){return T0(e,t,n,function(r,o){return r.push(o),r},[])}function O0(e,t){return fa(e,t,"post")}function P0(e,t){return fa(e,t,"pre")}function $0(e,t){var n;let r=new Sr,o={},i=new ca,s;function a(u){let d=u.v===s?u.w:u.v,f=i.priority(d);if(f!==void 0){let h=t(u);h<f&&(o[d]=s,i.decrease(d,h))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(u){i.add(u,Number.POSITIVE_INFINITY),r.setNode(u)});let c=e.nodes()[0];c!==void 0&&i.decrease(c,0);let l=!1;for(;i.size()>0;){if(s=i.removeMin(),s in o)r.setEdge(s,o[s]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}(n=e.nodeEdges(s))==null||n.forEach(a)}return r}function L0(e,t,n,r){return j0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function j0(e,t,n,r){if(n===void 0)return cn(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=i[s];if(a===void 0)continue;let c=r(a);for(let l=0;l<c.length;l++){let u=c[l];if(!u)continue;let d=u.v===a?u.v:u.w,f=d===u.v?u.w:u.v;n({v:d,w:f})<0&&(o=!0)}if(o)return aa(e,t,n,r)}return cn(e,t,n,r)}var we=Sr;function at(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Cr(r);return n.dummy=t,e.setNode(o,n),o}function D0(e){let t=new we().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function ha(e){let t=new we({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Ko(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,l=a):(o<0&&(s=-s),c=s,l=s*i/o),{x:n+c,y:r+l}}function Pt(e){let t=St(pa(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function R0(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=_e(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function H0(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=_e(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function Zo(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),at(e,"border",o,t)}function z0(e,t=ga){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var ga=65535;function _e(e,t){if(t.length>ga){let n=z0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function pa(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return _e(Math.max,t)}function F0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function B0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function ma(e,t){return t()}var V0=0;function Cr(e){let t=++V0;return e+(""+t)}function St(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function un(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _n(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function Y0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Nn="\0";function ya(e,t,n){var r,o,i,s,a,c;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let l=!0;t.edgeObj.w===n.edgeObj.w&&(l=!1);let u=l?(o=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?o:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,d=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===t.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&v[1].rank===u}),f=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===n.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&v[1].rank===u});if(!d||!f)return 0;let h=(a=d[1].order)!=null?a:NaN,g=(c=f[1].order)!=null?c:NaN;return isNaN(h-g)?0:h-g}var X0="3.1.1",W0=class{constructor(){f0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Uo(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Uo(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,G0)),n=n._prev;return"["+e.join(", ")+"]"}};function Uo(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function G0(e,t){if(e!=="_next"&&e!=="_prev")return t}var q0=W0,K0=()=>1;function Z0(e,t){if(e.nodeCount()<=1)return[];let n=Q0(e,t||K0);return U0(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function U0(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Hn(e,t,n,a);for(;a=i.dequeue();)Hn(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(Hn(e,t,n,a,!0)||[]);break}}}return o}function Hn(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=c,or(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,or(t,n,u)}),e.removeNode(r.v),s}function Q0(e,t){let n=new we,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,l=t(a),u=c+l;n.setEdge(a.v,a.w,u);let d=n.node(a.v),f=n.node(a.w);o=Math.max(o,d.out+=l),r=Math.max(r,f.in+=l)});let i=J0(o+r+3).map(()=>new q0),s=r+1;return n.nodes().forEach(a=>{or(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function or(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function J0(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function em(e,t){(e.graph().acyclicer==="greedy"?Z0(e,n(e)):tm(e,t??null)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,Cr("rev"))});function n(r){return o=>r.edge(o).weight}}function tm(e,t){let n=[],r={},o={};function i(c){Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,e.outEdges(c).forEach(l=>{Object.hasOwn(r,l.w)?n.push(l):i(l.w)}),delete r[c])}function s(c){var l;Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,(l=e.outEdges(c))==null||l.forEach(u=>{var d,f;Object.hasOwn(r,u.w)||((d=t.node(c))==null?void 0:d.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&rm(e,u.w,u)?n.push(u):s(u.w)}),delete r[c])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function nm(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function rm(e,t,n){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(t)}function om(e){e.graph().dummyChains=[],e.edges().forEach(t=>im(e,t))}function im(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<i;++d,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=at(e,"edge",u,"_d"),r===c&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,l,{weight:a.weight},s),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function sm(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Mr(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=_e(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function st(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var xa=am;function am(e){let t=new we({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;cm(t,e)<o&&(i=lm(t,e),!!i);)s=t.hasNode(i.v)?st(e,i):-st(e,i),um(t,e,s);return t}function cm(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!st(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function lm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=st(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function um(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:dm,postorder:fm}=kr,hm=Ke;Ke.initLowLimValues=Ar;Ke.initCutValues=Ir;Ke.calcCutValue=wa;Ke.leaveEdge=ba;Ke.enterEdge=Ea;Ke.exchangeEdges=_a;function Ke(e){e=D0(e),Mr(e);let t=xa(e);Ar(t),Ir(t,e);let n,r;for(;n=ba(t);)r=Ea(t,e,n),_a(t,e,n,r)}function Ir(e,t){let n=fm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>gm(e,t,r))}function gm(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=wa(e,t,n)}function wa(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let l=c.v===n,u=l?c.w:c.v;if(u!==r){let d=l===o,f=t.edge(c).weight;if(s+=d?f:-f,mm(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Ar(e,t){arguments.length<2&&(t=e.nodes()[0]),va(e,{},1,t)}function va(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=va(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function ba(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Ea(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(l=>c===Qo(e,e.node(l.v),a)&&c!==Qo(e,e.node(l.w),a)).reduce((l,u)=>st(t,u)<st(t,l)?u:l)}function _a(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Ar(e),Ir(e,t),pm(e,t)}function pm(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=dm(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function mm(e,t,n){return e.hasEdge(t,n)}function Qo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var ym=xm;function xm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Jo(e);break;case"tight-tree":vm(e);break;case"longest-path":wm(e);break;case"none":break;default:Jo(e)}}var wm=Mr;function vm(e){Mr(e),xa(e)}function Jo(e){hm(e)}var bm=Em;function Em(e){let t=Nm(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=_m(e,t,i.v,i.w),a=s.path,c=s.lca,l=0,u=a[l],d=!0;for(;r!==i.w;){if(o=e.node(r),d){for(;(u=a[l])!==c&&e.node(u).maxRank<o.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<a.length-1&&e.node(a[l+1]).minRank<=o.rank;)l++;u=a[l]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function _m(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)i.push(u);return{path:o.concat(i.reverse()),lca:l}}function Nm(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Nn).forEach(r),t}function Sm(e){let t=at(e,"root",{},"_root"),n=km(e),r=Object.values(n),o=_e(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Cm(e)+1;e.children(Nn).forEach(a=>{Na(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function Na(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let l=Zo(e,"_bt"),u=Zo(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(u,s),d.borderBottom=u,c.forEach(f=>{var h;Na(e,t,n,r,o,i,f);let g=e.node(f),v=g.borderTop?g.borderTop:f,w=g.borderBottom?g.borderBottom:f,m=g.borderTop?r:2*r,b=v!==w?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(l,v,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(w,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function km(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Nn).forEach(r=>n(r,1)),t}function Cm(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Mm(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Im=Am;function Am(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)ei(e,"borderLeft","_bl",n,o,i),ei(e,"borderRight","_br",n,o,i)}}e.children(Nn).forEach(t)}function ei(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=at(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function Tm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Sa(e)}function Om(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Pm(e),(n==="lr"||n==="rl")&&($m(e),Sa(e))}function Sa(e){e.nodes().forEach(t=>ti(e.node(t))),e.edges().forEach(t=>ti(e.edge(t)))}function ti(e){let t=e.width;e.width=e.height,e.height=t}function Pm(e){e.nodes().forEach(t=>zn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(zn),Object.hasOwn(r,"y")&&zn(r)})}function zn(e){e.y=-e.y}function $m(e){e.nodes().forEach(t=>Fn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Fn),Object.hasOwn(r,"x")&&Fn(r)})}function Fn(e){let t=e.x;e.x=e.y,e.y=t}function Lm(e,t=null){let n={},r=e.nodes().filter(l=>!e.children(l).length),o=r.map(l=>e.node(l).rank),i=_e(Math.max,o),s=St(i+1).map(()=>[]);function a(l){if(n[l])return;n[l]=!0;let u=e.node(l);s[u.rank].push(l);let d=e.successors(l);d&&[...d].sort((f,h)=>c(f,h)).forEach(a)}r.sort((l,u)=>e.node(l).rank-e.node(u).rank).forEach(a);function c(l,u){let d=e.node(l),f=e.node(u);return ya(t,d,f)}return s}function jm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Dm(e,t[r-1],t[r]);return n}function Dm(e,t,n){let r=Y0(n,n.map((l,u)=>u)),o=t.flatMap(l=>{let u=e.outEdges(l);return u?u.map(d=>({pos:r[d.w],weight:e.edge(d).weight})).sort((d,f)=>d.pos-f.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let u=l.pos+i;a[u]+=l.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*d}),c}function Rm(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function Hm(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return zm(r)}function zm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Fm(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>un(o,["vs","i","barycenter","weight"]))}function Fm(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Bm(e,t,n,r,o){let i={},s=null,a=null,c=o;typeof t=="boolean"?(c=t,i={}):t&&(i=t,s=n??null,a=r??null);let l=F0(e,m=>Object.hasOwn(m,"barycenter")),u=l.lhs,d=l.rhs.sort((m,b)=>b.i-m.i),f=[],h=0,g=0,v=0;u.sort(Vm(a,s,!!c));for(let[m,b]of Object.entries(i)){let p=u.findIndex(x=>x.vs[0]===m);u.splice(p+1,0,b)}v=ni(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=ni(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function ni(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Vm(e,t,n){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=ya(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function ka(e,t,n,r,o){var i,s,a,c,l,u,d,f,h,g,v;let w=null,m=o;typeof r=="boolean"?(m=r,w=null):r!==void 0&&(w=r);let b=e.children(t),p=e.node(t),x=p?p.borderLeft:void 0,E=p?p.borderRight:void 0,S={};x&&(b=b.filter($=>$!==x&&$!==E));let C=Rm(e,b);C.forEach($=>{if(e.children($.v).length){let{result:P}=ka(e,$.v,n,w,m);S[$.v]=P,Object.hasOwn(P,"barycenter")&&Xm($,P)}});let M=Hm(C,n);Ym(M,S);let I={},z=!1;for(let $=0;$<M.length;$++)for(let P=$+1;P<M.length;P++)if(!(!M[$]||!M[P]||!((i=M[$])!=null&&i.barycenter)||!((s=M[P])!=null&&s.barycenter))&&((a=M[$])==null?void 0:a.barycenter)===M[P].barycenter){let y=(l=(c=M[$])==null?void 0:c.vs[0])!=null?l:"",_=(d=(u=M[P])==null?void 0:u.vs[0])!=null?d:"",k=e.node(y),A=e.node(_);if(k.dummy==="edge"&&A.dummy==="edge"&&((f=k.edgeObj)==null?void 0:f.v)===((h=A.edgeObj)==null?void 0:h.v)&&((g=k.edgeObj)==null?void 0:g.w)===((v=A.edgeObj)==null?void 0:v.w))if(k.edgeLabel.reversed){I[_]=M[$],M.splice($,1),$--;break}else I[y]=M[P],M.splice(P,1),P--;else z=!0}let O=Bm(M,I,w,e,m);if(x&&E){O.vs=[x,O.vs,E].flat(1);let $=e.predecessors(x);if($&&$.length){let P=e.node($[0]),y=e.predecessors(E),_=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+_.order)/(O.weight+2),O.weight+=2}}return Object.defineProperty(O,"result",{value:O,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(O,"usedBias",{value:z,enumerable:!1,configurable:!0,writable:!0}),O}function Ym(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function Xm(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Wm(e,t,n,r){r||(r=e.nodes());let o=Gm(e),i=new we({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let l=e[n](s);l&&l.forEach(u=>{let d=u.v===s?u.w:u.v,f=i.edge(d,s),h=f!==void 0?f.weight:0;i.setEdge(d,s,{weight:e.edge(u).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function Gm(e){let t;for(;e.hasNode(t=Cr("_root")););return t}function qm(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Ca(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Ca);return}let r=pa(e),o=ri(e,St(1,r+1),"inEdges"),i=ri(e,St(r-1,-1,-1),"outEdges"),s=Lm(e,n);if(oi(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){Km(u%2?o:i,u%4>=2,l,n),s=Pt(e);let f=jm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}oi(e,c)}function ri(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return Wm(e,i,n,r.get(i)||[])})}function Km(e,t,n,r){let o=!0,i=new we;e.forEach(function(s){n.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:c,usedBias:l}=ka(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),qm(s,i,c.vs)})}function oi(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Zm(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,l=i[i.length-1];return i.forEach((u,d)=>{let f=Qm(e,u),h=f?e.node(f).order:c;(f||u===l)&&(i.slice(a,d+1).forEach(g=>{let v=e.predecessors(g);v&&v.forEach(w=>{let m=e.node(w),b=m.order;(b<s||h<b)&&!(m.dummy&&e.node(g).dummy)&&Ma(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function Um(e,t){let n={};function r(i,s,a,c,l){St(s,a).forEach(u=>{let d=i[u];if(d!==void 0&&e.node(d).dummy){let f=e.predecessors(d);f&&f.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<c||g.order>l)&&Ma(n,h,d)})}})}function o(i,s){let a=-1,c=-1,l=0;return s.forEach((u,d)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let h=f[0];if(h===void 0)return;c=e.node(h).order,r(s,l,d,a,c),l=d,a=c}}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function Qm(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Ma(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Jm(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function ey(e,t,n,r,o){let i={},s={},a={};return t.forEach(c=>{c.forEach((l,u)=>{i[l]=l,s[l]=l,a[l]=u})}),t.forEach(c=>{let l=-1,u=-1,d=!1,f=c,h=c.findIndex(g=>(o==null?void 0:o.includes(g))||ii(g,e,o));h>0&&(f=[c[h],...c.slice(0,h),...c.slice(h+1)],d=!0),f.forEach(g=>{var v;let w=r(g);if(w&&w.length){o!=null&&o.includes(g)&&(w=w.filter(p=>ii(p,e,o)));let m=w.sort((p,x)=>{let E=a[p],S=a[x];return(E!==void 0?E:0)-(S!==void 0?S:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let E=m[p];if(E===void 0)continue;let S=a[E];if(S!==void 0&&s[g]===g&&l<S&&a[E]!==u&&!Jm(n,g,E)){let C=i[E];C!==void 0&&(s[E]=g,s[g]=i[g]=C,l=S,d&&(l=-1,u=(v=a[E])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function ty(e,t,n,r,o=!1){let i={},s=ny(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,g){let v=s.nodes().slice(),w={},m=v.pop();for(;m;){if(w[m])h(m);else{w[m]=!0,v.push(m);for(let b of g(m))v.push(b)}m=v.pop()}}function l(h){let g=s.inEdges(h);g?i[h]=g.reduce((v,w)=>{var m;let b=(m=i[w.v])!=null?m:0,p=s.edge(w);return Math.max(v,b+(p!==void 0?p:0))},0):i[h]=0}function u(h){let g=s.outEdges(h),v=Number.POSITIVE_INFINITY;g&&(v=g.reduce((m,b)=>{let p=i[b.w],x=s.edge(b);return Math.min(m,(p!==void 0?p:0)-(x!==void 0?x:0))},Number.POSITIVE_INFINITY));let w=e.node(h);v!==Number.POSITIVE_INFINITY&&w.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,v))}function d(h){return s.predecessors(h)||[]}function f(h){return s.successors(h)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(h=>{var g;let v=n[h];v!==void 0&&(i[h]=(g=i[v])!=null?g:0)}),i}function ny(e,t,n,r){let o=new we,i=e.graph(),s=ay(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let u=n[l];if(u!==void 0){if(o.setNode(u),c!==void 0){let d=n[c];if(d!==void 0){let f=o.edge(d,u);o.setEdge(d,u,Math.max(s(e,l,c),f||0))}}c=l}})}),o}function ry(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let l=cy(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function oy(e,t){let n=Object.values(t),r=_e(Math.min,n),o=_e(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let l=Object.values(c),u=r-_e(Math.min,l);s!=="l"&&(u=o-_e(Math.max,l)),u&&(e[a]=_n(c,d=>d+u))})})}function iy(e,t=void 0){let n=e.ul;return n?_n(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),l=e[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(e).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function sy(e,t){let n=Pt(e),r=Object.assign(Zm(e,n),Um(e,n)),o={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(c=>{c==="r"&&(i=i.map(d=>Object.values(d).reverse()));let l=ey(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=ty(e,i,l.root,l.align,c==="r");c==="r"&&(u=_n(u,d=>-d)),o[a+c]=u})});let s=ry(e,o);return oy(o,s),iy(o,e.graph().align)}function ay(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=n?l:-l),c}}function cy(e,t){return e.node(t).width}function ii(e,t,n){var r;if(!n)return!1;let o=(r=t.node(e))==null?void 0:r.edgeObj;if(!o||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(o==null?void 0:o.v),s=n.indexOf(o==null?void 0:o.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function ly(e,t){e=ha(e),uy(e),Object.entries(sy(e,t)).forEach(([n,r])=>e.node(n).x=r)}function uy(e){let t=Pt(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,l)=>{var u;let d=(u=e.node(l).height)!=null?u:0;return c>d?c:d},0);s.forEach(c=>{let l=e.node(c);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var si=new WeakMap;function dy(e,t={}){return Ia(e,ma,t),e}function ai(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Ia(e,t,n){var r;let o=e.nodes().filter(b=>e.children(b).length),i={};o.forEach(b=>{let p=e.node(b);if(p&&p.rankdir){let x=new we({multigraph:!0,compound:!0});x.setGraph({rankdir:p.rankdir});let E=e.children(b);E.forEach(y=>{let _={...e.node(y)};x.setNode(y,_);let k=e.parent(y);k&&k!==b&&E.includes(k)&&x.setParent(y,k)});let S=new Set;e.edges().forEach(y=>{let _=ai(e,y.v,b),k=ai(e,y.w,b);if(_&&k&&_!==k){let A=`${_}\0${k}`;S.has(A)||(S.add(A),x.setEdge(_,k,{...e.edge(y)}))}}),Ia(x,t,n);let C=di(x);ci(C,t,n,null),li(x,C);let M=1/0,I=1/0,z=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let _=x.node(y);_&&typeof _.x=="number"&&typeof _.y=="number"&&typeof _.width=="number"&&typeof _.height=="number"&&(M=Math.min(M,_.x-_.width/2),z=Math.max(z,_.x+_.width/2),I=Math.min(I,_.y-_.height/2),O=Math.max(O,_.y+_.height/2))}),(!isFinite(M)||!isFinite(I)||!isFinite(z)||!isFinite(O))&&(M=I=0,z=O=0);let $=z-M,P=O-I;i[b]={minX:M,minY:I,maxX:z,maxY:O,width:$,height:P,offsetX:M,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(E=>E!==b);for(;x.length>0;){let E=x.shift();p.push(E),(e.children(E)||[]).filter(S=>S!==E).forEach(S=>x.push(S))}return p},c=new Map;o.forEach(b=>{let p=e.node(b);p&&p.rankdir&&i[b]&&c.set(b,(e.children(b)||[]).filter(x=>x!==b))});let l=new Set([...c.values()].flat()),u=new Map;c.forEach((b,p)=>{l.has(p)||u.set(p,a(p))});let d=new Set([...u.values()].flat()),f=b=>{for(let[p,x]of u)if(x.includes(b))return p;return b},h=[];e.edges().forEach(b=>{(d.has(b.v)||d.has(b.w))&&h.push({edge:b,label:e.edge(b)})});let g=new Map;d.forEach(b=>{let p=e.parent(b);g.set(b,typeof p=="string"?p:void 0)}),u.forEach((b,p)=>{let x=e.node(p),E=[];b.forEach(M=>{let I=e.node(M);I&&(E.push({id:M,node:I,parent:g.get(M)}),e.removeNode(M))});let S=h.filter(({edge:M})=>b.includes(M.v)||b.includes(M.w)),C=i[p];x&&(s.push({clusterId:p,subgraph:x._dagreClusterSubgraph,bounds:C,children:b,removedNodes:E,removedEdges:S}),x.width=C.width,x.height=C.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),E=f(b.w);if(x!==E&&e.hasNode(x)&&e.hasNode(E)){let S=`${x}\0${E}`;v.has(S)||(v.add(S),e.setEdge(x,E,{...p,width:0,height:0}))}});let w=di(e),m=ci(w,t,n,(r=si.get(e))!=null?r:null);si.set(e,m),li(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),E=b.slice(p+1);e.hasEdge(x,E)&&e.removeEdge(x,E)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:E,removedEdges:S})=>{var C,M;let I=e.node(b),z=(C=I==null?void 0:I.x)!=null?C:0,O=(M=I==null?void 0:I.y)!=null?M:0,$=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;E.forEach(({id:y,node:_,parent:k})=>{e.setNode(y,_),k!==void 0&&e.setParent(y,k)}),S.forEach(({edge:y,label:_})=>{e.setEdge(y,_)}),p.nodes().forEach(y=>{if(y===b)return;let _=p.node(y),k=e.node(y);k&&_&&typeof _.x=="number"&&typeof _.y=="number"&&(k.x=z+(_.x-$),k.y=O+(_.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let E=e.node(b),S=i[b];if(E&&E.rankdir&&E._dagreClusterSubgraph&&S){let C=E._dagreClusterSubgraph,M=(p=E.x)!=null?p:0,I=(x=E.y)!=null?x:0,z=(S.minX+S.maxX)/2,O=(S.minY+S.maxY)/2;C.nodes().forEach($=>{if($===b)return;let P=C.node($),y=e.node($);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let _=P.x-z,k=P.y-O;y.x=M+_,y.y=I+k}}),delete E._dagreClusterSubgraph}})}function ci(e,t,n,r=null){var o,i;let s=(n==null?void 0:n.useDynamic)!==!1,a=s&&(o=r==null?void 0:r.graph)!=null?o:null,c=s&&(i=r==null?void 0:r.rawNodes)!=null?i:null;t(" makeSpaceForEdgeLabels",()=>wy(e)),t(" removeSelfEdges",()=>My(e)),t(" acyclic",()=>em(e,a)),t(" nestingGraph.run",()=>Sm(e)),t(" rank",()=>ym(ha(e))),t(" injectEdgeLabelProxies",()=>vy(e)),t(" removeEmptyRanks",()=>H0(e)),t(" nestingGraph.cleanup",()=>Mm(e)),t(" normalizeRanks",()=>R0(e)),t(" assignRankMinMax",()=>by(e)),t(" removeEdgeLabelProxies",()=>Ey(e)),t(" normalize.run",()=>om(e)),t(" parentDummyChains",()=>bm(e)),t(" addBorderSegments",()=>Im(e)),t(" order",()=>Ca(e,n,c)),t(" insertSelfEdges",()=>Iy(e)),t(" adjustCoordinateSystem",()=>Tm(e)),t(" position",()=>ly(e,n.corePath)),t(" positionSelfEdges",()=>Ay(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>Cy(e)),t(" normalize.undo",()=>sm(e)),t(" fixupEdgeLabelCoords",()=>Sy(e)),t(" undoCoordinateSystem",()=>Om(e)),t(" translateGraph",()=>_y(e)),t(" assignNodeIntersects",()=>Ny(e)),t(" reversePoints",()=>ky(e)),t(" acyclic.undo",()=>nm(e)),{graph:e,rawNodes:l}}function li(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var fy=["nodesep","edgesep","ranksep","marginx","marginy"],hy={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},gy=["acyclicer","ranker","rankdir","align","rankalign"],py=["width","height","rank"],ui={width:0,height:0},my=["minlen","weight","width","height","labeloffset"],yy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},xy=["labelpos"];function di(e){let t=new we({multigraph:!0,compound:!0}),n=Vn(e.graph());return t.setGraph(Object.assign({},hy,Bn(n,fy),un(n,gy))),e.nodes().forEach(r=>{let o=Vn(e.node(r)),i=Bn(o,py);Object.keys(ui).forEach(a=>{i[a]===void 0&&(i[a]=ui[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Vn(e.edge(r));t.setEdge(r,Object.assign({},yy,Bn(o,my),un(o,xy)))}),t}function wy(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let o=e.edge(n);o.minlen*=2,((r=o.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?o.width+=o.labeloffset:o.height+=o.labeloffset)})}function vy(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};at(e,"edge-proxy",o,"_ep")}})}function by(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Ey(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function _y(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(l){let u=l.x,d=l.y,f=l.width,h=l.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,d-h/2),o=Math.max(o,d+h/2)}e.nodes().forEach(l=>c(e.node(l))),e.edges().forEach(l=>{let u=e.edge(l);Object.hasOwn(u,"x")&&c(u)}),t-=s,r-=a,e.nodes().forEach(l=>{let u=e.node(l);u.x-=t,u.y-=r}),e.edges().forEach(l=>{let u=e.edge(l);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+a}function Ny(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(Ko(r,i)),n.points.push(Ko(o,s))})}function Sy(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function ky(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Cy(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function My(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Iy(e){Pt(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);typeof i.rank!="number"&&(i.rank=0),i.order=o+n,(i.selfEdges||[]).forEach(s=>{at(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Ay(e){e.nodes().forEach(t=>{let n=e.node(t),r=o=>typeof o=="number"&&isFinite(o);if(n.dummy==="selfedge"){let o=n,i=e.node(o.e.v),s=r(i==null?void 0:i.x)?i.x:0,a=r(i==null?void 0:i.y)?i.y:0,c=r(i==null?void 0:i.width)?i.width:0,l=r(i==null?void 0:i.height)?i.height:0,u=r(n.x)?n.x:s,d=r(n.y)?n.y:a,f=c/2,h=l/2;o.edgeLabel.points=[{x:u+f,y:d-h},{x:u+f,y:d-h},{x:u,y:d},{x:u-f,y:d+h},{x:u-f,y:d+h},{x:u,y:d},{x:u,y:d}],o.edgeLabel.x=u,o.edgeLabel.y=d,e.setEdge(o.e,o.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,c=r(n.height)?n.height:0,l=a/2,u=c/2;o.label.points=[{x:i+l,y:s-u},{x:i+l,y:s-u},{x:i,y:s},{x:i-l,y:s+u},{x:i-l,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Bn(e,t){return _n(un(e,t),Number)}function Vn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function Ty(e){let t=Pt(e),n=new we({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Oy={graphlib:ia,version:X0,layout:dy,debug:Ty,util:{time:B0,notime:ma}},fi=Oy;/*! For license information please see dagre.esm.js.LEGAL.txt */const hi=80,Py=6.6,$y=18,Ly=16.5,jy=8;function hx(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*Py+$y,height:e.length*Ly+jy}}function Dy(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:o,maxHeight:i}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const c=a%r,l=Math.floor(a/r),u=t==="horizontal"?c:l,d=t==="horizontal"?l:c;n.set(s.id,{x:u*(o+hi),y:d*(i+hi)})}),n}function Ry(e){const t=new Set,n=[];for(const r of e){if(r.sourceId===r.targetId)continue;const o=`${r.sourceId} -> ${r.targetId}`;t.has(o)||(t.add(o),n.push(r))}return n}function gi(e,t,n){const r=new Map,o=new Map,i=new Map,s=new fi.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const c=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,c,a.id)}fi.layout(s);for(const a of s.nodes()){const c=s.node(a);c.x===void 0||c.y===void 0||r.set(a,{x:c.x-c.width/2,y:c.y-c.height/2})}for(const a of t){if(!s.hasEdge(a.sourceId,a.targetId,a.id))continue;const c=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),l=(c.points??[]).slice(1,-1);l.length>0&&o.set(a.id,l),c.x!==void 0&&c.y!==void 0&&i.set(a.id,{x:c.x,y:c.y})}return{positions:r,routes:o,labelPositions:i}}function gx(e,t,n){if(e.length===0)return{positions:new Map,routes:new Map,labelPositions:new Map};try{return gi(e,t,n)}catch{const r=Ry(t);if(r.length<t.length)try{return gi(e,r,n)}catch{}return{positions:Dy(e,n),routes:new Map,labelPositions:new Map}}}const px=256,Hy=26,zy=26,Fy=4;function By(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function Aa(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Fy,t))}function mx(e){if(e.length===0)return 0;const t=Aa(e),n=e.length>t;return t*Hy+(n?zy:0)}function yx({markerId:e,color:t,withStart:n}){return N.jsxs("defs",{children:[N.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:N.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&N.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:N.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function xx({x:e,y:t,lines:n,selected:r,dimmed:o}){return n.length===0?null:N.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:N.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${r?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:"none",opacity:o?l0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((i,s)=>N.jsx("div",{children:i},`${String(s)}-${i}`))})})}function wx(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function vx({isDraft:e,decorative:t=!1}){const n=e?"Draft":"Published";return N.jsxs("span",{className:"inline-flex shrink-0 items-center",title:n,children:[N.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:e?na:s0},"aria-hidden":"true"}),!t&&N.jsx("span",{className:"sr-only",children:n})]})}function bx({isDraft:e,joined:t=!1}){return N.jsxs("span",{className:`border-border inline-flex items-center gap-1 border px-1.5 py-0.25 text-[8px] font-semibold tracking-wide uppercase ${t?"rounded-l-full border-r-0 pl-1":"rounded-full"}`,children:[!e&&N.jsx(qc,{className:"h-2.5 w-2.5"}),e?"Draft":"Published"]})}function Ex({type:e,joined:t=!1}){if(!e)return null;const n=Kc.getInfo(e),r=n.icon;return N.jsxs("span",{className:`border-border inline-flex items-center gap-1 border px-1.5 py-0.25 text-[8px] font-semibold tracking-wide uppercase ${t?"rounded-r-full":"-ml-0.5 rounded-full"}`,children:[N.jsx(r,{className:"h-2.5 w-2.5"}),n.displayName]})}function Vy({field:e}){return N.jsxs("div",{className:"border-border/50 flex items-center gap-2 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:e.isHidden?`${e.alias} (hidden from reporting)`:e.alias,children:[e.isPrimaryKey?N.jsx(Qc,{className:"h-3 w-3 shrink-0",style:{color:na},"aria-label":"Primary key"}):N.jsx("span",{className:"w-3 shrink-0"}),N.jsx("span",{className:"text-foreground flex-1 truncate",children:e.alias}),N.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]})}function _x({fields:e,expanded:t,onToggleExpanded:n}){const r=By(e),o=Aa(e),i=t?r:r.slice(0,o),s=r.length-o;function a(c){c.stopPropagation(),c.preventDefault(),n()}return N.jsxs("div",{className:"border-t",children:[i.map(c=>N.jsx(Vy,{field:c},c.name)),s>0&&N.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:c=>{c.stopPropagation()},onClick:a,children:t?N.jsxs(N.Fragment,{children:[N.jsx(Zc,{className:"h-3 w-3"})," Show less"]}):N.jsxs(N.Fragment,{children:[N.jsx(Uc,{className:"h-3 w-3"})," +",s," more field",s!==1?"s":""]})})]})}export{xx as A,En as B,Uy as C,l0 as D,vx as E,px as F,mx as G,sn as H,Aa as I,Hy as J,zy as K,Xy as L,Zy as M,cx as N,c0 as O,W as P,bx as Q,Cp as R,sx as S,ig as T,sg as U,Df as V,Jy as W,Wy as Z,Ex as a,_x as b,_r as c,te as d,dx as e,ux as f,mr as g,lx as h,fx as i,Gy as j,qy as k,ix as l,na as m,Qy as n,ex as o,hx as p,ax as q,gx as r,as as s,tx as t,Ky as u,wx as v,yx as w,ox as x,rx as y,nx as z};
|
|
27
|
+
`,wx={highlighted:!1,dimmed:!1};function vx(e,t,n,r){const o=t.trim().toLowerCase(),i=new Map;for(const s of e){const a=o!==""&&r(s).toLowerCase().includes(o);i.set(n(s),{highlighted:a,dimmed:o!==""&&!a})}return i}function bx(e){if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.position.x),n=Math.min(n,i.position.y),r=Math.max(r,i.position.x+(i.width??0)),o=Math.max(o,i.position.y+(i.height??0));return{minX:t,minY:n,maxX:r,maxY:o}}function Ex(e,t,n,r,o){const i=o-t.maxX*e.zoom,s=n-o-t.minX*e.zoom,a=o-t.maxY*e.zoom,c=r-o-t.minY*e.zoom;return{x:Math.min(Math.max(e.x,i),s),y:Math.min(Math.max(e.y,a),c),zoom:e.zoom}}var na=Object.defineProperty,y0=(e,t,n)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x0=(e,t)=>{for(var n in t)na(e,n,{get:t[n],enumerable:!0})},w0=(e,t,n)=>y0(e,t+"",n),ra={};x0(ra,{Graph:()=>we,alg:()=>Sr});var v0=Object.defineProperty,oa=(e,t)=>{for(var n in t)v0(e,n,{get:t[n],enumerable:!0})},Nr=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let o of r)n.add(o);return Array.from(n.values())}}isLeaf(e){var t;let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),((t=n==null?void 0:n.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=ht(this._isDirected,o,i,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,i,s);let u=b0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Wo(this._preds[i],o),Wo(this._sucs[o],i),this._in[i][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"||r===null?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Go(this._preds[s],i),Go(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function Wo(e,t){e[t]?e[t]++:e[t]=1}function Go(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function ht(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function b0(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function Dn(e,t){return ht(e,t.v,t.w,t.name)}var E0={};oa(E0,{read:()=>k0,write:()=>_0});function _0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:N0(e),edges:S0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function N0(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function S0(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function k0(e){let t=new Nr(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Sr={};oa(Sr,{CycleException:()=>ln,bellmanFord:()=>ia,components:()=>I0,dijkstra:()=>cn,dijkstraAll:()=>O0,findCycles:()=>P0,floydWarshall:()=>j0,isAcyclic:()=>D0,postorder:()=>H0,preorder:()=>z0,prim:()=>F0,shortestPaths:()=>B0,tarjan:()=>aa,topsort:()=>ca});var C0=()=>1;function ia(e,t,n,r){return M0(e,String(t),n||C0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function M0(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(d){let f=o[d.v],h=o[d.w];if(!f||!h)return;let g=n(d);f.distance+g<h.distance&&(o[d.w]={distance:f.distance+g,predecessor:d.v},i=!0)},l=function(){a.forEach(function(d){r(d).forEach(function(f){let h=f.v===d?f.v:f.w,g=h===f.v?f.w:f.v;c({v:h,w:g})})})};a.forEach(function(d){let f=d===t?0:Number.POSITIVE_INFINITY;o[d]={distance:f,predecessor:""}});let u=a.length;for(let d=1;d<u&&(i=!1,s++,l(),!!i);d++);if(s===u-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function I0(e){let t={},n=[],r;function o(i){var s,a;i in t||(t[i]=!0,r.push(i),(s=e.successors(i))==null||s.forEach(o),(a=e.predecessors(i))==null||a.forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var sa=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},A0=()=>1;function cn(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return T0(e,String(t),n||A0,r||o)}function T0(e,t,n,r){let o={},i=new sa,s,a,c=function(l){let u=l.v!==s?l.v:l.w,d=o[u];if(!d)return;let f=n(l),h=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+f);h<d.distance&&(d.distance=h,d.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(l){let u=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},i.add(l,u)});i.size()>0;){s=i.removeMin();let l=o[s];if(!l||l.distance===Number.POSITIVE_INFINITY)break;a=l,r(s).forEach(c)}return o}function O0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=cn(e,o,t,n),r},{})}function aa(e){let t=0,n=[],r={},o=[];function i(s){var a;let c=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),(a=e.successors(s))==null||a.forEach(function(l){if(l in r){let u=r[l];u!=null&&u.onStack&&(c.lowlink=Math.min(c.lowlink,u.index))}else{i(l);let u=r[l];u&&(c.lowlink=Math.min(c.lowlink,u.lowlink))}}),c.lowlink===c.index){let l=[],u;do{u=n.pop();let d=r[u];d&&(d.onStack=!1),l.push(u)}while(s!==u);o.push(l)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function P0(e){return aa(e).filter(function(t){var n;let r=t[0];return r?t.length>1||t.length===1&&((n=e.outEdges(r,r))!=null?n:[]).length>0:!1})}var $0=()=>1;function j0(e,t,n){return L0(e,t||$0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function L0(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){let s={};r[i]=s,s[i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(s[a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let c=a.v===i?a.w:a.v,l=t(a);s[c]={distance:l,predecessor:i}})}),o.forEach(function(i){let s=r[i];s&&o.forEach(function(a){let c=r[a];c&&o.forEach(function(l){let u=c[i],d=s[l],f=c[l];if(u&&d&&f){let h=u.distance+d.distance;h<f.distance&&(f.distance=h,f.predecessor=d.predecessor)}})})}),r}var ln=class extends Error{constructor(e){super(e),this.name="CycleException"}};function ca(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new ln;i in t||(n[i]=!0,t[i]=!0,(s=e.predecessors(i))==null||s.forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new ln;return r}function D0(e){try{ca(e)}catch(t){if(t instanceof ln)return!1;throw t}return!0}function R0(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=la(e,a,n==="post",s,i,r,o)}),o}function la(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=la(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function ua(e,t,n){return R0(e,t,n,function(r,o){return r.push(o),r},[])}function H0(e,t){return ua(e,t,"post")}function z0(e,t){return ua(e,t,"pre")}function F0(e,t){var n;let r=new Nr,o={},i=new sa,s;function a(u){let d=u.v===s?u.w:u.v,f=i.priority(d);if(f!==void 0){let h=t(u);h<f&&(o[d]=s,i.decrease(d,h))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(u){i.add(u,Number.POSITIVE_INFINITY),r.setNode(u)});let c=e.nodes()[0];c!==void 0&&i.decrease(c,0);let l=!1;for(;i.size()>0;){if(s=i.removeMin(),s in o)r.setEdge(s,o[s]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}(n=e.nodeEdges(s))==null||n.forEach(a)}return r}function B0(e,t,n,r){return V0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function V0(e,t,n,r){if(n===void 0)return cn(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=i[s];if(a===void 0)continue;let c=r(a);for(let l=0;l<c.length;l++){let u=c[l];if(!u)continue;let d=u.v===a?u.v:u.w,f=d===u.v?u.w:u.v;n({v:d,w:f})<0&&(o=!0)}if(o)return ia(e,t,n,r)}return cn(e,t,n,r)}var we=Nr;function at(e,t,n,r){let o=r;for(;e.hasNode(o);)o=kr(r);return n.dummy=t,e.setNode(o,n),o}function Y0(e){let t=new we().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function da(e){let t=new we({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function qo(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,l=a):(o<0&&(s=-s),c=s,l=s*i/o),{x:n+c,y:r+l}}function Pt(e){let t=St(ha(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function X0(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=_e(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function W0(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=_e(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function Ko(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),at(e,"border",o,t)}function G0(e,t=fa){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var fa=65535;function _e(e,t){if(t.length>fa){let n=G0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function ha(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return _e(Math.max,t)}function q0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function K0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function ga(e,t){return t()}var Z0=0;function kr(e){let t=++Z0;return e+(""+t)}function St(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function un(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _n(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function U0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Nn="\0";function pa(e,t,n){var r,o,i,s,a,c;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let l=!0;t.edgeObj.w===n.edgeObj.w&&(l=!1);let u=l?(o=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?o:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,d=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===t.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&v[1].rank===u}),f=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===n.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&v[1].rank===u});if(!d||!f)return 0;let h=(a=d[1].order)!=null?a:NaN,g=(c=f[1].order)!=null?c:NaN;return isNaN(h-g)?0:h-g}var Q0="3.1.1",J0=class{constructor(){w0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Zo(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Zo(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,em)),n=n._prev;return"["+e.join(", ")+"]"}};function Zo(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function em(e,t){if(e!=="_next"&&e!=="_prev")return t}var tm=J0,nm=()=>1;function rm(e,t){if(e.nodeCount()<=1)return[];let n=im(e,t||nm);return om(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function om(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Rn(e,t,n,a);for(;a=i.dequeue();)Rn(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(Rn(e,t,n,a,!0)||[]);break}}}return o}function Rn(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=c,rr(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,rr(t,n,u)}),e.removeNode(r.v),s}function im(e,t){let n=new we,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,l=t(a),u=c+l;n.setEdge(a.v,a.w,u);let d=n.node(a.v),f=n.node(a.w);o=Math.max(o,d.out+=l),r=Math.max(r,f.in+=l)});let i=sm(o+r+3).map(()=>new tm),s=r+1;return n.nodes().forEach(a=>{rr(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function rr(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function sm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function am(e,t){(e.graph().acyclicer==="greedy"?rm(e,n(e)):cm(e,t??null)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,kr("rev"))});function n(r){return o=>r.edge(o).weight}}function cm(e,t){let n=[],r={},o={};function i(c){Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,e.outEdges(c).forEach(l=>{Object.hasOwn(r,l.w)?n.push(l):i(l.w)}),delete r[c])}function s(c){var l;Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,(l=e.outEdges(c))==null||l.forEach(u=>{var d,f;Object.hasOwn(r,u.w)||((d=t.node(c))==null?void 0:d.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&um(e,u.w,u)?n.push(u):s(u.w)}),delete r[c])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function lm(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function um(e,t,n){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(t)}function dm(e){e.graph().dummyChains=[],e.edges().forEach(t=>fm(e,t))}function fm(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<i;++d,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=at(e,"edge",u,"_d"),r===c&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,l,{weight:a.weight},s),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function hm(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Cr(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=_e(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function st(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var ma=gm;function gm(e){let t=new we({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;pm(t,e)<o&&(i=mm(t,e),!!i);)s=t.hasNode(i.v)?st(e,i):-st(e,i),ym(t,e,s);return t}function pm(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!st(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function mm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=st(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function ym(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:xm,postorder:wm}=Sr,vm=Ke;Ke.initLowLimValues=Ir;Ke.initCutValues=Mr;Ke.calcCutValue=ya;Ke.leaveEdge=wa;Ke.enterEdge=va;Ke.exchangeEdges=ba;function Ke(e){e=Y0(e),Cr(e);let t=ma(e);Ir(t),Mr(t,e);let n,r;for(;n=wa(t);)r=va(t,e,n),ba(t,e,n,r)}function Mr(e,t){let n=wm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>bm(e,t,r))}function bm(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=ya(e,t,n)}function ya(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let l=c.v===n,u=l?c.w:c.v;if(u!==r){let d=l===o,f=t.edge(c).weight;if(s+=d?f:-f,_m(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Ir(e,t){arguments.length<2&&(t=e.nodes()[0]),xa(e,{},1,t)}function xa(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=xa(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function wa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function va(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(l=>c===Uo(e,e.node(l.v),a)&&c!==Uo(e,e.node(l.w),a)).reduce((l,u)=>st(t,u)<st(t,l)?u:l)}function ba(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Ir(e),Mr(e,t),Em(e,t)}function Em(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=xm(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function _m(e,t,n){return e.hasEdge(t,n)}function Uo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Nm=Sm;function Sm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Qo(e);break;case"tight-tree":Cm(e);break;case"longest-path":km(e);break;case"none":break;default:Qo(e)}}var km=Cr;function Cm(e){Cr(e),ma(e)}function Qo(e){vm(e)}var Mm=Im;function Im(e){let t=Tm(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=Am(e,t,i.v,i.w),a=s.path,c=s.lca,l=0,u=a[l],d=!0;for(;r!==i.w;){if(o=e.node(r),d){for(;(u=a[l])!==c&&e.node(u).maxRank<o.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<a.length-1&&e.node(a[l+1]).minRank<=o.rank;)l++;u=a[l]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function Am(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)i.push(u);return{path:o.concat(i.reverse()),lca:l}}function Tm(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Nn).forEach(r),t}function Om(e){let t=at(e,"root",{},"_root"),n=Pm(e),r=Object.values(n),o=_e(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=$m(e)+1;e.children(Nn).forEach(a=>{Ea(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function Ea(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let l=Ko(e,"_bt"),u=Ko(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(u,s),d.borderBottom=u,c.forEach(f=>{var h;Ea(e,t,n,r,o,i,f);let g=e.node(f),v=g.borderTop?g.borderTop:f,w=g.borderBottom?g.borderBottom:f,m=g.borderTop?r:2*r,b=v!==w?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(l,v,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(w,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function Pm(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Nn).forEach(r=>n(r,1)),t}function $m(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function jm(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Lm=Dm;function Dm(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Jo(e,"borderLeft","_bl",n,o,i),Jo(e,"borderRight","_br",n,o,i)}}e.children(Nn).forEach(t)}function Jo(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=at(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function Rm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&_a(e)}function Hm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&zm(e),(n==="lr"||n==="rl")&&(Fm(e),_a(e))}function _a(e){e.nodes().forEach(t=>ei(e.node(t))),e.edges().forEach(t=>ei(e.edge(t)))}function ei(e){let t=e.width;e.width=e.height,e.height=t}function zm(e){e.nodes().forEach(t=>Hn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Hn),Object.hasOwn(r,"y")&&Hn(r)})}function Hn(e){e.y=-e.y}function Fm(e){e.nodes().forEach(t=>zn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(zn),Object.hasOwn(r,"x")&&zn(r)})}function zn(e){let t=e.x;e.x=e.y,e.y=t}function Bm(e,t=null){let n={},r=e.nodes().filter(l=>!e.children(l).length),o=r.map(l=>e.node(l).rank),i=_e(Math.max,o),s=St(i+1).map(()=>[]);function a(l){if(n[l])return;n[l]=!0;let u=e.node(l);s[u.rank].push(l);let d=e.successors(l);d&&[...d].sort((f,h)=>c(f,h)).forEach(a)}r.sort((l,u)=>e.node(l).rank-e.node(u).rank).forEach(a);function c(l,u){let d=e.node(l),f=e.node(u);return pa(t,d,f)}return s}function Vm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Ym(e,t[r-1],t[r]);return n}function Ym(e,t,n){let r=U0(n,n.map((l,u)=>u)),o=t.flatMap(l=>{let u=e.outEdges(l);return u?u.map(d=>({pos:r[d.w],weight:e.edge(d).weight})).sort((d,f)=>d.pos-f.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let u=l.pos+i;a[u]+=l.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*d}),c}function Xm(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function Wm(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return Gm(r)}function Gm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&qm(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>un(o,["vs","i","barycenter","weight"]))}function qm(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Km(e,t,n,r,o){let i={},s=null,a=null,c=o;typeof t=="boolean"?(c=t,i={}):t&&(i=t,s=n??null,a=r??null);let l=q0(e,m=>Object.hasOwn(m,"barycenter")),u=l.lhs,d=l.rhs.sort((m,b)=>b.i-m.i),f=[],h=0,g=0,v=0;u.sort(Zm(a,s,!!c));for(let[m,b]of Object.entries(i)){let p=u.findIndex(x=>x.vs[0]===m);u.splice(p+1,0,b)}v=ti(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=ti(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function ti(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Zm(e,t,n){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=pa(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function Na(e,t,n,r,o){var i,s,a,c,l,u,d,f,h,g,v;let w=null,m=o;typeof r=="boolean"?(m=r,w=null):r!==void 0&&(w=r);let b=e.children(t),p=e.node(t),x=p?p.borderLeft:void 0,_=p?p.borderRight:void 0,S={};x&&(b=b.filter($=>$!==x&&$!==_));let C=Xm(e,b);C.forEach($=>{if(e.children($.v).length){let{result:P}=Na(e,$.v,n,w,m);S[$.v]=P,Object.hasOwn(P,"barycenter")&&Qm($,P)}});let M=Wm(C,n);Um(M,S);let I={},z=!1;for(let $=0;$<M.length;$++)for(let P=$+1;P<M.length;P++)if(!(!M[$]||!M[P]||!((i=M[$])!=null&&i.barycenter)||!((s=M[P])!=null&&s.barycenter))&&((a=M[$])==null?void 0:a.barycenter)===M[P].barycenter){let y=(l=(c=M[$])==null?void 0:c.vs[0])!=null?l:"",N=(d=(u=M[P])==null?void 0:u.vs[0])!=null?d:"",k=e.node(y),A=e.node(N);if(k.dummy==="edge"&&A.dummy==="edge"&&((f=k.edgeObj)==null?void 0:f.v)===((h=A.edgeObj)==null?void 0:h.v)&&((g=k.edgeObj)==null?void 0:g.w)===((v=A.edgeObj)==null?void 0:v.w))if(k.edgeLabel.reversed){I[N]=M[$],M.splice($,1),$--;break}else I[y]=M[P],M.splice(P,1),P--;else z=!0}let O=Km(M,I,w,e,m);if(x&&_){O.vs=[x,O.vs,_].flat(1);let $=e.predecessors(x);if($&&$.length){let P=e.node($[0]),y=e.predecessors(_),N=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+N.order)/(O.weight+2),O.weight+=2}}return Object.defineProperty(O,"result",{value:O,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(O,"usedBias",{value:z,enumerable:!1,configurable:!0,writable:!0}),O}function Um(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function Qm(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Jm(e,t,n,r){r||(r=e.nodes());let o=ey(e),i=new we({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let l=e[n](s);l&&l.forEach(u=>{let d=u.v===s?u.w:u.v,f=i.edge(d,s),h=f!==void 0?f.weight:0;i.setEdge(d,s,{weight:e.edge(u).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function ey(e){let t;for(;e.hasNode(t=kr("_root")););return t}function ty(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Sa(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Sa);return}let r=ha(e),o=ni(e,St(1,r+1),"inEdges"),i=ni(e,St(r-1,-1,-1),"outEdges"),s=Bm(e,n);if(ri(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){ny(u%2?o:i,u%4>=2,l,n),s=Pt(e);let f=Vm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}ri(e,c)}function ni(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return Jm(e,i,n,r.get(i)||[])})}function ny(e,t,n,r){let o=!0,i=new we;e.forEach(function(s){n.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:c,usedBias:l}=Na(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),ty(s,i,c.vs)})}function ri(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function ry(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,l=i[i.length-1];return i.forEach((u,d)=>{let f=iy(e,u),h=f?e.node(f).order:c;(f||u===l)&&(i.slice(a,d+1).forEach(g=>{let v=e.predecessors(g);v&&v.forEach(w=>{let m=e.node(w),b=m.order;(b<s||h<b)&&!(m.dummy&&e.node(g).dummy)&&ka(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function oy(e,t){let n={};function r(i,s,a,c,l){St(s,a).forEach(u=>{let d=i[u];if(d!==void 0&&e.node(d).dummy){let f=e.predecessors(d);f&&f.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<c||g.order>l)&&ka(n,h,d)})}})}function o(i,s){let a=-1,c=-1,l=0;return s.forEach((u,d)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let h=f[0];if(h===void 0)return;c=e.node(h).order,r(s,l,d,a,c),l=d,a=c}}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function iy(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function ka(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function sy(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function ay(e,t,n,r,o){let i={},s={},a={};return t.forEach(c=>{c.forEach((l,u)=>{i[l]=l,s[l]=l,a[l]=u})}),t.forEach(c=>{let l=-1,u=-1,d=!1,f=c,h=c.findIndex(g=>(o==null?void 0:o.includes(g))||oi(g,e,o));h>0&&(f=[c[h],...c.slice(0,h),...c.slice(h+1)],d=!0),f.forEach(g=>{var v;let w=r(g);if(w&&w.length){o!=null&&o.includes(g)&&(w=w.filter(p=>oi(p,e,o)));let m=w.sort((p,x)=>{let _=a[p],S=a[x];return(_!==void 0?_:0)-(S!==void 0?S:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let _=m[p];if(_===void 0)continue;let S=a[_];if(S!==void 0&&s[g]===g&&l<S&&a[_]!==u&&!sy(n,g,_)){let C=i[_];C!==void 0&&(s[_]=g,s[g]=i[g]=C,l=S,d&&(l=-1,u=(v=a[_])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function cy(e,t,n,r,o=!1){let i={},s=ly(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,g){let v=s.nodes().slice(),w={},m=v.pop();for(;m;){if(w[m])h(m);else{w[m]=!0,v.push(m);for(let b of g(m))v.push(b)}m=v.pop()}}function l(h){let g=s.inEdges(h);g?i[h]=g.reduce((v,w)=>{var m;let b=(m=i[w.v])!=null?m:0,p=s.edge(w);return Math.max(v,b+(p!==void 0?p:0))},0):i[h]=0}function u(h){let g=s.outEdges(h),v=Number.POSITIVE_INFINITY;g&&(v=g.reduce((m,b)=>{let p=i[b.w],x=s.edge(b);return Math.min(m,(p!==void 0?p:0)-(x!==void 0?x:0))},Number.POSITIVE_INFINITY));let w=e.node(h);v!==Number.POSITIVE_INFINITY&&w.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,v))}function d(h){return s.predecessors(h)||[]}function f(h){return s.successors(h)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(h=>{var g;let v=n[h];v!==void 0&&(i[h]=(g=i[v])!=null?g:0)}),i}function ly(e,t,n,r){let o=new we,i=e.graph(),s=gy(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let u=n[l];if(u!==void 0){if(o.setNode(u),c!==void 0){let d=n[c];if(d!==void 0){let f=o.edge(d,u);o.setEdge(d,u,Math.max(s(e,l,c),f||0))}}c=l}})}),o}function uy(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let l=py(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function dy(e,t){let n=Object.values(t),r=_e(Math.min,n),o=_e(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let l=Object.values(c),u=r-_e(Math.min,l);s!=="l"&&(u=o-_e(Math.max,l)),u&&(e[a]=_n(c,d=>d+u))})})}function fy(e,t=void 0){let n=e.ul;return n?_n(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),l=e[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(e).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function hy(e,t){let n=Pt(e),r=Object.assign(ry(e,n),oy(e,n)),o={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(c=>{c==="r"&&(i=i.map(d=>Object.values(d).reverse()));let l=ay(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=cy(e,i,l.root,l.align,c==="r");c==="r"&&(u=_n(u,d=>-d)),o[a+c]=u})});let s=uy(e,o);return dy(o,s),fy(o,e.graph().align)}function gy(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=n?l:-l),c}}function py(e,t){return e.node(t).width}function oi(e,t,n){var r;if(!n)return!1;let o=(r=t.node(e))==null?void 0:r.edgeObj;if(!o||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(o==null?void 0:o.v),s=n.indexOf(o==null?void 0:o.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function my(e,t){e=da(e),yy(e),Object.entries(hy(e,t)).forEach(([n,r])=>e.node(n).x=r)}function yy(e){let t=Pt(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,l)=>{var u;let d=(u=e.node(l).height)!=null?u:0;return c>d?c:d},0);s.forEach(c=>{let l=e.node(c);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var ii=new WeakMap;function xy(e,t={}){return Ca(e,ga,t),e}function si(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Ca(e,t,n){var r;let o=e.nodes().filter(b=>e.children(b).length),i={};o.forEach(b=>{let p=e.node(b);if(p&&p.rankdir){let x=new we({multigraph:!0,compound:!0});x.setGraph({rankdir:p.rankdir});let _=e.children(b);_.forEach(y=>{let N={...e.node(y)};x.setNode(y,N);let k=e.parent(y);k&&k!==b&&_.includes(k)&&x.setParent(y,k)});let S=new Set;e.edges().forEach(y=>{let N=si(e,y.v,b),k=si(e,y.w,b);if(N&&k&&N!==k){let A=`${N}\0${k}`;S.has(A)||(S.add(A),x.setEdge(N,k,{...e.edge(y)}))}}),Ca(x,t,n);let C=ui(x);ai(C,t,n,null),ci(x,C);let M=1/0,I=1/0,z=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let N=x.node(y);N&&typeof N.x=="number"&&typeof N.y=="number"&&typeof N.width=="number"&&typeof N.height=="number"&&(M=Math.min(M,N.x-N.width/2),z=Math.max(z,N.x+N.width/2),I=Math.min(I,N.y-N.height/2),O=Math.max(O,N.y+N.height/2))}),(!isFinite(M)||!isFinite(I)||!isFinite(z)||!isFinite(O))&&(M=I=0,z=O=0);let $=z-M,P=O-I;i[b]={minX:M,minY:I,maxX:z,maxY:O,width:$,height:P,offsetX:M,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(_=>_!==b);for(;x.length>0;){let _=x.shift();p.push(_),(e.children(_)||[]).filter(S=>S!==_).forEach(S=>x.push(S))}return p},c=new Map;o.forEach(b=>{let p=e.node(b);p&&p.rankdir&&i[b]&&c.set(b,(e.children(b)||[]).filter(x=>x!==b))});let l=new Set([...c.values()].flat()),u=new Map;c.forEach((b,p)=>{l.has(p)||u.set(p,a(p))});let d=new Set([...u.values()].flat()),f=b=>{for(let[p,x]of u)if(x.includes(b))return p;return b},h=[];e.edges().forEach(b=>{(d.has(b.v)||d.has(b.w))&&h.push({edge:b,label:e.edge(b)})});let g=new Map;d.forEach(b=>{let p=e.parent(b);g.set(b,typeof p=="string"?p:void 0)}),u.forEach((b,p)=>{let x=e.node(p),_=[];b.forEach(M=>{let I=e.node(M);I&&(_.push({id:M,node:I,parent:g.get(M)}),e.removeNode(M))});let S=h.filter(({edge:M})=>b.includes(M.v)||b.includes(M.w)),C=i[p];x&&(s.push({clusterId:p,subgraph:x._dagreClusterSubgraph,bounds:C,children:b,removedNodes:_,removedEdges:S}),x.width=C.width,x.height=C.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),_=f(b.w);if(x!==_&&e.hasNode(x)&&e.hasNode(_)){let S=`${x}\0${_}`;v.has(S)||(v.add(S),e.setEdge(x,_,{...p,width:0,height:0}))}});let w=ui(e),m=ai(w,t,n,(r=ii.get(e))!=null?r:null);ii.set(e,m),ci(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),_=b.slice(p+1);e.hasEdge(x,_)&&e.removeEdge(x,_)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:_,removedEdges:S})=>{var C,M;let I=e.node(b),z=(C=I==null?void 0:I.x)!=null?C:0,O=(M=I==null?void 0:I.y)!=null?M:0,$=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;_.forEach(({id:y,node:N,parent:k})=>{e.setNode(y,N),k!==void 0&&e.setParent(y,k)}),S.forEach(({edge:y,label:N})=>{e.setEdge(y,N)}),p.nodes().forEach(y=>{if(y===b)return;let N=p.node(y),k=e.node(y);k&&N&&typeof N.x=="number"&&typeof N.y=="number"&&(k.x=z+(N.x-$),k.y=O+(N.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let _=e.node(b),S=i[b];if(_&&_.rankdir&&_._dagreClusterSubgraph&&S){let C=_._dagreClusterSubgraph,M=(p=_.x)!=null?p:0,I=(x=_.y)!=null?x:0,z=(S.minX+S.maxX)/2,O=(S.minY+S.maxY)/2;C.nodes().forEach($=>{if($===b)return;let P=C.node($),y=e.node($);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let N=P.x-z,k=P.y-O;y.x=M+N,y.y=I+k}}),delete _._dagreClusterSubgraph}})}function ai(e,t,n,r=null){var o,i;let s=(n==null?void 0:n.useDynamic)!==!1,a=s&&(o=r==null?void 0:r.graph)!=null?o:null,c=s&&(i=r==null?void 0:r.rawNodes)!=null?i:null;t(" makeSpaceForEdgeLabels",()=>ky(e)),t(" removeSelfEdges",()=>jy(e)),t(" acyclic",()=>am(e,a)),t(" nestingGraph.run",()=>Om(e)),t(" rank",()=>Nm(da(e))),t(" injectEdgeLabelProxies",()=>Cy(e)),t(" removeEmptyRanks",()=>W0(e)),t(" nestingGraph.cleanup",()=>jm(e)),t(" normalizeRanks",()=>X0(e)),t(" assignRankMinMax",()=>My(e)),t(" removeEdgeLabelProxies",()=>Iy(e)),t(" normalize.run",()=>dm(e)),t(" parentDummyChains",()=>Mm(e)),t(" addBorderSegments",()=>Lm(e)),t(" order",()=>Sa(e,n,c)),t(" insertSelfEdges",()=>Ly(e)),t(" adjustCoordinateSystem",()=>Rm(e)),t(" position",()=>my(e,n.corePath)),t(" positionSelfEdges",()=>Dy(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>$y(e)),t(" normalize.undo",()=>hm(e)),t(" fixupEdgeLabelCoords",()=>Oy(e)),t(" undoCoordinateSystem",()=>Hm(e)),t(" translateGraph",()=>Ay(e)),t(" assignNodeIntersects",()=>Ty(e)),t(" reversePoints",()=>Py(e)),t(" acyclic.undo",()=>lm(e)),{graph:e,rawNodes:l}}function ci(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var wy=["nodesep","edgesep","ranksep","marginx","marginy"],vy={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},by=["acyclicer","ranker","rankdir","align","rankalign"],Ey=["width","height","rank"],li={width:0,height:0},_y=["minlen","weight","width","height","labeloffset"],Ny={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Sy=["labelpos"];function ui(e){let t=new we({multigraph:!0,compound:!0}),n=Bn(e.graph());return t.setGraph(Object.assign({},vy,Fn(n,wy),un(n,by))),e.nodes().forEach(r=>{let o=Bn(e.node(r)),i=Fn(o,Ey);Object.keys(li).forEach(a=>{i[a]===void 0&&(i[a]=li[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Bn(e.edge(r));t.setEdge(r,Object.assign({},Ny,Fn(o,_y),un(o,Sy)))}),t}function ky(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let o=e.edge(n);o.minlen*=2,((r=o.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?o.width+=o.labeloffset:o.height+=o.labeloffset)})}function Cy(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};at(e,"edge-proxy",o,"_ep")}})}function My(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Iy(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Ay(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(l){let u=l.x,d=l.y,f=l.width,h=l.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,d-h/2),o=Math.max(o,d+h/2)}e.nodes().forEach(l=>c(e.node(l))),e.edges().forEach(l=>{let u=e.edge(l);Object.hasOwn(u,"x")&&c(u)}),t-=s,r-=a,e.nodes().forEach(l=>{let u=e.node(l);u.x-=t,u.y-=r}),e.edges().forEach(l=>{let u=e.edge(l);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+a}function Ty(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(qo(r,i)),n.points.push(qo(o,s))})}function Oy(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Py(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function $y(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function jy(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Ly(e){Pt(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);typeof i.rank!="number"&&(i.rank=0),i.order=o+n,(i.selfEdges||[]).forEach(s=>{at(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Dy(e){e.nodes().forEach(t=>{let n=e.node(t),r=o=>typeof o=="number"&&isFinite(o);if(n.dummy==="selfedge"){let o=n,i=e.node(o.e.v),s=r(i==null?void 0:i.x)?i.x:0,a=r(i==null?void 0:i.y)?i.y:0,c=r(i==null?void 0:i.width)?i.width:0,l=r(i==null?void 0:i.height)?i.height:0,u=r(n.x)?n.x:s,d=r(n.y)?n.y:a,f=c/2,h=l/2;o.edgeLabel.points=[{x:u+f,y:d-h},{x:u+f,y:d-h},{x:u,y:d},{x:u-f,y:d+h},{x:u-f,y:d+h},{x:u,y:d},{x:u,y:d}],o.edgeLabel.x=u,o.edgeLabel.y=d,e.setEdge(o.e,o.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,c=r(n.height)?n.height:0,l=a/2,u=c/2;o.label.points=[{x:i+l,y:s-u},{x:i+l,y:s-u},{x:i,y:s},{x:i-l,y:s+u},{x:i-l,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Fn(e,t){return _n(un(e,t),Number)}function Bn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function Ry(e){let t=Pt(e),n=new we({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Hy={graphlib:ra,version:Q0,layout:xy,debug:Ry,util:{time:K0,notime:ga}},di=Hy;/*! For license information please see dagre.esm.js.LEGAL.txt */const fi=80,zy=6.6,Fy=18,By=16.5,Vy=8;function _x(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*zy+Fy,height:e.length*By+Vy}}function Yy(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:o,maxHeight:i}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const c=a%r,l=Math.floor(a/r),u=t==="horizontal"?c:l,d=t==="horizontal"?l:c;n.set(s.id,{x:u*(o+fi),y:d*(i+fi)})}),n}function Xy(e){const t=new Set,n=[];for(const r of e){if(r.sourceId===r.targetId)continue;const o=`${r.sourceId} -> ${r.targetId}`;t.has(o)||(t.add(o),n.push(r))}return n}function hi(e,t,n){const r=new Map,o=new Map,i=new Map,s=new di.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const c=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,c,a.id)}di.layout(s);for(const a of s.nodes()){const c=s.node(a);c.x===void 0||c.y===void 0||r.set(a,{x:c.x-c.width/2,y:c.y-c.height/2})}for(const a of t){if(!s.hasEdge(a.sourceId,a.targetId,a.id))continue;const c=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),l=(c.points??[]).slice(1,-1);l.length>0&&o.set(a.id,l),c.x!==void 0&&c.y!==void 0&&i.set(a.id,{x:c.x,y:c.y})}return{positions:r,routes:o,labelPositions:i}}function Nx(e,t,n){if(e.length===0)return{positions:new Map,routes:new Map,labelPositions:new Map};try{return hi(e,t,n)}catch{const r=Xy(t);if(r.length<t.length)try{return hi(e,r,n)}catch{}return{positions:Yy(e,n),routes:new Map,labelPositions:new Map}}}const Ma={alias:!0,description:!0},Sx=256,Wy=26,Gy=14,qy=26,Ky=4;function Ia(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function Aa(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Ky,t))}function Ta(e){return e.alias.trim()!==e.name.trim()}function Zy(e,t){return t.alias&&Ta(e)?e.alias:e.name}function Oa(e,t){var n;return t.description&&((n=e.description)!=null&&n.trim())?e.description:null}function Uy(e,t){return Wy+(Oa(e,t)?Gy:0)}function kx(e,t=Ma){if(e.length===0)return 0;const n=Aa(e),r=e.length>n;return Ia(e).slice(0,n).reduce((s,a)=>s+Uy(a,t),0)+(r?qy:0)}function Cx({markerId:e,color:t,withStart:n}){return E.jsxs("defs",{children:[E.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&E.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function Mx({x:e,y:t,lines:n,selected:r,dimmed:o}){return n.length===0?null:E.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:E.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${r?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:"none",opacity:o?m0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((i,s)=>E.jsx("div",{children:i},`${String(s)}-${i}`))})})}function Ix(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function Qy({field:e,labels:t}){const n=Zy(e,t),r=Oa(e,t),o=Ta(e)?n===e.name?e.alias:e.name:null,i=[[n,o].filter(Boolean).join(" · "),e.isHidden?"(hidden from reporting)":null].filter(Boolean).join(" ");return E.jsxs("div",{className:"border-border/50 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:i,children:[E.jsxs("div",{className:"flex items-center gap-2",children:[e.isPrimaryKey?E.jsx(nl,{className:"h-3 w-3 shrink-0",style:{color:h0},"aria-label":"Primary key"}):E.jsx("span",{className:"w-3 shrink-0"}),E.jsx("span",{className:"text-foreground flex-1 truncate",children:n}),E.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]}),r&&E.jsx("div",{className:"text-muted-foreground/80 truncate pl-5 text-[10.5px] leading-[14px] italic",title:r,children:r})]})}function Ax({fields:e,labels:t=Ma,expanded:n,onToggleExpanded:r}){const o=Ia(e),i=Aa(e),s=n?o:o.slice(0,i),a=o.length-i;function c(l){l.stopPropagation(),l.preventDefault(),r()}return E.jsxs("div",{className:"border-t",children:[s.map(l=>E.jsx(Qy,{field:l,labels:t},l.name)),a>0&&E.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:l=>{l.stopPropagation()},onClick:c,children:n?E.jsxs(E.Fragment,{children:[E.jsx(el,{className:"h-3 w-3"})," Show less"]}):E.jsxs(E.Fragment,{children:[E.jsx(tl,{className:"h-3 w-3"})," +",a," more field",a!==1?"s":""]})})]})}export{Sx as A,En as B,sx as C,m0 as D,Ax as E,kx as F,Ma as G,sn as H,lg as I,ug as J,Ff as K,ex as L,ix as M,xx as N,h0 as O,W as P,Tp as R,mx as S,lx as W,tx as Z,ax as a,Er as b,te as c,bx as d,vx as e,wx as f,pr as g,Ex as h,nx as i,rx as j,px as k,p0 as l,cx as m,ux as n,_x as o,yx as p,ss as q,Nx as r,dx as s,Ix as t,ox as u,Cx as v,gx as w,hx as x,fx as y,Mx as z};
|