atomic-server 0.37.0

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