atomic-server 0.40.1

Create, share and model Atomic Data with this graph database server. Run atomic-server without any arguments to start the server. Use --help to learn about the options.
Documentation
var Ha=Object.defineProperty;var Fa=(e,t,n)=>t in e?Ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var te=(e,t,n)=>Fa(e,typeof t!="symbol"?t+"":t,n);import{r as _,a as ni,R as N,p as Fr,A as Tn,b as Ba,d as ja,n as ri,j as ae,u as Ga,_ as Ya,c as Xa,e as Wa,t as Ua}from"./index.js";function le(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=le(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var oi={exports:{}},ii={},si={exports:{}},ai={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var mt=_;function qa(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Za=typeof Object.is=="function"?Object.is:qa,Ka=mt.useState,Qa=mt.useEffect,Ja=mt.useLayoutEffect,ec=mt.useDebugValue;function tc(e,t){var n=t(),r=Ka({inst:{value:n,getSnapshot:t}}),o=r[0].inst,i=r[1];return Ja(function(){o.value=n,o.getSnapshot=t,On(o)&&i({inst:o})},[e,n,t]),Qa(function(){return On(o)&&i({inst:o}),e(function(){On(o)&&i({inst:o})})},[e]),ec(n),n}function On(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Za(e,n)}catch{return!0}}function nc(e,t){return t()}var rc=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?nc:tc;ai.useSyncExternalStore=mt.useSyncExternalStore!==void 0?mt.useSyncExternalStore:rc;si.exports=ai;var oc=si.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var xn=_,ic=oc;function sc(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ac=typeof Object.is=="function"?Object.is:sc,cc=ic.useSyncExternalStore,lc=xn.useRef,uc=xn.useEffect,fc=xn.useMemo,dc=xn.useDebugValue;ii.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var i=lc(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=fc(function(){function c(h){if(!l){if(l=!0,u=h,h=r(h),o!==void 0&&s.hasValue){var m=s.value;if(o(m,h))return f=m}return f=h}if(m=f,ac(u,h))return m;var g=r(h);return o!==void 0&&o(m,g)?m:(u=h,f=g)}var l=!1,u,f,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,o]);var a=cc(e,i[0],i[1]);return uc(function(){s.hasValue=!0,s.value=a},[a]),dc(a),a};oi.exports=ii;var hc=oi.exports;const pc=ni(hc),gc={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Br=e=>{let t;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(gc?"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},mc=e=>e?Br(e):Br,{useDebugValue:yc}=N,{useSyncExternalStoreWithSelector:wc}=pc,xc=e=>e;function ci(e,t=xc,n){const r=wc(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yc(r),r}const jr=(e,t)=>{const n=mc(e),r=(o,i=t)=>ci(n,o,i);return Object.assign(r,n),r},bc=(e,t)=>e?jr(e,t):jr;function se(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[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}var vc={value:()=>{}};function bn(){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 rn(n)}function rn(e){this._=e}function Ec(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}})}rn.prototype=bn.prototype={constructor:rn,on:function(e,t){var n=this._,r=Ec(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=_c(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]=Gr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Gr(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 rn(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 _c(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Gr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=vc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var qn="http://www.w3.org/1999/xhtml";const Yr={svg:"http://www.w3.org/2000/svg",xhtml:qn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Yr.hasOwnProperty(t)?{space:Yr[t],local:e}:e}function Sc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===qn&&t.documentElement.namespaceURI===qn?t.createElement(e):t.createElementNS(n,e)}}function Nc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function li(e){var t=vn(e);return(t.local?Nc:Sc)(t)}function kc(){}function hr(e){return e==null?kc:function(){return this.querySelector(e)}}function Cc(e){typeof e!="function"&&(e=hr(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 fe(r,this._parents)}function $c(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Mc(){return[]}function ui(e){return e==null?Mc:function(){return this.querySelectorAll(e)}}function Ac(e){return function(){return $c(e.apply(this,arguments))}}function Ic(e){typeof e=="function"?e=Ac(e):e=ui(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 fe(r,o)}function fi(e){return function(){return this.matches(e)}}function di(e){return function(t){return t.matches(e)}}var Tc=Array.prototype.find;function Oc(e){return function(){return Tc.call(this.children,e)}}function Rc(){return this.firstElementChild}function Pc(e){return this.select(e==null?Rc:Oc(typeof e=="function"?e:di(e)))}var Lc=Array.prototype.filter;function Dc(){return Array.from(this.children)}function zc(e){return function(){return Lc.call(this.children,e)}}function Vc(e){return this.selectAll(e==null?Dc:zc(typeof e=="function"?e:di(e)))}function Hc(e){typeof e!="function"&&(e=fi(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 fe(r,this._parents)}function hi(e){return new Array(e.length)}function Fc(){return new fe(this._enter||this._groups.map(hi),this._parents)}function cn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}cn.prototype={constructor:cn,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 Bc(e){return function(){return e}}function jc(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 cn(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Gc(e,t,n,r,o,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(d[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<f;++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 cn(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(o[a]=c)}function Yc(e){return e.__data__}function Xc(e,t){if(!arguments.length)return Array.from(this,Yc);var n=t?Gc:jc,r=this._parents,o=this._groups;typeof e!="function"&&(e=Bc(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],f=o[l],d=f.length,h=Wc(e.call(u,u&&u.__data__,l,r)),m=h.length,g=a[l]=new Array(m),w=s[l]=new Array(m),y=c[l]=new Array(d);n(u,f,g,w,y,h,t);for(var E=0,k=0,x,M;E<m;++E)if(x=g[E]){for(E>=k&&(k=E+1);!(M=w[k])&&++k<m;);x._next=M||null}}return s=new fe(s,r),s._enter=a,s._exit=c,s}function Wc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Uc(){return new fe(this._exit||this._groups.map(hi),this._parents)}function qc(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 Zc(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],f=l.length,d=a[c]=new Array(f),h,m=0;m<f;++m)(h=l[m]||u[m])&&(d[m]=h);for(;c<o;++c)a[c]=n[c];return new fe(a,this._parents)}function Kc(){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 Qc(e){e||(e=Jc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new fe(o,this._parents).order()}function Jc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function el(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tl(){return Array.from(this)}function nl(){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 ol(){return!this.node()}function il(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 sl(e){return function(){this.removeAttribute(e)}}function al(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cl(e,t){return function(){this.setAttribute(e,t)}}function ll(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ul(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function fl(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 dl(e,t){var n=vn(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?al:sl:typeof t=="function"?n.local?fl:ul:n.local?ll:cl)(n,t))}function pi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function hl(e){return function(){this.style.removeProperty(e)}}function pl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ml(e,t,n){return arguments.length>1?this.each((t==null?hl:typeof t=="function"?gl:pl)(e,t,n??"")):yt(this.node(),e)}function yt(e,t){return e.style.getPropertyValue(t)||pi(e).getComputedStyle(e,null).getPropertyValue(t)}function yl(e){return function(){delete this[e]}}function wl(e,t){return function(){this[e]=t}}function xl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bl(e,t){return arguments.length>1?this.each((t==null?yl:typeof t=="function"?xl:wl)(e,t)):this.node()[e]}function gi(e){return e.trim().split(/^|\s+/)}function pr(e){return e.classList||new mi(e)}function mi(e){this._node=e,this._names=gi(e.getAttribute("class")||"")}mi.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 yi(e,t){for(var n=pr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function wi(e,t){for(var n=pr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function vl(e){return function(){yi(this,e)}}function El(e){return function(){wi(this,e)}}function _l(e,t){return function(){(t.apply(this,arguments)?yi:wi)(this,e)}}function Sl(e,t){var n=gi(e+"");if(arguments.length<2){for(var r=pr(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?_l:t?vl:El)(n,t))}function Nl(){this.textContent=""}function kl(e){return function(){this.textContent=e}}function Cl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $l(e){return arguments.length?this.each(e==null?Nl:(typeof e=="function"?Cl:kl)(e)):this.node().textContent}function Ml(){this.innerHTML=""}function Al(e){return function(){this.innerHTML=e}}function Il(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tl(e){return arguments.length?this.each(e==null?Ml:(typeof e=="function"?Il:Al)(e)):this.node().innerHTML}function Ol(){this.nextSibling&&this.parentNode.appendChild(this)}function Rl(){return this.each(Ol)}function Pl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ll(){return this.each(Pl)}function Dl(e){var t=typeof e=="function"?e:li(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function zl(){return null}function Vl(e,t){var n=typeof e=="function"?e:li(e),r=t==null?zl:typeof t=="function"?t:hr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Hl(){var e=this.parentNode;e&&e.removeChild(this)}function Fl(){return this.each(Hl)}function Bl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gl(e){return this.select(e?jl:Bl)}function Yl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Xl(e){return function(t){e.call(this,t,this.__data__)}}function Wl(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 Ul(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 ql(e,t,n){return function(){var r=this.__on,o,i=Xl(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 Zl(e,t,n){var r=Wl(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?ql:Ul,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function xi(e,t,n){var r=pi(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 Kl(e,t){return function(){return xi(this,e,t)}}function Ql(e,t){return function(){return xi(this,e,t.apply(this,arguments))}}function Jl(e,t){return this.each((typeof t=="function"?Ql:Kl)(e,t))}function*eu(){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 bi=[null];function fe(e,t){this._groups=e,this._parents=t}function jt(){return new fe([[document.documentElement]],bi)}function tu(){return this}fe.prototype=jt.prototype={constructor:fe,select:Cc,selectAll:Ic,selectChild:Pc,selectChildren:Vc,filter:Hc,data:Xc,enter:Fc,exit:Uc,join:qc,merge:Zc,selection:tu,order:Kc,sort:Qc,call:el,nodes:tl,node:nl,size:rl,empty:ol,each:il,attr:dl,style:ml,property:bl,classed:Sl,text:$l,html:Tl,raise:Rl,lower:Ll,append:Dl,insert:Vl,remove:Fl,clone:Gl,datum:Yl,on:Zl,dispatch:Jl,[Symbol.iterator]:eu};function xe(e){return typeof e=="string"?new fe([[document.querySelector(e)]],[document.documentElement]):new fe([[e]],bi)}function nu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ne(e,t){if(e=nu(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},Pt={capture:!0,passive:!1};function Rn(e){e.stopImmediatePropagation()}function dt(e){e.preventDefault(),e.stopImmediatePropagation()}function vi(e){var t=e.document.documentElement,n=xe(e).on("dragstart.drag",dt,Pt);"onselectstart"in t?n.on("selectstart.drag",dt,Pt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ei(e,t){var n=e.document.documentElement,r=xe(e).on("dragstart.drag",null);t&&(r.on("click.drag",dt,Pt),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 Xt=e=>()=>e;function Zn(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}})}Zn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ou(e){return!e.ctrlKey&&!e.button}function iu(){return this.parentNode}function su(e,t){return t??{x:e.x,y:e.y}}function au(){return navigator.maxTouchPoints||"ontouchstart"in this}function cu(){var e=ou,t=iu,n=su,r=au,o={},i=bn("start","drag","end"),s=0,a,c,l,u,f=0;function d(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",y,ru).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,M){if(!(u||!e.call(this,x,M))){var I=k(this,t.call(this,x,M),x,M,"mouse");I&&(xe(x.view).on("mousemove.drag",m,Pt).on("mouseup.drag",g,Pt),vi(x.view),Rn(x),l=!1,a=x.clientX,c=x.clientY,I("start",x))}}function m(x){if(dt(x),!l){var M=x.clientX-a,I=x.clientY-c;l=M*M+I*I>f}o.mouse("drag",x)}function g(x){xe(x.view).on("mousemove.drag mouseup.drag",null),Ei(x.view,l),dt(x),o.mouse("end",x)}function w(x,M){if(e.call(this,x,M)){var I=x.changedTouches,P=t.call(this,x,M),D=I.length,A,z;for(A=0;A<D;++A)(z=k(this,P,x,M,I[A].identifier,I[A]))&&(Rn(x),z("start",x,I[A]))}}function y(x){var M=x.changedTouches,I=M.length,P,D;for(P=0;P<I;++P)(D=o[M[P].identifier])&&(dt(x),D("drag",x,M[P]))}function E(x){var M=x.changedTouches,I=M.length,P,D;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),P=0;P<I;++P)(D=o[M[P].identifier])&&(Rn(x),D("end",x,M[P]))}function k(x,M,I,P,D,A){var z=i.copy(),L=Ne(A||I,M),H,V,p;if((p=n.call(x,new Zn("beforestart",{sourceEvent:I,target:d,identifier:D,active:s,x:L[0],y:L[1],dx:0,dy:0,dispatch:z}),P))!=null)return H=p.x-L[0]||0,V=p.y-L[1]||0,function S(v,$,T){var b=L,C;switch(v){case"start":o[D]=S,C=s++;break;case"end":delete o[D],--s;case"drag":L=Ne(T||$,M),C=s;break}z.call(v,x,new Zn(v,{sourceEvent:$,subject:p,target:d,identifier:D,active:C,x:L[0]+H,y:L[1]+V,dx:L[0]-b[0],dy:L[1]-b[1],dispatch:z}),P)}}return d.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Xt(!!x),d):e},d.container=function(x){return arguments.length?(t=typeof x=="function"?x:Xt(x),d):t},d.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Xt(x),d):n},d.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:Xt(!!x),d):r},d.on=function(){var x=i.on.apply(i,arguments);return x===i?d:x},d.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,d):Math.sqrt(f)},d}function gr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _i(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Gt(){}var Lt=.7,ln=1/Lt,ht="\\s*([+-]?\\d+)\\s*",Dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ke="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",lu=/^#([0-9a-f]{3,8})$/,uu=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),fu=new RegExp(`^rgb\\(${ke},${ke},${ke}\\)$`),du=new RegExp(`^rgba\\(${ht},${ht},${ht},${Dt}\\)$`),hu=new RegExp(`^rgba\\(${ke},${ke},${ke},${Dt}\\)$`),pu=new RegExp(`^hsl\\(${Dt},${ke},${ke}\\)$`),gu=new RegExp(`^hsla\\(${Dt},${ke},${ke},${Dt}\\)$`),Xr={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};gr(Gt,zt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wr,formatHex:Wr,formatHex8:mu,formatHsl:yu,formatRgb:Ur,toString:Ur});function Wr(){return this.rgb().formatHex()}function mu(){return this.rgb().formatHex8()}function yu(){return Si(this).formatHsl()}function Ur(){return this.rgb().formatRgb()}function zt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=lu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?qr(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Wt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Wt(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=uu.exec(e))?new ce(t[1],t[2],t[3],1):(t=fu.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=du.exec(e))?Wt(t[1],t[2],t[3],t[4]):(t=hu.exec(e))?Wt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=pu.exec(e))?Qr(t[1],t[2]/100,t[3]/100,1):(t=gu.exec(e))?Qr(t[1],t[2]/100,t[3]/100,t[4]):Xr.hasOwnProperty(e)?qr(Xr[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function qr(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function Wt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ce(e,t,n,r)}function wu(e){return e instanceof Gt||(e=zt(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function Kn(e,t,n,r){return arguments.length===1?wu(e):new ce(e,t,n,r??1)}function ce(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gr(ce,Kn,_i(Gt,{brighter(e){return e=e==null?ln:Math.pow(ln,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(Qe(this.r),Qe(this.g),Qe(this.b),un(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:Zr,formatHex:Zr,formatHex8:xu,formatRgb:Kr,toString:Kr}));function Zr(){return`#${Ze(this.r)}${Ze(this.g)}${Ze(this.b)}`}function xu(){return`#${Ze(this.r)}${Ze(this.g)}${Ze(this.b)}${Ze((isNaN(this.opacity)?1:this.opacity)*255)}`}function Kr(){const e=un(this.opacity);return`${e===1?"rgb(":"rgba("}${Qe(this.r)}, ${Qe(this.g)}, ${Qe(this.b)}${e===1?")":`, ${e})`}`}function un(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ze(e){return e=Qe(e),(e<16?"0":"")+e.toString(16)}function Qr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new be(e,t,n,r)}function Si(e){if(e instanceof be)return new be(e.h,e.s,e.l,e.opacity);if(e instanceof Gt||(e=zt(e)),!e)return new be;if(e instanceof be)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 be(s,a,c,e.opacity)}function bu(e,t,n,r){return arguments.length===1?Si(e):new be(e,t,n,r??1)}function be(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gr(be,bu,_i(Gt,{brighter(e){return e=e==null?ln:Math.pow(ln,e),new be(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new be(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 ce(Pn(e>=240?e-240:e+120,o,r),Pn(e,o,r),Pn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new be(Jr(this.h),Ut(this.s),Ut(this.l),un(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=un(this.opacity);return`${e===1?"hsl(":"hsla("}${Jr(this.h)}, ${Ut(this.s)*100}%, ${Ut(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Jr(e){return e=(e||0)%360,e<0?e+360:e}function Ut(e){return Math.max(0,Math.min(1,e||0))}function Pn(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 Ni=e=>()=>e;function vu(e,t){return function(n){return e+n*t}}function Eu(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 _u(e){return(e=+e)==1?ki:function(t,n){return n-t?Eu(t,n,e):Ni(isNaN(t)?n:t)}}function ki(e,t){var n=t-e;return n?vu(e,n):Ni(isNaN(e)?t:e)}const eo=function e(t){var n=_u(t);function r(o,i){var s=n((o=Kn(o)).r,(i=Kn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=ki(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 Le(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ln=new RegExp(Qn.source,"g");function Su(e){return function(){return e}}function Nu(e){return function(t){return e(t)+""}}function ku(e,t){var n=Qn.lastIndex=Ln.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Qn.exec(e))&&(o=Ln.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:Le(r,o)})),n=Ln.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Nu(c[0].x):Su(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}var to=180/Math.PI,Jn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ci(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)*to,skewX:Math.atan(c)*to,scaleX:s,scaleY:a}}var qt;function Cu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Jn:Ci(t.a,t.b,t.c,t.d,t.e,t.f)}function $u(e){return e==null||(qt||(qt=document.createElementNS("http://www.w3.org/2000/svg","g")),qt.setAttribute("transform",e),!(e=qt.transform.baseVal.consolidate()))?Jn:(e=e.matrix,Ci(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,f,d,h,m){if(l!==f||u!==d){var g=h.push("translate(",null,t,null,n);m.push({i:g-4,x:Le(l,f)},{i:g-2,x:Le(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(o(f)+"rotate(",null,r)-2,x:Le(l,u)})):u&&f.push(o(f)+"rotate("+u+r)}function a(l,u,f,d){l!==u?d.push({i:f.push(o(f)+"skewX(",null,r)-2,x:Le(l,u)}):u&&f.push(o(f)+"skewX("+u+r)}function c(l,u,f,d,h,m){if(l!==f||u!==d){var g=h.push(o(h)+"scale(",null,",",null,")");m.push({i:g-4,x:Le(l,f)},{i:g-2,x:Le(u,d)})}else(f!==1||d!==1)&&h.push(o(h)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(h){for(var m=-1,g=d.length,w;++m<g;)f[(w=d[m]).i]=w.x(h);return f.join("")}}}var Mu=$i(Cu,"px, ","px)","deg)"),Au=$i($u,", ",")",")"),Iu=1e-12;function no(e){return((e=Math.exp(e))+1/e)/2}function Tu(e){return((e=Math.exp(e))-1/e)/2}function Ou(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ru=function e(t,n,r){function o(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],h=u-a,m=f-c,g=h*h+m*m,w,y;if(g<Iu)y=Math.log(d/l)/t,w=function(P){return[a+P*h,c+P*m,l*Math.exp(t*P*y)]};else{var E=Math.sqrt(g),k=(d*d-l*l+r*g)/(2*l*n*E),x=(d*d-l*l-r*g)/(2*d*n*E),M=Math.log(Math.sqrt(k*k+1)-k),I=Math.log(Math.sqrt(x*x+1)-x);y=(I-M)/t,w=function(P){var D=P*y,A=no(M),z=l/(n*E)*(A*Ou(t*D+M)-Tu(M));return[a+z*h,c+z*m,l*A/no(t*D+M)]}}return w.duration=y*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 wt=0,It=0,St=0,Mi=1e3,fn,Tt,dn=0,Je=0,En=0,Vt=typeof performance=="object"&&performance.now?performance:Date,Ai=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mr(){return Je||(Ai(Pu),Je=Vt.now()+En)}function Pu(){Je=0}function hn(){this._call=this._time=this._next=null}hn.prototype=Ii.prototype={constructor:hn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?mr():+n)+(t==null?0:+t),!this._next&&Tt!==this&&(Tt?Tt._next=this:fn=this,Tt=this),this._call=e,this._time=n,er()},stop:function(){this._call&&(this._call=null,this._time=1/0,er())}};function Ii(e,t,n){var r=new hn;return r.restart(e,t,n),r}function Lu(){mr(),++wt;for(var e=fn,t;e;)(t=Je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wt}function ro(){Je=(dn=Vt.now())+En,wt=It=0;try{Lu()}finally{wt=0,zu(),Je=0}}function Du(){var e=Vt.now(),t=e-dn;t>Mi&&(En-=t,dn=e)}function zu(){for(var e,t=fn,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:fn=n);Tt=e,er(r)}function er(e){if(!wt){It&&(It=clearTimeout(It));var t=e-Je;t>24?(e<1/0&&(It=setTimeout(ro,e-Vt.now()-En)),St&&(St=clearInterval(St))):(St||(dn=Vt.now(),St=setInterval(Du,Mi)),wt=1,Ai(ro))}}function oo(e,t,n){var r=new hn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Vu=bn("start","end","cancel","interrupt"),Hu=[],Ti=0,io=1,tr=2,on=3,so=4,nr=5,sn=6;function _n(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Fu(e,n,{name:t,index:r,group:o,on:Vu,tween:Hu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ti})}function yr(e,t){var n=ve(e,t);if(n.state>Ti)throw new Error("too late; already scheduled");return n}function Ce(e,t){var n=ve(e,t);if(n.state>on)throw new Error("too late; already running");return n}function ve(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Ii(i,0,n.time);function i(l){n.state=io,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,h;if(n.state!==io)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===on)return oo(s);h.state===so?(h.state=sn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=sn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(oo(function(){n.state===on&&(n.state=so,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=tr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===tr){for(n.state=on,o=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++f]=h);o.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=nr,1),f=-1,d=o.length;++f<d;)o[f].call(e,u);n.state===nr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=sn,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function an(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>tr&&r.state<nr,r.state=sn,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Bu(e){return this.each(function(){an(this,e)})}function ju(e,t){var n,r;return function(){var o=Ce(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 Gu(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Ce(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 Yu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ve(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?ju:Gu)(n,e,t))}function wr(e,t,n){var r=e._id;return e.each(function(){var o=Ce(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ve(o,r).value[t]}}function Oi(e,t){var n;return(typeof t=="number"?Le:t instanceof zt?eo:(n=zt(t))?(t=n,eo):ku)(e,t)}function Xu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Uu(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 qu(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 Zu(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 Ku(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 Qu(e,t){var n=vn(e),r=n==="transform"?Au:Oi;return this.attrTween(e,typeof t=="function"?(n.local?Ku:Zu)(n,r,wr(this,"attr."+e,t)):t==null?(n.local?Wu:Xu)(n):(n.local?qu:Uu)(n,r,t))}function Ju(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ef(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function tf(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&ef(e,i)),n}return o._value=t,o}function nf(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ju(e,i)),n}return o._value=t,o}function rf(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=vn(e);return this.tween(n,(r.local?tf:nf)(r,t))}function of(e,t){return function(){yr(this,e).delay=+t.apply(this,arguments)}}function sf(e,t){return t=+t,function(){yr(this,e).delay=t}}function af(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?of:sf)(t,e)):ve(this.node(),t).delay}function cf(e,t){return function(){Ce(this,e).duration=+t.apply(this,arguments)}}function lf(e,t){return t=+t,function(){Ce(this,e).duration=t}}function uf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?cf:lf)(t,e)):ve(this.node(),t).duration}function ff(e,t){if(typeof t!="function")throw new Error;return function(){Ce(this,e).ease=t}}function df(e){var t=this._id;return arguments.length?this.each(ff(t,e)):ve(this.node(),t).ease}function hf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ce(this,e).ease=n}}function pf(e){if(typeof e!="function")throw new Error;return this.each(hf(this._id,e))}function gf(e){typeof e!="function"&&(e=fi(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 Oe(r,this._parents,this._name,this._id)}function mf(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,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=c[h]||l[h])&&(f[h]=d);for(;a<r;++a)s[a]=t[a];return new Oe(s,this._parents,this._name,this._id)}function yf(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 wf(e,t,n){var r,o,i=yf(t)?yr:Ce;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function xf(e,t){var n=this._id;return arguments.length<2?ve(this.node(),n).on.on(e):this.each(wf(n,e,t))}function bf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vf(){return this.on("end.remove",bf(this._id))}function Ef(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hr(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,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,_n(l[d],t,n,d,l,ve(u,n)));return new Oe(i,this._parents,t,n)}function _f(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ui(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,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),h,m=ve(u,n),g=0,w=d.length;g<w;++g)(h=d[g])&&_n(h,t,n,g,d,m);i.push(d),s.push(u)}return new Oe(i,s,t,n)}var Sf=jt.prototype.constructor;function Nf(){return new Sf(this._groups,this._parents)}function kf(e,t){var n,r,o;return function(){var i=yt(this,e),s=(this.style.removeProperty(e),yt(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Ri(e){return function(){this.style.removeProperty(e)}}function Cf(e,t,n){var r,o=n+"",i;return function(){var s=yt(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function $f(e,t,n){var r,o,i;return function(){var s=yt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),yt(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=Ce(this,e),l=c.on,u=c.value[i]==null?a||(a=Ri(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function Af(e,t,n){var r=(e+="")=="transform"?Mu:Oi;return t==null?this.styleTween(e,kf(e,r)).on("end.style."+e,Ri(e)):typeof t=="function"?this.styleTween(e,$f(e,r,wr(this,"style."+e,t))).each(Mf(this._id,e)):this.styleTween(e,Cf(e,r,t),n).on("end.style."+e,null)}function If(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Tf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&If(e,s,n)),r}return i._value=t,i}function Of(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,Tf(e,t,n??""))}function Rf(e){return function(){this.textContent=e}}function Pf(e){return function(){var t=e(this);this.textContent=t??""}}function Lf(e){return this.tween("text",typeof e=="function"?Pf(wr(this,"text",e)):Rf(e==null?"":e+""))}function Df(e){return function(t){this.textContent=e.call(this,t)}}function zf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Df(o)),t}return r._value=e,r}function Vf(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,zf(e))}function Hf(){for(var e=this._name,t=this._id,n=Pi(),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=ve(c,t);_n(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Oe(r,this._parents,e,n)}function Ff(){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=Ce(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 Bf=0;function Oe(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Pi(){return++Bf}var Ae=jt.prototype;Oe.prototype={constructor:Oe,select:Ef,selectAll:_f,selectChild:Ae.selectChild,selectChildren:Ae.selectChildren,filter:gf,merge:mf,selection:Nf,transition:Hf,call:Ae.call,nodes:Ae.nodes,node:Ae.node,size:Ae.size,empty:Ae.empty,each:Ae.each,on:xf,attr:Qu,attrTween:rf,style:Af,styleTween:Of,text:Lf,textTween:Vf,remove:vf,tween:Yu,delay:af,duration:uf,ease:df,easeVarying:pf,end:Ff,[Symbol.iterator]:Ae[Symbol.iterator]};function jf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gf={time:null,delay:0,duration:250,ease:jf};function Yf(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 Xf(e){var t,n;e instanceof Oe?(t=e._id,e=e._name):(t=Pi(),(n=Gf).time=mr(),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])&&_n(c,e,t,l,s,n||Yf(c,t));return new Oe(r,this._parents,e,t)}jt.prototype.interrupt=Bu;jt.prototype.transition=Xf;const Zt=e=>()=>e;function Wf(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 Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(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 Ve=new Te(1,0,0);Te.prototype;function Dn(e){e.stopImmediatePropagation()}function Nt(e){e.preventDefault(),e.stopImmediatePropagation()}function Uf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qf(){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 ao(){return this.__zoom||Ve}function Zf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qf(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 Jf(){var e=Uf,t=qf,n=Qf,r=Zf,o=Kf,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ru,l=bn("start","zoom","end"),u,f,d,h=500,m=150,g=0,w=10;function y(p){p.property("__zoom",ao).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",L).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(p,S,v,$){var T=p.selection?p.selection():p;T.property("__zoom",ao),p!==T?M(p,S,v,$):T.interrupt().each(function(){I(this,arguments).event($).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},y.scaleBy=function(p,S,v,$){y.scaleTo(p,function(){var T=this.__zoom.k,b=typeof S=="function"?S.apply(this,arguments):S;return T*b},v,$)},y.scaleTo=function(p,S,v,$){y.transform(p,function(){var T=t.apply(this,arguments),b=this.__zoom,C=v==null?x(T):typeof v=="function"?v.apply(this,arguments):v,O=b.invert(C),R=typeof S=="function"?S.apply(this,arguments):S;return n(k(E(b,R),C,O),T,s)},v,$)},y.translateBy=function(p,S,v,$){y.transform(p,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),s)},null,$)},y.translateTo=function(p,S,v,$,T){y.transform(p,function(){var b=t.apply(this,arguments),C=this.__zoom,O=$==null?x(b):typeof $=="function"?$.apply(this,arguments):$;return n(Ve.translate(O[0],O[1]).scale(C.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof v=="function"?-v.apply(this,arguments):-v),b,s)},$,T)};function E(p,S){return S=Math.max(i[0],Math.min(i[1],S)),S===p.k?p:new Te(S,p.x,p.y)}function k(p,S,v){var $=S[0]-v[0]*p.k,T=S[1]-v[1]*p.k;return $===p.x&&T===p.y?p:new Te(p.k,$,T)}function x(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function M(p,S,v,$){p.on("start.zoom",function(){I(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event($).end()}).tween("zoom",function(){var T=this,b=arguments,C=I(T,b).event($),O=t.apply(T,b),R=v==null?x(O):typeof v=="function"?v.apply(T,b):v,B=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),F=T.__zoom,Y=typeof S=="function"?S.apply(T,b):S,W=c(F.invert(R).concat(B/F.k),Y.invert(R).concat(B/Y.k));return function(U){if(U===1)U=Y;else{var q=W(U),J=B/q[2];U=new Te(J,R[0]-q[0]*J,R[1]-q[1]*J)}C.zoom(null,U)}})}function I(p,S,v){return!v&&p.__zooming||new P(p,S)}function P(p,S){this.that=p,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,S),this.taps=0}P.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,S){return this.mouse&&p!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var S=xe(this.that).datum();l.call(p,this.that,new Wf(p,{sourceEvent:this.sourceEvent,target:y,type:p,transform:this.that.__zoom,dispatch:l}),S)}};function D(p,...S){if(!e.apply(this,arguments))return;var v=I(this,S).event(p),$=this.__zoom,T=Math.max(i[0],Math.min(i[1],$.k*Math.pow(2,r.apply(this,arguments)))),b=Ne(p);if(v.wheel)(v.mouse[0][0]!==b[0]||v.mouse[0][1]!==b[1])&&(v.mouse[1]=$.invert(v.mouse[0]=b)),clearTimeout(v.wheel);else{if($.k===T)return;v.mouse=[b,$.invert(b)],an(this),v.start()}Nt(p),v.wheel=setTimeout(C,m),v.zoom("mouse",n(k(E($,T),v.mouse[0],v.mouse[1]),v.extent,s));function C(){v.wheel=null,v.end()}}function A(p,...S){if(d||!e.apply(this,arguments))return;var v=p.currentTarget,$=I(this,S,!0).event(p),T=xe(p.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",B,!0),b=Ne(p,v),C=p.clientX,O=p.clientY;vi(p.view),Dn(p),$.mouse=[b,this.__zoom.invert(b)],an(this),$.start();function R(F){if(Nt(F),!$.moved){var Y=F.clientX-C,W=F.clientY-O;$.moved=Y*Y+W*W>g}$.event(F).zoom("mouse",n(k($.that.__zoom,$.mouse[0]=Ne(F,v),$.mouse[1]),$.extent,s))}function B(F){T.on("mousemove.zoom mouseup.zoom",null),Ei(F.view,$.moved),Nt(F),$.event(F).end()}}function z(p,...S){if(e.apply(this,arguments)){var v=this.__zoom,$=Ne(p.changedTouches?p.changedTouches[0]:p,this),T=v.invert($),b=v.k*(p.shiftKey?.5:2),C=n(k(E(v,b),$,T),t.apply(this,S),s);Nt(p),a>0?xe(this).transition().duration(a).call(M,C,$,p):xe(this).call(y.transform,C,$,p)}}function L(p,...S){if(e.apply(this,arguments)){var v=p.touches,$=v.length,T=I(this,S,p.changedTouches.length===$).event(p),b,C,O,R;for(Dn(p),C=0;C<$;++C)O=v[C],R=Ne(O,this),R=[R,this.__zoom.invert(R),O.identifier],T.touch0?!T.touch1&&T.touch0[2]!==R[2]&&(T.touch1=R,T.taps=0):(T.touch0=R,b=!0,T.taps=1+!!u);u&&(u=clearTimeout(u)),b&&(T.taps<2&&(f=R[0],u=setTimeout(function(){u=null},h)),an(this),T.start())}}function H(p,...S){if(this.__zooming){var v=I(this,S).event(p),$=p.changedTouches,T=$.length,b,C,O,R;for(Nt(p),b=0;b<T;++b)C=$[b],O=Ne(C,this),v.touch0&&v.touch0[2]===C.identifier?v.touch0[0]=O:v.touch1&&v.touch1[2]===C.identifier&&(v.touch1[0]=O);if(C=v.that.__zoom,v.touch1){var B=v.touch0[0],F=v.touch0[1],Y=v.touch1[0],W=v.touch1[1],U=(U=Y[0]-B[0])*U+(U=Y[1]-B[1])*U,q=(q=W[0]-F[0])*q+(q=W[1]-F[1])*q;C=E(C,Math.sqrt(U/q)),O=[(B[0]+Y[0])/2,(B[1]+Y[1])/2],R=[(F[0]+W[0])/2,(F[1]+W[1])/2]}else if(v.touch0)O=v.touch0[0],R=v.touch0[1];else return;v.zoom("touch",n(k(C,O,R),v.extent,s))}}function V(p,...S){if(this.__zooming){var v=I(this,S).event(p),$=p.changedTouches,T=$.length,b,C;for(Dn(p),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),b=0;b<T;++b)C=$[b],v.touch0&&v.touch0[2]===C.identifier?delete v.touch0:v.touch1&&v.touch1[2]===C.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(C=Ne(C,this),Math.hypot(f[0]-C[0],f[1]-C[1])<w)){var O=xe(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return y.wheelDelta=function(p){return arguments.length?(r=typeof p=="function"?p:Zt(+p),y):r},y.filter=function(p){return arguments.length?(e=typeof p=="function"?p:Zt(!!p),y):e},y.touchable=function(p){return arguments.length?(o=typeof p=="function"?p:Zt(!!p),y):o},y.extent=function(p){return arguments.length?(t=typeof p=="function"?p:Zt([[+p[0][0],+p[0][1]],[+p[1][0],+p[1][1]]]),y):t},y.scaleExtent=function(p){return arguments.length?(i[0]=+p[0],i[1]=+p[1],y):[i[0],i[1]]},y.translateExtent=function(p){return arguments.length?(s[0][0]=+p[0][0],s[1][0]=+p[1][0],s[0][1]=+p[0][1],s[1][1]=+p[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(p){return arguments.length?(n=p,y):n},y.duration=function(p){return arguments.length?(a=+p,y):a},y.interpolate=function(p){return arguments.length?(c=p,y):c},y.on=function(){var p=l.on.apply(l,arguments);return p===l?y:p},y.clickDistance=function(p){return arguments.length?(g=(p=+p)*p,y):Math.sqrt(g)},y.tapDistance=function(p){return arguments.length?(w=+p,y):w},y}const Sn=_.createContext(null),ed=Sn.Provider,Re={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Li=Re.error001();function Q(e,t){const n=_.useContext(Sn);if(n===null)throw new Error(Li);return ci(n,e,t)}const oe=()=>{const e=_.useContext(Sn);if(e===null)throw new Error(Li);return _.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},td=e=>e.userSelectionActive?"none":"all";function Di({position:e,children:t,className:n,style:r,...o}){const i=Q(td),s=`${e}`.split("-");return N.createElement("div",{className:le(["react-flow__panel",n,...s]),style:{...r,pointerEvents:i},...o},t)}function nd({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:N.createElement(Di,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},N.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const rd=({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 f=_.useRef(null),[d,h]=_.useState({x:0,y:0,width:0,height:0}),m=le(["react-flow__edge-textwrapper",l]);return _.useEffect(()=>{if(f.current){const g=f.current.getBBox();h({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),typeof n>"u"||!n?null:N.createElement("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:m,visibility:d.width?"visible":"hidden",...u},o&&N.createElement("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.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:f,style:r},n),c)};var zi=_.memo(rd);const xr=e=>({width:e.offsetWidth,height:e.offsetHeight}),xt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),br=(e={x:0,y:0},t)=>({x:xt(e.x,t[0][0],t[1][0]),y:xt(e.y,t[0][1],t[1][1])}),co=(e,t,n)=>e<t?xt(Math.abs(e-t),1,50)/50:e>n?-xt(Math.abs(e-n),1,50)/50:0,Vi=(e,t)=>{const n=co(e.x,35,t.width-35)*20,r=co(e.y,35,t.height-35)*20;return[n,r]},Hi=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},od=(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)}),vr=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),id=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),lo=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),rr=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},sd=e=>pe(e.width)&&pe(e.height)&&pe(e.x)&&pe(e.y),pe=e=>!isNaN(e)&&isFinite(e),ee=Symbol.for("internals"),Fi=["Enter"," ","Escape"],ad=(e,t)=>{},cd=e=>"nativeEvent"in e;function or(e){var o,i;const t=cd(e)?e.nativeEvent:e,n=((i=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:i[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Bi=e=>"clientX"in e,He=(e,t)=>{var i,s;const n=Bi(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)}},pn=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Yt=({id:e,path:t,labelX:n,labelY:r,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:h=20})=>N.createElement(N.Fragment,null,N.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:d}),h&&N.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),o&&pe(n)&&pe(r)?N.createElement(zi,{x:n,y:r,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null);Yt.displayName="BaseEdge";function kt(e,t,n){return n===void 0?n:r=>{const o=t().edges.find(i=>i.id===e);o&&n(r,{...o})}}function ji({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 Gi({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),f=Math.abs(l-t);return[c,l,u,f]}var et;(function(e){e.Strict="strict",e.Loose="loose"})(et||(et={}));var Ke;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ke||(Ke={}));var Ht;(function(e){e.Partial="partial",e.Full="full"})(Ht||(Ht={}));var ze;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ze||(ze={}));var Ft;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ft||(Ft={}));var j;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(j||(j={}));function uo({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===j.Left||e===j.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Yi({sourceX:e,sourceY:t,sourcePosition:n=j.Bottom,targetX:r,targetY:o,targetPosition:i=j.Top}){const[s,a]=uo({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=uo({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,f,d,h]=Gi({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,f,d,h]}const Er=_.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=j.Bottom,targetPosition:i=j.Top,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,interactionWidth:g})=>{const[w,y,E]=Yi({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:i});return N.createElement(Yt,{path:w,labelX:y,labelY:E,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,interactionWidth:g})});Er.displayName="SimpleBezierEdge";const fo={[j.Left]:{x:-1,y:0},[j.Right]:{x:1,y:0},[j.Top]:{x:0,y:-1},[j.Bottom]:{x:0,y:1}},ld=({source:e,sourcePosition:t=j.Bottom,target:n})=>t===j.Left||t===j.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},ho=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ud({source:e,sourcePosition:t=j.Bottom,target:n,targetPosition:r=j.Top,center:o,offset:i}){const s=fo[t],a=fo[r],c={x:e.x+s.x*i,y:e.y+s.y*i},l={x:n.x+a.x*i,y:n.y+a.y*i},u=ld({source:c,sourcePosition:t,target:l}),f=u.x!==0?"x":"y",d=u[f];let h=[],m,g;const w={x:0,y:0},y={x:0,y:0},[E,k,x,M]=ji({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*a[f]===-1){m=o.x??E,g=o.y??k;const P=[{x:m,y:c.y},{x:m,y:l.y}],D=[{x:c.x,y:g},{x:l.x,y:g}];s[f]===d?h=f==="x"?P:D:h=f==="x"?D:P}else{const P=[{x:c.x,y:l.y}],D=[{x:l.x,y:c.y}];if(f==="x"?h=s.x===d?D:P:h=s.y===d?P:D,t===r){const V=Math.abs(e[f]-n[f]);if(V<=i){const p=Math.min(i-1,i-V);s[f]===d?w[f]=(c[f]>e[f]?-1:1)*p:y[f]=(l[f]>n[f]?-1:1)*p}}if(t!==r){const V=f==="x"?"y":"x",p=s[f]===a[V],S=c[V]>l[V],v=c[V]<l[V];(s[f]===1&&(!p&&S||p&&v)||s[f]!==1&&(!p&&v||p&&S))&&(h=f==="x"?P:D)}const A={x:c.x+w.x,y:c.y+w.y},z={x:l.x+y.x,y:l.y+y.y},L=Math.max(Math.abs(A.x-h[0].x),Math.abs(z.x-h[0].x)),H=Math.max(Math.abs(A.y-h[0].y),Math.abs(z.y-h[0].y));L>=H?(m=(A.x+z.x)/2,g=h[0].y):(m=h[0].x,g=(A.y+z.y)/2)}return[[e,{x:c.x+w.x,y:c.y+w.y},...h,{x:l.x+y.x,y:l.y+y.y},n],m,g,x,M]}function fd(e,t,n,r){const o=Math.min(ho(e,t)/2,ho(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 ir({sourceX:e,sourceY:t,sourcePosition:n=j.Bottom,targetX:r,targetY:o,targetPosition:i=j.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20}){const[u,f,d,h,m]=ud({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:l});return[u.reduce((w,y,E)=>{let k="";return E>0&&E<u.length-1?k=fd(u[E-1],y,u[E+1],s):k=`${E===0?"M":"L"}${y.x} ${y.y}`,w+=k,w},""),f,d,h,m]}const Nn=_.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:f=j.Bottom,targetPosition:d=j.Top,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:w})=>{const[y,E,k]=ir({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:r,targetPosition:d,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset});return N.createElement(Yt,{path:y,labelX:E,labelY:k,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:m,interactionWidth:w})});Nn.displayName="SmoothStepEdge";const _r=_.memo(e=>{var t;return N.createElement(Nn,{...e,pathOptions:_.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});_r.displayName="StepEdge";function dd({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=ji({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const Sr=_.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:h})=>{const[m,g,w]=dd({sourceX:e,sourceY:t,targetX:n,targetY:r});return N.createElement(Yt,{path:m,labelX:g,labelY:w,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:h})});Sr.displayName="StraightEdge";function Kt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function po({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case j.Left:return[t-Kt(t-r,i),n];case j.Right:return[t+Kt(r-t,i),n];case j.Top:return[t,n-Kt(n-o,i)];case j.Bottom:return[t,n+Kt(o-n,i)]}}function Nr({sourceX:e,sourceY:t,sourcePosition:n=j.Bottom,targetX:r,targetY:o,targetPosition:i=j.Top,curvature:s=.25}){const[a,c]=po({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=po({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[f,d,h,m]=Gi({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}`,f,d,h,m]}const gn=_.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=j.Bottom,targetPosition:i=j.Top,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:w})=>{const[y,E,k]=Nr({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:i,curvature:g==null?void 0:g.curvature});return N.createElement(Yt,{path:y,labelX:E,labelY:k,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,interactionWidth:w})});gn.displayName="BezierEdge";const kr=_.createContext(null),hd=kr.Provider;kr.Consumer;const pd=()=>_.useContext(kr),gd=e=>"id"in e&&"source"in e&&"target"in e,md=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,sr=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,yd=(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)),wd=(e,t)=>{if(!e.source||!e.target)return t;let n;return gd(e)?n={...e}:n={...e,id:md(e)},yd(n,t)?t:t.concat(n)},ar=({x:e,y:t},[n,r,o],i,[s,a])=>{const c={x:(e-n)/o,y:(t-r)/o};return i?{x:s*Math.round(c.x/s),y:a*Math.round(c.y/a)}:c},Xi=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),pt=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},Cr=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const{x:i,y:s}=pt(o,t).positionAbsolute;return od(r,vr({x:i,y:s,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return id(n)},Wi=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1,a=[0,0])=>{const c={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},l=[];return e.forEach(u=>{const{width:f,height:d,selectable:h=!0,hidden:m=!1}=u;if(s&&!h||m)return!1;const{positionAbsolute:g}=pt(u,a),w={x:g.x,y:g.y,width:f||0,height:d||0},y=rr(c,w),E=typeof f>"u"||typeof d>"u"||f===null||d===null,k=i&&y>0,x=(f||0)*(d||0);(E||k||y>=x||u.dragging)&&l.push(u)}),l},Ui=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},qi=(e,t,n,r,o,i=.1)=>{const s=t/(e.width*(1+i)),a=n/(e.height*(1+i)),c=Math.min(s,a),l=xt(c,r,o),u=e.x+e.width/2,f=e.y+e.height/2,d=t/2-u*l,h=n/2-f*l;return{x:d,y:h,zoom:l}},qe=(e,t=0)=>e.transition().duration(t);function go(e,t,n,r){return(t[n]||[]).reduce((o,i)=>{var s,a;return`${e.id}-${i.id}-${n}`!==r&&o.push({id:i.id||null,type:n,nodeId:e.id,x:(((s=e.positionAbsolute)==null?void 0:s.x)??0)+i.x+i.width/2,y:(((a=e.positionAbsolute)==null?void 0:a.y)??0)+i.y+i.height/2}),o},[])}function xd(e,t,n,r,o,i){const{x:s,y:a}=He(e),l=t.elementsFromPoint(s,a).find(m=>m.classList.contains("react-flow__handle"));if(l){const m=l.getAttribute("data-nodeid");if(m){const g=$r(void 0,l),w=l.getAttribute("data-handleid"),y=i({nodeId:m,id:w,type:g});if(y){const E=o.find(k=>k.nodeId===m&&k.type===g&&k.id===w);return{handle:{id:w,type:g,nodeId:m,x:(E==null?void 0:E.x)||n.x,y:(E==null?void 0:E.y)||n.y},validHandleResult:y}}}}let u=[],f=1/0;if(o.forEach(m=>{const g=Math.sqrt((m.x-n.x)**2+(m.y-n.y)**2);if(g<=r){const w=i(m);g<=f&&(g<f?u=[{handle:m,validHandleResult:w}]:g===f&&u.push({handle:m,validHandleResult:w}),f=g)}}),!u.length)return{handle:null,validHandleResult:Zi()};if(u.length===1)return u[0];const d=u.some(({validHandleResult:m})=>m.isValid),h=u.some(({handle:m})=>m.type==="target");return u.find(({handle:m,validHandleResult:g})=>h?m.type==="target":d?g.isValid:!0)||u[0]}const bd={source:null,target:null,sourceHandle:null,targetHandle:null},Zi=()=>({handleDomNode:null,isValid:!1,connection:bd,endHandle:null});function Ki(e,t,n,r,o,i,s){const a=o==="target",c=s.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),l={...Zi(),handleDomNode:c};if(c){const u=$r(void 0,c),f=c.getAttribute("data-nodeid"),d=c.getAttribute("data-handleid"),h=c.classList.contains("connectable"),m=c.classList.contains("connectableend"),g={source:a?f:n,sourceHandle:a?d:r,target:a?n:f,targetHandle:a?r:d};l.connection=g,h&&m&&(t===et.Strict?a&&u==="source"||!a&&u==="target":f!==n||d!==r)&&(l.endHandle={nodeId:f,handleId:d,type:u},l.isValid=i(g))}return l}function vd({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((o,i)=>{if(i[ee]){const{handleBounds:s}=i[ee];let a=[],c=[];s&&(a=go(i,s,"source",`${t}-${n}-${r}`),c=go(i,s,"target",`${t}-${n}-${r}`)),o.push(...a,...c)}return o},[])}function $r(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zn(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Ed(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Qi({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:i,setState:s,isValidConnection:a,edgeUpdaterType:c,onReconnectEnd:l}){const u=Hi(e.target),{connectionMode:f,domNode:d,autoPanOnConnect:h,connectionRadius:m,onConnectStart:g,panBy:w,getNodes:y,cancelConnection:E}=i();let k=0,x;const{x:M,y:I}=He(e),P=u==null?void 0:u.elementFromPoint(M,I),D=$r(c,P),A=d==null?void 0:d.getBoundingClientRect();if(!A||!D)return;let z,L=He(e,A),H=!1,V=null,p=!1,S=null;const v=vd({nodes:y(),nodeId:n,handleId:t,handleType:D}),$=()=>{if(!h)return;const[C,O]=Vi(L,A);w({x:C,y:O}),k=requestAnimationFrame($)};s({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:D,connectionStartHandle:{nodeId:n,handleId:t,type:D},connectionEndHandle:null}),g==null||g(e,{nodeId:n,handleId:t,handleType:D});function T(C){const{transform:O}=i();L=He(C,A);const{handle:R,validHandleResult:B}=xd(C,u,ar(L,O,!1,[1,1]),m,v,F=>Ki(F,f,n,t,o?"target":"source",a,u));if(x=R,H||($(),H=!0),S=B.handleDomNode,V=B.connection,p=B.isValid,s({connectionPosition:x&&p?Xi({x:x.x,y:x.y},O):L,connectionStatus:Ed(!!x,p),connectionEndHandle:B.endHandle}),!x&&!p&&!S)return zn(z);V.source!==V.target&&S&&(zn(z),z=S,S.classList.add("connecting","react-flow__handle-connecting"),S.classList.toggle("valid",p),S.classList.toggle("react-flow__handle-valid",p))}function b(C){var O,R;(x||S)&&V&&p&&(r==null||r(V)),(R=(O=i()).onConnectEnd)==null||R.call(O,C),c&&(l==null||l(C)),zn(z),E(),cancelAnimationFrame(k),H=!1,p=!1,V=null,S=null,u.removeEventListener("mousemove",T),u.removeEventListener("mouseup",b),u.removeEventListener("touchmove",T),u.removeEventListener("touchend",b)}u.addEventListener("mousemove",T),u.addEventListener("mouseup",b),u.addEventListener("touchmove",T),u.addEventListener("touchend",b)}const mo=()=>!0,_d=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Sd=(e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:i,connectionClickStartHandle:s}=r;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n||(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n}},Ji=_.forwardRef(({type:e="source",position:t=j.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:f,...d},h)=>{var A,z;const m=s||null,g=e==="target",w=oe(),y=pd(),{connectOnClick:E,noPanClassName:k}=Q(_d,se),{connecting:x,clickConnecting:M}=Q(Sd(y,m,e),se);y||(z=(A=w.getState()).onError)==null||z.call(A,"010",Re.error010());const I=L=>{const{defaultEdgeOptions:H,onConnect:V,hasDefaultEdges:p}=w.getState(),S={...H,...L};if(p){const{edges:v,setEdges:$}=w.getState();$(wd(S,v))}V==null||V(S),a==null||a(S)},P=L=>{if(!y)return;const H=Bi(L);o&&(H&&L.button===0||!H)&&Qi({event:L,handleId:m,nodeId:y,onConnect:I,isTarget:g,getState:w.getState,setState:w.setState,isValidConnection:n||w.getState().isValidConnection||mo}),H?u==null||u(L):f==null||f(L)},D=L=>{const{onClickConnectStart:H,onClickConnectEnd:V,connectionClickStartHandle:p,connectionMode:S,isValidConnection:v}=w.getState();if(!y||!p&&!o)return;if(!p){H==null||H(L,{nodeId:y,handleId:m,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:y,type:e,handleId:m}});return}const $=Hi(L.target),T=n||v||mo,{connection:b,isValid:C}=Ki({nodeId:y,id:m,type:e},S,p.nodeId,p.handleId||null,p.type,T,$);C&&I(b),V==null||V(L),w.setState({connectionClickStartHandle:null})};return N.createElement("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${y}-${m}-${e}`,className:le(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,l,{source:!g,target:g,connectable:r,connectablestart:o,connectableend:i,connecting:M,connectionindicator:r&&(o&&!x||i&&x)}]),onMouseDown:P,onTouchStart:P,onClick:E?D:void 0,ref:h,...d},c)});Ji.displayName="Handle";var mn=_.memo(Ji);const es=({data:e,isConnectable:t,targetPosition:n=j.Top,sourcePosition:r=j.Bottom})=>N.createElement(N.Fragment,null,N.createElement(mn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,N.createElement(mn,{type:"source",position:r,isConnectable:t}));es.displayName="DefaultNode";var cr=_.memo(es);const ts=({data:e,isConnectable:t,sourcePosition:n=j.Bottom})=>N.createElement(N.Fragment,null,e==null?void 0:e.label,N.createElement(mn,{type:"source",position:n,isConnectable:t}));ts.displayName="InputNode";var ns=_.memo(ts);const rs=({data:e,isConnectable:t,targetPosition:n=j.Top})=>N.createElement(N.Fragment,null,N.createElement(mn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);rs.displayName="OutputNode";var os=_.memo(rs);const Mr=()=>null;Mr.displayName="GroupNode";const Nd=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Qt=e=>e.id;function kd(e,t){return se(e.selectedNodes.map(Qt),t.selectedNodes.map(Qt))&&se(e.selectedEdges.map(Qt),t.selectedEdges.map(Qt))}const is=_.memo(({onSelectionChange:e})=>{const t=oe(),{selectedNodes:n,selectedEdges:r}=Q(Nd,kd);return _.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChange.forEach(i=>i(o))},[n,r,e]),null});is.displayName="SelectionListener";const Cd=e=>!!e.onSelectionChange;function $d({onSelectionChange:e}){const t=Q(Cd);return e||t?N.createElement(is,{onSelectionChange:e}):null}const Md=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function at(e,t){_.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function X(e,t,n){_.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const Ad=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:i,onConnectEnd:s,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:f,edgesFocusable:d,edgesUpdatable:h,elevateNodesOnSelect:m,minZoom:g,maxZoom:w,nodeExtent:y,onNodesChange:E,onEdgesChange:k,elementsSelectable:x,connectionMode:M,snapGrid:I,snapToGrid:P,translateExtent:D,connectOnClick:A,defaultEdgeOptions:z,fitView:L,fitViewOptions:H,onNodesDelete:V,onEdgesDelete:p,onNodeDrag:S,onNodeDragStart:v,onNodeDragStop:$,onSelectionDrag:T,onSelectionDragStart:b,onSelectionDragStop:C,noPanClassName:O,nodeOrigin:R,rfId:B,autoPanOnConnect:F,autoPanOnNodeDrag:Y,onError:W,connectionRadius:U,isValidConnection:q,nodeDragThreshold:J})=>{const{setNodes:Z,setEdges:me,setDefaultNodesAndEdges:de,setMinZoom:ye,setMaxZoom:he,setTranslateExtent:re,setNodeExtent:_e,reset:K}=Q(Md,se),G=oe();return _.useEffect(()=>{const ue=r==null?void 0:r.map(Fe=>({...Fe,...z}));return de(n,ue),()=>{K()}},[]),X("defaultEdgeOptions",z,G.setState),X("connectionMode",M,G.setState),X("onConnect",o,G.setState),X("onConnectStart",i,G.setState),X("onConnectEnd",s,G.setState),X("onClickConnectStart",a,G.setState),X("onClickConnectEnd",c,G.setState),X("nodesDraggable",l,G.setState),X("nodesConnectable",u,G.setState),X("nodesFocusable",f,G.setState),X("edgesFocusable",d,G.setState),X("edgesUpdatable",h,G.setState),X("elementsSelectable",x,G.setState),X("elevateNodesOnSelect",m,G.setState),X("snapToGrid",P,G.setState),X("snapGrid",I,G.setState),X("onNodesChange",E,G.setState),X("onEdgesChange",k,G.setState),X("connectOnClick",A,G.setState),X("fitViewOnInit",L,G.setState),X("fitViewOnInitOptions",H,G.setState),X("onNodesDelete",V,G.setState),X("onEdgesDelete",p,G.setState),X("onNodeDrag",S,G.setState),X("onNodeDragStart",v,G.setState),X("onNodeDragStop",$,G.setState),X("onSelectionDrag",T,G.setState),X("onSelectionDragStart",b,G.setState),X("onSelectionDragStop",C,G.setState),X("noPanClassName",O,G.setState),X("nodeOrigin",R,G.setState),X("rfId",B,G.setState),X("autoPanOnConnect",F,G.setState),X("autoPanOnNodeDrag",Y,G.setState),X("onError",W,G.setState),X("connectionRadius",U,G.setState),X("isValidConnection",q,G.setState),X("nodeDragThreshold",J,G.setState),at(e,Z),at(t,me),at(g,ye),at(w,he),at(D,re),at(y,_e),null},yo={display:"none"},Id={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ss="react-flow__node-desc",as="react-flow__edge-desc",Td="react-flow__aria-live",Od=e=>e.ariaLiveMessage;function Rd({rfId:e}){const t=Q(Od);return N.createElement("div",{id:`${Td}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Id},t)}function Pd({rfId:e,disableKeyboardA11y:t}){return N.createElement(N.Fragment,null,N.createElement("div",{id:`${ss}-${e}`,style:yo},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),N.createElement("div",{id:`${as}-${e}`,style:yo},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&N.createElement(Rd,{rfId:e}))}var Bt=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=_.useState(!1),o=_.useRef(!1),i=_.useRef(new Set([])),[s,a]=_.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),u=l.reduce((f,d)=>f.concat(...d),[]);return[l,u]}return[[],[]]},[e]);return _.useEffect(()=>{const c=typeof document<"u"?document:null,l=(t==null?void 0:t.target)||c;if(e!==null){const u=h=>{if(o.current=h.ctrlKey||h.metaKey||h.shiftKey,(!o.current||o.current&&!t.actInsideInputWithModifier)&&or(h))return!1;const g=xo(h.code,a);i.current.add(h[g]),wo(s,i.current,!1)&&(h.preventDefault(),r(!0))},f=h=>{if((!o.current||o.current&&!t.actInsideInputWithModifier)&&or(h))return!1;const g=xo(h.code,a);wo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},d=()=>{i.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",d),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",d)}}},[e,r]),n};function wo(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function xo(e,t){return t.includes(e)?"code":"key"}function cs(e,t,n,r){var a,c;const o=e.parentNode||e.parentId;if(!o)return n;const i=t.get(o),s=pt(i,r);return cs(i,t,{x:(n.x??0)+s.x,y:(n.y??0)+s.y,z:(((a=i[ee])==null?void 0:a.z)??0)>(n.z??0)?((c=i[ee])==null?void 0:c.z)??0:n.z??0},r)}function ls(e,t,n){e.forEach(r=>{var i;const o=r.parentNode||r.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||n!=null&&n[r.id]){const{x:s,y:a,z:c}=cs(r,e,{...r.position,z:((i=r[ee])==null?void 0:i.z)??0},t);r.positionAbsolute={x:s,y:a},r[ee].z=c,n!=null&&n[r.id]&&(r[ee].isParent=!0)}})}function Vn(e,t,n,r){const o=new Map,i={},s=r?1e3:0;return e.forEach(a=>{var h;const c=(pe(a.zIndex)?a.zIndex:0)+(a.selected?s:0),l=t.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},f=a.parentNode||a.parentId;f&&(i[f]=!0);const d=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==a.type;Object.defineProperty(u,ee,{enumerable:!1,value:{handleBounds:d||(h=l==null?void 0:l[ee])==null?void 0:h.handleBounds,z:c}}),o.set(a.id,u)}),ls(o,n,i),o}function us(e,t={}){const{getNodes:n,width:r,height:o,minZoom:i,maxZoom:s,d3Zoom:a,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:f}=e(),d=t.initial&&!l&&u;if(a&&c&&(d||!t.initial)){const m=n().filter(w=>{var E;const y=t.includeHiddenNodes?w.width&&w.height:!w.hidden;return(E=t.nodes)!=null&&E.length?y&&t.nodes.some(k=>k.id===w.id):y}),g=m.every(w=>w.width&&w.height);if(m.length>0&&g){const w=Cr(m,f),{x:y,y:E,zoom:k}=qi(w,r,o,t.minZoom??i,t.maxZoom??s,t.padding??.1),x=Ve.translate(y,E).scale(k);return typeof t.duration=="number"&&t.duration>0?a.transform(qe(c,t.duration),x):a.transform(c,x),!0}}return!1}function Ld(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[ee]:r[ee],selected:n.selected})}),new Map(t)}function Dd(e,t){return t.map(n=>{const r=e.find(o=>o.id===n.id);return r&&(n.selected=r.selected),n})}function Jt({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:i,onNodesChange:s,onEdgesChange:a,hasDefaultNodes:c,hasDefaultEdges:l}=n();e!=null&&e.length&&(c&&r({nodeInternals:Ld(e,o)}),s==null||s(e)),t!=null&&t.length&&(l&&r({edges:Dd(t,i)}),a==null||a(t))}const ct=()=>{},zd={zoomIn:ct,zoomOut:ct,zoomTo:ct,getZoom:()=>1,setViewport:ct,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ct,fitBounds:ct,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},Vd=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),Hd=()=>{const e=oe(),{d3Zoom:t,d3Selection:n}=Q(Vd,se);return _.useMemo(()=>n&&t?{zoomIn:o=>t.scaleBy(qe(n,o==null?void 0:o.duration),1.2),zoomOut:o=>t.scaleBy(qe(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,i)=>t.scaleTo(qe(n,i==null?void 0:i.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,i)=>{const[s,a,c]=e.getState().transform,l=Ve.translate(o.x??s,o.y??a).scale(o.zoom??c);t.transform(qe(n,i==null?void 0:i.duration),l)},getViewport:()=>{const[o,i,s]=e.getState().transform;return{x:o,y:i,zoom:s}},fitView:o=>us(e.getState,o),setCenter:(o,i,s)=>{const{width:a,height:c,maxZoom:l}=e.getState(),u=typeof(s==null?void 0:s.zoom)<"u"?s.zoom:l,f=a/2-o*u,d=c/2-i*u,h=Ve.translate(f,d).scale(u);t.transform(qe(n,s==null?void 0:s.duration),h)},fitBounds:(o,i)=>{const{width:s,height:a,minZoom:c,maxZoom:l}=e.getState(),{x:u,y:f,zoom:d}=qi(o,s,a,c,l,(i==null?void 0:i.padding)??.1),h=Ve.translate(u,f).scale(d);t.transform(qe(n,i==null?void 0:i.duration),h)},project:o=>{const{transform:i,snapToGrid:s,snapGrid:a}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),ar(o,i,s,a)},screenToFlowPosition:o=>{const{transform:i,snapToGrid:s,snapGrid:a,domNode:c}=e.getState();if(!c)return o;const{x:l,y:u}=c.getBoundingClientRect(),f={x:o.x-l,y:o.y-u};return ar(f,i,s,a)},flowToScreenPosition:o=>{const{transform:i,domNode:s}=e.getState();if(!s)return o;const{x:a,y:c}=s.getBoundingClientRect(),l=Xi(o,i);return{x:l.x+a,y:l.y+c}},viewportInitialized:!0}:zd,[t,n])};function kn(){const e=Hd(),t=oe(),n=_.useCallback(()=>t.getState().getNodes().map(g=>({...g})),[]),r=_.useCallback(g=>t.getState().nodeInternals.get(g),[]),o=_.useCallback(()=>{const{edges:g=[]}=t.getState();return g.map(w=>({...w}))},[]),i=_.useCallback(g=>{const{edges:w=[]}=t.getState();return w.find(y=>y.id===g)},[]),s=_.useCallback(g=>{const{getNodes:w,setNodes:y,hasDefaultNodes:E,onNodesChange:k}=t.getState(),x=w(),M=typeof g=="function"?g(x):g;if(E)y(M);else if(k){const I=M.length===0?x.map(P=>({type:"remove",id:P.id})):M.map(P=>({item:P,type:"reset"}));k(I)}},[]),a=_.useCallback(g=>{const{edges:w=[],setEdges:y,hasDefaultEdges:E,onEdgesChange:k}=t.getState(),x=typeof g=="function"?g(w):g;if(E)y(x);else if(k){const M=x.length===0?w.map(I=>({type:"remove",id:I.id})):x.map(I=>({item:I,type:"reset"}));k(M)}},[]),c=_.useCallback(g=>{const w=Array.isArray(g)?g:[g],{getNodes:y,setNodes:E,hasDefaultNodes:k,onNodesChange:x}=t.getState();if(k){const I=[...y(),...w];E(I)}else if(x){const M=w.map(I=>({item:I,type:"add"}));x(M)}},[]),l=_.useCallback(g=>{const w=Array.isArray(g)?g:[g],{edges:y=[],setEdges:E,hasDefaultEdges:k,onEdgesChange:x}=t.getState();if(k)E([...y,...w]);else if(x){const M=w.map(I=>({item:I,type:"add"}));x(M)}},[]),u=_.useCallback(()=>{const{getNodes:g,edges:w=[],transform:y}=t.getState(),[E,k,x]=y;return{nodes:g().map(M=>({...M})),edges:w.map(M=>({...M})),viewport:{x:E,y:k,zoom:x}}},[]),f=_.useCallback(({nodes:g,edges:w})=>{const{nodeInternals:y,getNodes:E,edges:k,hasDefaultNodes:x,hasDefaultEdges:M,onNodesDelete:I,onEdgesDelete:P,onNodesChange:D,onEdgesChange:A}=t.getState(),z=(g||[]).map(S=>S.id),L=(w||[]).map(S=>S.id),H=E().reduce((S,v)=>{const $=v.parentNode||v.parentId,T=!z.includes(v.id)&&$&&S.find(C=>C.id===$);return(typeof v.deletable=="boolean"?v.deletable:!0)&&(z.includes(v.id)||T)&&S.push(v),S},[]),V=k.filter(S=>typeof S.deletable=="boolean"?S.deletable:!0),p=V.filter(S=>L.includes(S.id));if(H||p){const S=Ui(H,V),v=[...p,...S],$=v.reduce((T,b)=>(T.includes(b.id)||T.push(b.id),T),[]);if((M||x)&&(M&&t.setState({edges:k.filter(T=>!$.includes(T.id))}),x&&(H.forEach(T=>{y.delete(T.id)}),t.setState({nodeInternals:new Map(y)}))),$.length>0&&(P==null||P(v),A&&A($.map(T=>({id:T,type:"remove"})))),H.length>0&&(I==null||I(H),D)){const T=H.map(b=>({id:b.id,type:"remove"}));D(T)}}},[]),d=_.useCallback(g=>{const w=sd(g),y=w?null:t.getState().nodeInternals.get(g.id);return!w&&!y?[null,null,w]:[w?g:lo(y),y,w]},[]),h=_.useCallback((g,w=!0,y)=>{const[E,k,x]=d(g);return E?(y||t.getState().getNodes()).filter(M=>{if(!x&&(M.id===k.id||!M.positionAbsolute))return!1;const I=lo(M),P=rr(I,E);return w&&P>0||P>=E.width*E.height}):[]},[]),m=_.useCallback((g,w,y=!0)=>{const[E]=d(g);if(!E)return!1;const k=rr(E,w);return y&&k>0||k>=E.width*E.height},[]);return _.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:o,getEdge:i,setNodes:s,setEdges:a,addNodes:c,addEdges:l,toObject:u,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:m}),[e,n,r,o,i,s,a,c,l,u,f,h,m])}const Fd={actInsideInputWithModifier:!1};var Bd=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=oe(),{deleteElements:r}=kn(),o=Bt(e,Fd),i=Bt(t);_.useEffect(()=>{if(o){const{edges:s,getNodes:a}=n.getState(),c=a().filter(u=>u.selected),l=s.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[o]),_.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])};function jd(e){const t=oe();_.useEffect(()=>{let n;const r=()=>{var i,s;if(!e.current)return;const o=xr(e.current);(o.height===0||o.width===0)&&((s=(i=t.getState()).onError)==null||s.call(i,"004",Re.error004())),t.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Ar={position:"absolute",width:"100%",height:"100%",top:0,left:0},Gd=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,en=e=>({x:e.x,y:e.y,zoom:e.k}),lt=(e,t)=>e.target.closest(`.${t}`),bo=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vo=e=>{const t=e.ctrlKey&&pn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Yd=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),Xd=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=Ke.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:f=!0,defaultViewport:d,translateExtent:h,minZoom:m,maxZoom:g,zoomActivationKeyCode:w,preventScrolling:y=!0,children:E,noWheelClassName:k,noPanClassName:x})=>{const M=_.useRef(),I=oe(),P=_.useRef(!1),D=_.useRef(!1),A=_.useRef(null),z=_.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:H,d3ZoomHandler:V,userSelectionActive:p}=Q(Yd,se),S=Bt(w),v=_.useRef(0),$=_.useRef(!1),T=_.useRef();return jd(A),_.useEffect(()=>{if(A.current){const b=A.current.getBoundingClientRect(),C=Jf().scaleExtent([m,g]).translateExtent(h),O=xe(A.current).call(C),R=Ve.translate(d.x,d.y).scale(xt(d.zoom,m,g)),B=[[0,0],[b.width,b.height]],F=C.constrain()(R,B,h);C.transform(O,F),C.wheelDelta(vo),I.setState({d3Zoom:C,d3Selection:O,d3ZoomHandler:O.on("wheel.zoom"),transform:[F.x,F.y,F.k],domNode:A.current.closest(".react-flow")})}},[]),_.useEffect(()=>{H&&L&&(s&&!S&&!p?H.on("wheel.zoom",b=>{if(lt(b,k))return!1;b.preventDefault(),b.stopImmediatePropagation();const C=H.property("__zoom").k||1;if(b.ctrlKey&&i){const q=Ne(b),J=vo(b),Z=C*Math.pow(2,J);L.scaleTo(H,Z,q,b);return}const O=b.deltaMode===1?20:1;let R=c===Ke.Vertical?0:b.deltaX*O,B=c===Ke.Horizontal?0:b.deltaY*O;!pn()&&b.shiftKey&&c!==Ke.Vertical&&(R=b.deltaY*O,B=0),L.translateBy(H,-(R/C)*a,-(B/C)*a,{internal:!0});const F=en(H.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:W,onViewportChangeEnd:U}=I.getState();clearTimeout(T.current),$.current||($.current=!0,t==null||t(b,F),Y==null||Y(F)),$.current&&(e==null||e(b,F),W==null||W(F),T.current=setTimeout(()=>{n==null||n(b,F),U==null||U(F),$.current=!1},150))},{passive:!1}):typeof V<"u"&&H.on("wheel.zoom",function(b,C){if(!y&&b.type==="wheel"&&!b.ctrlKey||lt(b,k))return null;b.preventDefault(),V.call(this,b,C)},{passive:!1}))},[p,s,c,H,L,V,S,i,y,k,t,e,n]),_.useEffect(()=>{L&&L.on("start",b=>{var R,B;if(!b.sourceEvent||b.sourceEvent.internal)return null;v.current=(R=b.sourceEvent)==null?void 0:R.button;const{onViewportChangeStart:C}=I.getState(),O=en(b.transform);P.current=!0,z.current=O,((B=b.sourceEvent)==null?void 0:B.type)==="mousedown"&&I.setState({paneDragging:!0}),C==null||C(O),t==null||t(b.sourceEvent,O)})},[L,t]),_.useEffect(()=>{L&&(p&&!P.current?L.on("zoom",null):p||L.on("zoom",b=>{var O;const{onViewportChange:C}=I.getState();if(I.setState({transform:[b.transform.x,b.transform.y,b.transform.k]}),D.current=!!(r&&bo(f,v.current??0)),(e||C)&&!((O=b.sourceEvent)!=null&&O.internal)){const R=en(b.transform);C==null||C(R),e==null||e(b.sourceEvent,R)}}))},[p,L,e,f,r]),_.useEffect(()=>{L&&L.on("end",b=>{if(!b.sourceEvent||b.sourceEvent.internal)return null;const{onViewportChangeEnd:C}=I.getState();if(P.current=!1,I.setState({paneDragging:!1}),r&&bo(f,v.current??0)&&!D.current&&r(b.sourceEvent),D.current=!1,(n||C)&&Gd(z.current,b.transform)){const O=en(b.transform);z.current=O,clearTimeout(M.current),M.current=setTimeout(()=>{C==null||C(O),n==null||n(b.sourceEvent,O)},s?150:0)}})},[L,s,f,n,r]),_.useEffect(()=>{L&&L.filter(b=>{const C=S||o,O=i&&b.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&b.button===1&&b.type==="mousedown"&&(lt(b,"react-flow__node")||lt(b,"react-flow__edge")))return!0;if(!f&&!C&&!s&&!l&&!i||p||!l&&b.type==="dblclick"||lt(b,k)&&b.type==="wheel"||lt(b,x)&&(b.type!=="wheel"||s&&b.type==="wheel"&&!S)||!i&&b.ctrlKey&&b.type==="wheel"||!C&&!s&&!O&&b.type==="wheel"||!f&&(b.type==="mousedown"||b.type==="touchstart")||Array.isArray(f)&&!f.includes(b.button)&&b.type==="mousedown")return!1;const R=Array.isArray(f)&&f.includes(b.button)||!b.button||b.button<=1;return(!b.ctrlKey||b.type==="wheel")&&R})},[p,L,o,i,s,l,f,u,S]),N.createElement("div",{className:"react-flow__renderer",ref:A,style:Ar},E)},Wd=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ud(){const{userSelectionActive:e,userSelectionRect:t}=Q(Wd,se);return e&&t?N.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Eo(e,t){const n=t.parentNode||t.parentId,r=e.find(o=>o.id===n);if(r){const o=t.position.x+t.width-r.width,i=t.position.y+t.height-r.height;if(o>0||i>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,o>0&&(r.style.width+=o),i>0&&(r.style.height+=i),t.position.x<0){const s=Math.abs(t.position.x);r.position.x=r.position.x-s,r.style.width+=s,t.position.x=0}if(t.position.y<0){const s=Math.abs(t.position.y);r.position.y=r.position.y-s,r.style.height+=s,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function qd(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,o)=>{const i=e.filter(a=>a.id===o.id);if(i.length===0)return r.push(o),r;const s={...o};for(const a of i)if(a)switch(a.type){case"select":{s.selected=a.selected;break}case"position":{typeof a.position<"u"&&(s.position=a.position),typeof a.positionAbsolute<"u"&&(s.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(s.dragging=a.dragging),s.expandParent&&Eo(r,s);break}case"dimensions":{typeof a.dimensions<"u"&&(s.width=a.dimensions.width,s.height=a.dimensions.height),typeof a.updateStyle<"u"&&(s.style={...s.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(s.resizing=a.resizing),s.expandParent&&Eo(r,s);break}case"remove":return r}return r.push(s),r},n)}function fs(e,t){return qd(e,t)}const De=(e,t)=>({id:e,type:"select",selected:t});function ft(e,t){return e.reduce((n,r)=>{const o=t.includes(r.id);return!r.selected&&o?(r.selected=!0,n.push(De(r.id,!0))):r.selected&&!o&&(r.selected=!1,n.push(De(r.id,!1))),n},[])}const Hn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Zd=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),ds=_.memo(({isSelecting:e,selectionMode:t=Ht.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:i,onPaneContextMenu:s,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:f})=>{const d=_.useRef(null),h=oe(),m=_.useRef(0),g=_.useRef(0),w=_.useRef(),{userSelectionActive:y,elementsSelectable:E,dragging:k}=Q(Zd,se),x=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,g.current=0},M=V=>{i==null||i(V),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},I=V=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){V.preventDefault();return}s==null||s(V)},P=a?V=>a(V):void 0,D=V=>{const{resetSelectedElements:p,domNode:S}=h.getState();if(w.current=S==null?void 0:S.getBoundingClientRect(),!E||!e||V.button!==0||V.target!==d.current||!w.current)return;const{x:v,y:$}=He(V,w.current);p(),h.setState({userSelectionRect:{width:0,height:0,startX:v,startY:$,x:v,y:$}}),r==null||r(V)},A=V=>{const{userSelectionRect:p,nodeInternals:S,edges:v,transform:$,onNodesChange:T,onEdgesChange:b,nodeOrigin:C,getNodes:O}=h.getState();if(!e||!w.current||!p)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const R=He(V,w.current),B=p.startX??0,F=p.startY??0,Y={...p,x:R.x<B?R.x:B,y:R.y<F?R.y:F,width:Math.abs(R.x-B),height:Math.abs(R.y-F)},W=O(),U=Wi(S,Y,$,t===Ht.Partial,!0,C),q=Ui(U,v).map(Z=>Z.id),J=U.map(Z=>Z.id);if(m.current!==J.length){m.current=J.length;const Z=ft(W,J);Z.length&&(T==null||T(Z))}if(g.current!==q.length){g.current=q.length;const Z=ft(v,q);Z.length&&(b==null||b(Z))}h.setState({userSelectionRect:Y})},z=V=>{if(V.button!==0)return;const{userSelectionRect:p}=h.getState();!y&&p&&V.target===d.current&&(M==null||M(V)),h.setState({nodesSelectionActive:m.current>0}),x(),o==null||o(V)},L=V=>{y&&(h.setState({nodesSelectionActive:m.current>0}),o==null||o(V)),x()},H=E&&(e||y);return N.createElement("div",{className:le(["react-flow__pane",{dragging:k,selection:e}]),onClick:H?void 0:Hn(M,d),onContextMenu:Hn(I,d),onWheel:Hn(P,d),onMouseEnter:H?void 0:c,onMouseDown:H?D:void 0,onMouseMove:H?A:l,onMouseUp:H?z:void 0,onMouseLeave:H?L:u,ref:d,style:Ar},f,N.createElement(Ud,null))});ds.displayName="Pane";function hs(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:hs(r,t):!1}function _o(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Kd(e,t,n,r){return Array.from(e.values()).filter(o=>(o.selected||o.id===r)&&(!o.parentNode||o.parentId||!hs(o,e))&&(o.draggable||t&&typeof o.draggable>"u")).map(o=>{var i,s;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((i=o.positionAbsolute)==null?void 0:i.x)??0),y:n.y-(((s=o.positionAbsolute)==null?void 0:s.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function Qd(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function ps(e,t,n,r,o=[0,0],i){const s=Qd(e,e.extent||r);let a=s;const c=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(c&&e.width&&e.height){const f=n.get(c),{x:d,y:h}=pt(f,o).positionAbsolute;a=f&&pe(d)&&pe(h)&&pe(f.width)&&pe(f.height)?[[d+e.width*o[0],h+e.height*o[1]],[d+f.width-e.width+e.width*o[0],h+f.height-e.height+e.height*o[1]]]:a}else i==null||i("005",Re.error005()),a=s;else if(e.extent&&c&&e.extent!=="parent"){const f=n.get(c),{x:d,y:h}=pt(f,o).positionAbsolute;a=[[e.extent[0][0]+d,e.extent[0][1]+h],[e.extent[1][0]+d,e.extent[1][1]+h]]}let l={x:0,y:0};if(c){const f=n.get(c);l=pt(f,o).positionAbsolute}const u=a&&a!=="parent"?br(t,a):t;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function Fn({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(o=>({...n.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?r.find(o=>o.id===e):r[0],r]}const So=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const i=Array.from(o),s=t.getBoundingClientRect(),a={x:s.width*r[0],y:s.height*r[1]};return i.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-s.left-a.x)/n,y:(l.top-s.top-a.y)/n,...xr(c)}})};function Ct(e,t,n){return n===void 0?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function lr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeInternals:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",Re.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 Jd(){const e=oe();return _.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:o,snapToGrid:i}=e.getState(),s=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,c={x:(s-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:i?o[0]*Math.round(c.x/o[0]):c.x,ySnapped:i?o[1]*Math.round(c.y/o[1]):c.y,...c}},[])}function Bn(e){return(t,n,r)=>e==null?void 0:e(t,r)}function gs({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,selectNodesOnDrag:s}){const a=oe(),[c,l]=_.useState(!1),u=_.useRef([]),f=_.useRef({x:null,y:null}),d=_.useRef(0),h=_.useRef(null),m=_.useRef({x:0,y:0}),g=_.useRef(null),w=_.useRef(!1),y=_.useRef(!1),E=_.useRef(!1),k=Jd();return _.useEffect(()=>{if(e!=null&&e.current){const x=xe(e.current),M=({x:D,y:A})=>{const{nodeInternals:z,onNodeDrag:L,onSelectionDrag:H,updateNodePositions:V,nodeExtent:p,snapGrid:S,snapToGrid:v,nodeOrigin:$,onError:T}=a.getState();f.current={x:D,y:A};let b=!1,C={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&p){const R=Cr(u.current,$);C=vr(R)}if(u.current=u.current.map(R=>{const B={x:D-R.distance.x,y:A-R.distance.y};v&&(B.x=S[0]*Math.round(B.x/S[0]),B.y=S[1]*Math.round(B.y/S[1]));const F=[[p[0][0],p[0][1]],[p[1][0],p[1][1]]];u.current.length>1&&p&&!R.extent&&(F[0][0]=R.positionAbsolute.x-C.x+p[0][0],F[1][0]=R.positionAbsolute.x+(R.width??0)-C.x2+p[1][0],F[0][1]=R.positionAbsolute.y-C.y+p[0][1],F[1][1]=R.positionAbsolute.y+(R.height??0)-C.y2+p[1][1]);const Y=ps(R,B,z,F,$,T);return b=b||R.position.x!==Y.position.x||R.position.y!==Y.position.y,R.position=Y.position,R.positionAbsolute=Y.positionAbsolute,R}),!b)return;V(u.current,!0,!0),l(!0);const O=o?L:Bn(H);if(O&&g.current){const[R,B]=Fn({nodeId:o,dragItems:u.current,nodeInternals:z});O(g.current,R,B)}},I=()=>{if(!h.current)return;const[D,A]=Vi(m.current,h.current);if(D!==0||A!==0){const{transform:z,panBy:L}=a.getState();f.current.x=(f.current.x??0)-D/z[2],f.current.y=(f.current.y??0)-A/z[2],L({x:D,y:A})&&M(f.current)}d.current=requestAnimationFrame(I)},P=D=>{var $;const{nodeInternals:A,multiSelectionActive:z,nodesDraggable:L,unselectNodesAndEdges:H,onNodeDragStart:V,onSelectionDragStart:p}=a.getState();y.current=!0;const S=o?V:Bn(p);(!s||!i)&&!z&&o&&(($=A.get(o))!=null&&$.selected||H()),o&&i&&s&&lr({id:o,store:a,nodeRef:e});const v=k(D);if(f.current=v,u.current=Kd(A,L,v,o),S&&u.current){const[T,b]=Fn({nodeId:o,dragItems:u.current,nodeInternals:A});S(D.sourceEvent,T,b)}};if(t)x.on(".drag",null);else{const D=cu().on("start",A=>{const{domNode:z,nodeDragThreshold:L}=a.getState();L===0&&P(A),E.current=!1;const H=k(A);f.current=H,h.current=(z==null?void 0:z.getBoundingClientRect())||null,m.current=He(A.sourceEvent,h.current)}).on("drag",A=>{var V,p;const z=k(A),{autoPanOnNodeDrag:L,nodeDragThreshold:H}=a.getState();if(A.sourceEvent.type==="touchmove"&&A.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!w.current&&y.current&&L&&(w.current=!0,I()),!y.current){const S=z.xSnapped-(((V=f==null?void 0:f.current)==null?void 0:V.x)??0),v=z.ySnapped-(((p=f==null?void 0:f.current)==null?void 0:p.y)??0);Math.sqrt(S*S+v*v)>H&&P(A)}(f.current.x!==z.xSnapped||f.current.y!==z.ySnapped)&&u.current&&y.current&&(g.current=A.sourceEvent,m.current=He(A.sourceEvent,h.current),M(z))}}).on("end",A=>{if(!(!y.current||E.current)&&(l(!1),w.current=!1,y.current=!1,cancelAnimationFrame(d.current),u.current)){const{updateNodePositions:z,nodeInternals:L,onNodeDragStop:H,onSelectionDragStop:V}=a.getState(),p=o?H:Bn(V);if(z(u.current,!1,!1),p){const[S,v]=Fn({nodeId:o,dragItems:u.current,nodeInternals:L});p(A.sourceEvent,S,v)}}}).filter(A=>{const z=A.target;return!A.button&&(!n||!_o(z,`.${n}`,e))&&(!r||_o(z,r,e))});return x.call(D),()=>{x.on(".drag",null)}}}},[e,t,n,r,i,a,o,s,k]),c}function ms(){const e=oe();return _.useCallback(n=>{const{nodeInternals:r,nodeExtent:o,updateNodePositions:i,getNodes:s,snapToGrid:a,snapGrid:c,onError:l,nodesDraggable:u}=e.getState(),f=s().filter(E=>E.selected&&(E.draggable||u&&typeof E.draggable>"u")),d=a?c[0]:5,h=a?c[1]:5,m=n.isShiftPressed?4:1,g=n.x*d*m,w=n.y*h*m,y=f.map(E=>{if(E.positionAbsolute){const k={x:E.positionAbsolute.x+g,y:E.positionAbsolute.y+w};a&&(k.x=c[0]*Math.round(k.x/c[0]),k.y=c[1]*Math.round(k.y/c[1]));const{positionAbsolute:x,position:M}=ps(E,k,r,o,void 0,l);E.position=M,E.positionAbsolute=x}return E});i(y,!0,!1)},[])}const gt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var $t=e=>{const t=({id:n,type:r,data:o,xPos:i,yPos:s,xPosOrigin:a,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:f,onMouseMove:d,onMouseLeave:h,onContextMenu:m,onDoubleClick:g,style:w,className:y,isDraggable:E,isSelectable:k,isConnectable:x,isFocusable:M,selectNodesOnDrag:I,sourcePosition:P,targetPosition:D,hidden:A,resizeObserver:z,dragHandle:L,zIndex:H,isParent:V,noDragClassName:p,noPanClassName:S,initialized:v,disableKeyboardA11y:$,ariaLabel:T,rfId:b,hasHandleBounds:C})=>{const O=oe(),R=_.useRef(null),B=_.useRef(null),F=_.useRef(P),Y=_.useRef(D),W=_.useRef(r),U=k||E||u||f||d||h,q=ms(),J=Ct(n,O.getState,f),Z=Ct(n,O.getState,d),me=Ct(n,O.getState,h),de=Ct(n,O.getState,m),ye=Ct(n,O.getState,g),he=K=>{const{nodeDragThreshold:G}=O.getState();if(k&&(!I||!E||G>0)&&lr({id:n,store:O,nodeRef:R}),u){const ue=O.getState().nodeInternals.get(n);ue&&u(K,{...ue})}},re=K=>{if(!or(K)&&!$)if(Fi.includes(K.key)&&k){const G=K.key==="Escape";lr({id:n,store:O,unselect:G,nodeRef:R})}else E&&l&&Object.prototype.hasOwnProperty.call(gt,K.key)&&(O.setState({ariaLiveMessage:`Moved selected node ${K.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~s}`}),q({x:gt[K.key].x,y:gt[K.key].y,isShiftPressed:K.shiftKey}))};_.useEffect(()=>()=>{B.current&&(z==null||z.unobserve(B.current),B.current=null)},[]),_.useEffect(()=>{if(R.current&&!A){const K=R.current;(!v||!C||B.current!==K)&&(B.current&&(z==null||z.unobserve(B.current)),z==null||z.observe(K),B.current=K)}},[A,v,C]),_.useEffect(()=>{const K=W.current!==r,G=F.current!==P,ue=Y.current!==D;R.current&&(K||G||ue)&&(K&&(W.current=r),G&&(F.current=P),ue&&(Y.current=D),O.getState().updateNodeDimensions([{id:n,nodeElement:R.current,forceUpdate:!0}]))},[n,r,P,D]);const _e=gs({nodeRef:R,disabled:A||!E,noDragClassName:p,handleSelector:L,nodeId:n,isSelectable:k,selectNodesOnDrag:I});return A?null:N.createElement("div",{className:le(["react-flow__node",`react-flow__node-${r}`,{[S]:E},y,{selected:l,selectable:k,parent:V,dragging:_e}]),ref:R,style:{zIndex:H,transform:`translate(${a}px,${c}px)`,pointerEvents:U?"all":"none",visibility:v?"visible":"hidden",...w},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:J,onMouseMove:Z,onMouseLeave:me,onContextMenu:de,onClick:he,onDoubleClick:ye,onKeyDown:M?re:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":$?void 0:`${ss}-${b}`,"aria-label":T},N.createElement(hd,{value:n},N.createElement(e,{id:n,data:o,type:r,xPos:i,yPos:s,selected:l,isConnectable:x,sourcePosition:P,targetPosition:D,dragging:_e,dragHandle:L,zIndex:H})))};return t.displayName="NodeWrapper",_.memo(t)};const eh=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Cr(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function th({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,x:s,y:a,transformString:c,userSelectionActive:l}=Q(eh,se),u=ms(),f=_.useRef(null);if(_.useEffect(()=>{var m;n||(m=f.current)==null||m.focus({preventScroll:!0})},[n]),gs({nodeRef:f}),l||!o||!i)return null;const d=e?m=>{const g=r.getState().getNodes().filter(w=>w.selected);e(m,g)}:void 0,h=m=>{Object.prototype.hasOwnProperty.call(gt,m.key)&&u({x:gt[m.key].x,y:gt[m.key].y,isShiftPressed:m.shiftKey})};return N.createElement("div",{className:le(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},N.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:i,top:a,left:s}}))}var nh=_.memo(th);const rh=e=>e.nodesSelectionActive,ys=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,deleteKeyCode:a,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:f,selectionOnDrag:d,selectionMode:h,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:w,panActivationKeyCode:y,zoomActivationKeyCode:E,elementsSelectable:k,zoomOnScroll:x,zoomOnPinch:M,panOnScroll:I,panOnScrollSpeed:P,panOnScrollMode:D,zoomOnDoubleClick:A,panOnDrag:z,defaultViewport:L,translateExtent:H,minZoom:V,maxZoom:p,preventScrolling:S,onSelectionContextMenu:v,noWheelClassName:$,noPanClassName:T,disableKeyboardA11y:b})=>{const C=Q(rh),O=Bt(f),R=Bt(y),B=R||z,F=R||I,Y=O||d&&B!==!0;return Bd({deleteKeyCode:a,multiSelectionKeyCode:w}),N.createElement(Xd,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:i,elementsSelectable:k,zoomOnScroll:x,zoomOnPinch:M,panOnScroll:F,panOnScrollSpeed:P,panOnScrollMode:D,zoomOnDoubleClick:A,panOnDrag:!O&&B,defaultViewport:L,translateExtent:H,minZoom:V,maxZoom:p,zoomActivationKeyCode:E,preventScrolling:S,noWheelClassName:$,noPanClassName:T},N.createElement(ds,{onSelectionStart:m,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:B,isSelecting:!!Y,selectionMode:h},e,C&&N.createElement(nh,{onSelectionContextMenu:v,noPanClassName:T,disableKeyboardA11y:b})))};ys.displayName="FlowRenderer";var oh=_.memo(ys);function ih(e){return Q(_.useCallback(n=>e?Wi(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function sh(e){const t={input:$t(e.input||ns),default:$t(e.default||cr),output:$t(e.output||os),group:$t(e.group||Mr)},n={},r=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,i)=>(o[i]=$t(e[i]||cr),o),n);return{...t,...r}}const ah=({x:e,y:t,width:n,height:r,origin:o})=>!n||!r?{x:e,y:t}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]},ch=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),ws=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:i,onError:s}=Q(ch,se),a=ih(e.onlyRenderVisibleElements),c=_.useRef(),l=_.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(f=>{const d=f.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));i(d)});return c.current=u,u},[]);return _.useEffect(()=>()=>{var u;(u=c==null?void 0:c.current)==null||u.disconnect()},[]),N.createElement("div",{className:"react-flow__nodes",style:Ar},a.map(u=>{var M,I,P;let f=u.type||"default";e.nodeTypes[f]||(s==null||s("003",Re.error003(f)),f="default");const d=e.nodeTypes[f]||e.nodeTypes.default,h=!!(u.draggable||t&&typeof u.draggable>"u"),m=!!(u.selectable||o&&typeof u.selectable>"u"),g=!!(u.connectable||n&&typeof u.connectable>"u"),w=!!(u.focusable||r&&typeof u.focusable>"u"),y=e.nodeExtent?br(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,E=(y==null?void 0:y.x)??0,k=(y==null?void 0:y.y)??0,x=ah({x:E,y:k,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return N.createElement(d,{key:u.id,id:u.id,className:u.className,style:u.style,type:f,data:u.data,sourcePosition:u.sourcePosition||j.Bottom,targetPosition:u.targetPosition||j.Top,hidden:u.hidden,xPos:E,yPos:k,xPosOrigin:x.x,yPosOrigin:x.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:m,isConnectable:g,isFocusable:w,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((M=u[ee])==null?void 0:M.z)??0,isParent:!!((I=u[ee])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((P=u[ee])!=null&&P.handleBounds)})}))};ws.displayName="NodeRenderer";var lh=_.memo(ws);const uh=(e,t,n)=>n===j.Left?e-t:n===j.Right?e+t:e,fh=(e,t,n)=>n===j.Top?e-t:n===j.Bottom?e+t:e,No="react-flow__edgeupdater",ko=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a})=>N.createElement("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:le([No,`${No}-${a}`]),cx:uh(t,r,e),cy:fh(n,r,e),r,stroke:"transparent",fill:"transparent"}),dh=()=>!0;var ut=e=>{const t=({id:n,className:r,type:o,data:i,onClick:s,onEdgeDoubleClick:a,selected:c,animated:l,label:u,labelStyle:f,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:w,source:y,target:E,sourceX:k,sourceY:x,targetX:M,targetY:I,sourcePosition:P,targetPosition:D,elementsSelectable:A,hidden:z,sourceHandleId:L,targetHandleId:H,onContextMenu:V,onMouseEnter:p,onMouseMove:S,onMouseLeave:v,reconnectRadius:$,onReconnect:T,onReconnectStart:b,onReconnectEnd:C,markerEnd:O,markerStart:R,rfId:B,ariaLabel:F,isFocusable:Y,isReconnectable:W,pathOptions:U,interactionWidth:q,disableKeyboardA11y:J})=>{const Z=_.useRef(null),[me,de]=_.useState(!1),[ye,he]=_.useState(!1),re=oe(),_e=_.useMemo(()=>`url('#${sr(R,B)}')`,[R,B]),K=_.useMemo(()=>`url('#${sr(O,B)}')`,[O,B]);if(z)return null;const G=ie=>{var Se;const{edges:we,addSelectedEdges:Ge,unselectNodesAndEdges:Ye,multiSelectionActive:Xe}=re.getState(),Me=we.find(Et=>Et.id===n);Me&&(A&&(re.setState({nodesSelectionActive:!1}),Me.selected&&Xe?(Ye({nodes:[],edges:[Me]}),(Se=Z.current)==null||Se.blur()):Ge([n])),s&&s(ie,Me))},ue=kt(n,re.getState,a),Fe=kt(n,re.getState,V),bt=kt(n,re.getState,p),nt=kt(n,re.getState,S),rt=kt(n,re.getState,v),$e=(ie,we)=>{if(ie.button!==0)return;const{edges:Ge,isValidConnection:Ye}=re.getState(),Xe=we?E:y,Me=(we?H:L)||null,Se=we?"target":"source",Et=Ye||dh,Mn=we,_t=Ge.find(We=>We.id===n);he(!0),b==null||b(ie,_t,Se);const An=We=>{he(!1),C==null||C(We,_t,Se)};Qi({event:ie,handleId:Me,nodeId:Xe,onConnect:We=>T==null?void 0:T(_t,We),isTarget:Mn,getState:re.getState,setState:re.setState,isValidConnection:Et,edgeUpdaterType:Se,onReconnectEnd:An})},ot=ie=>$e(ie,!0),Be=ie=>$e(ie,!1),je=()=>de(!0),it=()=>de(!1),st=!A&&!s,vt=ie=>{var we;if(!J&&Fi.includes(ie.key)&&A){const{unselectNodesAndEdges:Ge,addSelectedEdges:Ye,edges:Xe}=re.getState();ie.key==="Escape"?((we=Z.current)==null||we.blur(),Ge({edges:[Xe.find(Se=>Se.id===n)]})):Ye([n])}};return N.createElement("g",{className:le(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:c,animated:l,inactive:st,updating:me}]),onClick:G,onDoubleClick:ue,onContextMenu:Fe,onMouseEnter:bt,onMouseMove:nt,onMouseLeave:rt,onKeyDown:Y?vt:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":F===null?void 0:F||`Edge from ${y} to ${E}`,"aria-describedby":Y?`${as}-${B}`:void 0,ref:Z},!ye&&N.createElement(e,{id:n,source:y,target:E,selected:c,animated:l,label:u,labelStyle:f,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,data:i,style:w,sourceX:k,sourceY:x,targetX:M,targetY:I,sourcePosition:P,targetPosition:D,sourceHandleId:L,targetHandleId:H,markerStart:_e,markerEnd:K,pathOptions:U,interactionWidth:q}),W&&N.createElement(N.Fragment,null,(W==="source"||W===!0)&&N.createElement(ko,{position:P,centerX:k,centerY:x,radius:$,onMouseDown:ot,onMouseEnter:je,onMouseOut:it,type:"source"}),(W==="target"||W===!0)&&N.createElement(ko,{position:D,centerX:M,centerY:I,radius:$,onMouseDown:Be,onMouseEnter:je,onMouseOut:it,type:"target"})))};return t.displayName="EdgeWrapper",_.memo(t)};function hh(e){const t={default:ut(e.default||gn),straight:ut(e.bezier||Sr),step:ut(e.step||_r),smoothstep:ut(e.step||Nn),simplebezier:ut(e.simplebezier||Er)},n={},r=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,i)=>(o[i]=ut(e[i]||gn),o),n);return{...t,...r}}function Co(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,o=((n==null?void 0:n.y)||0)+t.y,i=(n==null?void 0:n.width)||t.width,s=(n==null?void 0:n.height)||t.height;switch(e){case j.Top:return{x:r+i/2,y:o};case j.Right:return{x:r+i,y:o+s/2};case j.Bottom:return{x:r+i/2,y:o+s};case j.Left:return{x:r,y:o+s/2}}}function $o(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const ph=(e,t,n,r,o,i)=>{const s=Co(n,e,t),a=Co(i,r,o);return{sourceX:s.x,sourceY:s.y,targetX:a.x,targetY:a.y}};function gh({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:i,width:s,height:a,transform:c}){const l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+i)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=vr({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:s/c[2],height:a/c[2]}),f=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),d=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(f*d)>0}function Mo(e){var r,o,i,s,a;const t=((r=e==null?void 0:e[ee])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.y)<"u";return[{x:((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)||0,y:((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const mh=[{level:0,isMaxLevel:!0,edges:[]}];function yh(e,t,n=!1){let r=-1;const o=e.reduce((s,a)=>{var u,f;const c=pe(a.zIndex);let l=c?a.zIndex:0;if(n){const d=t.get(a.target),h=t.get(a.source),m=a.selected||(d==null?void 0:d.selected)||(h==null?void 0:h.selected),g=Math.max(((u=h==null?void 0:h[ee])==null?void 0:u.z)||0,((f=d==null?void 0:d[ee])==null?void 0:f.z)||0,1e3);l=(c?a.zIndex:0)+(m?g:0)}return s[l]?s[l].push(a):s[l]=[a],r=l>r?l:r,s},{}),i=Object.entries(o).map(([s,a])=>{const c=+s;return{edges:a,level:c,isMaxLevel:c===r}});return i.length===0?mh:i}function wh(e,t,n){const r=Q(_.useCallback(o=>e?o.edges.filter(i=>{const s=t.get(i.source),a=t.get(i.target);return(s==null?void 0:s.width)&&(s==null?void 0:s.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&gh({sourcePos:s.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:s.width,sourceHeight:s.height,targetWidth:a.width,targetHeight:a.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,t]));return yh(r,t,n)}const xh=({color:e="none",strokeWidth:t=1})=>N.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),bh=({color:e="none",strokeWidth:t=1})=>N.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ao={[Ft.Arrow]:xh,[Ft.ArrowClosed]:bh};function vh(e){const t=oe();return _.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Ao,e)?Ao[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",Re.error009(e)),null)},[e])}const Eh=({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=vh(t);return c?N.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0"},N.createElement(c,{color:n,strokeWidth:s})):null},_h=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((o,i)=>([i.markerStart,i.markerEnd].forEach(s=>{if(s&&typeof s=="object"){const a=sr(s,t);r.includes(a)||(o.push({id:a,color:s.color||e,...s}),r.push(a))}}),o),[]).sort((o,i)=>o.id.localeCompare(i.id))},xs=({defaultColor:e,rfId:t})=>{const n=Q(_.useCallback(_h({defaultColor:e,rfId:t}),[e,t]),(r,o)=>!(r.length!==o.length||r.some((i,s)=>i.id!==o[s].id)));return N.createElement("defs",null,n.map(r=>N.createElement(Eh,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};xs.displayName="MarkerDefinitions";var Sh=_.memo(xs);const Nh=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),bs=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,children:w,disableKeyboardA11y:y})=>{const{edgesFocusable:E,edgesUpdatable:k,elementsSelectable:x,width:M,height:I,connectionMode:P,nodeInternals:D,onError:A}=Q(Nh,se),z=wh(t,D,n);return M?N.createElement(N.Fragment,null,z.map(({level:L,edges:H,isMaxLevel:V})=>N.createElement("svg",{key:L,style:{zIndex:L},width:M,height:I,className:"react-flow__edges react-flow__container"},V&&N.createElement(Sh,{defaultColor:e,rfId:r}),N.createElement("g",null,H.map(p=>{const[S,v,$]=Mo(D.get(p.source)),[T,b,C]=Mo(D.get(p.target));if(!$||!C)return null;let O=p.type||"default";o[O]||(A==null||A("011",Re.error011(O)),O="default");const R=o[O]||o.default,B=P===et.Strict?b.target:(b.target??[]).concat(b.source??[]),F=$o(v.source,p.sourceHandle),Y=$o(B,p.targetHandle),W=(F==null?void 0:F.position)||j.Bottom,U=(Y==null?void 0:Y.position)||j.Top,q=!!(p.focusable||E&&typeof p.focusable>"u"),J=p.reconnectable||p.updatable,Z=typeof d<"u"&&(J||k&&typeof J>"u");if(!F||!Y)return A==null||A("008",Re.error008(F,p)),null;const{sourceX:me,sourceY:de,targetX:ye,targetY:he}=ph(S,F,W,T,Y,U);return N.createElement(R,{key:p.id,id:p.id,className:le([p.className,i]),type:O,data:p.data,selected:!!p.selected,animated:!!p.animated,hidden:!!p.hidden,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,style:p.style,source:p.source,target:p.target,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerEnd:p.markerEnd,markerStart:p.markerStart,sourceX:me,sourceY:de,targetX:ye,targetY:he,sourcePosition:W,targetPosition:U,elementsSelectable:x,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,rfId:r,ariaLabel:p.ariaLabel,isFocusable:q,isReconnectable:Z,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth,disableKeyboardA11y:y})})))),w):null};bs.displayName="EdgeRenderer";var kh=_.memo(bs);const Ch=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function $h({children:e}){const t=Q(Ch);return N.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function Mh(e){const t=kn(),n=_.useRef(!1);_.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Ah={[j.Left]:j.Right,[j.Right]:j.Left,[j.Top]:j.Bottom,[j.Bottom]:j.Top},vs=({nodeId:e,handleType:t,style:n,type:r=ze.Bezier,CustomComponent:o,connectionStatus:i})=>{var I,P,D;const{fromNode:s,handleId:a,toX:c,toY:l,connectionMode:u}=Q(_.useCallback(A=>({fromNode:A.nodeInternals.get(e),handleId:A.connectionHandleId,toX:(A.connectionPosition.x-A.transform[0])/A.transform[2],toY:(A.connectionPosition.y-A.transform[1])/A.transform[2],connectionMode:A.connectionMode}),[e]),se),f=(I=s==null?void 0:s[ee])==null?void 0:I.handleBounds;let d=f==null?void 0:f[t];if(u===et.Loose&&(d=d||(f==null?void 0:f[t==="source"?"target":"source"])),!s||!d)return null;const h=a?d.find(A=>A.id===a):d[0],m=h?h.x+h.width/2:(s.width??0)/2,g=h?h.y+h.height/2:s.height??0,w=(((P=s.positionAbsolute)==null?void 0:P.x)??0)+m,y=(((D=s.positionAbsolute)==null?void 0:D.y)??0)+g,E=h==null?void 0:h.position,k=E?Ah[E]:null;if(!E||!k)return null;if(o)return N.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:s,fromHandle:h,fromX:w,fromY:y,toX:c,toY:l,fromPosition:E,toPosition:k,connectionStatus:i});let x="";const M={sourceX:w,sourceY:y,sourcePosition:E,targetX:c,targetY:l,targetPosition:k};return r===ze.Bezier?[x]=Nr(M):r===ze.Step?[x]=ir({...M,borderRadius:0}):r===ze.SmoothStep?[x]=ir(M):r===ze.SimpleBezier?[x]=Yi(M):x=`M${w},${y} ${c},${l}`,N.createElement("path",{d:x,fill:"none",className:"react-flow__connection-path",style:n})};vs.displayName="ConnectionLine";const Ih=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Th({containerStyle:e,style:t,type:n,component:r}){const{nodeId:o,handleType:i,nodesConnectable:s,width:a,height:c,connectionStatus:l}=Q(Ih,se);return!(o&&i&&a&&s)?null:N.createElement("svg",{style:e,width:a,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},N.createElement("g",{className:le(["react-flow__connection",l])},N.createElement(vs,{nodeId:o,handleType:i,style:t,type:n,CustomComponent:r,connectionStatus:l})))}function Io(e,t){return _.useRef(null),oe(),_.useMemo(()=>t(e),[e])}const Es=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:i,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:h,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:w,connectionLineType:y,connectionLineStyle:E,connectionLineComponent:k,connectionLineContainerStyle:x,selectionKeyCode:M,selectionOnDrag:I,selectionMode:P,multiSelectionKeyCode:D,panActivationKeyCode:A,zoomActivationKeyCode:z,deleteKeyCode:L,onlyRenderVisibleElements:H,elementsSelectable:V,selectNodesOnDrag:p,defaultViewport:S,translateExtent:v,minZoom:$,maxZoom:T,preventScrolling:b,defaultMarkerColor:C,zoomOnScroll:O,zoomOnPinch:R,panOnScroll:B,panOnScrollSpeed:F,panOnScrollMode:Y,zoomOnDoubleClick:W,panOnDrag:U,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:me,onPaneScroll:de,onPaneContextMenu:ye,onEdgeContextMenu:he,onEdgeMouseEnter:re,onEdgeMouseMove:_e,onEdgeMouseLeave:K,onReconnect:G,onReconnectStart:ue,onReconnectEnd:Fe,reconnectRadius:bt,noDragClassName:nt,noWheelClassName:rt,noPanClassName:$e,elevateEdgesOnSelect:ot,disableKeyboardA11y:Be,nodeOrigin:je,nodeExtent:it,rfId:st})=>{const vt=Io(e,sh),ie=Io(t,hh);return Mh(i),N.createElement(oh,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:me,onPaneContextMenu:ye,onPaneScroll:de,deleteKeyCode:L,selectionKeyCode:M,selectionOnDrag:I,selectionMode:P,onSelectionStart:g,onSelectionEnd:w,multiSelectionKeyCode:D,panActivationKeyCode:A,zoomActivationKeyCode:z,elementsSelectable:V,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:O,zoomOnPinch:R,zoomOnDoubleClick:W,panOnScroll:B,panOnScrollSpeed:F,panOnScrollMode:Y,panOnDrag:U,defaultViewport:S,translateExtent:v,minZoom:$,maxZoom:T,onSelectionContextMenu:m,preventScrolling:b,noDragClassName:nt,noWheelClassName:rt,noPanClassName:$e,disableKeyboardA11y:Be},N.createElement($h,null,N.createElement(kh,{edgeTypes:ie,onEdgeClick:a,onEdgeDoubleClick:l,onlyRenderVisibleElements:H,onEdgeContextMenu:he,onEdgeMouseEnter:re,onEdgeMouseMove:_e,onEdgeMouseLeave:K,onReconnect:G,onReconnectStart:ue,onReconnectEnd:Fe,reconnectRadius:bt,defaultMarkerColor:C,noPanClassName:$e,elevateEdgesOnSelect:!!ot,disableKeyboardA11y:Be,rfId:st},N.createElement(Th,{style:E,type:y,component:k,containerStyle:x})),N.createElement("div",{className:"react-flow__edgelabel-renderer"}),N.createElement(lh,{nodeTypes:vt,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:h,selectNodesOnDrag:p,onlyRenderVisibleElements:H,noPanClassName:$e,noDragClassName:nt,disableKeyboardA11y:Be,nodeOrigin:je,nodeExtent:it,rfId:st})))};Es.displayName="GraphView";var Oh=_.memo(Es);const ur=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Pe={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:ur,nodeExtent:ur,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:et.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:ad,isValidConnection:void 0},Rh=()=>bc((e,t)=>({...Pe,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:i}=t();e({nodeInternals:Vn(n,r,o,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(o=>({...r,...o}))})},setDefaultNodesAndEdges:(n,r)=>{const o=typeof n<"u",i=typeof r<"u",s=o?Vn(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:s,edges:i?r:[],hasDefaultNodes:o,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:i,fitViewOnInitDone:s,fitViewOnInitOptions:a,domNode:c,nodeOrigin:l}=t(),u=c==null?void 0:c.querySelector(".react-flow__viewport");if(!u)return;const f=window.getComputedStyle(u),{m22:d}=new window.DOMMatrixReadOnly(f.transform),h=n.reduce((g,w)=>{const y=o.get(w.id);if(y!=null&&y.hidden)o.set(y.id,{...y,[ee]:{...y[ee],handleBounds:void 0}});else if(y){const E=xr(w.nodeElement);!!(E.width&&E.height&&(y.width!==E.width||y.height!==E.height||w.forceUpdate))&&(o.set(y.id,{...y,[ee]:{...y[ee],handleBounds:{source:So(".source",w.nodeElement,d,l),target:So(".target",w.nodeElement,d,l)}},...E}),g.push({id:y.id,type:"dimensions",dimensions:E}))}return g},[]);ls(o,l);const m=s||i&&!s&&us(t,{initial:!0,...a});e({nodeInternals:new Map(o),fitViewOnInitDone:m}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,o=!1)=>{const{triggerNodeChanges:i}=t(),s=n.map(a=>{const c={id:a.id,type:"position",dragging:o};return r&&(c.positionAbsolute=a.positionAbsolute,c.position=a.position),c});i(s)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:i,nodeOrigin:s,getNodes:a,elevateNodesOnSelect:c}=t();if(n!=null&&n.length){if(i){const l=fs(n,a()),u=Vn(l,o,s,c);e({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let s,a=null;r?s=n.map(c=>De(c,!0)):(s=ft(i(),n),a=ft(o,[])),Jt({changedNodes:s,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let s,a=null;r?s=n.map(c=>De(c,!0)):(s=ft(o,n),a=ft(i(),[])),Jt({changedNodes:a,changedEdges:s,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:i}=t(),s=n||i(),a=r||o,c=s.map(u=>(u.selected=!1,De(u.id,!1))),l=a.map(u=>De(u.id,!1));Jt({changedNodes:c,changedEdges:l,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();r==null||r.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();r==null||r.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),i=r().filter(a=>a.selected).map(a=>De(a.id,!1)),s=n.filter(a=>a.selected).map(a=>De(a.id,!1));Jt({changedNodes:i,changedEdges:s,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(o=>{o.positionAbsolute=br(o.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:o,height:i,d3Zoom:s,d3Selection:a,translateExtent:c}=t();if(!s||!a||!n.x&&!n.y)return!1;const l=Ve.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[o,i]],f=s==null?void 0:s.constrain()(l,u,c);return s.transform(a,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>e({connectionNodeId:Pe.connectionNodeId,connectionHandleId:Pe.connectionHandleId,connectionHandleType:Pe.connectionHandleType,connectionStatus:Pe.connectionStatus,connectionStartHandle:Pe.connectionStartHandle,connectionEndHandle:Pe.connectionEndHandle}),reset:()=>e({...Pe})}),Object.is),Ir=({children:e})=>{const t=_.useRef(null);return t.current||(t.current=Rh()),N.createElement(ed,{value:t.current},e)};Ir.displayName="ReactFlowProvider";const _s=({children:e})=>_.useContext(Sn)?N.createElement(N.Fragment,null,e):N.createElement(Ir,null,e);_s.displayName="ReactFlowWrapper";const Ph={input:ns,default:cr,output:os,group:Mr},Lh={default:gn,straight:Sr,step:_r,smoothstep:Nn,simplebezier:Er},Dh=[0,0],zh=[15,15],Vh={x:0,y:0,zoom:1},Hh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Ss=_.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i=Ph,edgeTypes:s=Lh,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:w,onClickConnectEnd:y,onNodeMouseEnter:E,onNodeMouseMove:k,onNodeMouseLeave:x,onNodeContextMenu:M,onNodeDoubleClick:I,onNodeDragStart:P,onNodeDrag:D,onNodeDragStop:A,onNodesDelete:z,onEdgesDelete:L,onSelectionChange:H,onSelectionDragStart:V,onSelectionDrag:p,onSelectionDragStop:S,onSelectionContextMenu:v,onSelectionStart:$,onSelectionEnd:T,connectionMode:b=et.Strict,connectionLineType:C=ze.Bezier,connectionLineStyle:O,connectionLineComponent:R,connectionLineContainerStyle:B,deleteKeyCode:F="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:W=!1,selectionMode:U=Ht.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:J=pn()?"Meta":"Control",zoomActivationKeyCode:Z=pn()?"Meta":"Control",snapToGrid:me=!1,snapGrid:de=zh,onlyRenderVisibleElements:ye=!1,selectNodesOnDrag:he=!0,nodesDraggable:re,nodesConnectable:_e,nodesFocusable:K,nodeOrigin:G=Dh,edgesFocusable:ue,edgesUpdatable:Fe,elementsSelectable:bt,defaultViewport:nt=Vh,minZoom:rt=.5,maxZoom:$e=2,translateExtent:ot=ur,preventScrolling:Be=!0,nodeExtent:je,defaultMarkerColor:it="#b1b1b7",zoomOnScroll:st=!0,zoomOnPinch:vt=!0,panOnScroll:ie=!1,panOnScrollSpeed:we=.5,panOnScrollMode:Ge=Ke.Free,zoomOnDoubleClick:Ye=!0,panOnDrag:Xe=!0,onPaneClick:Me,onPaneMouseEnter:Se,onPaneMouseMove:Et,onPaneMouseLeave:Mn,onPaneScroll:_t,onPaneContextMenu:An,children:Dr,onEdgeContextMenu:We,onEdgeDoubleClick:aa,onEdgeMouseEnter:ca,onEdgeMouseMove:la,onEdgeMouseLeave:ua,onEdgeUpdate:fa,onEdgeUpdateStart:da,onEdgeUpdateEnd:ha,onReconnect:pa,onReconnectStart:ga,onReconnectEnd:ma,reconnectRadius:ya=10,edgeUpdaterRadius:wa=10,onNodesChange:xa,onEdgesChange:ba,noDragClassName:va="nodrag",noWheelClassName:Ea="nowheel",noPanClassName:zr="nopan",fitView:_a=!1,fitViewOptions:Sa,connectOnClick:Na=!0,attributionPosition:ka,proOptions:Ca,defaultEdgeOptions:$a,elevateNodesOnSelect:Ma=!0,elevateEdgesOnSelect:Aa=!1,disableKeyboardA11y:Vr=!1,autoPanOnConnect:Ia=!0,autoPanOnNodeDrag:Ta=!0,connectionRadius:Oa=20,isValidConnection:Ra,onError:Pa,style:La,id:Hr,nodeDragThreshold:Da,...za},Va)=>{const In=Hr||"1";return N.createElement("div",{...za,style:{...La,...Hh},ref:Va,className:le(["react-flow",o]),"data-testid":"rf__wrapper",id:Hr},N.createElement(_s,null,N.createElement(Oh,{onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:E,onNodeMouseMove:k,onNodeMouseLeave:x,onNodeContextMenu:M,onNodeDoubleClick:I,nodeTypes:i,edgeTypes:s,connectionLineType:C,connectionLineStyle:O,connectionLineComponent:R,connectionLineContainerStyle:B,selectionKeyCode:Y,selectionOnDrag:W,selectionMode:U,deleteKeyCode:F,multiSelectionKeyCode:J,panActivationKeyCode:q,zoomActivationKeyCode:Z,onlyRenderVisibleElements:ye,selectNodesOnDrag:he,defaultViewport:nt,translateExtent:ot,minZoom:rt,maxZoom:$e,preventScrolling:Be,zoomOnScroll:st,zoomOnPinch:vt,zoomOnDoubleClick:Ye,panOnScroll:ie,panOnScrollSpeed:we,panOnScrollMode:Ge,panOnDrag:Xe,onPaneClick:Me,onPaneMouseEnter:Se,onPaneMouseMove:Et,onPaneMouseLeave:Mn,onPaneScroll:_t,onPaneContextMenu:An,onSelectionContextMenu:v,onSelectionStart:$,onSelectionEnd:T,onEdgeContextMenu:We,onEdgeDoubleClick:aa,onEdgeMouseEnter:ca,onEdgeMouseMove:la,onEdgeMouseLeave:ua,onReconnect:pa??fa,onReconnectStart:ga??da,onReconnectEnd:ma??ha,reconnectRadius:ya??wa,defaultMarkerColor:it,noDragClassName:va,noWheelClassName:Ea,noPanClassName:zr,elevateEdgesOnSelect:Aa,rfId:In,disableKeyboardA11y:Vr,nodeOrigin:G,nodeExtent:je}),N.createElement(Ad,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:w,onClickConnectEnd:y,nodesDraggable:re,nodesConnectable:_e,nodesFocusable:K,edgesFocusable:ue,edgesUpdatable:Fe,elementsSelectable:bt,elevateNodesOnSelect:Ma,minZoom:rt,maxZoom:$e,nodeExtent:je,onNodesChange:xa,onEdgesChange:ba,snapToGrid:me,snapGrid:de,connectionMode:b,translateExtent:ot,connectOnClick:Na,defaultEdgeOptions:$a,fitView:_a,fitViewOptions:Sa,onNodesDelete:z,onEdgesDelete:L,onNodeDragStart:P,onNodeDrag:D,onNodeDragStop:A,onSelectionDrag:p,onSelectionDragStart:V,onSelectionDragStop:S,noPanClassName:zr,nodeOrigin:G,rfId:In,autoPanOnConnect:Ia,autoPanOnNodeDrag:Ta,onError:Pa,connectionRadius:Oa,isValidConnection:Ra,nodeDragThreshold:Da}),N.createElement($d,{onSelectionChange:H}),Dr,N.createElement(nd,{proOptions:Ca,position:ka}),N.createElement(Pd,{rfId:In,disableKeyboardA11y:Vr})))});Ss.displayName="ReactFlow";function Fh(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},N.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Bh(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},N.createElement("path",{d:"M0 0h32v4.2H0z"}))}function jh(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},N.createElement("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 Gh(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},N.createElement("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 Yh(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},N.createElement("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"}))}const Ot=({children:e,className:t,...n})=>N.createElement("button",{type:"button",className:le(["react-flow__controls-button",t]),...n},e);Ot.displayName="ControlButton";const Xh=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Ns=({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:f="bottom-left"})=>{const d=oe(),[h,m]=_.useState(!1),{isInteractive:g,minZoomReached:w,maxZoomReached:y}=Q(Xh,se),{zoomIn:E,zoomOut:k,fitView:x}=kn();if(_.useEffect(()=>{m(!0)},[]),!h)return null;const M=()=>{E(),i==null||i()},I=()=>{k(),s==null||s()},P=()=>{x(o),a==null||a()},D=()=>{d.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),c==null||c(!g)};return N.createElement(Di,{className:le(["react-flow__controls",l]),position:f,style:e,"data-testid":"rf__controls"},t&&N.createElement(N.Fragment,null,N.createElement(Ot,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y},N.createElement(Fh,null)),N.createElement(Ot,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:w},N.createElement(Bh,null))),n&&N.createElement(Ot,{className:"react-flow__controls-fitview",onClick:P,title:"fit view","aria-label":"fit view"},N.createElement(jh,null)),r&&N.createElement(Ot,{className:"react-flow__controls-interactive",onClick:D,title:"toggle interactivity","aria-label":"toggle interactivity"},g?N.createElement(Yh,null):N.createElement(Gh,null)),u)};Ns.displayName="Controls";var Wh=_.memo(Ns);const Uh=[Fr.ATOMIC_URL,Fr.RESOURCEARRAY];var To;(function(e){e[e.First=0]="First",e[e.Second=1]="Second"})(To||(To={}));const ks=(e,t)=>`${t?"*":""}${e}`,qh=(e,t,n,r)=>({...e,id:Ba(),label:ks(t,n),markerEnd:{type:Ft.ArrowClosed,width:15,height:15},type:"floating",data:{required:n,overlapping:r}}),Zh=(e,t)=>e.findIndex(n=>n.source===t.source&&n.target===t.target),Kh=(e,t)=>{const n=e.findIndex(r=>r.target===t.source&&r.source===t.target);return n!==-1&&(e[n]={...e[n],data:{...e[n].data,overlapping:!0}}),n!==-1},Qh=(e,t,n)=>{var r,o;return{...e,data:{required:n||(((r=e.data)==null?void 0:r.required)??!1),overlapping:((o=e.data)==null?void 0:o.overlapping)??!1},label:`${e.label},
${ks(t,n)}`}};async function Jh(e,t){const n=e.get(Tn.properties.classes),r=new Set,o=[],i=[],s=async(c,l=!1)=>{const u=await t.getResource(c);return l||await a(u),{id:c,position:{x:0,y:100},width:100,height:100,data:{label:u.title,external:l}}},a=async c=>{const l=c.get(Tn.properties.recommends)??[],u=c.get(Tn.properties.requires)??[];for(const f of[...l,...u]){const d=await t.getProperty(f),h=u.includes(f);if(Uh.includes(d.datatype)&&d.classType){const m={source:c.subject,target:d.classType},g=Zh(i,m);if(g===-1){const w=Kh(i,m);i.push(qh(m,d.shortname,h,w)),n.includes(d.classType)||r.add(d.classType);continue}i[g]=Qh(i[g],d.shortname,h)}}};for(const c of n)o.push(await s(c));for(const c of r)o.push(await s(c,!0));return[o,i]}function ep(e,t){return e.map(n=>({...n,style:{...n.style,backgroundColor:t.colors.bg,borderColor:t.colors.bg2,color:t.colors.text,borderStyle:n.data.external?"dashed":"solid"}}))}function Oo(e,t){const{width:n,height:r,positionAbsolute:o}=e,i=t.positionAbsolute,s=n/2,a=r/2,c=o.x+s,l=o.y+a,u=i.x+s,f=i.y+a,d=(u-c)/(2*s)-(f-l)/(2*a),h=(u-c)/(2*s)+(f-l)/(2*a),m=1/(Math.abs(d)+Math.abs(h)),g=m*d,w=m*h,y=s*(g+w)+c,E=a*(-g+w)+l;return{x:y,y:E}}function Ro(e,t){const n={...e.positionAbsolute,...e},r=Math.round(n.x),o=Math.round(n.y),i=Math.round(t.x),s=Math.round(t.y);return i<=r+1?j.Left:i>=r+n.width-1?j.Right:s<=o+1?j.Top:s>=n.y+n.height-1?j.Bottom:j.Top}function tp(e,t,n){const r=Oo(e,t),o=Oo(t,e),i=Ro(e,r),s=Ro(t,o);let a=r.x;if(n){const c=e.positionAbsolute.x+e.width/2,l=Math.abs(a-c);a<c?a=c+l:a=c-l}return{sx:a,sy:r.y,tx:o.x,ty:o.y,sourcePos:i,targetPos:s}}function np(e){const{positionAbsolute:t,width:n,height:r}=e,{x:o,y:i}=t,s=20,a=50,c=15,l=10,u={x:o+n-s,y:i+r},f=[`M ${u.x}, ${u.y}`,Mt(0,c-l),tn(l,l),Mt(a-l,0),tn(l,-l),Mt(0,(r+(c-l)*2)*-1),tn(-l,-l),Mt((a-l)*-1,0),tn(-l,l),Mt(0,c-l)].join(", "),d=o+n+a-s/2,h=i+r/2;return[f,d,h]}const Mt=(e,t)=>`l ${e} ${t}`,tn=(e,t,n=!1)=>`a ${e} ${e} 0 0 ${n?1:0} ${e} ${t}`,rp=(e,t,n)=>{if(e.id===t.id)return np(e);const{sx:r,sy:o,tx:i,ty:s,sourcePos:a,targetPos:c}=tp(e,t,n);return Nr({sourceX:r,sourceY:o,sourcePosition:a,targetPosition:c,targetX:i,targetY:s})};function op({text:e}){const t=e.split(`
`);return t.length===1?ae.jsx(ae.Fragment,{children:e}):ae.jsx(ae.Fragment,{children:t.map((n,r)=>ae.jsx("tspan",{x:0,dy:r===0?"-0.3em":"1.2em",children:n},n))})}function ip({id:e,source:t,target:n,markerEnd:r,style:o,label:i,data:s}){const a=ri(),c=Q(_.useCallback(h=>h.nodeInternals.get(t),[t])),l=Q(_.useCallback(h=>h.nodeInternals.get(n),[n]));if(!c||!l)return null;const[u,f,d]=rp(c,l,!!(s!=null&&s.overlapping));return ae.jsxs(ae.Fragment,{children:[ae.jsx(sp,{id:e,className:"react-flow__edge-path",d:u,markerEnd:r,style:o}),ae.jsx(zi,{x:f,y:d,label:ae.jsx(op,{text:i}),labelStyle:{fill:a.colors.text},labelShowBg:!0,labelBgStyle:{fill:a.colors.bg1},labelBgPadding:[2,4],labelBgBorderRadius:2})]})}const sp=ja.path.withConfig({displayName:"FloatingEdge__Path",componentId:"sc-67a32bf9-0"})(["flex-direction:column;display:flex;flex-grow:1;height:100%;& .react-flow__handle{opacity:0;}"]);var ap="\0",Ue="\0",Po="";let cp=class{constructor(t){te(this,"_isDirected",!0);te(this,"_isMultigraph",!1);te(this,"_isCompound",!1);te(this,"_label");te(this,"_defaultNodeLabelFn",()=>{});te(this,"_defaultEdgeLabelFn",()=>{});te(this,"_nodes",{});te(this,"_in",{});te(this,"_preds",{});te(this,"_out",{});te(this,"_sucs",{});te(this,"_edgeObjs",{});te(this,"_edgeLabels",{});te(this,"_nodeCount",0);te(this,"_edgeCount",0);te(this,"_parent");te(this,"_children");t&&(this._isDirected=Object.hasOwn(t,"directed")?t.directed:!0,this._isMultigraph=Object.hasOwn(t,"multigraph")?t.multigraph:!1,this._isCompound=Object.hasOwn(t,"compound")?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[Ue]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,typeof t!="function"&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(n=>Object.keys(t._in[n]).length===0)}sinks(){var t=this;return this.nodes().filter(n=>Object.keys(t._out[n]).length===0)}setNodes(t,n){var r=arguments,o=this;return t.forEach(function(i){r.length>1?o.setNode(i,n):o.setNode(i)}),this}setNode(t,n){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=Ue,this._children[t]={},this._children[Ue][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var n=this;if(Object.hasOwn(this._nodes,t)){var r=o=>n.removeEdge(n._edgeObjs[o]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(o){n.setParent(o)}),delete this._children[t]),Object.keys(this._in[t]).forEach(r),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n=Ue;else{n+="";for(var r=n;r!==void 0;r=this.parent(r))if(r===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var n=this._parent[t];if(n!==Ue)return n}}children(t=Ue){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===Ue)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var n=this._preds[t];if(n)return Object.keys(n)}successors(t){var n=this._sucs[t];if(n)return Object.keys(n)}neighbors(t){var n=this.predecessors(t);if(n){const o=new Set(n);for(var r of this.successors(t))o.add(r);return Array.from(o.values())}}isLeaf(t){var n;return this.isDirected()?n=this.successors(t):n=this.neighbors(t),n.length===0}filterNodes(t){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([s,a]){t(s)&&n.setNode(s,a)}),Object.values(this._edgeObjs).forEach(function(s){n.hasNode(s.v)&&n.hasNode(s.w)&&n.setEdge(s,r.edge(s))});var o={};function i(s){var a=r.parent(s);return a===void 0||n.hasNode(a)?(o[s]=a,a):a in o?o[a]:i(a)}return this._isCompound&&n.nodes().forEach(s=>n.setParent(s,i(s))),n}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,typeof t!="function"&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,n){var r=this,o=arguments;return t.reduce(function(i,s){return o.length>1?r.setEdge(i,s,n):r.setEdge(i,s),s}),this}setEdge(){var t,n,r,o,i=!1,s=arguments[0];typeof s=="object"&&s!==null&&"v"in s?(t=s.v,n=s.w,r=s.name,arguments.length===2&&(o=arguments[1],i=!0)):(t=s,n=arguments[1],r=arguments[3],arguments.length>2&&(o=arguments[2],i=!0)),t=""+t,n=""+n,r!==void 0&&(r=""+r);var a=Rt(this._isDirected,t,n,r);if(Object.hasOwn(this._edgeLabels,a))return i&&(this._edgeLabels[a]=o),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(n),this._edgeLabels[a]=i?o:this._defaultEdgeLabelFn(t,n,r);var c=lp(this._isDirected,t,n,r);return t=c.v,n=c.w,Object.freeze(c),this._edgeObjs[a]=c,Lo(this._preds[n],t),Lo(this._sucs[t],n),this._in[n][a]=c,this._out[t][a]=c,this._edgeCount++,this}edge(t,n,r){var o=arguments.length===1?jn(this._isDirected,arguments[0]):Rt(this._isDirected,t,n,r);return this._edgeLabels[o]}edgeAsObj(){const t=this.edge(...arguments);return typeof t!="object"?{label:t}:t}hasEdge(t,n,r){var o=arguments.length===1?jn(this._isDirected,arguments[0]):Rt(this._isDirected,t,n,r);return Object.hasOwn(this._edgeLabels,o)}removeEdge(t,n,r){var o=arguments.length===1?jn(this._isDirected,arguments[0]):Rt(this._isDirected,t,n,r),i=this._edgeObjs[o];return i&&(t=i.v,n=i.w,delete this._edgeLabels[o],delete this._edgeObjs[o],Do(this._preds[n],t),Do(this._sucs[t],n),delete this._in[n][o],delete this._out[t][o],this._edgeCount--),this}inEdges(t,n){var r=this._in[t];if(r){var o=Object.values(r);return n?o.filter(i=>i.v===n):o}}outEdges(t,n){var r=this._out[t];if(r){var o=Object.values(r);return n?o.filter(i=>i.w===n):o}}nodeEdges(t,n){var r=this.inEdges(t,n);if(r)return r.concat(this.outEdges(t,n))}};function Lo(e,t){e[t]?e[t]++:e[t]=1}function Do(e,t){--e[t]||delete e[t]}function Rt(e,t,n,r){var o=""+t,i=""+n;if(!e&&o>i){var s=o;o=i,i=s}return o+Po+i+Po+(r===void 0?ap:r)}function lp(e,t,n,r){var o=""+t,i=""+n;if(!e&&o>i){var s=o;o=i,i=s}var a={v:o,w:i};return r&&(a.name=r),a}function jn(e,t){return Rt(e,t.v,t.w,t.name)}var Tr=cp,up="2.2.4",fp={Graph:Tr,version:up},dp=Tr,hp={write:pp,read:yp};function pp(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:gp(e),edges:mp(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function gp(e){return e.nodes().map(function(t){var 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 mp(e){return e.edges().map(function(t){var 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 yp(e){var t=new dp(e.options).setGraph(e.value);return e.nodes.forEach(function(n){t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(function(n){t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var wp=xp;function xp(e){var t={},n=[],r;function o(i){Object.hasOwn(t,i)||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}let bp=class{constructor(){te(this,"_arr",[]);te(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,n){var r=this._keyIndices;if(t=String(t),!Object.hasOwn(r,t)){var o=this._arr,i=o.length;return r[t]=i,o.push({key:t,priority:n}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,n){var r=this._keyIndices[t];if(n>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+n);this._arr[r].priority=n,this._decrease(r)}_heapify(t){var n=this._arr,r=2*t,o=r+1,i=t;r<n.length&&(i=n[r].priority<n[i].priority?r:i,o<n.length&&(i=n[o].priority<n[i].priority?o:i),i!==t&&(this._swap(t,i),this._heapify(i)))}_decrease(t){for(var n=this._arr,r=n[t].priority,o;t!==0&&(o=t>>1,!(n[o].priority<r));)this._swap(t,o),t=o}_swap(t,n){var r=this._arr,o=this._keyIndices,i=r[t],s=r[n];r[t]=s,r[n]=i,o[s.key]=t,o[i.key]=n}};var Cs=bp,vp=Cs,$s=_p,Ep=()=>1;function _p(e,t,n,r){return Sp(e,String(t),n||Ep,r||function(o){return e.outEdges(o)})}function Sp(e,t,n,r){var o={},i=new vp,s,a,c=function(l){var u=l.v!==s?l.v:l.w,f=o[u],d=n(l),h=a.distance+d;if(d<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+d);h<f.distance&&(f.distance=h,f.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(l){var u=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:u},i.add(l,u)});i.size()>0&&(s=i.removeMin(),a=o[s],a.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(c);return o}var Np=$s,kp=Cp;function Cp(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=Np(e,o,t,n),r},{})}var Ms=$p;function $p(e){var t=0,n=[],r={},o=[];function i(s){var a=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(u){Object.hasOwn(r,u)?r[u].onStack&&(a.lowlink=Math.min(a.lowlink,r[u].index)):(i(u),a.lowlink=Math.min(a.lowlink,r[u].lowlink))}),a.lowlink===a.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(s!==l);o.push(c)}}return e.nodes().forEach(function(s){Object.hasOwn(r,s)||i(s)}),o}var Mp=Ms,Ap=Ip;function Ip(e){return Mp(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Tp=Rp,Op=()=>1;function Rp(e,t,n){return Pp(e,t||Op,n||function(r){return e.outEdges(r)})}function Pp(e,t,n){var r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0},o.forEach(function(s){i!==s&&(r[i][s]={distance:Number.POSITIVE_INFINITY})}),n(i).forEach(function(s){var a=s.v===i?s.w:s.v,c=t(s);r[i][a]={distance:c,predecessor:i}})}),o.forEach(function(i){var s=r[i];o.forEach(function(a){var c=r[a];o.forEach(function(l){var u=c[i],f=s[l],d=c[l],h=u.distance+f.distance;h<d.distance&&(d.distance=h,d.predecessor=f.predecessor)})})}),r}function As(e){var t={},n={},r=[];function o(i){if(Object.hasOwn(n,i))throw new fr;Object.hasOwn(t,i)||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new fr;return r}class fr extends Error{constructor(){super(...arguments)}}var Is=As;As.CycleException=fr;var zo=Is,Lp=Dp;function Dp(e){try{zo(e)}catch(t){if(t instanceof zo.CycleException)return!1;throw t}return!0}var Ts=zp;function zp(e,t,n){Array.isArray(t)||(t=[t]);var r=e.isDirected()?a=>e.successors(a):a=>e.neighbors(a),o=n==="post"?Vp:Hp,i=[],s={};return t.forEach(a=>{if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o(a,r,s,i)}),i}function Vp(e,t,n,r){for(var o=[[e,!1]];o.length>0;){var i=o.pop();i[1]?r.push(i[0]):Object.hasOwn(n,i[0])||(n[i[0]]=!0,o.push([i[0],!0]),Os(t(i[0]),s=>o.push([s,!1])))}}function Hp(e,t,n,r){for(var o=[e];o.length>0;){var i=o.pop();Object.hasOwn(n,i)||(n[i]=!0,r.push(i),Os(t(i),s=>o.push(s)))}}function Os(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var Fp=Ts,Bp=jp;function jp(e,t){return Fp(e,t,"post")}var Gp=Ts,Yp=Xp;function Xp(e,t){return Gp(e,t,"pre")}var Wp=Tr,Up=Cs,qp=Zp;function Zp(e,t){var n=new Wp,r={},o=new Up,i;function s(c){var l=c.v===i?c.w:c.v,u=o.priority(l);if(u!==void 0){var f=t(c);f<u&&(r[l]=i,o.decrease(l,f))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(c){o.add(c,Number.POSITIVE_INFINITY),n.setNode(c)}),o.decrease(e.nodes()[0],0);for(var a=!1;o.size()>0;){if(i=o.removeMin(),Object.hasOwn(r,i))n.setEdge(i,r[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(s)}return n}var Kp={components:wp,dijkstra:$s,dijkstraAll:kp,findCycles:Ap,floydWarshall:Tp,isAcyclic:Lp,postorder:Bp,preorder:Yp,prim:qp,tarjan:Ms,topsort:Is},Vo=fp,Ee={Graph:Vo.Graph,json:hp,alg:Kp,version:Vo.version};let Qp=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,n=t._prev;if(n!==t)return Ho(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&Ho(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n}toString(){let t=[],n=this._sentinel,r=n._prev;for(;r!==n;)t.push(JSON.stringify(r,Jp)),r=r._prev;return"["+t.join(", ")+"]"}};function Ho(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Jp(e,t){if(e!=="_next"&&e!=="_prev")return t}var eg=Qp;let tg=Ee.Graph,ng=eg;var rg=ig;let og=()=>1;function ig(e,t){if(e.nodeCount()<=1)return[];let n=ag(e,t||og);return sg(n.graph,n.buckets,n.zeroIdx).flatMap(o=>e.outEdges(o.v,o.w))}function sg(e,t,n){let r=[],o=t[t.length-1],i=t[0],s;for(;e.nodeCount();){for(;s=i.dequeue();)Gn(e,t,n,s);for(;s=o.dequeue();)Gn(e,t,n,s);if(e.nodeCount()){for(let a=t.length-2;a>0;--a)if(s=t[a].dequeue(),s){r=r.concat(Gn(e,t,n,s,!0));break}}}return r}function Gn(e,t,n,r,o){let i=o?[]:void 0;return e.inEdges(r.v).forEach(s=>{let a=e.edge(s),c=e.node(s.v);o&&i.push({v:s.v,w:s.w}),c.out-=a,dr(t,n,c)}),e.outEdges(r.v).forEach(s=>{let a=e.edge(s),c=s.w,l=e.node(c);l.in-=a,dr(t,n,l)}),e.removeNode(r.v),i}function ag(e,t){let n=new tg,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),o=Math.max(o,n.node(a.v).out+=l),r=Math.max(r,n.node(a.w).in+=l)});let i=cg(o+r+3).map(()=>new ng),s=r+1;return n.nodes().forEach(a=>{dr(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function dr(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function cg(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}let Rs=Ee.Graph;var ne={addBorderNode:yg,addDummyNode:Ps,applyWithChunking:Cn,asNonCompoundGraph:ug,buildLayerMatrix:pg,intersectRect:hg,mapValues:Sg,maxRank:Ds,normalizeRanks:gg,notime:vg,partition:xg,pick:_g,predecessorWeights:dg,range:Vs,removeEmptyRanks:mg,simplify:lg,successorWeights:fg,time:bg,uniqueId:zs,zipObject:Or};function Ps(e,t,n,r){let o;do o=zs(r);while(e.hasNode(o));return n.dummy=t,e.setNode(o,n),o}function lg(e){let t=new Rs().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 ug(e){let t=new Rs({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 fg(e){let t=e.nodes().map(n=>{let r={};return e.outEdges(n).forEach(o=>{r[o.w]=(r[o.w]||0)+e.edge(o).weight}),r});return Or(e.nodes(),t)}function dg(e){let t=e.nodes().map(n=>{let r={};return e.inEdges(n).forEach(o=>{r[o.v]=(r[o.v]||0)+e.edge(o).weight}),r});return Or(e.nodes(),t)}function hg(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 pg(e){let t=Vs(Ds(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o][r.order]=n)}),t}function gg(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=Cn(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function mg(e){let t=e.nodes().map(s=>e.node(s).rank),n=Cn(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 yg(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),Ps(e,"border",o,t)}function wg(e,t=Ls){const n=[];for(let r=0;r<e.length;r+=t){const o=e.slice(r,r+t);n.push(o)}return n}const Ls=65535;function Cn(e,t){if(t.length>Ls){const n=wg(t);return e.apply(null,n.map(r=>e.apply(null,r)))}else return e.apply(null,t)}function Ds(e){const n=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MIN_VALUE:o});return Cn(Math.max,n)}function xg(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function bg(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function vg(e,t){return t()}let Eg=0;function zs(e){var t=++Eg;return toString(e)+t}function Vs(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);const o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function _g(e,t){const n={};for(const r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Sg(e,t){let n=t;return typeof t=="string"&&(n=r=>r[t]),Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function Or(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}let Ng=rg,kg=ne.uniqueId;var Cg={run:$g,undo:Ag};function $g(e){(e.graph().acyclicer==="greedy"?Ng(e,n(e)):Mg(e)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,kg("rev"))});function n(r){return o=>r.edge(o).weight}}function Mg(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(n,s.w)?t.push(s):o(s.w)}),delete n[i])}return e.nodes().forEach(o),t}function Ag(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)}})}let Ig=ne;var Tg={run:Og,undo:Pg};function Og(e){e.graph().dummyChains=[],e.edges().forEach(t=>Rg(e,t))}function Rg(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,f;for(f=0,++r;r<i;++f,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=Ig.addDummyNode(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),f===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function Pg(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)})}const{applyWithChunking:Lg}=ne;var $n={longestPath:Dg,slack:zg};function Dg(e){var t={};function n(r){var o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r).map(a=>a==null?Number.POSITIVE_INFINITY:n(a.w)-e.edge(a).minlen);var s=Lg(Math.min,i);return s===Number.POSITIVE_INFINITY&&(s=0),o.rank=s}e.sources().forEach(n)}function zg(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Vg=Ee.Graph,yn=$n.slack,Hs=Hg;function Hg(e){var t=new Vg({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var o,i;Fg(t,e)<r;)o=Bg(t,e),i=t.hasNode(o.v)?yn(e,o):-yn(e,o),jg(t,e,i);return t}function Fg(e,t){function n(r){t.nodeEdges(r).forEach(o=>{var i=o.v,s=r===i?o.w:i;!e.hasNode(s)&&!yn(t,o)&&(e.setNode(s,{}),e.setEdge(r,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function Bg(e,t){return t.edges().reduce((r,o)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(i=yn(t,o)),i<r[0]?[i,o]:r},[Number.POSITIVE_INFINITY,null])[1]}function jg(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var Gg=Hs,Fo=$n.slack,Yg=$n.longestPath,Xg=Ee.alg.preorder,Wg=Ee.alg.postorder,Ug=ne.simplify,qg=tt;tt.initLowLimValues=Pr;tt.initCutValues=Rr;tt.calcCutValue=Fs;tt.leaveEdge=js;tt.enterEdge=Gs;tt.exchangeEdges=Ys;function tt(e){e=Ug(e),Yg(e);var t=Gg(e);Pr(t),Rr(t,e);for(var n,r;n=js(t);)r=Gs(t,e,n),Ys(t,e,n,r)}function Rr(e,t){var n=Wg(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Zg(e,t,r))}function Zg(e,t,n){var r=e.node(n),o=r.parent;e.edge(n,o).cutvalue=Fs(e,t,n)}function Fs(e,t,n){var r=e.node(n),o=r.parent,i=!0,s=t.edge(n,o),a=0;return s||(i=!1,s=t.edge(o,n)),a=s.weight,t.nodeEdges(n).forEach(c=>{var l=c.v===n,u=l?c.w:c.v;if(u!==o){var f=l===i,d=t.edge(c).weight;if(a+=f?d:-d,Qg(e,n,u)){var h=e.edge(n,u).cutvalue;a+=f?-h:h}}}),a}function Pr(e,t){arguments.length<2&&(t=e.nodes()[0]),Bs(e,{},1,t)}function Bs(e,t,n,r,o){var i=n,s=e.node(r);return t[r]=!0,e.neighbors(r).forEach(a=>{Object.hasOwn(t,a)||(n=Bs(e,t,n,a,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function js(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Gs(e,t,n){var r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);var i=e.node(r),s=e.node(o),a=i,c=!1;i.lim>s.lim&&(a=s,c=!0);var l=t.edges().filter(u=>c===Bo(e,e.node(u.v),a)&&c!==Bo(e,e.node(u.w),a));return l.reduce((u,f)=>Fo(t,f)<Fo(t,u)?f:u)}function Ys(e,t,n,r){var o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Pr(e),Rr(e,t),Kg(e,t)}function Kg(e,t){var n=e.nodes().find(o=>!t.node(o).parent),r=Xg(e,n);r=r.slice(1),r.forEach(o=>{var 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 Qg(e,t,n){return e.hasEdge(t,n)}function Bo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Jg=$n,Xs=Jg.longestPath,em=Hs,tm=qg,nm=rm;function rm(e){switch(e.graph().ranker){case"network-simplex":jo(e);break;case"tight-tree":im(e);break;case"longest-path":om(e);break;default:jo(e)}}var om=Xs;function im(e){Xs(e),em(e)}function jo(e){tm(e)}var sm=am;function am(e){let t=lm(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=cm(e,t,o.v,o.w),s=i.path,a=i.lca,c=0,l=s[c],u=!0;for(;n!==o.w;){if(r=e.node(n),u){for(;(l=s[c])!==a&&e.node(l).maxRank<r.rank;)c++;l===a&&(u=!1)}if(!u){for(;c<s.length-1&&e.node(l=s[c+1]).minRank<=r.rank;)c++;l=s[c]}e.setParent(n,l),n=e.successors(n)[0]}})}function cm(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,l;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)i.push(c);return{path:o.concat(i.reverse()),lca:l}}function lm(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().forEach(r),t}let wn=ne;var um={run:fm,cleanup:pm};function fm(e){let t=wn.addDummyNode(e,"root",{},"_root"),n=dm(e),r=Object.values(n),o=wn.applyWithChunking(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=hm(e)+1;e.children().forEach(a=>Ws(e,t,i,s,o,n,a)),e.graph().nodeRankFactor=i}function Ws(e,t,n,r,o,i,s){let a=e.children(s);if(!a.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let c=wn.addBorderNode(e,"_bt"),l=wn.addBorderNode(e,"_bb"),u=e.node(s);e.setParent(c,s),u.borderTop=c,e.setParent(l,s),u.borderBottom=l,a.forEach(f=>{Ws(e,t,n,r,o,i,f);let d=e.node(f),h=d.borderTop?d.borderTop:f,m=d.borderBottom?d.borderBottom:f,g=d.borderTop?r:2*r,w=h!==m?1:o-i[s]+1;e.setEdge(c,h,{weight:g,minlen:w,nestingEdge:!0}),e.setEdge(m,l,{weight:g,minlen:w,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,c,{weight:0,minlen:o+i[s]})}function dm(e){var t={};function n(r,o){var i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children().forEach(r=>n(r,1)),t}function hm(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function pm(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}let gm=ne;var mm=ym;function ym(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Go(e,"borderLeft","_bl",n,o,i),Go(e,"borderRight","_br",n,o,i)}}e.children().forEach(t)}function Go(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=gm.addDummyNode(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}var wm={adjust:xm,undo:bm};function xm(e){let t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&Us(e)}function bm(e){let t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&vm(e),(t==="lr"||t==="rl")&&(Em(e),Us(e))}function Us(e){e.nodes().forEach(t=>Yo(e.node(t))),e.edges().forEach(t=>Yo(e.edge(t)))}function Yo(e){let t=e.width;e.width=e.height,e.height=t}function vm(e){e.nodes().forEach(t=>Yn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Yn),Object.hasOwn(n,"y")&&Yn(n)})}function Yn(e){e.y=-e.y}function Em(e){e.nodes().forEach(t=>Xn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Xn),Object.hasOwn(n,"x")&&Xn(n)})}function Xn(e){let t=e.x;e.x=e.y,e.y=t}let Xo=ne;var _m=Sm;function Sm(e){let t={},n=e.nodes().filter(c=>!e.children(c).length),r=n.map(c=>e.node(c).rank),o=Xo.applyWithChunking(Math.max,r),i=Xo.range(o+1).map(()=>[]);function s(c){if(t[c])return;t[c]=!0;let l=e.node(c);i[l.rank].push(c),e.successors(c).forEach(s)}return n.sort((c,l)=>e.node(c).rank-e.node(l).rank).forEach(s),i}let Nm=ne.zipObject;var km=Cm;function Cm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=$m(e,t[r-1],t[r]);return n}function $m(e,t,n){let r=Nm(n,n.map((l,u)=>u)),o=t.flatMap(l=>e.outEdges(l).map(u=>({pos:r[u.w],weight:e.edge(u).weight})).sort((u,f)=>u.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 f=0;for(;u>0;)u%2&&(f+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*f}),c}var Mm=Am;function Am(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(r.length){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}}else return{v:n}})}let Im=ne;var Tm=Om;function Om(e,t){let n={};e.forEach((o,i)=>{let s=n[o.v]={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight)}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(n[o.w]))});let r=Object.values(n).filter(o=>!o.indegree);return Rm(r)}function Rm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Pm(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=>Im.pick(o,["vs","i","barycenter","weight"]))}function Pm(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}let Lm=ne;var Dm=zm;function zm(e,t){let n=Lm.partition(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,o=n.rhs.sort((u,f)=>f.i-u.i),i=[],s=0,a=0,c=0;r.sort(Vm(!!t)),c=Wo(i,o,c),r.forEach(u=>{c+=u.vs.length,i.push(u.vs),s+=u.barycenter*u.weight,a+=u.weight,c=Wo(i,o,c)});let l={vs:i.flat(!0)};return a&&(l.barycenter=s/a,l.weight=a),l}function Wo(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){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}let Hm=Mm,Fm=Tm,Bm=Dm;var jm=qs;function qs(e,t,n,r){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,a=i?i.borderRight:void 0,c={};s&&(o=o.filter(d=>d!==s&&d!==a));let l=Hm(e,o);l.forEach(d=>{if(e.children(d.v).length){let h=qs(e,d.v,n,r);c[d.v]=h,Object.hasOwn(h,"barycenter")&&Ym(d,h)}});let u=Fm(l,n);Gm(u,c);let f=Bm(u,r);if(s&&(f.vs=[s,f.vs,a].flat(!0),e.predecessors(s).length)){let d=e.node(e.predecessors(s)[0]),h=e.node(e.predecessors(a)[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+d.order+h.order)/(f.weight+2),f.weight+=2}return f}function Gm(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function Ym(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)}let Xm=Ee.Graph,Wm=ne;var Um=qm;function qm(e,t,n){let r=Zm(e),o=new Xm({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(i=>e.node(i));return e.nodes().forEach(i=>{let s=e.node(i),a=e.parent(i);(s.rank===t||s.minRank<=t&&t<=s.maxRank)&&(o.setNode(i),o.setParent(i,a||r),e[n](i).forEach(c=>{let l=c.v===i?c.w:c.v,u=o.edge(l,i),f=u!==void 0?u.weight:0;o.setEdge(l,i,{weight:e.edge(c).weight+f})}),Object.hasOwn(s,"minRank")&&o.setNode(i,{borderLeft:s.borderLeft[t],borderRight:s.borderRight[t]}))}),o}function Zm(e){for(var t;e.hasNode(t=Wm.uniqueId("_root")););return t}var Km=Qm;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}})}let Jm=_m,e0=km,t0=jm,n0=Um,r0=Km,o0=Ee.Graph,nn=ne;var i0=Zs;function Zs(e,t){if(t&&typeof t.customOrder=="function"){t.customOrder(e,Zs);return}let n=nn.maxRank(e),r=Uo(e,nn.range(1,n+1),"inEdges"),o=Uo(e,nn.range(n-1,-1,-1),"outEdges"),i=Jm(e);if(qo(e,i),t&&t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,a;for(let c=0,l=0;l<4;++c,++l){s0(c%2?r:o,c%4>=2),i=nn.buildLayerMatrix(e);let u=e0(e,i);u<s&&(l=0,a=Object.assign({},i),s=u)}qo(e,a)}function Uo(e,t,n){return t.map(function(r){return n0(e,r,n)})}function s0(e,t){let n=new o0;e.forEach(function(r){let o=r.graph().root,i=t0(r,o,n,t);i.vs.forEach((s,a)=>r.node(s).order=a),r0(r,n,i.vs)})}function qo(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}let a0=Ee.Graph,Ie=ne;var c0={positionX:f0,findType1Conflicts:Ks,findType2Conflicts:Qs,addConflict:Lr,hasConflict:Js,verticalAlignment:ea,horizontalCompaction:ta,alignCoordinates:ra,findSmallestWidthAlignment:na,balance:oa};function Ks(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,f)=>{let d=l0(e,u),h=d?e.node(d).order:c;(d||u===l)&&(i.slice(a,f+1).forEach(m=>{e.predecessors(m).forEach(g=>{let w=e.node(g),y=w.order;(y<s||h<y)&&!(w.dummy&&e.node(m).dummy)&&Lr(n,g,m)})}),a=f+1,s=h)}),i}return t.length&&t.reduce(r),n}function Qs(e,t){let n={};function r(i,s,a,c,l){let u;Ie.range(s,a).forEach(f=>{u=i[f],e.node(u).dummy&&e.predecessors(u).forEach(d=>{let h=e.node(d);h.dummy&&(h.order<c||h.order>l)&&Lr(n,d,u)})})}function o(i,s){let a=-1,c,l=0;return s.forEach((u,f)=>{if(e.node(u).dummy==="border"){let d=e.predecessors(u);d.length&&(c=e.node(d[0]).order,r(s,l,f,a,c),l=f,a=c)}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function l0(e,t){if(e.node(t).dummy)return e.predecessors(t).find(n=>e.node(n).dummy)}function Lr(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 Js(e,t,n){if(t>n){let r=t;t=n,n=r}return!!e[t]&&Object.hasOwn(e[t],n)}function ea(e,t,n,r){let o={},i={},s={};return t.forEach(a=>{a.forEach((c,l)=>{o[c]=c,i[c]=c,s[c]=l})}),t.forEach(a=>{let c=-1;a.forEach(l=>{let u=r(l);if(u.length){u=u.sort((d,h)=>s[d]-s[h]);let f=(u.length-1)/2;for(let d=Math.floor(f),h=Math.ceil(f);d<=h;++d){let m=u[d];i[l]===l&&c<s[m]&&!Js(n,l,m)&&(i[m]=l,i[l]=o[l]=o[m],c=s[m])}}})}),{root:o,align:i}}function ta(e,t,n,r,o){let i={},s=u0(e,t,n,o),a=o?"borderLeft":"borderRight";function c(f,d){let h=s.nodes(),m=h.pop(),g={};for(;m;)g[m]?f(m):(g[m]=!0,h.push(m),h=h.concat(d(m))),m=h.pop()}function l(f){i[f]=s.inEdges(f).reduce((d,h)=>Math.max(d,i[h.v]+s.edge(h)),0)}function u(f){let d=s.outEdges(f).reduce((m,g)=>Math.min(m,i[g.w]-s.edge(g)),Number.POSITIVE_INFINITY),h=e.node(f);d!==Number.POSITIVE_INFINITY&&h.borderType!==a&&(i[f]=Math.max(i[f],d))}return c(l,s.predecessors.bind(s)),c(u,s.successors.bind(s)),Object.keys(r).forEach(f=>i[f]=i[n[f]]),i}function u0(e,t,n,r){let o=new a0,i=e.graph(),s=d0(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let u=n[l];if(o.setNode(u),c){var f=n[c],d=o.edge(f,u);o.setEdge(f,u,Math.max(s(e,l,c),d||0))}c=l})}),o}function na(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=h0(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});const s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function ra(e,t){let n=Object.values(t),r=Ie.applyWithChunking(Math.min,n),o=Ie.applyWithChunking(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(c===t)return;let l=Object.values(c),u=r-Ie.applyWithChunking(Math.min,l);s!=="l"&&(u=o-Ie.applyWithChunking(Math.max,l)),u&&(e[a]=Ie.mapValues(c,f=>f+u))})})}function oa(e,t){return Ie.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let o=Object.values(e).map(i=>i[r]).sort((i,s)=>i-s);return(o[1]+o[2])/2}})}function f0(e){let t=Ie.buildLayerMatrix(e),n=Object.assign(Ks(e,t),Qs(e,t)),r={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(a=>{a==="r"&&(o=o.map(f=>Object.values(f).reverse()));let c=(s==="u"?e.predecessors:e.successors).bind(e),l=ea(e,o,n,c),u=ta(e,o,l.root,l.align,a==="r");a==="r"&&(u=Ie.mapValues(u,f=>-f)),r[s+a]=u})});let i=na(e,r);return ra(r,i),oa(r,e.graph().align)}function d0(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=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),l=0,c}}function h0(e,t){return e.node(t).width}let ia=ne,p0=c0.positionX;var g0=m0;function m0(e){e=ia.asNonCompoundGraph(e),y0(e),Object.entries(p0(e)).forEach(([t,n])=>e.node(t).x=n)}function y0(e){let t=ia.buildLayerMatrix(e),n=e.graph().ranksep,r=0;t.forEach(o=>{const i=o.reduce((s,a)=>{const c=e.node(a).height;return s>c?s:c},0);o.forEach(s=>e.node(s).y=r+i/2),r+=i+n})}let Zo=Cg,Ko=Tg,w0=nm,x0=ne.normalizeRanks,b0=sm,v0=ne.removeEmptyRanks,Qo=um,E0=mm,Jo=wm,_0=i0,S0=g0,ge=ne,N0=Ee.Graph;var k0=C0;function C0(e,t){let n=t&&t.debugTiming?ge.time:ge.notime;n("layout",()=>{let r=n("  buildLayoutGraph",()=>D0(e));n("  runLayout",()=>$0(r,n,t)),n("  updateInputGraph",()=>M0(e,r))})}function $0(e,t,n){t("    makeSpaceForEdgeLabels",()=>z0(e)),t("    removeSelfEdges",()=>W0(e)),t("    acyclic",()=>Zo.run(e)),t("    nestingGraph.run",()=>Qo.run(e)),t("    rank",()=>w0(ge.asNonCompoundGraph(e))),t("    injectEdgeLabelProxies",()=>V0(e)),t("    removeEmptyRanks",()=>v0(e)),t("    nestingGraph.cleanup",()=>Qo.cleanup(e)),t("    normalizeRanks",()=>x0(e)),t("    assignRankMinMax",()=>H0(e)),t("    removeEdgeLabelProxies",()=>F0(e)),t("    normalize.run",()=>Ko.run(e)),t("    parentDummyChains",()=>b0(e)),t("    addBorderSegments",()=>E0(e)),t("    order",()=>_0(e,n)),t("    insertSelfEdges",()=>U0(e)),t("    adjustCoordinateSystem",()=>Jo.adjust(e)),t("    position",()=>S0(e)),t("    positionSelfEdges",()=>q0(e)),t("    removeBorderNodes",()=>X0(e)),t("    normalize.undo",()=>Ko.undo(e)),t("    fixupEdgeLabelCoords",()=>G0(e)),t("    undoCoordinateSystem",()=>Jo.undo(e)),t("    translateGraph",()=>B0(e)),t("    assignNodeIntersects",()=>j0(e)),t("    reversePoints",()=>Y0(e)),t("    acyclic.undo",()=>Zo.undo(e))}function M0(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.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}let A0=["nodesep","edgesep","ranksep","marginx","marginy"],I0={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},T0=["acyclicer","ranker","rankdir","align"],O0=["width","height"],ei={width:0,height:0},R0=["minlen","weight","width","height","labeloffset"],P0={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L0=["labelpos"];function D0(e){let t=new N0({multigraph:!0,compound:!0}),n=Un(e.graph());return t.setGraph(Object.assign({},I0,Wn(n,A0),ge.pick(n,T0))),e.nodes().forEach(r=>{let o=Un(e.node(r));const i=Wn(o,O0);Object.keys(ei).forEach(s=>{i[s]===void 0&&(i[s]=ei[s])}),t.setNode(r,i),t.setParent(r,e.parent(r))}),e.edges().forEach(r=>{let o=Un(e.edge(r));t.setEdge(r,Object.assign({},P0,Wn(o,R0),ge.pick(o,L0)))}),t}function z0(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function V0(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ge.addDummyNode(e,"edge-proxy",i,"_ep")}})}function H0(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 F0(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function B0(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,f=l.y,d=l.width,h=l.height;t=Math.min(t,u-d/2),n=Math.max(n,u+d/2),r=Math.min(r,f-h/2),o=Math.max(o,f+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(f=>{f.x-=t,f.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 j0(e){e.edges().forEach(t=>{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(ge.intersectRect(r,i)),n.points.push(ge.intersectRect(o,s))})}function G0(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 Y0(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function X0(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 W0(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function U0(e){var t=ge.buildLayerMatrix(e);t.forEach(n=>{var r=0;n.forEach((o,i)=>{var s=e.node(o);s.order=i+r,(s.selfEdges||[]).forEach(a=>{ge.addDummyNode(e,"selfedge",{width:a.label.width,height:a.label.height,rank:s.rank,order:i+ ++r,e:a.e,label:a.label},"_se")}),delete s.selfEdges})})}function q0(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),o=r.x+r.width/2,i=r.y,s=n.x-o,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:o+2*s/3,y:i-a},{x:o+5*s/6,y:i-a},{x:o+s,y:i},{x:o+5*s/6,y:i+a},{x:o+2*s/3,y:i+a}],n.label.x=n.x,n.label.y=n.y}})}function Wn(e,t){return ge.mapValues(ge.pick(e,t),Number)}function Un(e){var t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}let Z0=ne,K0=Ee.Graph;var Q0={debugOrdering:J0};function J0(e){let t=Z0.buildLayerMatrix(e),n=new K0({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 ey="1.1.4",ty={graphlib:Ee,layout:k0,debug:Q0,util:{time:ne.time,notime:ne.notime},version:ey};const sa=ni(ty),At=new sa.graphlib.Graph().setDefaultEdgeLabel(()=>({})),ny=(e,t)=>(At.setGraph({rankdir:"vertical",ranksep:70}),t.forEach(n=>At.setEdge(n.source,n.target)),e.forEach(n=>At.setNode(n.id,{width:120,height:100})),sa.layout(At),{positionedNodes:e.map(n=>{const{x:r,y:o}=At.node(n.id);return{...n,position:{x:r,y:o}}}),positionedEdges:t}),ti=(e,t,n)=>{const{positionedNodes:r,positionedEdges:o}=ny(e,t);return[r.map(s=>{if(n[s.id]){const[a,c]=n[s.id];return{...s,position:{x:a,y:c},positionAbsolute:{x:a,y:c}}}return s}),o]};function ry(e){const t=ri(),[n,r]=Ga(e,Ya.properties.customNodePositioning,{commit:!0}),o=_.useMemo(()=>JSON.parse(n||"{}"),[n]),[i,s]=_.useState([]),[a,c]=_.useState([]),[l,u]=_.useState(),f=_.useCallback((m,g)=>{const[w,y]=ti(m,g,o);s(ep(w,t)),c(y)},[t,o]),d=_.useCallback(async(m,g)=>{const w={...o};delete w[g.id],await r(JSON.stringify(w));const[y]=ti(i,a,w);s(y)},[o,i,a]),h=_.useCallback(m=>{var w,y;const g=m[0];g.type==="position"&&(g.dragging?u(g):r(JSON.stringify({...o,[g.id]:[(w=l.positionAbsolute)==null?void 0:w.x,(y=l.positionAbsolute)==null?void 0:y.y]}))),s(E=>fs(m,E))},[o,l]);return{nodes:i,edges:a,setGraph:f,handleNodeChange:h,handleNodeDoubleClick:d}}const oy={floating:ip};function fy({...e}){return ae.jsx(Ir,{children:ae.jsx(iy,{...e})})}function iy({ontology:e}){const t=Xa(),{fitView:n}=kn(),{nodes:r,edges:o,setGraph:i,handleNodeChange:s,handleNodeDoubleClick:a}=ry(e);Wa(()=>{Jh(e,t).then(([l,u])=>{i(l,u),requestAnimationFrame(()=>{n()})})});const c=_.useCallback((l,u)=>{var d;const f=Ua(u.id);(d=document.getElementById(f))==null||d.scrollIntoView({behavior:"smooth"})},[]);return ae.jsx(Ss,{fitView:!0,nodes:r,edges:o,edgeTypes:oy,onNodesChange:s,onNodeClick:c,onNodeDoubleClick:a,children:ae.jsx(Wh,{position:"top-left",showInteractive:!1})})}export{fy as default};
//# sourceMappingURL=chunk_OntologyGraph.js.map