yamlover 0.3.48 → 0.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -18
- package/bin/ga4.js +77 -0
- package/bin/yamlover.js +56 -18
- package/dist/agent-docs/AGENTS.md +86 -51
- package/dist/agent-docs/CLAUDE.md +1 -1
- package/dist/builtin-taxonomy/$defs/board +1 -1
- package/dist/builtin-taxonomy/$defs/bullets +1 -1
- package/dist/builtin-taxonomy/$defs/chapter +4 -4
- package/dist/builtin-taxonomy/$defs/chunk +1 -1
- package/dist/builtin-taxonomy/$defs/config +1 -1
- package/dist/builtin-taxonomy/$defs/numbered +1 -1
- package/dist/builtin-taxonomy/$defs/table +2 -2
- package/dist/builtin-taxonomy/tags/{.yamlover/body.yamlover → .yo/body.yo} +1 -1
- package/dist/client/assets/{decoded-Dfxf1BRR.js → decoded-D_YQdg1-.js} +1 -1
- package/dist/client/assets/djvu-Di4fPA-J.js +1 -0
- package/dist/client/assets/{docx-aCX_2O0_.js → docx-BSduN32X.js} +1 -1
- package/dist/client/assets/{heic-8pzTwsCx.js → heic-DOAG7EsW.js} +1 -1
- package/dist/client/assets/{imagemap-Bp26n33x.js → imagemap-B8RthxNE.js} +1 -1
- package/dist/client/assets/index-Bf2L7I9e.js +752 -0
- package/dist/client/assets/index-N41EyNG2.css +1 -0
- package/dist/client/assets/{map-Dtw0_sOf.js → map-Cf7ar1_U.js} +1 -1
- package/dist/client/assets/openable-CCBlc-Ws.js +4 -0
- package/dist/client/assets/{paged-BGVPKMC7.js → paged-bLurvatj.js} +1 -1
- package/dist/client/assets/{pdf-eI1AsxuB.js → pdf-D1ox8M9A.js} +2 -2
- package/dist/client/assets/{psd-BD_hUWIy.js → psd-AT50x-YR.js} +1 -1
- package/dist/client/assets/{spreadsheet-D_yjjR8a.js → spreadsheet-DeQh5CNF.js} +1 -1
- package/dist/client/assets/{tiff-BewNDYwu.js → tiff-B3-awhzQ.js} +1 -1
- package/dist/client/assets/xyflow-BnuhLJ6X.css +1 -0
- package/dist/client/assets/xyflow-DuQ4jjaq.js +23 -0
- package/dist/client/index.html +6 -2
- package/dist/client/yo-favicon.svg +16 -0
- package/dist/server.js +1862 -1018
- package/package.json +11 -4
- package/dist/client/assets/djvu-BAFaxONw.js +0 -1
- package/dist/client/assets/index-BohJjyVY.css +0 -1
- package/dist/client/assets/index-DXrtwPKE.js +0 -754
- package/dist/client/assets/openable-Banncb36.js +0 -4
- /package/dist/builtin-taxonomy/$defs/{.yamlover/meta.yamlover → .yo/meta.yo} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{r as T,g as Zc,R as Wc,j as I,l as ft,m as Gc,n as qc,o as Kc,p as vi,q as Uc,t as Kn,v as bi,w as Qc,x as Jc}from"./index-Bf2L7I9e.js";import{a as el}from"./paged-bLurvatj.js";function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ie(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var tl={value:()=>{}};function gn(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Gt(n)}function Gt(e){this._=e}function nl(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Gt.prototype=gn.prototype={constructor:Gt,on:function(e,t){var n=this._,o=nl(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=ol(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Wo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Wo(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Gt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function ol(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Wo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=tl,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Un="http://www.w3.org/1999/xhtml";const Go={svg:"http://www.w3.org/2000/svg",xhtml:Un,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function pn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Go.hasOwnProperty(t)?{space:Go[t],local:e}:e}function rl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Un&&t.documentElement.namespaceURI===Un?t.createElement(e):t.createElementNS(n,e)}}function il(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ei(e){var t=pn(e);return(t.local?il:rl)(t)}function sl(){}function go(e){return e==null?sl:function(){return this.querySelector(e)}}function al(e){typeof e!="function"&&(e=go(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),l,c,u=0;u<s;++u)(l=i[u])&&(c=e.call(l,l.__data__,u,i))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new le(o,this._parents)}function cl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ll(){return[]}function _i(e){return e==null?ll:function(){return this.querySelectorAll(e)}}function ul(e){return function(){return cl(e.apply(this,arguments))}}function dl(e){typeof e=="function"?e=ul(e):e=_i(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new le(o,r)}function Ni(e){return function(){return this.matches(e)}}function Si(e){return function(t){return t.matches(e)}}var fl=Array.prototype.find;function hl(e){return function(){return fl.call(this.children,e)}}function gl(){return this.firstElementChild}function pl(e){return this.select(e==null?gl:hl(typeof e=="function"?e:Si(e)))}var ml=Array.prototype.filter;function yl(){return Array.from(this.children)}function wl(e){return function(){return ml.call(this.children,e)}}function xl(e){return this.selectAll(e==null?yl:wl(typeof e=="function"?e:Si(e)))}function vl(e){typeof e!="function"&&(e=Ni(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new le(o,this._parents)}function ki(e){return new Array(e.length)}function bl(){return new le(this._enter||this._groups.map(ki),this._parents)}function en(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}en.prototype={constructor:en,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 El(e){return function(){return e}}function _l(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new en(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Nl(e,t,n,o,r,i,s){var a,l,c=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(l=t[a])&&(d[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new en(e,i[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(d[a])===l&&(r[a]=l)}function Sl(e){return e.__data__}function kl(e,t){if(!arguments.length)return Array.from(this,Sl);var n=t?Nl:_l,o=this._parents,r=this._groups;typeof e!="function"&&(e=El(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var u=o[c],f=r[c],d=f.length,h=Cl(e.call(u,u&&u.__data__,c,o)),g=h.length,w=a[c]=new Array(g),m=s[c]=new Array(g),p=l[c]=new Array(d);n(u,f,w,m,p,h,t);for(var b=0,y=0,x,_;b<g;++b)if(x=w[b]){for(b>=y&&(y=b+1);!(_=m[y])&&++y<g;);x._next=_||null}}return s=new le(s,o),s._enter=a,s._exit=l,s}function Cl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ml(){return new le(this._exit||this._groups.map(ki),this._parents)}function Il(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Ol(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=n[l],u=o[l],f=c.length,d=a[l]=new Array(f),h,g=0;g<f;++g)(h=c[g]||u[g])&&(d[g]=h);for(;l<r;++l)a[l]=n[l];return new le(a,this._parents)}function Al(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Pl(e){e||(e=$l);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,l=r[i]=new Array(a),c,u=0;u<a;++u)(c=s[u])&&(l[u]=c);l.sort(t)}return new le(r,this._parents).order()}function $l(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Tl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Dl(){return Array.from(this)}function Rl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function Ll(){let e=0;for(const t of this)++e;return e}function zl(){return!this.node()}function jl(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Hl(e){return function(){this.removeAttribute(e)}}function Vl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Bl(e,t){return function(){this.setAttribute(e,t)}}function Fl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Yl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Xl(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 Zl(e,t){var n=pn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Vl:Hl:typeof t=="function"?n.local?Xl:Yl:n.local?Fl:Bl)(n,t))}function Ci(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Wl(e){return function(){this.style.removeProperty(e)}}function Gl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ql(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Kl(e,t,n){return arguments.length>1?this.each((t==null?Wl:typeof t=="function"?ql:Gl)(e,t,n??"")):et(this.node(),e)}function et(e,t){return e.style.getPropertyValue(t)||Ci(e).getComputedStyle(e,null).getPropertyValue(t)}function Ul(e){return function(){delete this[e]}}function Ql(e,t){return function(){this[e]=t}}function Jl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function eu(e,t){return arguments.length>1?this.each((t==null?Ul:typeof t=="function"?Jl:Ql)(e,t)):this.node()[e]}function Mi(e){return e.trim().split(/^|\s+/)}function po(e){return e.classList||new Ii(e)}function Ii(e){this._node=e,this._names=Mi(e.getAttribute("class")||"")}Ii.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 Oi(e,t){for(var n=po(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Ai(e,t){for(var n=po(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function tu(e){return function(){Oi(this,e)}}function nu(e){return function(){Ai(this,e)}}function ou(e,t){return function(){(t.apply(this,arguments)?Oi:Ai)(this,e)}}function ru(e,t){var n=Mi(e+"");if(arguments.length<2){for(var o=po(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?ou:t?tu:nu)(n,t))}function iu(){this.textContent=""}function su(e){return function(){this.textContent=e}}function au(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function cu(e){return arguments.length?this.each(e==null?iu:(typeof e=="function"?au:su)(e)):this.node().textContent}function lu(){this.innerHTML=""}function uu(e){return function(){this.innerHTML=e}}function du(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function fu(e){return arguments.length?this.each(e==null?lu:(typeof e=="function"?du:uu)(e)):this.node().innerHTML}function hu(){this.nextSibling&&this.parentNode.appendChild(this)}function gu(){return this.each(hu)}function pu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mu(){return this.each(pu)}function yu(e){var t=typeof e=="function"?e:Ei(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wu(){return null}function xu(e,t){var n=typeof e=="function"?e:Ei(e),o=t==null?wu:typeof t=="function"?t:go(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function vu(){var e=this.parentNode;e&&e.removeChild(this)}function bu(){return this.each(vu)}function Eu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _u(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nu(e){return this.select(e?_u:Eu)}function Su(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ku(e){return function(t){e.call(this,t,this.__data__)}}function Cu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Mu(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Iu(e,t,n){return function(){var o=this.__on,r,i=ku(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Ou(e,t,n){var o=Cu(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(r=0,u=a[l];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Iu:Mu,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function Pi(e,t,n){var o=Ci(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Au(e,t){return function(){return Pi(this,e,t)}}function Pu(e,t){return function(){return Pi(this,e,t.apply(this,arguments))}}function $u(e,t){return this.each((typeof t=="function"?Pu:Au)(e,t))}function*Tu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var $i=[null];function le(e,t){this._groups=e,this._parents=t}function Pt(){return new le([[document.documentElement]],$i)}function Du(){return this}le.prototype=Pt.prototype={constructor:le,select:al,selectAll:dl,selectChild:pl,selectChildren:xl,filter:vl,data:kl,enter:bl,exit:Ml,join:Il,merge:Ol,selection:Du,order:Al,sort:Pl,call:Tl,nodes:Dl,node:Rl,size:Ll,empty:zl,each:jl,attr:Zl,style:Kl,property:eu,classed:ru,text:cu,html:fu,raise:gu,lower:mu,append:yu,insert:xu,remove:bu,clone:Nu,datum:Su,on:Ou,dispatch:$u,[Symbol.iterator]:Tu};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],$i)}function Ru(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Ru(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Lu={passive:!1},vt={capture:!0,passive:!1};function An(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Ti(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,vt);"onselectstart"in t?n.on("selectstart.drag",Qe,vt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Di(e,t){var n=e.document.documentElement,o=ce(e).on("dragstart.drag",null);t&&(o.on("click.drag",Qe,vt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const jt=e=>()=>e;function Qn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Qn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function zu(e){return!e.ctrlKey&&!e.button}function ju(){return this.parentNode}function Hu(e,t){return t??{x:e.x,y:e.y}}function Vu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ri(){var e=zu,t=ju,n=Hu,o=Vu,r={},i=gn("start","drag","end"),s=0,a,l,c,u,f=0;function d(x){x.on("mousedown.drag",h).filter(o).on("touchstart.drag",m).on("touchmove.drag",p,Lu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,_){if(!(u||!e.call(this,x,_))){var E=y(this,t.call(this,x,_),x,_,"mouse");E&&(ce(x.view).on("mousemove.drag",g,vt).on("mouseup.drag",w,vt),Ti(x.view),An(x),c=!1,a=x.clientX,l=x.clientY,E("start",x))}}function g(x){if(Qe(x),!c){var _=x.clientX-a,E=x.clientY-l;c=_*_+E*E>f}r.mouse("drag",x)}function w(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Di(x.view,c),Qe(x),r.mouse("end",x)}function m(x,_){if(e.call(this,x,_)){var E=x.changedTouches,S=t.call(this,x,_),C=E.length,A,z;for(A=0;A<C;++A)(z=y(this,S,x,_,E[A].identifier,E[A]))&&(An(x),z("start",x,E[A]))}}function p(x){var _=x.changedTouches,E=_.length,S,C;for(S=0;S<E;++S)(C=r[_[S].identifier])&&(Qe(x),C("drag",x,_[S]))}function b(x){var _=x.changedTouches,E=_.length,S,C;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<E;++S)(C=r[_[S].identifier])&&(An(x),C("end",x,_[S]))}function y(x,_,E,S,C,A){var z=i.copy(),P=fe(A||E,_),$,M,v;if((v=n.call(x,new Qn("beforestart",{sourceEvent:E,target:d,identifier:C,active:s,x:P[0],y:P[1],dx:0,dy:0,dispatch:z}),S))!=null)return $=v.x-P[0]||0,M=v.y-P[1]||0,function N(k,O,R){var D=P,V;switch(k){case"start":r[C]=N,V=s++;break;case"end":delete r[C],--s;case"drag":P=fe(R||O,_),V=s;break}z.call(k,x,new Qn(k,{sourceEvent:O,subject:v,target:d,identifier:C,active:V,x:P[0]+$,y:P[1]+M,dx:P[0]-D[0],dy:P[1]-D[1],dispatch:z}),S)}}return d.filter=function(x){return arguments.length?(e=typeof x=="function"?x:jt(!!x),d):e},d.container=function(x){return arguments.length?(t=typeof x=="function"?x:jt(x),d):t},d.subject=function(x){return arguments.length?(n=typeof x=="function"?x:jt(x),d):n},d.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:jt(!!x),d):o},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 mo(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Li(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function $t(){}var bt=.7,tn=1/bt,Je="\\s*([+-]?\\d+)\\s*",Et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Bu=/^#([0-9a-f]{3,8})$/,Fu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Yu=new RegExp(`^rgb\\(${Ee},${Ee},${Ee}\\)$`),Xu=new RegExp(`^rgba\\(${Je},${Je},${Je},${Et}\\)$`),Zu=new RegExp(`^rgba\\(${Ee},${Ee},${Ee},${Et}\\)$`),Wu=new RegExp(`^hsl\\(${Et},${Ee},${Ee}\\)$`),Gu=new RegExp(`^hsla\\(${Et},${Ee},${Ee},${Et}\\)$`),qo={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};mo($t,Fe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ko,formatHex:Ko,formatHex8:qu,formatHsl:Ku,formatRgb:Uo,toString:Uo});function Ko(){return this.rgb().formatHex()}function qu(){return this.rgb().formatHex8()}function Ku(){return zi(this).formatHsl()}function Uo(){return this.rgb().formatRgb()}function Fe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Bu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Qo(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ht(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ht(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=Fu.exec(e))?new ae(t[1],t[2],t[3],1):(t=Yu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Xu.exec(e))?Ht(t[1],t[2],t[3],t[4]):(t=Zu.exec(e))?Ht(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Wu.exec(e))?tr(t[1],t[2]/100,t[3]/100,1):(t=Gu.exec(e))?tr(t[1],t[2]/100,t[3]/100,t[4]):qo.hasOwnProperty(e)?Qo(qo[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Qo(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Ht(e,t,n,o){return o<=0&&(e=t=n=NaN),new ae(e,t,n,o)}function Uu(e){return e instanceof $t||(e=Fe(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Jn(e,t,n,o){return arguments.length===1?Uu(e):new ae(e,t,n,o??1)}function ae(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}mo(ae,Jn,Li($t,{brighter(e){return e=e==null?tn:Math.pow(tn,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bt:Math.pow(bt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Ve(this.r),Ve(this.g),Ve(this.b),nn(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:Jo,formatHex:Jo,formatHex8:Qu,formatRgb:er,toString:er}));function Jo(){return`#${He(this.r)}${He(this.g)}${He(this.b)}`}function Qu(){return`#${He(this.r)}${He(this.g)}${He(this.b)}${He((isNaN(this.opacity)?1:this.opacity)*255)}`}function er(){const e=nn(this.opacity);return`${e===1?"rgb(":"rgba("}${Ve(this.r)}, ${Ve(this.g)}, ${Ve(this.b)}${e===1?")":`, ${e})`}`}function nn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ve(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function He(e){return e=Ve(e),(e<16?"0":"")+e.toString(16)}function tr(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,o)}function zi(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof $t||(e=Fe(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new he(s,a,l,e.opacity)}function Ju(e,t,n,o){return arguments.length===1?zi(e):new he(e,t,n,o??1)}function he(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}mo(he,Ju,Li($t,{brighter(e){return e=e==null?tn:Math.pow(tn,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bt:Math.pow(bt,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ae(Pn(e>=240?e-240:e+120,r,o),Pn(e,r,o),Pn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new he(nr(this.h),Vt(this.s),Vt(this.l),nn(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=nn(this.opacity);return`${e===1?"hsl(":"hsla("}${nr(this.h)}, ${Vt(this.s)*100}%, ${Vt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function nr(e){return e=(e||0)%360,e<0?e+360:e}function Vt(e){return Math.max(0,Math.min(1,e||0))}function Pn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const yo=e=>()=>e;function ed(e,t){return function(n){return e+n*t}}function td(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function nd(e){return(e=+e)==1?ji:function(t,n){return n-t?td(t,n,e):yo(isNaN(t)?n:t)}}function ji(e,t){var n=t-e;return n?ed(e,n):yo(isNaN(e)?t:e)}const on=function e(t){var n=nd(t);function o(r,i){var s=n((r=Jn(r)).r,(i=Jn(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=ji(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=l(u),r.opacity=c(u),r+""}}return o.gamma=e,o}(1);function od(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function rd(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function id(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=wt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function sd(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function ve(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ad(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=wt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var eo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$n=new RegExp(eo.source,"g");function cd(e){return function(){return e}}function ld(e){return function(t){return e(t)+""}}function Hi(e,t){var n=eo.lastIndex=$n.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=eo.exec(e))&&(r=$n.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:ve(o,r)})),n=$n.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?ld(l[0].x):cd(t):(t=l.length,function(c){for(var u=0,f;u<t;++u)a[(f=l[u]).i]=f.x(c);return a.join("")})}function wt(e,t){var n=typeof t,o;return t==null||n==="boolean"?yo(t):(n==="number"?ve:n==="string"?(o=Fe(t))?(t=o,on):Hi:t instanceof Fe?on:t instanceof Date?sd:rd(t)?od:Array.isArray(t)?id:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ad:ve)(e,t)}var or=180/Math.PI,to={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Vi(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*or,skewX:Math.atan(l)*or,scaleX:s,scaleY:a}}var Bt;function ud(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?to:Vi(t.a,t.b,t.c,t.d,t.e,t.f)}function dd(e){return e==null||(Bt||(Bt=document.createElementNS("http://www.w3.org/2000/svg","g")),Bt.setAttribute("transform",e),!(e=Bt.transform.baseVal.consolidate()))?to:(e=e.matrix,Vi(e.a,e.b,e.c,e.d,e.e,e.f))}function Bi(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,u,f,d,h,g){if(c!==f||u!==d){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:ve(c,f)},{i:w-2,x:ve(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(c,u,f,d){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:ve(c,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(c,u,f,d){c!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:ve(c,u)}):u&&f.push(r(f)+"skewX("+u+o)}function l(c,u,f,d,h,g){if(c!==f||u!==d){var w=h.push(r(h)+"scale(",null,",",null,")");g.push({i:w-4,x:ve(c,f)},{i:w-2,x:ve(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(c,u){var f=[],d=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,f,d),s(c.rotate,u.rotate,f,d),a(c.skewX,u.skewX,f,d),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,d),c=u=null,function(h){for(var g=-1,w=d.length,m;++g<w;)f[(m=d[g]).i]=m.x(h);return f.join("")}}}var fd=Bi(ud,"px, ","px)","deg)"),hd=Bi(dd,", ",")",")"),gd=1e-12;function rr(e){return((e=Math.exp(e))+1/e)/2}function pd(e){return((e=Math.exp(e))-1/e)/2}function md(e){return((e=Math.exp(2*e))-1)/(e+1)}const qt=function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],u=s[0],f=s[1],d=s[2],h=u-a,g=f-l,w=h*h+g*g,m,p;if(w<gd)p=Math.log(d/c)/t,m=function(S){return[a+S*h,l+S*g,c*Math.exp(t*S*p)]};else{var b=Math.sqrt(w),y=(d*d-c*c+o*w)/(2*c*n*b),x=(d*d-c*c-o*w)/(2*d*n*b),_=Math.log(Math.sqrt(y*y+1)-y),E=Math.log(Math.sqrt(x*x+1)-x);p=(E-_)/t,m=function(S){var C=S*p,A=rr(_),z=c/(n*b)*(A*md(t*C+_)-pd(_));return[a+z*h,l+z*g,c*A/rr(t*C+_)]}}return m.duration=p*1e3*t/Math.SQRT2,m}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r}(Math.SQRT2,2,4);var tt=0,pt=0,ht=0,Fi=1e3,rn,mt,sn=0,Ye=0,mn=0,_t=typeof performance=="object"&&performance.now?performance:Date,Yi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wo(){return Ye||(Yi(yd),Ye=_t.now()+mn)}function yd(){Ye=0}function an(){this._call=this._time=this._next=null}an.prototype=Xi.prototype={constructor:an,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?wo():+n)+(t==null?0:+t),!this._next&&mt!==this&&(mt?mt._next=this:rn=this,mt=this),this._call=e,this._time=n,no()},stop:function(){this._call&&(this._call=null,this._time=1/0,no())}};function Xi(e,t,n){var o=new an;return o.restart(e,t,n),o}function wd(){wo(),++tt;for(var e=rn,t;e;)(t=Ye-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}function ir(){Ye=(sn=_t.now())+mn,tt=pt=0;try{wd()}finally{tt=0,vd(),Ye=0}}function xd(){var e=_t.now(),t=e-sn;t>Fi&&(mn-=t,sn=e)}function vd(){for(var e,t=rn,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:rn=n);mt=e,no(o)}function no(e){if(!tt){pt&&(pt=clearTimeout(pt));var t=e-Ye;t>24?(e<1/0&&(pt=setTimeout(ir,e-_t.now()-mn)),ht&&(ht=clearInterval(ht))):(ht||(sn=_t.now(),ht=setInterval(xd,Fi)),tt=1,Yi(ir))}}function sr(e,t,n){var o=new an;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var bd=gn("start","end","cancel","interrupt"),Ed=[],Zi=0,ar=1,oo=2,Kt=3,cr=4,ro=5,Ut=6;function yn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;_d(e,n,{name:t,index:o,group:r,on:bd,tween:Ed,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Zi})}function xo(e,t){var n=ye(e,t);if(n.state>Zi)throw new Error("too late; already scheduled");return n}function _e(e,t){var n=ye(e,t);if(n.state>Kt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function _d(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Xi(i,0,n.time);function i(c){n.state=ar,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,f,d,h;if(n.state!==ar)return l();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Kt)return sr(s);h.state===cr?(h.state=Ut,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Ut,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(sr(function(){n.state===Kt&&(n.state=cr,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=oo,n.on.call("start",e,e.__data__,n.index,n.group),n.state===oo){for(n.state=Kt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=ro,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===ro&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Ut,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function Qt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>oo&&o.state<ro,o.state=Ut,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Nd(e){return this.each(function(){Qt(this,e)})}function Sd(e,t){var n,o;return function(){var r=_e(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function kd(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=_e(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Cd(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=ye(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Sd:kd)(n,e,t))}function vo(e,t,n){var o=e._id;return e.each(function(){var r=_e(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return ye(r,o).value[t]}}function Wi(e,t){var n;return(typeof t=="number"?ve:t instanceof Fe?on:(n=Fe(t))?(t=n,on):Hi)(e,t)}function Md(e){return function(){this.removeAttribute(e)}}function Id(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Od(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Ad(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Pd(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function $d(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function Td(e,t){var n=pn(e),o=n==="transform"?hd:Wi;return this.attrTween(e,typeof t=="function"?(n.local?$d:Pd)(n,o,vo(this,"attr."+e,t)):t==null?(n.local?Id:Md)(n):(n.local?Ad:Od)(n,o,t))}function Dd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Rd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ld(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Rd(e,i)),n}return r._value=t,r}function zd(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Dd(e,i)),n}return r._value=t,r}function jd(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 o=pn(e);return this.tween(n,(o.local?Ld:zd)(o,t))}function Hd(e,t){return function(){xo(this,e).delay=+t.apply(this,arguments)}}function Vd(e,t){return t=+t,function(){xo(this,e).delay=t}}function Bd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hd:Vd)(t,e)):ye(this.node(),t).delay}function Fd(e,t){return function(){_e(this,e).duration=+t.apply(this,arguments)}}function Yd(e,t){return t=+t,function(){_e(this,e).duration=t}}function Xd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fd:Yd)(t,e)):ye(this.node(),t).duration}function Zd(e,t){if(typeof t!="function")throw new Error;return function(){_e(this,e).ease=t}}function Wd(e){var t=this._id;return arguments.length?this.each(Zd(t,e)):ye(this.node(),t).ease}function Gd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;_e(this,e).ease=n}}function qd(e){if(typeof e!="function")throw new Error;return this.each(Gd(this._id,e))}function Kd(e){typeof e!="function"&&(e=Ni(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ae(o,this._parents,this._name,this._id)}function Ud(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l=t[a],c=n[a],u=l.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=l[h]||c[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Ae(s,this._parents,this._name,this._id)}function Qd(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 Jd(e,t,n){var o,r,i=Qd(t)?xo:_e;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ef(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(Jd(n,e,t))}function tf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function nf(){return this.on("end.remove",tf(this._id))}function of(e){var t=this._name,n=this._id;typeof e!="function"&&(e=go(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),u,f,d=0;d<l;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),c[d]=f,yn(c[d],t,n,d,c,ye(u,n)));return new Ae(i,this._parents,t,n)}function rf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=_i(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var d=e.call(u,u.__data__,f,l),h,g=ye(u,n),w=0,m=d.length;w<m;++w)(h=d[w])&&yn(h,t,n,w,d,g);i.push(d),s.push(u)}return new Ae(i,s,t,n)}var sf=Pt.prototype.constructor;function af(){return new sf(this._groups,this._parents)}function cf(e,t){var n,o,r;return function(){var i=et(this,e),s=(this.style.removeProperty(e),et(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Gi(e){return function(){this.style.removeProperty(e)}}function lf(e,t,n){var o,r=n+"",i;return function(){var s=et(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function uf(e,t,n){var o,r,i;return function(){var s=et(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),et(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function df(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=_e(this,e),c=l.on,u=l.value[i]==null?a||(a=Gi(t)):void 0;(c!==n||r!==u)&&(o=(n=c).copy()).on(s,r=u),l.on=o}}function ff(e,t,n){var o=(e+="")=="transform"?fd:Wi;return t==null?this.styleTween(e,cf(e,o)).on("end.style."+e,Gi(e)):typeof t=="function"?this.styleTween(e,uf(e,o,vo(this,"style."+e,t))).each(df(this._id,e)):this.styleTween(e,lf(e,o,t),n).on("end.style."+e,null)}function hf(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function gf(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&hf(e,s,n)),o}return i._value=t,i}function pf(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,gf(e,t,n??""))}function mf(e){return function(){this.textContent=e}}function yf(e){return function(){var t=e(this);this.textContent=t??""}}function wf(e){return this.tween("text",typeof e=="function"?yf(vo(this,"text",e)):mf(e==null?"":e+""))}function xf(e){return function(t){this.textContent=e.call(this,t)}}function vf(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&xf(r)),t}return o._value=e,o}function bf(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,vf(e))}function Ef(){for(var e=this._name,t=this._id,n=qi(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var u=ye(l,t);yn(l,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ae(o,this._parents,e,n)}function _f(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=_e(this,o),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Nf=0;function Ae(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function qi(){return++Nf}var Ie=Pt.prototype;Ae.prototype={constructor:Ae,select:of,selectAll:rf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:Kd,merge:Ud,selection:af,transition:Ef,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:ef,attr:Td,attrTween:jd,style:ff,styleTween:pf,text:wf,textTween:bf,remove:nf,tween:Cd,delay:Bd,duration:Xd,ease:Wd,easeVarying:qd,end:_f,[Symbol.iterator]:Ie[Symbol.iterator]};function Sf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kf={time:null,delay:0,duration:250,ease:Sf};function Cf(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 Mf(e){var t,n;e instanceof Ae?(t=e._id,e=e._name):(t=qi(),(n=kf).time=wo(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&yn(l,e,t,c,s,n||Cf(l,t));return new Ae(o,this._parents,e,t)}Pt.prototype.interrupt=Nd;Pt.prototype.transition=Mf;const Ft=e=>()=>e;function If(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){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:o,enumerable:!0,configurable:!0},_:{value:r}})}function Oe(e,t,n){this.k=e,this.x=t,this.y=n}Oe.prototype={constructor:Oe,scale:function(e){return e===1?this:new Oe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Oe(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 wn=new Oe(1,0,0);Ki.prototype=Oe.prototype;function Ki(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wn;return e.__zoom}function Tn(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function Of(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Af(){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 lr(){return this.__zoom||wn}function Pf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $f(){return navigator.maxTouchPoints||"ontouchstart"in this}function Tf(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=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(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ui(){var e=Of,t=Af,n=Tf,o=Pf,r=$f,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=qt,c=gn("start","zoom","end"),u,f,d,h=500,g=150,w=0,m=10;function p(v){v.property("__zoom",lr).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",P).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(v,N,k,O){var R=v.selection?v.selection():v;R.property("__zoom",lr),v!==R?_(v,N,k,O):R.interrupt().each(function(){E(this,arguments).event(O).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},p.scaleBy=function(v,N,k,O){p.scaleTo(v,function(){var R=this.__zoom.k,D=typeof N=="function"?N.apply(this,arguments):N;return R*D},k,O)},p.scaleTo=function(v,N,k,O){p.transform(v,function(){var R=t.apply(this,arguments),D=this.__zoom,V=k==null?x(R):typeof k=="function"?k.apply(this,arguments):k,H=D.invert(V),j=typeof N=="function"?N.apply(this,arguments):N;return n(y(b(D,j),V,H),R,s)},k,O)},p.translateBy=function(v,N,k,O){p.transform(v,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,O)},p.translateTo=function(v,N,k,O,R){p.transform(v,function(){var D=t.apply(this,arguments),V=this.__zoom,H=O==null?x(D):typeof O=="function"?O.apply(this,arguments):O;return n(wn.translate(H[0],H[1]).scale(V.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof k=="function"?-k.apply(this,arguments):-k),D,s)},O,R)};function b(v,N){return N=Math.max(i[0],Math.min(i[1],N)),N===v.k?v:new Oe(N,v.x,v.y)}function y(v,N,k){var O=N[0]-k[0]*v.k,R=N[1]-k[1]*v.k;return O===v.x&&R===v.y?v:new Oe(v.k,O,R)}function x(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function _(v,N,k,O){v.on("start.zoom",function(){E(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(O).end()}).tween("zoom",function(){var R=this,D=arguments,V=E(R,D).event(O),H=t.apply(R,D),j=k==null?x(H):typeof k=="function"?k.apply(R,D):k,X=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),F=R.__zoom,W=typeof N=="function"?N.apply(R,D):N,Q=l(F.invert(j).concat(X/F.k),W.invert(j).concat(X/W.k));return function(G){if(G===1)G=W;else{var L=Q(G),B=X/L[2];G=new Oe(B,j[0]-L[0]*B,j[1]-L[1]*B)}V.zoom(null,G)}})}function E(v,N,k){return!k&&v.__zooming||new S(v,N)}function S(v,N){this.that=v,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,N),this.taps=0}S.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,N){return this.mouse&&v!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&v!=="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(v){var N=ce(this.that).datum();c.call(v,this.that,new If(v,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:c}),N)}};function C(v,...N){if(!e.apply(this,arguments))return;var k=E(this,N).event(v),O=this.__zoom,R=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,o.apply(this,arguments)))),D=fe(v);if(k.wheel)(k.mouse[0][0]!==D[0]||k.mouse[0][1]!==D[1])&&(k.mouse[1]=O.invert(k.mouse[0]=D)),clearTimeout(k.wheel);else{if(O.k===R)return;k.mouse=[D,O.invert(D)],Qt(this),k.start()}gt(v),k.wheel=setTimeout(V,g),k.zoom("mouse",n(y(b(O,R),k.mouse[0],k.mouse[1]),k.extent,s));function V(){k.wheel=null,k.end()}}function A(v,...N){if(d||!e.apply(this,arguments))return;var k=v.currentTarget,O=E(this,N,!0).event(v),R=ce(v.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",X,!0),D=fe(v,k),V=v.clientX,H=v.clientY;Ti(v.view),Tn(v),O.mouse=[D,this.__zoom.invert(D)],Qt(this),O.start();function j(F){if(gt(F),!O.moved){var W=F.clientX-V,Q=F.clientY-H;O.moved=W*W+Q*Q>w}O.event(F).zoom("mouse",n(y(O.that.__zoom,O.mouse[0]=fe(F,k),O.mouse[1]),O.extent,s))}function X(F){R.on("mousemove.zoom mouseup.zoom",null),Di(F.view,O.moved),gt(F),O.event(F).end()}}function z(v,...N){if(e.apply(this,arguments)){var k=this.__zoom,O=fe(v.changedTouches?v.changedTouches[0]:v,this),R=k.invert(O),D=k.k*(v.shiftKey?.5:2),V=n(y(b(k,D),O,R),t.apply(this,N),s);gt(v),a>0?ce(this).transition().duration(a).call(_,V,O,v):ce(this).call(p.transform,V,O,v)}}function P(v,...N){if(e.apply(this,arguments)){var k=v.touches,O=k.length,R=E(this,N,v.changedTouches.length===O).event(v),D,V,H,j;for(Tn(v),V=0;V<O;++V)H=k[V],j=fe(H,this),j=[j,this.__zoom.invert(j),H.identifier],R.touch0?!R.touch1&&R.touch0[2]!==j[2]&&(R.touch1=j,R.taps=0):(R.touch0=j,D=!0,R.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(R.taps<2&&(f=j[0],u=setTimeout(function(){u=null},h)),Qt(this),R.start())}}function $(v,...N){if(this.__zooming){var k=E(this,N).event(v),O=v.changedTouches,R=O.length,D,V,H,j;for(gt(v),D=0;D<R;++D)V=O[D],H=fe(V,this),k.touch0&&k.touch0[2]===V.identifier?k.touch0[0]=H:k.touch1&&k.touch1[2]===V.identifier&&(k.touch1[0]=H);if(V=k.that.__zoom,k.touch1){var X=k.touch0[0],F=k.touch0[1],W=k.touch1[0],Q=k.touch1[1],G=(G=W[0]-X[0])*G+(G=W[1]-X[1])*G,L=(L=Q[0]-F[0])*L+(L=Q[1]-F[1])*L;V=b(V,Math.sqrt(G/L)),H=[(X[0]+W[0])/2,(X[1]+W[1])/2],j=[(F[0]+Q[0])/2,(F[1]+Q[1])/2]}else if(k.touch0)H=k.touch0[0],j=k.touch0[1];else return;k.zoom("touch",n(y(V,H,j),k.extent,s))}}function M(v,...N){if(this.__zooming){var k=E(this,N).event(v),O=v.changedTouches,R=O.length,D,V;for(Tn(v),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),D=0;D<R;++D)V=O[D],k.touch0&&k.touch0[2]===V.identifier?delete k.touch0:k.touch1&&k.touch1[2]===V.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(V=fe(V,this),Math.hypot(f[0]-V[0],f[1]-V[1])<m)){var H=ce(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return p.wheelDelta=function(v){return arguments.length?(o=typeof v=="function"?v:Ft(+v),p):o},p.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Ft(!!v),p):e},p.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Ft(!!v),p):r},p.extent=function(v){return arguments.length?(t=typeof v=="function"?v:Ft([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),p):t},p.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],p):[i[0],i[1]]},p.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],p):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},p.constrain=function(v){return arguments.length?(n=v,p):n},p.duration=function(v){return arguments.length?(a=+v,p):a},p.interpolate=function(v){return arguments.length?(l=v,p):l},p.on=function(){var v=c.on.apply(c,arguments);return v===c?p:v},p.clickDistance=function(v){return arguments.length?(w=(v=+v)*v,p):Math.sqrt(w)},p.tapDistance=function(v){return arguments.length?(m=+v,p):m},p}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Nt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Qi=["Enter"," ","Escape"],Ji={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var nt;(function(e){e.Strict="strict",e.Loose="loose"})(nt||(nt={}));var Be;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Be||(Be={}));var St;(function(e){e.Partial="partial",e.Full="full"})(St||(St={}));const es={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Te;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Te||(Te={}));var kt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(kt||(kt={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const ur={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function ts(e){return e===null?null:e?"valid":"invalid"}const ns=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Df=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),bo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Tt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Rf=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):bo(r)?r:t.nodeLookup.get(r.id));const a=s?cn(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return xn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return vn(n)},Dt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=xn(n,cn(r)),o=!0)}),o?vn(n):{x:0,y:0,width:0,height:0}},Eo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,l=(t.y-o)/r,c=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:h,selectable:g=!0,hidden:w=!1}=d;if(s&&!g||w)continue;const m=h.width??d.width??d.initialWidth??0,p=h.height??d.height??d.initialHeight??0,{x:b,y}=d.internals.positionAbsolute,x=ss(a,l,c,u,b,y,m,p),_=m*p,E=i&&x>0;(!d.internals.handleBounds||E||x>=_||d.dragging)&&f.push(d)}return f},Lf=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function zf(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=Ne(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function jf({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=zf(e,s),l=Dt(a),c=No(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function os({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",me.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(f=[[l,c],[l+h,c+g]])}else a&&Ze(s.extent)&&(f=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const d=Ze(f)?Xe(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",me.error015()),{position:{x:d.x-l+(s.measured.width??0)*u[0],y:d.y-c+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function Hf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&s.find(w=>w.id===d.parentId);(h||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),l=o.filter(d=>d.deletable!==!1),u=Lf(s,l);for(const d of l)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const ot=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xe=(e={x:0,y:0},t,n)=>({x:ot(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ot(e.y,t[0][1],t[1][1]-(n?.height??0))});function rs(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Xe(e,[[i,s],[i+o,s+r]],t)}const dr=(e,t,n)=>e<t?ot(Math.abs(e-t),1,t)/t:e>n?-ot(Math.abs(e-n),1,t)/t:0,_o=(e,t,n=15,o=40)=>{const r=dr(e.x,o,t.width-o)*n,i=dr(e.y,o,t.height-o)*n;return[r,i]},xn=(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)}),io=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),vn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ct=(e,t=[0,0])=>{const{x:n,y:o}=bo(e)?e.internals.positionAbsolute:Tt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},cn=(e,t=[0,0])=>{const{x:n,y:o}=bo(e)?e.internals.positionAbsolute:Tt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},is=(e,t)=>vn(xn(io(e),io(t))),ss=(e,t,n,o,r,i,s,a)=>{const l=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),c=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(l*c)},ln=(e,t)=>ss(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),fr=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),as=(e,t)=>(n,o)=>{},Rt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Lt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?Rt(a,s):a},rt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function qe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Vf(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=qe(e,n),r=qe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=qe(e.top??e.y??0,n),r=qe(e.bottom??e.y??0,n),i=qe(e.left??e.x??0,t),s=qe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Bf(e,t,n,o,r,i){const{x:s,y:a}=rt(e,[t,n,o]),{x:l,y:c}=rt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-l,f=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const No=(e,t,n,o,r,i)=>{const s=Vf(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),u=ot(c,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,g=n/2-d*u,w=Bf(e,h,g,u,t,n),m={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:h-m.left+m.right,y:g-m.top+m.bottom,zoom:u}},Mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ze(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function cs(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function ls(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function hr(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Ff(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Yf(e){return{...Ji,...e||{}}}function xt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=pe(e),a=Lt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?Rt(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const So=e=>({width:e.offsetWidth,height:e.offsetHeight}),us=e=>e?.getRootNode?.()||window?.document,Xf=["INPUT","SELECT","TEXTAREA"];function ds(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Xf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const fs=e=>"clientX"in e,pe=(e,t)=>{const n=fs(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},gr=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...So(s)}})};function hs({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,u=Math.abs(l-e),f=Math.abs(c-t);return[l,c,u,f]}function Yt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function pr({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case Y.Left:return[t-Yt(t-o,i),n];case Y.Right:return[t+Yt(o-t,i),n];case Y.Top:return[t,n-Yt(n-r,i)];case Y.Bottom:return[t,n+Yt(r-n,i)]}}function ko({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top,curvature:s=.25}){const[a,l]=pr({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,u]=pr({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,g]=hs({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${o},${r}`,f,d,h,g]}function gs({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function Zf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function Wf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=xn(cn(e),cn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ln(s,vn(i))>0}const Gf=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,qf=(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)),Kf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",me.error006()),t;const o=n.getEdgeId||Gf;let r;return ns(e)?r={...e}:r={...e,id:o(e)},qf(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function ps({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=gs({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const mr={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Uf=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.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},yr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Qf({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:o=Y.Top,center:r,offset:i,stepPosition:s}){const a=mr[t],l=mr[o],c={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+l.x*i,y:n.y+l.y*i},f=Uf({source:c,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let g=[],w,m;const p={x:0,y:0},b={x:0,y:0},[,,y,x]=gs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*l[d]===-1){d==="x"?(w=r.x??c.x+(u.x-c.x)*s,m=r.y??(c.y+u.y)/2):(w=r.x??(c.x+u.x)/2,m=r.y??c.y+(u.y-c.y)*s);const C=[{x:w,y:c.y},{x:w,y:u.y}],A=[{x:c.x,y:m},{x:u.x,y:m}];a[d]===h?g=d==="x"?C:A:g=d==="x"?A:C}else{const C=[{x:c.x,y:u.y}],A=[{x:u.x,y:c.y}];if(d==="x"?g=a.x===h?A:C:g=a.y===h?C:A,t===o){const v=Math.abs(e[d]-n[d]);if(v<=i){const N=Math.min(i-1,i-v);a[d]===h?p[d]=(c[d]>e[d]?-1:1)*N:b[d]=(u[d]>n[d]?-1:1)*N}}if(t!==o){const v=d==="x"?"y":"x",N=a[d]===l[v],k=c[v]>u[v],O=c[v]<u[v];(a[d]===1&&(!N&&k||N&&O)||a[d]!==1&&(!N&&O||N&&k))&&(g=d==="x"?C:A)}const z={x:c.x+p.x,y:c.y+p.y},P={x:u.x+b.x,y:u.y+b.y},$=Math.max(Math.abs(z.x-g[0].x),Math.abs(P.x-g[0].x)),M=Math.max(Math.abs(z.y-g[0].y),Math.abs(P.y-g[0].y));$>=M?(w=(z.x+P.x)/2,m=g[0].y):(w=g[0].x,m=(z.y+P.y)/2)}const _={x:c.x+p.x,y:c.y+p.y},E={x:u.x+b.x,y:u.y+b.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],w,m,y,x]}function Jf(e,t,n,o){const r=Math.min(yr(e,t)/2,yr(t,n)/2,o),{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 c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function so({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:u=.5}){const[f,d,h,g,w]=Qf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:u});let m=`M${f[0].x} ${f[0].y}`;for(let p=1;p<f.length-1;p++)m+=Jf(f[p-1],f[p],f[p+1],s);return m+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[m,d,h,g,w]}function wr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function eh(e){const{sourceNode:t,targetNode:n}=e;if(!wr(t)||!wr(n))return null;const o=t.internals.handleBounds||xr(t.handles),r=n.internals.handleBounds||xr(n.handles),i=vr(o?.source??[],e.sourceHandle),s=vr(e.connectionMode===nt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||Y.Bottom,l=s?.position||Y.Top,c=We(t,i,a),u=We(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:l}}function xr(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function We(e,t,n=Y.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Ne(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case Y.Top:return{x:r+s/2,y:i};case Y.Right:return{x:r+s,y:i+a/2};case Y.Bottom:return{x:r+s/2,y:i+a};case Y.Left:return{x:r,y:i+a/2}}}function vr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function ao(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function th(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const c=ao(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const ms=1e3,nh=10,Co={nodeOrigin:[0,0],nodeExtent:Nt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oh={...Co,checkEquality:!0};function Mo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function rh(e,t,n){const o=Mo(Co,n);for(const r of e.values())if(r.parentId)Oo(r,e,t,o);else{const i=Tt(r,o.nodeOrigin),s=Ze(r.extent)?r.extent:o.nodeExtent,a=Xe(i,s,Ne(r));r.internals.positionAbsolute=a}}function ih(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function Io(e){return e==="manual"}function co(e,t,n,o={}){const r=Mo(oh,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!Io(r.zIndexMode)?ms:0;let l=e.length>0,c=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=Tt(u,r.nodeOrigin),h=Ze(u.extent)?u.extent:r.nodeExtent,g=Xe(d,h,Ne(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:g,handleBounds:ih(u,f),z:ys(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(l=!1),u.parentId&&Oo(f,t,n,o,i),c||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function sh(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Oo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=Mo(Co,o),c=e.parentId,u=t.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}sh(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*nh),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!Io(l)?ms:0,{x:d,y:h,z:g}=ah(e,u,s,a,f,l),{positionAbsolute:w}=e.internals,m=d!==w.x||h!==w.y;(m||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:d,y:h}:w,z:g}})}function ys(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return Io(n)?o:o+(e.selected?t:0)}function ah(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=Ne(e),c=Tt(e,n),u=Ze(e.extent)?Xe(c,e.extent,l):c;let f=Xe({x:s+u.x,y:a+u.y},o,l);e.extent==="parent"&&(f=rs(f,l,t));const d=ys(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function Ao(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const l=i.get(s.parentId)?.expandedRect??Ct(a),c=is(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,u=Ne(a),f=a.origin??o,d=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(u.width,Math.round(s.width)),w=Math.max(u.height,Math.round(s.height)),m=(g-u.width)*f[0],p=(w-u.height)*f[1];(d>0||h>0||m||p)&&(r.push({id:l,type:"position",position:{x:a.position.x-d+m,y:a.position.y-h+p}}),n.get(l)?.forEach(b=>{e.some(y=>y.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+d,y:b.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(d?f[0]*d-m:0),height:w+(h?f[1]*h-p:0)}})}),r}function ch(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const w=So(h.nodeElement),m=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(m||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),y=Ze(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;if(g.parentId&&g.extent==="parent"){const E=t.get(g.parentId);E&&(x=rs(x,w,E))}else y&&(x=Xe(x,y,w));const _={...g,measured:w,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:gr("source",h.nodeElement,b,f,g.id),target:gr("target",h.nodeElement,b,f,g.id)}}};t.set(g.id,_),g.parentId&&Oo(_,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,m&&(c.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Ct(_,r)}))}}if(d.length>0){const h=Ao(d,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function lh({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function br(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function ws(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;br("source",l,u,e,r,s),br("target",l,c,e,i,a),t.set(o.id,o)}}function xs(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:xs(n,t):!1}function Er(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function uh(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!xs(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function Dn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function dh({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=Rt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function fh({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},u=null,f=!1,d=null,h=!1,g=!1,w=null;function m({noDragClassName:b,handleSelector:y,domNode:x,isSelectable:_,nodeId:E,nodeClickDistance:S=0}){d=ce(x);function C({x:$,y:M}){const{nodeLookup:v,nodeExtent:N,snapGrid:k,snapToGrid:O,nodeOrigin:R,onNodeDrag:D,onSelectionDrag:V,onError:H,updateNodePositions:j}=t();i={x:$,y:M};let X=!1;const F=a.size>1,W=F&&N?io(Dt(a)):null,Q=F&&O?dh({dragItems:a,snapGrid:k,x:$,y:M}):null;for(const[G,L]of a){if(!v.has(G))continue;let B={x:$-L.distance.x,y:M-L.distance.y};O&&(B=Q?{x:Math.round(B.x+Q.x),y:Math.round(B.y+Q.y)}:Rt(B,k));let U=null;if(F&&N&&!L.extent&&W){const{positionAbsolute:q}=L.internals,J=q.x-W.x+N[0][0],te=q.x+L.measured.width-W.x2+N[1][0],oe=q.y-W.y+N[0][1],se=q.y+L.measured.height-W.y2+N[1][1];U=[[J,oe],[te,se]]}const{position:K,positionAbsolute:Z}=os({nodeId:G,nextPosition:B,nodeLookup:v,nodeExtent:U||N,nodeOrigin:R,onError:H});X=X||L.position.x!==K.x||L.position.y!==K.y,L.position=K,L.internals.positionAbsolute=Z}if(g=g||X,!!X&&(j(a,!0),w&&(o||D||!E&&V))){const[G,L]=Dn({nodeId:E,dragItems:a,nodeLookup:v});o?.(w,a,G,L),D?.(w,G,L),E||V?.(w,L)}}async function A(){if(!u)return;const{transform:$,panBy:M,autoPanSpeed:v,autoPanOnNodeDrag:N}=t();if(!N){l=!1,cancelAnimationFrame(s);return}const[k,O]=_o(c,u,v);(k!==0||O!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-O/$[2],await M({x:k,y:O})&&C(i)),s=requestAnimationFrame(A)}function z($){const{nodeLookup:M,multiSelectionActive:v,nodesDraggable:N,transform:k,snapGrid:O,snapToGrid:R,selectNodesOnDrag:D,onNodeDragStart:V,onSelectionDragStart:H,unselectNodesAndEdges:j}=t();f=!0,(!D||!_)&&!v&&E&&(M.get(E)?.selected||j()),_&&D&&E&&e?.(E);const X=xt($.sourceEvent,{transform:k,snapGrid:O,snapToGrid:R,containerBounds:u});if(i=X,a=uh(M,N,X,E),a.size>0&&(n||V||!E&&H)){const[F,W]=Dn({nodeId:E,dragItems:a,nodeLookup:M});n?.($.sourceEvent,a,F,W),V?.($.sourceEvent,F,W),E||H?.($.sourceEvent,W)}}const P=Ri().clickDistance(S).on("start",$=>{const{domNode:M,nodeDragThreshold:v,transform:N,snapGrid:k,snapToGrid:O}=t();u=M?.getBoundingClientRect()||null,h=!1,g=!1,w=$.sourceEvent,v===0&&z($),i=xt($.sourceEvent,{transform:N,snapGrid:k,snapToGrid:O,containerBounds:u}),c=pe($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:M,transform:v,snapGrid:N,snapToGrid:k,nodeDragThreshold:O,nodeLookup:R}=t(),D=xt($.sourceEvent,{transform:v,snapGrid:N,snapToGrid:k,containerBounds:u});if(w=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||E&&!R.has(E))&&(h=!0),!h){if(!l&&M&&f&&(l=!0,A()),!f){const V=pe($.sourceEvent,u),H=V.x-c.x,j=V.y-c.y;Math.sqrt(H*H+j*j)>O&&z($)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&f&&(c=pe($.sourceEvent,u),C(D))}}).on("end",$=>{if(!f||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(l=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:M,updateNodePositions:v,onNodeDragStop:N,onSelectionDragStop:k}=t();if(g&&(v(a,!1),g=!1),r||N||!E&&k){const[O,R]=Dn({nodeId:E,dragItems:a,nodeLookup:M,dragging:!1});r?.($.sourceEvent,a,O,R),N?.($.sourceEvent,O,R),E||k?.($.sourceEvent,R)}}}).filter($=>{const M=$.target;return!$.button&&(!b||!Er(M,`.${b}`,x))&&(!y||Er(M,y,x))});d.call(P)}function p(){d?.on(".drag",null)}return{update:m,destroy:p}}function hh(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())ln(r,Ct(i))>0&&o.push(i);return o}const gh=250;function ph(e,t,n,o){let r=[],i=1/0;const s=hh(e,n,t+gh);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:u,y:f}=We(a,c,c.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...c,x:u,y:f}],i=d):d===i&&r.push({...c,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function vs(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...We(s,l,l.position,!0)}:l}function bs(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function mh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Es=()=>!0;function yh(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:m,isValidConnection:p=Es,onReconnectEnd:b,updateConnection:y,getTransform:x,getFromHandle:_,autoPanSpeed:E,dragThreshold:S=1,handleDomNode:C}){const A=us(e.target);let z=0,P;const{x:$,y:M}=pe(e),v=bs(i,C),N=a?.getBoundingClientRect();let k=!1;if(!N||!v)return;const O=vs(r,v,o,l,t);if(!O)return;let R=pe(e,N),D=!1,V=null,H=!1,j=null;function X(){if(!u||!N)return;const[K,Z]=_o(R,N,E);d({x:K,y:Z}),z=requestAnimationFrame(X)}const F={...O,nodeId:r,type:v,position:O.position},W=l.get(r);let G={inProgress:!0,isValid:null,from:We(W,F,Y.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:W,to:R,toHandle:null,toPosition:ur[F.position],toNode:null,pointer:R};function L(){k=!0,y(G),g?.(e,{nodeId:r,handleId:o,handleType:v})}S===0&&L();function B(K){if(!k){const{x:se,y:Se}=pe(K),we=se-$,xe=Se-M;if(!(we*we+xe*xe>S*S))return;L()}if(!_()||!F){U(K);return}const Z=x();R=pe(K,N),P=ph(Lt(R,Z,!1,[1,1]),n,l,F),D||(X(),D=!0);const q=_s(K,{handle:P,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:p,doc:A,lib:c,flowId:f,nodeLookup:l});j=q.handleDomNode,V=q.connection,H=mh(!!P,q.isValid);const J=l.get(r),te=J?We(J,F,Y.Left,!0):G.from,oe={...G,from:te,isValid:H,to:q.toHandle&&H?rt({x:q.toHandle.x,y:q.toHandle.y},Z):R,toHandle:q.toHandle,toPosition:H&&q.toHandle?q.toHandle.position:ur[F.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:R};y(oe),G=oe}function U(K){if(!("touches"in K&&K.touches.length>0)){if(k){(P||j)&&V&&H&&w?.(V);const{inProgress:Z,...q}=G,J={...q,toPosition:G.toHandle?G.toPosition:null};m?.(K,J),i&&b?.(K,J)}h(),cancelAnimationFrame(z),D=!1,H=!1,V=null,j=null,A.removeEventListener("mousemove",B),A.removeEventListener("mouseup",U),A.removeEventListener("touchmove",B),A.removeEventListener("touchend",U)}}A.addEventListener("mousemove",B),A.addEventListener("mouseup",U),A.addEventListener("touchmove",B),A.addEventListener("touchend",U)}function _s(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Es,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=pe(e),w=s.elementFromPoint(h,g),m=w?.classList.contains(`${a}-flow__handle`)?w:d,p={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){const b=bs(void 0,m),y=m.getAttribute("data-nodeid"),x=m.getAttribute("data-handleid"),_=m.classList.contains("connectable"),E=m.classList.contains("connectableend");if(!y||!b)return p;const S={source:f?y:o,sourceHandle:f?x:r,target:f?o:y,targetHandle:f?r:x};p.connection=S;const A=_&&E&&(n===nt.Strict?f&&b==="source"||!f&&b==="target":y!==o||x!==r);p.isValid=A&&c(S),p.toHandle=vs(y,b,x,u,n,!0)}return p}const lo={onPointerDown:yh,isValid:_s};function wh({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ce(e);function i({translateExtent:a,width:l,height:c,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const g=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const x=n(),_=y.sourceEvent.ctrlKey&&Mt()?10:1,E=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*u,S=x[2]*Math.pow(2,E*_);t.scaleTo(S)};let w=[0,0];const m=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(w=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},p=y=>{const x=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const _=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],E=[_[0]-w[0],_[1]-w[1]];w=_;const S=o()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),C={x:x[0]-E[0]*S,y:x[1]-E[1]*S},A=[[0,0],[l,c]];t.setViewportConstrained({x:C.x,y:C.y,zoom:x[2]},A,a)},b=Ui().on("start",m).on("zoom",f?p:null).on("zoom.wheel",d?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const bn=e=>({x:e.x,y:e.y,zoom:e.k}),Rn=({x:e,y:t,zoom:n})=>wn.translate(e,t).scale(n),Ke=(e,t)=>e.target.closest(`.${t}`),Ns=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),xh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ln=(e,t=0,n=xh,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Ss=e=>{const t=e.ctrlKey&&Mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function vh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return u=>{if(Ke(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const m=fe(u),p=Ss(u),b=f*Math.pow(2,p);o.scaleTo(n,b,m,u);return}const d=u.deltaMode===1?20:1;let h=r===Be.Vertical?0:u.deltaX*d,g=r===Be.Horizontal?0:u.deltaY*d;!Mt()&&u.shiftKey&&r!==Be.Vertical&&(h=u.deltaY*d,g=0),o.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const w=bn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(u,w):(e.isPanScrolling=!0,a?.(u,w)),e.panScrollTimeout=setTimeout(()=>{c?.(u,w),e.isPanScrolling=!1},150)}}function bh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Ke(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Eh({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=bn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function _h({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ns(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,bn(i.transform))}}function Nh({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ns(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=bn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Sh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:u}){return f=>{const d=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Ke(f,`${c}-flow__node`)||Ke(f,`${c}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||u&&!g||Ke(f,a)&&g||Ke(f,l)&&(!g||r&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!d&&!r&&!h&&g||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&w}}function kh({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(M=>{const v=M[0];v&&(f=[[0,0],[v.contentRect.width,v.contentRect.height]])}):null)?.observe(e);const h=Ui().extent(()=>f).scaleExtent([t,n]).translateExtent(o),g=ce(e).call(h);x({x:r.x,y:r.y,zoom:ot(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const w=g.on("wheel.zoom"),m=g.on("dblclick.zoom");h.wheelDelta(Ss);async function p(M,v){return g?new Promise(N=>{h?.interpolate(v?.interpolate==="linear"?wt:qt).transform(Ln(g,v?.duration,v?.ease,()=>N(!0)),M)}):!1}function b({noWheelClassName:M,noPanClassName:v,onPaneContextMenu:N,userSelectionActive:k,panOnScroll:O,panOnDrag:R,panOnScrollMode:D,panOnScrollSpeed:V,preventScrolling:H,zoomOnPinch:j,zoomOnScroll:X,zoomOnDoubleClick:F,zoomActivationKeyPressed:W,lib:Q,onTransformChange:G,connectionInProgress:L,paneClickDistance:B,selectionOnDrag:U}){k&&!c.isZoomingOrPanning&&y();const K=O&&!W&&!k;h.clickDistance(U?1/0:!ge(B)||B<0?0:B);const Z=K?vh({zoomPanValues:c,noWheelClassName:M,d3Selection:g,d3Zoom:h,panOnScrollMode:D,panOnScrollSpeed:V,zoomOnPinch:j,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):bh({noWheelClassName:M,preventScrolling:H,d3ZoomHandler:w});g.on("wheel.zoom",Z,{passive:!1});const q=Eh({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});h.on("start",q);const J=_h({zoomPanValues:c,panOnDrag:R,onPaneContextMenu:!!N,onPanZoom:i,onTransformChange:G});h.on("zoom",J);const te=Nh({zoomPanValues:c,panOnDrag:R,panOnScroll:O,onPaneContextMenu:N,onPanZoomEnd:a,onDraggingChange:l});h.on("end",te);const oe=Sh({zoomActivationKeyPressed:W,panOnDrag:R,zoomOnScroll:X,panOnScroll:O,zoomOnDoubleClick:F,zoomOnPinch:j,userSelectionActive:k,noPanClassName:v,noWheelClassName:M,lib:Q,connectionInProgress:L});h.filter(oe),F?g.on("dblclick.zoom",m):g.on("dblclick.zoom",null)}function y(){h.on("zoom",null)}async function x(M,v,N){const k=Rn(M),O=h?.constrain()(k,v,N);return O&&await p(O),O}async function _(M,v){const N=Rn(M);return await p(N,v),N}function E(M){if(g){const v=Rn(M),N=g.property("__zoom");(N.k!==M.zoom||N.x!==M.x||N.y!==M.y)&&h?.transform(g,v,null,{sync:!0})}}function S(){const M=g?Ki(g.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function C(M,v){return g?new Promise(N=>{h?.interpolate(v?.interpolate==="linear"?wt:qt).scaleTo(Ln(g,v?.duration,v?.ease,()=>N(!0)),M)}):!1}async function A(M,v){return g?new Promise(N=>{h?.interpolate(v?.interpolate==="linear"?wt:qt).scaleBy(Ln(g,v?.duration,v?.ease,()=>N(!0)),M)}):!1}function z(M){h?.scaleExtent(M)}function P(M){h?.translateExtent(M)}function $(M){const v=!ge(M)||M<0?0:M;h?.clickDistance(v)}return{update:b,destroy:y,setViewport:_,setViewportConstrained:x,getViewport:S,scaleTo:C,scaleBy:A,setScaleExtent:z,setTranslateExtent:P,syncViewport:E,setClickDistance:$}}var it;(function(e){e.Line="line",e.Handle="handle"})(it||(it={}));function Ch({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function _r(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function Xt(e,t,n){return Math.max(0,t-e,e-n)}function Nr(e,t){return e?!t:t}function Mh(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:m,minHeight:p,maxHeight:b}=o,{x:y,y:x,width:_,height:E,aspectRatio:S}=e;let C=Math.floor(u?h-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const z=_+(l?-C:C),P=E+(c?-A:A),$=-i[0]*_,M=-i[1]*E;let v=Xt(z,w,m),N=Xt(P,p,b);if(s){let R=0,D=0;l&&C<0?R=Pe(y+C+$,s[0][0]):!l&&C>0&&(R=$e(y+z+$,s[1][0])),c&&A<0?D=Pe(x+A+M,s[0][1]):!c&&A>0&&(D=$e(x+P+M,s[1][1])),v=Math.max(v,R),N=Math.max(N,D)}if(a){let R=0,D=0;l&&C>0?R=$e(y+C,a[0][0]):!l&&C<0&&(R=Pe(y+z,a[1][0])),c&&A>0?D=$e(x+A,a[0][1]):!c&&A<0&&(D=Pe(x+P,a[1][1])),v=Math.max(v,R),N=Math.max(N,D)}if(r){if(u){const R=Xt(z/S,p,b)*S;if(v=Math.max(v,R),s){let D=0;!l&&!c||l&&!c&&d?D=$e(x+M+z/S,s[1][1])*S:D=Pe(x+M+(l?C:-C)/S,s[0][1])*S,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&d?D=Pe(x+z/S,a[1][1])*S:D=$e(x+(l?C:-C)/S,a[0][1])*S,v=Math.max(v,D)}}if(f){const R=Xt(P*S,w,m)/S;if(N=Math.max(N,R),s){let D=0;!l&&!c||c&&!l&&d?D=$e(y+P*S+$,s[1][0])/S:D=Pe(y+(c?A:-A)*S+$,s[0][0])/S,N=Math.max(N,D)}if(a){let D=0;!l&&!c||c&&!l&&d?D=Pe(y+P*S,a[1][0])/S:D=$e(y+(c?A:-A)*S,a[0][0])/S,N=Math.max(N,D)}}}A=A+(A<0?N:-N),C=C+(C<0?v:-v),r&&(d?z>P*S?A=(Nr(l,c)?-C:C)/S:C=(Nr(l,c)?-A:A)*S:u?(A=C/S,c=l):(C=A*S,l=c));const k=l?y+C:y,O=c?x+A:x;return{width:_+(l?-C:C),height:E+(c?-A:A),x:i[0]*C*(l?-1:1)+k,y:i[1]*A*(c?-1:1)+O}}const ks={width:0,height:0,x:0,y:0},Ih={...ks,pointerX:0,pointerY:0,aspectRatio:1};function Oh(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function Ah({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ce(e);let s={controlDirection:_r("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:m}){let p={...ks},b={...Ih};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:_r(c)};let y,x=null,_=[],E,S,C,A=!1;const z=Ri().on("start",P=>{const{nodeLookup:$,transform:M,snapGrid:v,snapToGrid:N,nodeOrigin:k,paneDomNode:O}=n();if(y=$.get(t),!y)return;x=O?.getBoundingClientRect()??null;const{xSnapped:R,ySnapped:D}=xt(P.sourceEvent,{transform:M,snapGrid:v,snapToGrid:N,containerBounds:x});p={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},b={...p,pointerX:R,pointerY:D,aspectRatio:p.width/p.height},E=void 0,S=Ze(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(E=$.get(y.parentId)),E&&y.extent==="parent"&&(S=[[0,0],[E.measured.width,E.measured.height]]),_=[],C=void 0;for(const[V,H]of $)if(H.parentId===t&&(_.push({id:V,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const j=Oh(H,y,H.origin??k);C?C=[[Math.min(j[0][0],C[0][0]),Math.min(j[0][1],C[0][1])],[Math.max(j[1][0],C[1][0]),Math.max(j[1][1],C[1][1])]]:C=j}h?.(P,{...p})}).on("drag",P=>{const{transform:$,snapGrid:M,snapToGrid:v,nodeOrigin:N}=n(),k=xt(P.sourceEvent,{transform:$,snapGrid:M,snapToGrid:v,containerBounds:x}),O=[];if(!y)return;const{x:R,y:D,width:V,height:H}=p,j={},X=y.origin??N,{width:F,height:W,x:Q,y:G}=Mh(b,s.controlDirection,k,s.boundaries,s.keepAspectRatio,X,S,C),L=F!==V,B=W!==H,U=Q!==R&&L,K=G!==D&&B;if(!U&&!K&&!L&&!B)return;if((U||K||X[0]===1||X[1]===1)&&(j.x=U?Q:p.x,j.y=K?G:p.y,p.x=j.x,p.y=j.y,_.length>0)){const te=Q-R,oe=G-D;for(const se of _)se.position={x:se.position.x-te+X[0]*(F-V),y:se.position.y-oe+X[1]*(W-H)},O.push(se)}if((L||B)&&(j.width=L&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:p.width,j.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?W:p.height,p.width=j.width,p.height=j.height),E&&y.expandParent){const te=X[0]*(j.width??0);j.x&&j.x<te&&(p.x=te,b.x=b.x-(j.x-te));const oe=X[1]*(j.height??0);j.y&&j.y<oe&&(p.y=oe,b.y=b.y-(j.y-oe))}const Z=Ch({width:p.width,prevWidth:V,height:p.height,prevHeight:H,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...p,direction:Z};m?.(P,q)!==!1&&(A=!0,g?.(P,q),o(j,O))}).on("end",P=>{A&&(w?.(P,{...p}),r?.({...p}),A=!1)});i.call(z)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var Cs={exports:{}},Ms={},Is={exports:{}},Os={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* use-sync-external-store-shim.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var st=T;function Ph(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $h=typeof Object.is=="function"?Object.is:Ph,Th=st.useState,Dh=st.useEffect,Rh=st.useLayoutEffect,Lh=st.useDebugValue;function zh(e,t){var n=t(),o=Th({inst:{value:n,getSnapshot:t}}),r=o[0].inst,i=o[1];return Rh(function(){r.value=n,r.getSnapshot=t,zn(r)&&i({inst:r})},[e,n,t]),Dh(function(){return zn(r)&&i({inst:r}),e(function(){zn(r)&&i({inst:r})})},[e]),Lh(n),n}function zn(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$h(e,n)}catch{return!0}}function jh(e,t){return t()}var Hh=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?jh:zh;Os.useSyncExternalStore=st.useSyncExternalStore!==void 0?st.useSyncExternalStore:Hh;Is.exports=Os;var Vh=Is.exports;/**
|
|
10
|
+
* @license React
|
|
11
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var En=T,Bh=Vh;function Fh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Yh=typeof Object.is=="function"?Object.is:Fh,Xh=Bh.useSyncExternalStore,Zh=En.useRef,Wh=En.useEffect,Gh=En.useMemo,qh=En.useDebugValue;Ms.useSyncExternalStoreWithSelector=function(e,t,n,o,r){var i=Zh(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Gh(function(){function l(h){if(!c){if(c=!0,u=h,h=o(h),r!==void 0&&s.hasValue){var g=s.value;if(r(g,h))return f=g}return f=h}if(g=f,Yh(u,h))return g;var w=o(h);return r!==void 0&&r(g,w)?(u=h,g):(u=h,f=w)}var c=!1,u,f,d=n===void 0?null:n;return[function(){return l(t())},d===null?void 0:function(){return l(d())}]},[t,n,o,r]);var a=Xh(e,i[0],i[1]);return Wh(function(){s.hasValue=!0,s.value=a},[a]),qh(a),a};Cs.exports=Ms;var Kh=Cs.exports;const Uh=Zc(Kh),Qh={},Sr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Qh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,l);return l},Jh=e=>e?Sr(e):Sr,{useDebugValue:eg}=Wc,{useSyncExternalStoreWithSelector:tg}=Uh,ng=e=>e;function As(e,t=ng,n){const o=tg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return eg(o),o}const kr=(e,t)=>{const n=Jh(e),o=(r,i=t)=>As(n,r,i);return Object.assign(o,n),o},og=(e,t)=>e?kr(e,t):kr;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const _n=T.createContext(null),rg=_n.Provider,Ps=me.error001("react");function ee(e,t){const n=T.useContext(_n);if(n===null)throw new Error(Ps);return As(n,e,t)}function ne(){const e=T.useContext(_n);if(e===null)throw new Error(Ps);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Cr={display:"none"},ig={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$s="react-flow__node-desc",Ts="react-flow__edge-desc",sg="react-flow__aria-live",ag=e=>e.ariaLiveMessage,cg=e=>e.ariaLabelConfig;function lg({rfId:e}){const t=ee(ag);return I.jsx("div",{id:`${sg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ig,children:t})}function ug({rfId:e,disableKeyboardA11y:t}){const n=ee(cg);return I.jsxs(I.Fragment,{children:[I.jsx("div",{id:`${$s}-${e}`,style:Cr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),I.jsx("div",{id:`${Ts}-${e}`,style:Cr,children:n["edge.a11yDescription.default"]}),!t&&I.jsx(lg,{rfId:e})]})}const Nn=T.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return I.jsx("div",{className:ie(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Nn.displayName="Panel";const Mr="https://reactflow.dev?utm_source=attribution";function dg({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:I.jsx(Nn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Mr}`,children:I.jsx("a",{href:Mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const fg=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Zt=e=>e.id;function hg(e,t){return re(e.selectedNodes.map(Zt),t.selectedNodes.map(Zt))&&re(e.selectedEdges.map(Zt),t.selectedEdges.map(Zt))}function gg({onSelectionChange:e}){const t=ne(),{selectedNodes:n,selectedEdges:o}=ee(fg,hg);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const pg=e=>!!e.onSelectionChangeHandlers;function mg({onSelectionChange:e}){const t=ee(pg);return e||t?I.jsx(gg,{onSelectionChange:e}):null}const Ds=[0,0],yg={x:0,y:0,zoom:1},wg=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Ir=[...wg,"rfId"],xg=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Or={translateExtent:Nt,nodeOrigin:Ds,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function vg(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(xg,re),c=ne();T.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=Or,a()}),[]);const u=T.useRef(Or);return T.useEffect(()=>{for(const f of Ir){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?c.setState({ariaLabelConfig:Yf(d)}):f==="fitView"?c.setState({fitViewQueued:d}):f==="fitViewOptions"?c.setState({fitViewOptions:d}):c.setState({[f]:d})))}u.current=e},Ir.map(f=>e[f])),null}function Ar(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function bg(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=Ar(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:Ar()?.matches?"dark":"light"}const Pr=typeof document<"u"?document:null;function It(e=null,t={target:Pr,actInsideInputWithModifier:!0}){const[n,o]=T.useState(!1),r=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
18
|
+
`).replace(`
|
|
19
|
+
|
|
20
|
+
`,`
|
|
21
|
+
+`).split(`
|
|
22
|
+
`)),u=c.reduce((f,d)=>f.concat(...d),[]);return[c,u]}return[[],[]]},[e]);return T.useEffect(()=>{const l=t?.target??Pr,c=t?.actInsideInputWithModifier??!0;if(e!==null){const u=h=>{if(r.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!r.current||r.current&&!c)&&ds(h))return!1;const w=Tr(h.code,a);if(i.current.add(h[w]),$r(s,i.current,!1)){const m=h.composedPath?.()?.[0]||h.target,p=m?.nodeName==="BUTTON"||m?.nodeName==="A";t.preventDefault!==!1&&(r.current||!p)&&h.preventDefault(),o(!0)}},f=h=>{const g=Tr(h.code,a);$r(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),r.current=!1},d=()=>{i.current.clear(),o(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function $r(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function Tr(e,t){return t.includes(e)?"code":"key"}const Eg=()=>{const e=ne();return T.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=No(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:l}=s.getBoundingClientRect(),c={x:t.x-a,y:t.y-l},u=n.snapGrid??r,f=n.snapToGrid??i;return Lt(c,o,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=rt(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Rs(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const l of s)_g(l,a);n.push(a)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function _g(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Ls(e,t){return Rs(e,t)}function Ng(e,t){return Rs(e,t)}function je(e,t){return{id:e,type:"select",selected:t}}function Ue(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(je(i.id,s)))}return o}function Dr({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),a=s?.internals?.userNode??s;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:"replace"}),a===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function Rr(e){return{id:e.id,type:"remove"}}const Sg=as();function kg(e,t,n={}){return Kf(e,t,{...n,onError:n.onError??Sg})}const Lr=e=>Df(e),Cg=e=>ns(e);function zs(e){return T.forwardRef(e)}const js=typeof window<"u"?T.useLayoutEffect:T.useEffect;function zr(e){const[t,n]=T.useState(BigInt(0)),[o]=T.useState(()=>Mg(()=>n(r=>r+BigInt(1))));return js(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Mg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Hs=T.createContext(null);function Ig({children:e}){const t=ne(),n=T.useCallback(a=>{const{nodes:l=[],setNodes:c,hasDefaultNodes:u,onNodesChange:f,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let w=l;for(const p of a)w=typeof p=="function"?p(w):p;let m=Dr({items:w,lookup:d});for(const p of g.values())m=p(m);u&&c(w),m.length>0?f?.(m):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:p,nodes:b,setNodes:y}=t.getState();p&&y(b)})},[]),o=zr(n),r=T.useCallback(a=>{const{edges:l=[],setEdges:c,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:d}=t.getState();let h=l;for(const g of a)h=typeof g=="function"?g(h):g;u?c(h):f&&f(Dr({items:h,lookup:d}))},[]),i=zr(r),s=T.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return I.jsx(Hs.Provider,{value:s,children:e})}function Og(){const e=T.useContext(Hs);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Ag=e=>!!e.panZoom;function Po(){const e=Eg(),t=ne(),n=Og(),o=ee(Ag),r=T.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),s=f=>{n.nodeQueue.push(f)},a=f=>{n.edgeQueue.push(f)},l=f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState(),g=Lr(f)?f:d.get(f.id),w=g.parentId?ls(g.position,g.measured,g.parentId,d,h):g.position,m={...g,position:w,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return Ct(m)},c=(f,d,h={replace:!1})=>{s(g=>g.map(w=>{if(w.id===f){const m=typeof d=="function"?d(w):d;return h.replace&&Lr(m)?m:{...w,...m}}return w}))},u=(f,d,h={replace:!1})=>{a(g=>g.map(w=>{if(w.id===f){const m=typeof d=="function"?d(w):d;return h.replace&&Cg(m)?m:{...w,...m}}return w}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>i(f)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:s,setEdges:a,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:h}=t.getState(),[g,w,m]=h;return{nodes:f.map(p=>({...p})),edges:d.map(p=>({...p})),viewport:{x:g,y:w,zoom:m}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:h,edges:g,onNodesDelete:w,onEdgesDelete:m,triggerNodeChanges:p,triggerEdgeChanges:b,onDelete:y,onBeforeDelete:x}=t.getState(),{nodes:_,edges:E}=await Hf({nodesToRemove:f,edgesToRemove:d,nodes:h,edges:g,onBeforeDelete:x}),S=E.length>0,C=_.length>0;if(S){const A=E.map(Rr);m?.(E),b(A)}if(C){const A=_.map(Rr);w?.(_),p(A)}return(C||S)&&y?.({nodes:_,edges:E}),{deletedNodes:_,deletedEdges:E}},getIntersectingNodes:(f,d=!0,h)=>{const g=fr(f),w=g?f:l(f),m=h!==void 0;return w?(h||t.getState().nodes).filter(p=>{const b=t.getState().nodeLookup.get(p.id);if(b&&!g&&(p.id===f.id||!b.internals.positionAbsolute))return!1;const y=Ct(m?p:b),x=ln(y,w);return d&&x>0||x>=y.width*y.height||x>=w.width*w.height}):[]},isNodeIntersecting:(f,d,h=!0)=>{const w=fr(f)?f:l(f);if(!w)return!1;const m=ln(w,d);return h&&m>0||m>=d.width*d.height||m>=w.width*w.height},updateNode:c,updateNodeData:(f,d,h={replace:!1})=>{c(f,g=>{const w=typeof d=="function"?d(g):d;return h.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},h)},updateEdge:u,updateEdgeData:(f,d,h={replace:!1})=>{u(f,g=>{const w=typeof d=="function"?d(g):d;return h.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},h)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return Rf(f,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:f,id:d,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${f}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:d,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${f?d?`-${f}-${d}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const d=t.getState().fitViewResolver??Ff();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return T.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const jr=e=>e.selected,Pg=typeof window<"u"?window:void 0;function $g({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ne(),{deleteElements:o}=Po(),r=It(e,{actInsideInputWithModifier:!1}),i=It(t,{target:Pg});T.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(jr),edges:s.filter(jr)}),n.setState({nodesSelectionActive:!1})}},[r]),T.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Tg(e){const t=ne();T.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=So(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",me.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Sn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Dg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Rg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=Be.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:u,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:h=!0,children:g,noWheelClassName:w,noPanClassName:m,onViewportChange:p,isControlledViewport:b,paneClickDistance:y,selectionOnDrag:x}){const _=ne(),E=T.useRef(null),{userSelectionActive:S,lib:C,connectionInProgress:A}=ee(Dg,re),z=It(d),P=T.useRef();Tg(E);const $=T.useCallback(M=>{p?.({x:M[0],y:M[1],zoom:M[2]}),b||_.setState({transform:M})},[p,b]);return T.useEffect(()=>{if(E.current){P.current=kh({domNode:E.current,minZoom:u,maxZoom:f,translateExtent:c,viewport:l,onDraggingChange:k=>_.setState(O=>O.paneDragging===k?O:{paneDragging:k}),onPanZoomStart:(k,O)=>{const{onViewportChangeStart:R,onMoveStart:D}=_.getState();D?.(k,O),R?.(O)},onPanZoom:(k,O)=>{const{onViewportChange:R,onMove:D}=_.getState();D?.(k,O),R?.(O)},onPanZoomEnd:(k,O)=>{const{onViewportChangeEnd:R,onMoveEnd:D}=_.getState();D?.(k,O),R?.(O)}});const{x:M,y:v,zoom:N}=P.current.getViewport();return _.setState({panZoom:P.current,transform:[M,v,N],domNode:E.current.closest(".react-flow")}),()=>{P.current?.destroy()}}},[]),T.useEffect(()=>{P.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:z,preventScrolling:h,noPanClassName:m,userSelectionActive:S,noWheelClassName:w,lib:C,onTransformChange:$,connectionInProgress:A,selectionOnDrag:x,paneClickDistance:y})},[e,t,n,o,r,i,s,a,z,h,m,S,w,C,$,A,x,y]),I.jsx("div",{className:"react-flow__renderer",ref:E,style:Sn,children:g})}const Lg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function zg(){const{userSelectionActive:e,userSelectionRect:t}=ee(Lg,re);return e&&t?I.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const jn=(e,t)=>n=>{n.target===t.current&&e?.(n)},jg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Hg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=St.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:g,children:w}){const m=T.useRef(0),p=ne(),{userSelectionActive:b,elementsSelectable:y,dragging:x,panBy:_,autoPanSpeed:E}=ee(jg,re),S=y&&(e||b),C=T.useRef(null),A=T.useRef(),z=T.useRef(new Set),P=T.useRef(new Set),$=T.useRef(!1),M=T.useRef(!1),v=T.useRef({x:0,y:0}),N=T.useRef(!1),k=L=>{if(M.current||$.current||p.getState().connection.inProgress){M.current=!1,$.current=!1;return}c?.(L),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},O=L=>{if(Array.isArray(o)&&o?.includes(2)){L.preventDefault();return}u?.(L)},R=f?L=>f(L):void 0,D=L=>{M.current&&(L.stopPropagation(),M.current=!1)},V=L=>{const{domNode:B,transform:U}=p.getState();if(A.current=B?.getBoundingClientRect(),!A.current)return;const K=L.target===C.current;if(!K&&!!L.target.closest(".nokey")||!e||!(s&&K||t)||L.button!==0||!L.isPrimary)return;L.target?.setPointerCapture?.(L.pointerId),M.current=!1;const{x:J,y:te}=pe(L.nativeEvent,A.current),oe=Lt({x:J,y:te},U);p.setState({userSelectionRect:{width:0,height:0,startX:oe.x,startY:oe.y,x:J,y:te}}),K||(L.stopPropagation(),L.preventDefault())};function H(L,B){const{userSelectionRect:U}=p.getState();if(!U)return;const{transform:K,nodeLookup:Z,edgeLookup:q,connectionLookup:J,triggerNodeChanges:te,triggerEdgeChanges:oe,defaultEdgeOptions:se}=p.getState(),Se={x:U.startX,y:U.startY},{x:we,y:xe}=rt(Se,K),ke={startX:Se.x,startY:Se.y,x:L<we?L:we,y:B<xe?B:xe,width:Math.abs(L-we),height:Math.abs(B-xe)},dt=z.current,Re=P.current;z.current=new Set(Eo(Z,ke,K,n===St.Partial,!0).map(de=>de.id)),P.current=new Set;const Le=se?.selectable??!0;for(const de of z.current){const Ce=J.get(de);if(Ce)for(const{edgeId:Me}of Ce.values()){const ze=q.get(Me);ze&&(ze.selectable??Le)&&P.current.add(Me)}}if(!hr(dt,z.current)){const de=Ue(Z,z.current,!0);te(de)}if(!hr(Re,P.current)){const de=Ue(q,P.current);oe(de)}p.setState({userSelectionRect:ke,userSelectionActive:!0,nodesSelectionActive:!1})}function j(){if(!r||!A.current)return;const[L,B]=_o(v.current,A.current,E);_({x:L,y:B}).then(U=>{if(!M.current||!U){m.current=requestAnimationFrame(j);return}const{x:K,y:Z}=v.current;H(K,Z),m.current=requestAnimationFrame(j)})}const X=()=>{cancelAnimationFrame(m.current),m.current=0,N.current=!1};T.useEffect(()=>()=>X(),[]);const F=L=>{const{userSelectionRect:B,transform:U,resetSelectedElements:K}=p.getState();if(!A.current||!B)return;const{x:Z,y:q}=pe(L.nativeEvent,A.current);v.current={x:Z,y:q};const J=rt({x:B.startX,y:B.startY},U);if(!M.current){const te=t?0:i;if(Math.hypot(Z-J.x,q-J.y)<=te)return;K(),a?.(L)}M.current=!0,N.current||(j(),N.current=!0),H(Z,q)},W=L=>{if(!S){L.target===C.current&&p.getState().connection.inProgress&&($.current=!0);return}L.button===0&&(L.target?.releasePointerCapture?.(L.pointerId),!b&&L.target===C.current&&p.getState().userSelectionRect&&k?.(L),p.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l?.(L),p.setState({nodesSelectionActive:z.current.size>0})),X())},Q=L=>{L.target?.releasePointerCapture?.(L.pointerId),X()},G=o===!0||Array.isArray(o)&&o.includes(0);return I.jsxs("div",{className:ie(["react-flow__pane",{draggable:G,dragging:x,selection:e}]),onClick:S?void 0:jn(k,C),onContextMenu:jn(O,C),onWheel:jn(R,C),onPointerEnter:S?void 0:d,onPointerMove:S?F:h,onPointerUp:W,onPointerCancel:S?Q:void 0,onPointerDownCapture:S?V:void 0,onClickCapture:S?D:void 0,onPointerLeave:g,ref:C,style:Sn,children:[w,I.jsx(zg,{})]})}function uo({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=t.getState(),c=a.get(e);if(!c){l?.("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Vs({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=ne(),[l,c]=T.useState(!1),u=T.useRef();return T.useEffect(()=>{if(!t)return u.current=fh({getStoreItems:()=>a.getState(),onNodeMouseDown:f=>{uo({id:f,store:a,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,a,e]),T.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s})},[n,o,t,i,e,r,s]),l}const Vg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Bs(){const e=ne();return T.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:l,nodeLookup:c,nodeOrigin:u}=e.getState(),f=new Map,d=Vg(s),h=r?i[0]:5,g=r?i[1]:5,w=n.direction.x*h*n.factor,m=n.direction.y*g*n.factor;for(const[,p]of c){if(!d(p))continue;let b={x:p.internals.positionAbsolute.x+w,y:p.internals.positionAbsolute.y+m};r&&(b=Rt(b,i));const{position:y,positionAbsolute:x}=os({nodeId:p.id,nextPosition:b,nodeLookup:c,nodeExtent:o,nodeOrigin:u,onError:a});p.position=y,p.internals.positionAbsolute=x,f.set(p.id,p)}l(f)},[])}const $o=T.createContext(null),Bg=$o.Provider;$o.Consumer;const Fs=()=>T.useContext($o),Fg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Ys=T.createContext(null);function Yg({children:e}){const t=ee(Fg,re);return I.jsx(Ys.Provider,{value:t,children:e})}function Xg(){const e=T.useContext(Ys);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Zg={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Wg=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:l,isValid:c}=s;if(!a&&!r)return Zg;const u=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:u,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===nt.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:u&&c}};function Gg({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:l,className:c,onMouseDown:u,onTouchStart:f,...d},h){const g=s||null,w=e==="target",m=ne(),p=Fs(),{connectOnClick:b,noPanClassName:y,rfId:x}=Xg(),{connectingFrom:_,connectingTo:E,clickConnecting:S,isPossibleEndHandle:C,connectionInProcess:A,clickConnectionInProcess:z,valid:P}=ee(Wg(p,g,e),re);p||m.getState().onError?.("010",me.error010());const $=N=>{const{defaultEdgeOptions:k,onConnect:O,hasDefaultEdges:R}=m.getState(),D={...k,...N};if(R){const{edges:V,setEdges:H,onError:j}=m.getState();H(kg(D,V,{onError:j}))}O?.(D),a?.(D)},M=N=>{if(!p)return;const k=fs(N.nativeEvent);if(r&&(k&&N.button===0||!k)){const O=m.getState();lo.onPointerDown(N.nativeEvent,{handleDomNode:N.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:w,handleId:g,nodeId:p,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(...R)=>m.getState().onConnectEnd?.(...R),updateConnection:O.updateConnection,onConnect:$,isValidConnection:n||((...R)=>m.getState().isValidConnection?.(...R)??!0),getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}k?u?.(N):f?.(N)},v=N=>{const{onClickConnectStart:k,onClickConnectEnd:O,connectionClickStartHandle:R,connectionMode:D,isValidConnection:V,lib:H,rfId:j,nodeLookup:X,connection:F}=m.getState();if(!p||!R&&!r)return;if(!R){k?.(N.nativeEvent,{nodeId:p,handleId:g,handleType:e}),m.setState({connectionClickStartHandle:{nodeId:p,type:e,id:g}});return}const W=us(N.target),Q=n||V,{connection:G,isValid:L}=lo.isValid(N.nativeEvent,{handle:{nodeId:p,id:g,type:e},connectionMode:D,fromNodeId:R.nodeId,fromHandleId:R.id||null,fromType:R.type,isValidConnection:Q,flowId:j,doc:W,lib:H,nodeLookup:X});L&&G&&$(G);const B=structuredClone(F);delete B.inProgress,B.toPosition=B.toHandle?B.toHandle.position:null,O?.(N,B),m.setState({connectionClickStartHandle:null})};return I.jsx("div",{"data-handleid":g,"data-nodeid":p,"data-handlepos":t,"data-id":`${x}-${p}-${g}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,c,{source:!w,target:w,connectable:o,connectablestart:r,connectableend:i,clickconnecting:S,connectingfrom:_,connectingto:E,valid:P,connectionindicator:o&&(!A||C)&&(A||z?i:r)}]),onMouseDown:M,onTouchStart:M,onClick:b?v:void 0,ref:h,...d,children:l})}const at=T.memo(zs(Gg));function qg({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return I.jsxs(I.Fragment,{children:[e?.label,I.jsx(at,{type:"source",position:n,isConnectable:t})]})}function Kg({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:o=Y.Bottom}){return I.jsxs(I.Fragment,{children:[I.jsx(at,{type:"target",position:n,isConnectable:t}),e?.label,I.jsx(at,{type:"source",position:o,isConnectable:t})]})}function Ug(){return null}function Qg({data:e,isConnectable:t,targetPosition:n=Y.Top}){return I.jsxs(I.Fragment,{children:[I.jsx(at,{type:"target",position:n,isConnectable:t}),e?.label]})}const un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Hr={input:qg,default:Kg,output:Qg,group:Ug};function Jg(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const ep=e=>{const{width:t,height:n,x:o,y:r}=Dt(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function tp({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ne(),{width:r,height:i,transformString:s,userSelectionActive:a}=ee(ep,re),l=Bs(),c=T.useRef(null);T.useEffect(()=>{n||c.current?.focus({preventScroll:!0})},[n]);const u=!a&&r!==null&&i!==null;if(Vs({nodeRef:c,disabled:!u}),!u)return null;const f=e?h=>{const g=o.getState().nodes.filter(w=>w.selected);e(h,g)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(un,h.key)&&(h.preventDefault(),l({direction:un[h.key],factor:h.shiftKey?4:1}))};return I.jsx("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:I.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:i}})})}const Vr=typeof window<"u"?window:void 0,np=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Xs({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:u,selectionMode:f,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:w,zoomActivationKeyCode:m,elementsSelectable:p,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:x,panOnScrollSpeed:_,panOnScrollMode:E,zoomOnDoubleClick:S,panOnDrag:C,autoPanOnSelection:A,defaultViewport:z,translateExtent:P,minZoom:$,maxZoom:M,preventScrolling:v,onSelectionContextMenu:N,noWheelClassName:k,noPanClassName:O,disableKeyboardA11y:R,onViewportChange:D,isControlledViewport:V}){const{nodesSelectionActive:H,userSelectionActive:j}=ee(np,re),X=It(c,{target:Vr}),F=It(w,{target:Vr}),W=F||C,Q=F||x,G=u&&W!==!0,L=X||j||G;return $g({deleteKeyCode:l,multiSelectionKeyCode:g}),I.jsx(Rg,{onPaneContextMenu:i,elementsSelectable:p,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:Q,panOnScrollSpeed:_,panOnScrollMode:E,zoomOnDoubleClick:S,panOnDrag:!X&&W,defaultViewport:z,translateExtent:P,minZoom:$,maxZoom:M,zoomActivationKeyCode:m,preventScrolling:v,noWheelClassName:k,noPanClassName:O,onViewportChange:D,isControlledViewport:V,paneClickDistance:a,selectionOnDrag:G,children:I.jsxs(Hg,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:W,autoPanOnSelection:A,isSelecting:!!L,selectionMode:f,selectionKeyPressed:X,paneClickDistance:a,selectionOnDrag:G,children:[e,H&&I.jsx(tp,{onSelectionContextMenu:N,noPanClassName:O,disableKeyboardA11y:R})]})})}Xs.displayName="FlowRenderer";const op=T.memo(Xs),rp=e=>t=>e?Eo(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function ip(e){return ee(T.useCallback(rp(e),[e]),re)}const sp=e=>e.updateNodeInternals;function ap(){const e=ee(sp),[t]=T.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return T.useEffect(()=>()=>{t?.disconnect()},[t]),t}function cp({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=ne(),i=T.useRef(null),s=T.useRef(null),a=T.useRef(e.sourcePosition),l=T.useRef(e.targetPosition),c=T.useRef(t),u=n&&!!e.internals.handleBounds;return T.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[u,e.hidden]),T.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),T.useEffect(()=>{if(i.current){const f=c.current!==t,d=a.current!==e.sourcePosition,h=l.current!==e.targetPosition;(f||d||h)&&(c.current=t,a.current=e.sourcePosition,l.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function lp({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:u,resizeObserver:f,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:g,rfId:w,nodeTypes:m,nodeClickDistance:p,onError:b}){const{node:y,internals:x,isParent:_}=ee(L=>{const B=L.nodeLookup.get(e),U=L.parentLookup.has(e);return{node:B,internals:B.internals,isParent:U}},re);let E=y.type||"default",S=m?.[E]||Hr[E];S===void 0&&(b?.("003",me.error003(E)),E="default",S=m?.default||Hr.default);const C=!!(y.draggable||a&&typeof y.draggable>"u"),A=!!(y.selectable||l&&typeof y.selectable>"u"),z=!!(y.connectable||c&&typeof y.connectable>"u"),P=!!(y.focusable||u&&typeof y.focusable>"u"),$=ne(),M=cs(y),v=cp({node:y,nodeType:E,hasDimensions:M,resizeObserver:f}),N=Vs({nodeRef:v,disabled:y.hidden||!C,noDragClassName:d,handleSelector:y.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:p}),k=Bs();if(y.hidden)return null;const O=Ne(y),R=Jg(y),D=A||C||t||n||o||r,V=n?L=>n(L,{...x.userNode}):void 0,H=o?L=>o(L,{...x.userNode}):void 0,j=r?L=>r(L,{...x.userNode}):void 0,X=i?L=>i(L,{...x.userNode}):void 0,F=s?L=>s(L,{...x.userNode}):void 0,W=L=>{const{selectNodesOnDrag:B,nodeDragThreshold:U}=$.getState();A&&(!B||!C||U>0)&&uo({id:e,store:$,nodeRef:v}),t&&t(L,{...x.userNode})},Q=L=>{if(!(ds(L.nativeEvent)||g)){if(Qi.includes(L.key)&&A){const B=L.key==="Escape";uo({id:e,store:$,unselect:B,nodeRef:v})}else if(C&&y.selected&&Object.prototype.hasOwnProperty.call(un,L.key)){L.preventDefault();const{ariaLabelConfig:B}=$.getState();$.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:L.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),k({direction:un[L.key],factor:L.shiftKey?4:1})}}},G=()=>{if(g||!v.current?.matches(":focus-visible"))return;const{transform:L,width:B,height:U,autoPanOnNodeFocus:K,setCenter:Z}=$.getState();if(!K)return;Eo(new Map([[e,y]]),{x:0,y:0,width:B,height:U},L,!0).length>0||Z(y.position.x+O.width/2,y.position.y+O.height/2,{zoom:L[2]})};return I.jsx("div",{className:ie(["react-flow__node",`react-flow__node-${E}`,{[h]:C},y.className,{selected:y.selected,selectable:A,parent:_,draggable:C,dragging:N}]),ref:v,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:M?"visible":"hidden",...y.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:V,onMouseMove:H,onMouseLeave:j,onContextMenu:X,onClick:W,onDoubleClick:F,onKeyDown:P?Q:void 0,tabIndex:P?0:void 0,onFocus:P?G:void 0,role:y.ariaRole??(P?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${$s}-${w}`,"aria-label":y.ariaLabel,...y.domAttributes,children:I.jsx(Bg,{value:e,children:I.jsx(S,{id:e,data:y.data,type:E,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:y.selected??!1,selectable:A,draggable:C,deletable:y.deletable??!0,isConnectable:z,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:N,dragHandle:y.dragHandle,zIndex:x.z,parentId:y.parentId,...O})})})}var up=T.memo(lp);const dp=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Zs(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=ee(dp,re),i=ip(e.onlyRenderVisibleElements),s=ap();return I.jsx("div",{className:"react-flow__nodes",style:Sn,children:i.map(a=>I.jsx(up,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},a))})}Zs.displayName="NodeRenderer";const fp=T.memo(Zs);function hp(e){return ee(T.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&Wf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),re)}const gp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return I.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},pp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return I.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Br={[kt.Arrow]:gp,[kt.ArrowClosed]:pp};function mp(e){const t=ne();return T.useMemo(()=>Object.prototype.hasOwnProperty.call(Br,e)?Br[e]:(t.getState().onError?.("009",me.error009(e)),null),[e])}const yp=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const l=mp(t);return l?I.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:I.jsx(l,{color:n,strokeWidth:s})}):null},Ws=({defaultColor:e,rfId:t})=>{const n=ee(i=>i.edges),o=ee(i=>i.defaultEdgeOptions),r=T.useMemo(()=>th(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?I.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:I.jsx("defs",{children:r.map(i=>I.jsx(yp,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Ws.displayName="MarkerDefinitions";var wp=T.memo(Ws);function Gs({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...u}){const[f,d]=T.useState({x:1,y:0,width:0,height:0}),h=ie(["react-flow__edge-textwrapper",c]),g=T.useRef(null);return T.useEffect(()=>{if(g.current){const w=g.current.getBBox();d({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?I.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...u,children:[r&&I.jsx("rect",{width:f.width+2*s[0],x:-s[0],y:-s[1],height:f.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),I.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:o,children:n}),l]}):null}Gs.displayName="EdgeText";const xp=T.memo(Gs);function ct({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...u}){return I.jsxs(I.Fragment,{children:[I.jsx("path",{...u,d:e,fill:"none",className:ie(["react-flow__edge-path",u.className])}),c?I.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,o&&ge(t)&&ge(n)?I.jsx(xp,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function Fr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function qs({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top}){const[s,a]=Fr({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=Fr({pos:i,x1:o,y1:r,x2:e,y2:t}),[u,f,d,h]=hs({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${a} ${l},${c} ${o},${r}`,u,f,d,h]}function Ks(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:m,interactionWidth:p})=>{const[b,y,x]=qs({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),_=e.isInternal?void 0:t;return I.jsx(ct,{id:_,path:b,labelX:y,labelY:x,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:m,interactionWidth:p})})}const vp=Ks({isInternal:!1}),Us=Ks({isInternal:!0});vp.displayName="SimpleBezierEdge";Us.displayName="SimpleBezierEdgeInternal";function Qs(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:d,sourcePosition:h=Y.Bottom,targetPosition:g=Y.Top,markerEnd:w,markerStart:m,pathOptions:p,interactionWidth:b})=>{const[y,x,_]=so({sourceX:n,sourceY:o,sourcePosition:h,targetX:r,targetY:i,targetPosition:g,borderRadius:p?.borderRadius,offset:p?.offset,stepPosition:p?.stepPosition}),E=e.isInternal?void 0:t;return I.jsx(ct,{id:E,path:y,labelX:x,labelY:_,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:w,markerStart:m,interactionWidth:b})})}const Js=Qs({isInternal:!1}),ea=Qs({isInternal:!0});Js.displayName="SmoothStepEdge";ea.displayName="SmoothStepEdgeInternal";function ta(e){return T.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return I.jsx(Js,{...n,id:o,pathOptions:T.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const bp=ta({isInternal:!1}),na=ta({isInternal:!0});bp.displayName="StepEdge";na.displayName="StepEdgeInternal";function oa(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:g,interactionWidth:w})=>{const[m,p,b]=ps({sourceX:n,sourceY:o,targetX:r,targetY:i}),y=e.isInternal?void 0:t;return I.jsx(ct,{id:y,path:m,labelX:p,labelY:b,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:g,interactionWidth:w})})}const Ep=oa({isInternal:!1}),ra=oa({isInternal:!0});Ep.displayName="StraightEdge";ra.displayName="StraightEdgeInternal";function ia(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=Y.Bottom,targetPosition:a=Y.Top,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:m,pathOptions:p,interactionWidth:b})=>{const[y,x,_]=ko({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:p?.curvature}),E=e.isInternal?void 0:t;return I.jsx(ct,{id:E,path:y,labelX:x,labelY:_,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:m,interactionWidth:b})})}const _p=ia({isInternal:!1}),sa=ia({isInternal:!0});_p.displayName="BezierEdge";sa.displayName="BezierEdgeInternal";const Yr={default:sa,straight:ra,step:na,smoothstep:ea,simplebezier:Us},Xr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Np=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Sp=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Zr="react-flow__edgeupdater";function Wr({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return I.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:ie([Zr,`${Zr}-${a}`]),cx:Np(t,o,e),cy:Sp(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function kp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:u,onReconnectEnd:f,setReconnecting:d,setUpdateHover:h}){const g=ne(),w=(x,_)=>{if(x.button!==0)return;const{autoPanOnConnect:E,domNode:S,connectionMode:C,connectionRadius:A,lib:z,onConnectStart:P,cancelConnection:$,nodeLookup:M,rfId:v,panBy:N,updateConnection:k}=g.getState(),O=_.type==="target",R=(H,j)=>{d(!1),f?.(H,n,_.type,j)},D=H=>c?.(n,H),V=(H,j)=>{d(!0),u?.(x,n,_.type),P?.(H,j)};lo.onPointerDown(x.nativeEvent,{autoPanOnConnect:E,connectionMode:C,connectionRadius:A,domNode:S,handleId:_.id,nodeId:_.nodeId,nodeLookup:M,isTarget:O,edgeUpdaterType:_.type,lib:z,flowId:v,cancelConnection:$,panBy:N,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:D,onConnectStart:V,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:R,updateConnection:k,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},m=x=>w(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),p=x=>w(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),y=()=>h(!1);return I.jsxs(I.Fragment,{children:[(e===!0||e==="source")&&I.jsx(Wr,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&I.jsx(Wr,{position:l,centerX:i,centerY:s,radius:t,onMouseDown:p,onMouseEnter:b,onMouseOut:y,type:"target"})]})}function Cp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,rfId:g,edgeTypes:w,noPanClassName:m,onError:p,disableKeyboardA11y:b}){let y=ee(Z=>Z.edgeLookup.get(e));const x=ee(Z=>Z.defaultEdgeOptions);y=x?{...x,...y}:y;let _=y.type||"default",E=w?.[_]||Yr[_];E===void 0&&(p?.("011",me.error011(_)),_="default",E=w?.default||Yr.default);const S=!!(y.focusable||t&&typeof y.focusable>"u"),C=typeof f<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),A=!!(y.selectable||o&&typeof y.selectable>"u"),z=T.useRef(null),[P,$]=T.useState(!1),[M,v]=T.useState(!1),N=ne(),{zIndex:k=y.zIndex,sourceX:O,sourceY:R,targetX:D,targetY:V,sourcePosition:H,targetPosition:j}=ee(T.useCallback(Z=>{const q=Z.nodeLookup.get(y.source),J=Z.nodeLookup.get(y.target);if(!q||!J)return Xr;const te=eh({id:e,sourceNode:q,targetNode:J,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:Z.connectionMode,onError:p}),oe=Zf({selected:y.selected,zIndex:y.zIndex,sourceNode:q,targetNode:J,elevateOnSelect:Z.elevateEdgesOnSelect,zIndexMode:Z.zIndexMode});return{...te||Xr,zIndex:oe}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),re),X=T.useMemo(()=>y.markerStart?`url('#${ao(y.markerStart,g)}')`:void 0,[y.markerStart,g]),F=T.useMemo(()=>y.markerEnd?`url('#${ao(y.markerEnd,g)}')`:void 0,[y.markerEnd,g]);if(y.hidden||O===null||R===null||D===null||V===null)return null;const W=Z=>{const{addSelectedEdges:q,unselectNodesAndEdges:J,multiSelectionActive:te}=N.getState();A&&(N.setState({nodesSelectionActive:!1}),y.selected&&te?(J({nodes:[],edges:[y]}),z.current?.blur()):q([e])),r&&r(Z,y)},Q=i?Z=>{i(Z,{...y})}:void 0,G=s?Z=>{s(Z,{...y})}:void 0,L=a?Z=>{a(Z,{...y})}:void 0,B=l?Z=>{l(Z,{...y})}:void 0,U=c?Z=>{c(Z,{...y})}:void 0,K=Z=>{if(!b&&Qi.includes(Z.key)&&A){const{unselectNodesAndEdges:q,addSelectedEdges:J}=N.getState();Z.key==="Escape"?(z.current?.blur(),q({edges:[y]})):J([e])}};return I.jsx("svg",{style:{zIndex:k},children:I.jsxs("g",{className:ie(["react-flow__edge",`react-flow__edge-${_}`,y.className,m,{selected:y.selected,animated:y.animated,inactive:!A&&!r,updating:P,selectable:A}]),onClick:W,onDoubleClick:Q,onContextMenu:G,onMouseEnter:L,onMouseMove:B,onMouseLeave:U,onKeyDown:S?K:void 0,tabIndex:S?0:void 0,role:y.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":S?`${Ts}-${g}`:void 0,ref:z,...y.domAttributes,children:[!M&&I.jsx(E,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:A,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:O,sourceY:R,targetX:D,targetY:V,sourcePosition:H,targetPosition:j,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:X,markerEnd:F,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),C&&I.jsx(kp,{edge:y,isReconnectable:C,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,sourceX:O,sourceY:R,targetX:D,targetY:V,sourcePosition:H,targetPosition:j,setUpdateHover:$,setReconnecting:v})]})})}var Mp=T.memo(Cp);const Ip=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function aa({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:w}){const{edgesFocusable:m,edgesReconnectable:p,elementsSelectable:b,onError:y}=ee(Ip,re),x=hp(t);return I.jsxs("div",{className:"react-flow__edges",children:[I.jsx(wp,{defaultColor:e,rfId:n}),x.map(_=>I.jsx(Mp,{id:_,edgesFocusable:m,edgesReconnectable:p,elementsSelectable:b,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:u,reconnectRadius:f,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:y,edgeTypes:o,disableKeyboardA11y:w},_))]})}aa.displayName="EdgeRenderer";const Op=T.memo(aa),Gr=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Ap({children:e}){const t=ne(),n=T.useRef(null),[o]=T.useState(()=>t.getState().transform);return js(()=>{let r=null;const i=()=>{const s=t.getState().transform;r&&s[0]===r[0]&&s[1]===r[1]&&s[2]===r[2]||(r=s,n.current&&(n.current.style.transform=Gr(s)))};return i(),t.subscribe(i)},[t]),I.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Gr(o)},children:e})}function Pp(e){const t=Po(),n=T.useRef(!1);T.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const $p=e=>e.panZoom?.syncViewport;function Tp(e){const t=ee($p),n=ne();return T.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Dp(e){return e.connection.inProgress?{...e.connection,to:Lt(e.connection.to,e.transform)}:{...e.connection}}function Rp(e){return Dp}function Lp(e){const t=Rp();return ee(t,re)}const zp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function jp({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:l}=ee(zp,re);return!(i&&r&&l)?null:I.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:I.jsx("g",{className:ie(["react-flow__connection",ts(a)]),children:I.jsx(ca,{style:t,type:n,CustomComponent:o,isValid:a})})})}const ca=({style:e,type:t=Te.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:l,to:c,toNode:u,toHandle:f,toPosition:d,pointer:h}=Lp();if(!r)return;if(n)return I.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:d,connectionStatus:ts(o),toNode:u,toHandle:f,pointer:h});let g="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:d};switch(t){case Te.Bezier:[g]=ko(w);break;case Te.SimpleBezier:[g]=qs(w);break;case Te.Step:[g]=so({...w,borderRadius:0});break;case Te.SmoothStep:[g]=so(w);break;default:[g]=ps(w)}return I.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};ca.displayName="ConnectionLine";const Hp={};function qr(e=Hp){T.useRef(e),ne(),T.useEffect(()=>{},[e])}function Vp(){ne(),T.useRef(!1),T.useEffect(()=>{},[])}function la({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:w,connectionLineComponent:m,connectionLineContainerStyle:p,selectionKeyCode:b,selectionOnDrag:y,selectionMode:x,multiSelectionKeyCode:_,panActivationKeyCode:E,zoomActivationKeyCode:S,deleteKeyCode:C,onlyRenderVisibleElements:A,elementsSelectable:z,defaultViewport:P,translateExtent:$,minZoom:M,maxZoom:v,preventScrolling:N,defaultMarkerColor:k,zoomOnScroll:O,zoomOnPinch:R,panOnScroll:D,panOnScrollSpeed:V,panOnScrollMode:H,zoomOnDoubleClick:j,panOnDrag:X,autoPanOnSelection:F,onPaneClick:W,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:L,onPaneScroll:B,onPaneContextMenu:U,paneClickDistance:K,nodeClickDistance:Z,onEdgeContextMenu:q,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:se,onReconnect:Se,onReconnectStart:we,onReconnectEnd:xe,noDragClassName:ke,noWheelClassName:dt,noPanClassName:Re,disableKeyboardA11y:Le,nodeExtent:de,rfId:Ce,viewport:Me,onViewportChange:ze,nodesDraggable:Mn}){return qr(e),qr(t),Vp(),Pp(n),Tp(Me),I.jsx(op,{onPaneClick:W,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:L,onPaneContextMenu:U,onPaneScroll:B,paneClickDistance:K,deleteKeyCode:C,selectionKeyCode:b,selectionOnDrag:y,selectionMode:x,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:_,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:z,zoomOnScroll:O,zoomOnPinch:R,zoomOnDoubleClick:j,panOnScroll:D,panOnScrollSpeed:V,panOnScrollMode:H,panOnDrag:X,autoPanOnSelection:F,defaultViewport:P,translateExtent:$,minZoom:M,maxZoom:v,onSelectionContextMenu:f,preventScrolling:N,noDragClassName:ke,noWheelClassName:dt,noPanClassName:Re,disableKeyboardA11y:Le,onViewportChange:ze,isControlledViewport:!!Me,children:I.jsxs(Ap,{children:[I.jsx(Op,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:Se,onReconnectStart:we,onReconnectEnd:xe,onlyRenderVisibleElements:A,onEdgeContextMenu:q,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:se,defaultMarkerColor:k,noPanClassName:Re,disableKeyboardA11y:Le,rfId:Ce}),I.jsx(jp,{style:w,type:g,component:m,containerStyle:p}),I.jsx("div",{className:"react-flow__edgelabel-renderer"}),I.jsx(fp,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:u,nodeClickDistance:Z,onlyRenderVisibleElements:A,noPanClassName:Re,noDragClassName:ke,disableKeyboardA11y:Le,nodeExtent:de,rfId:Ce,nodesDraggable:Mn}),I.jsx("div",{className:"react-flow__viewport-portal"})]})})}la.displayName="GraphView";const Bp=T.memo(la),Fp=as(),Kr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:u,nodeExtent:f,zIndexMode:d="basic"}={})=>{const h=new Map,g=new Map,w=new Map,m=new Map,p=o??t??[],b=n??e??[],y=u??[0,0],x=f??Nt;ws(w,m,p);const{nodesInitialized:_}=co(b,h,g,{nodeOrigin:y,nodeExtent:x,zIndexMode:d});let E=[0,0,1];if(s&&r&&i){const S=Dt(h,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:C,y:A,zoom:z}=No(S,r,i,l,c,a?.padding??.1);E=[C,A,z]}return{rfId:"1",width:r??0,height:i??0,transform:E,nodes:b,nodesInitialized:_,nodeLookup:h,parentLookup:g,edges:p,edgeLookup:m,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:Nt,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:nt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...es},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Fp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ji,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Yp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:u,nodeExtent:f,zIndexMode:d})=>og((h,g)=>{async function w(){const{nodeLookup:m,panZoom:p,fitViewOptions:b,fitViewResolver:y,width:x,height:_,minZoom:E,maxZoom:S}=g();p&&(await jf({nodes:m,width:x,height:_,panZoom:p,minZoom:E,maxZoom:S},b),y?.resolve(!0),h({fitViewResolver:null}))}return{...Kr({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:u,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:m=>{const{nodeLookup:p,parentLookup:b,nodeOrigin:y,elevateNodesOnSelect:x,fitViewQueued:_,zIndexMode:E,nodesSelectionActive:S}=g(),{nodesInitialized:C,hasSelectedNodes:A}=co(m,p,b,{nodeOrigin:y,nodeExtent:f,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:E}),z=S&&A;_&&C?(w(),h({nodes:m,nodesInitialized:C,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):h({nodes:m,nodesInitialized:C,nodesSelectionActive:z})},setEdges:m=>{const{connectionLookup:p,edgeLookup:b}=g();ws(p,b,m),h({edges:m})},setDefaultNodesAndEdges:(m,p)=>{if(m){const{setNodes:b}=g();b(m),h({hasDefaultNodes:!0})}if(p){const{setEdges:b}=g();b(p),h({hasDefaultEdges:!0})}},updateNodeInternals:m=>{const{triggerNodeChanges:p,nodeLookup:b,parentLookup:y,domNode:x,nodeOrigin:_,nodeExtent:E,debug:S,fitViewQueued:C,zIndexMode:A}=g(),{changes:z,updatedInternals:P}=ch(m,b,y,x,_,E,A);P&&(rh(b,y,{nodeOrigin:_,nodeExtent:E,zIndexMode:A}),C?(w(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),z?.length>0&&(S&&console.log("React Flow: trigger node changes",z),p?.(z)))},updateNodePositions:(m,p=!1)=>{const b=[];let y=[];const{nodeLookup:x,triggerNodeChanges:_,connection:E,updateConnection:S,onNodesChangeMiddlewareMap:C}=g();for(const[A,z]of m){const P=x.get(A),$=!!(P?.expandParent&&P?.parentId&&z?.position),M={id:A,type:"position",position:$?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:p};if(P&&E.inProgress&&E.fromNode.id===P.id){const v=We(P,E.fromHandle,Y.Left,!0);S({...E,from:v})}$&&P.parentId&&b.push({id:A,parentId:P.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),y.push(M)}if(b.length>0){const{parentLookup:A,nodeOrigin:z}=g(),P=Ao(b,x,A,z);y.push(...P)}for(const A of C.values())y=A(y);_(y)},triggerNodeChanges:m=>{const{onNodesChange:p,setNodes:b,nodes:y,hasDefaultNodes:x,debug:_}=g();if(m?.length){if(x){const E=Ls(m,y);b(E)}_&&console.log("React Flow: trigger node changes",m),p?.(m)}},triggerEdgeChanges:m=>{const{onEdgesChange:p,setEdges:b,edges:y,hasDefaultEdges:x,debug:_}=g();if(m?.length){if(x){const E=Ng(m,y);b(E)}_&&console.log("React Flow: trigger edge changes",m),p?.(m)}},addSelectedNodes:m=>{const{multiSelectionActive:p,edgeLookup:b,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:_}=g();if(p){const E=m.map(S=>je(S,!0));x(E);return}x(Ue(y,new Set([...m]),!0)),_(Ue(b))},addSelectedEdges:m=>{const{multiSelectionActive:p,edgeLookup:b,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:_}=g();if(p){const E=m.map(S=>je(S,!0));_(E);return}_(Ue(b,new Set([...m]))),x(Ue(y,new Set,!0))},unselectNodesAndEdges:({nodes:m,edges:p}={})=>{const{edges:b,nodes:y,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:E}=g(),S=m||y,C=p||b,A=[];for(const P of S){if(!P.selected)continue;const $=x.get(P.id);$&&($.selected=!1),A.push(je(P.id,!1))}const z=[];for(const P of C)P.selected&&z.push(je(P.id,!1));_(A),E(z)},setMinZoom:m=>{const{panZoom:p,maxZoom:b}=g();p?.setScaleExtent([m,b]),h({minZoom:m})},setMaxZoom:m=>{const{panZoom:p,minZoom:b}=g();p?.setScaleExtent([b,m]),h({maxZoom:m})},setTranslateExtent:m=>{g().panZoom?.setTranslateExtent(m),h({translateExtent:m})},resetSelectedElements:()=>{const{edges:m,nodes:p,triggerNodeChanges:b,triggerEdgeChanges:y,elementsSelectable:x}=g();if(!x)return;const _=p.reduce((S,C)=>C.selected?[...S,je(C.id,!1)]:S,[]),E=m.reduce((S,C)=>C.selected?[...S,je(C.id,!1)]:S,[]);b(_),y(E)},setNodeExtent:m=>{const{nodes:p,nodeLookup:b,parentLookup:y,nodeOrigin:x,elevateNodesOnSelect:_,nodeExtent:E,zIndexMode:S}=g();m[0][0]===E[0][0]&&m[0][1]===E[0][1]&&m[1][0]===E[1][0]&&m[1][1]===E[1][1]||(co(p,b,y,{nodeOrigin:x,nodeExtent:m,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:S}),h({nodeExtent:m}))},panBy:m=>{const{transform:p,width:b,height:y,panZoom:x,translateExtent:_}=g();return lh({delta:m,panZoom:x,transform:p,translateExtent:_,width:b,height:y})},setCenter:async(m,p,b)=>{const{width:y,height:x,maxZoom:_,panZoom:E}=g();if(!E)return!1;const S=typeof b?.zoom<"u"?b.zoom:_;return await E.setViewport({x:y/2-m*S,y:x/2-p*S,zoom:S},{duration:b?.duration,ease:b?.ease,interpolate:b?.interpolate}),!0},cancelConnection:()=>{h({connection:{...es}})},updateConnection:m=>{h({connection:m})},reset:()=>h({...Kr()})}},Object.is);function Xp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:u,nodeExtent:f,zIndexMode:d,children:h}){const[g]=T.useState(()=>Yp({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:c,minZoom:s,maxZoom:a,fitViewOptions:l,nodeOrigin:u,nodeExtent:f,zIndexMode:d}));return I.jsx(rg,{value:g,children:I.jsx(Ig,{children:I.jsx(Yg,{children:h})})})}function Zp({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:d,zIndexMode:h}){return T.useContext(_n)?I.jsx(I.Fragment,{children:e}):I.jsx(Xp,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:u,nodeOrigin:f,nodeExtent:d,zIndexMode:h,children:e})}const Wp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Gp({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:u,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:g,onConnectEnd:w,onClickConnectStart:m,onClickConnectEnd:p,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:_,onNodeDoubleClick:E,onNodeDragStart:S,onNodeDrag:C,onNodeDragStop:A,onNodesDelete:z,onEdgesDelete:P,onDelete:$,onSelectionChange:M,onSelectionDragStart:v,onSelectionDrag:N,onSelectionDragStop:k,onSelectionContextMenu:O,onSelectionStart:R,onSelectionEnd:D,onBeforeDelete:V,connectionMode:H,connectionLineType:j=Te.Bezier,connectionLineStyle:X,connectionLineComponent:F,connectionLineContainerStyle:W,deleteKeyCode:Q="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:L=!1,selectionMode:B=St.Full,panActivationKeyCode:U="Space",multiSelectionKeyCode:K=Mt()?"Meta":"Control",zoomActivationKeyCode:Z=Mt()?"Meta":"Control",snapToGrid:q,snapGrid:J,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:oe,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:xe,nodeOrigin:ke=Ds,edgesFocusable:dt,edgesReconnectable:Re,elementsSelectable:Le=!0,defaultViewport:de=yg,minZoom:Ce=.5,maxZoom:Me=2,translateExtent:ze=Nt,preventScrolling:Mn=!0,nodeExtent:In,defaultMarkerColor:Fa="#b1b1b7",zoomOnScroll:Ya=!0,zoomOnPinch:Xa=!0,panOnScroll:Za=!1,panOnScrollSpeed:Wa=.5,panOnScrollMode:Ga=Be.Free,zoomOnDoubleClick:qa=!0,panOnDrag:Ka=!0,onPaneClick:Ua,onPaneMouseEnter:Qa,onPaneMouseMove:Ja,onPaneMouseLeave:ec,onPaneScroll:tc,onPaneContextMenu:nc,paneClickDistance:oc=1,nodeClickDistance:rc=0,children:ic,onReconnect:sc,onReconnectStart:ac,onReconnectEnd:cc,onEdgeContextMenu:lc,onEdgeDoubleClick:uc,onEdgeMouseEnter:dc,onEdgeMouseMove:fc,onEdgeMouseLeave:hc,reconnectRadius:gc=10,onNodesChange:pc,onEdgesChange:mc,noDragClassName:yc="nodrag",noWheelClassName:wc="nowheel",noPanClassName:jo="nopan",fitView:Ho,fitViewOptions:Vo,connectOnClick:xc,attributionPosition:vc,proOptions:bc,defaultEdgeOptions:Ec,elevateNodesOnSelect:_c=!0,elevateEdgesOnSelect:Nc=!1,disableKeyboardA11y:Bo=!1,autoPanOnConnect:Sc,autoPanOnNodeDrag:kc,autoPanOnSelection:Cc=!0,autoPanSpeed:Mc,connectionRadius:Ic,isValidConnection:Oc,onError:Ac,style:Pc,id:Fo,nodeDragThreshold:$c,connectionDragThreshold:Tc,viewport:Dc,onViewportChange:Rc,width:Lc,height:zc,colorMode:jc="light",debug:Hc,onScroll:Yo,ariaLabelConfig:Vc,zIndexMode:Xo="basic",...Bc},Fc){const On=Fo||"1",Yc=bg(jc),Xc=T.useCallback(Zo=>{Zo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Yo?.(Zo)},[Yo]);return I.jsx("div",{"data-testid":"rf__wrapper",...Bc,onScroll:Xc,style:{...Pc,...Wp},ref:Fc,className:ie(["react-flow",r,Yc]),id:Fo,role:"application",children:I.jsxs(Zp,{nodes:e,edges:t,width:Lc,height:zc,fitView:Ho,fitViewOptions:Vo,minZoom:Ce,maxZoom:Me,nodeOrigin:ke,nodeExtent:In,zIndexMode:Xo,children:[I.jsx(vg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:w,onClickConnectStart:m,onClickConnectEnd:p,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:xe,edgesFocusable:dt,edgesReconnectable:Re,elementsSelectable:Le,elevateNodesOnSelect:_c,elevateEdgesOnSelect:Nc,minZoom:Ce,maxZoom:Me,nodeExtent:In,onNodesChange:pc,onEdgesChange:mc,snapToGrid:q,snapGrid:J,connectionMode:H,translateExtent:ze,connectOnClick:xc,defaultEdgeOptions:Ec,fitView:Ho,fitViewOptions:Vo,onNodesDelete:z,onEdgesDelete:P,onDelete:$,onNodeDragStart:S,onNodeDrag:C,onNodeDragStop:A,onSelectionDrag:N,onSelectionDragStart:v,onSelectionDragStop:k,onMove:u,onMoveStart:f,onMoveEnd:d,noPanClassName:jo,nodeOrigin:ke,rfId:On,autoPanOnConnect:Sc,autoPanOnNodeDrag:kc,autoPanSpeed:Mc,onError:Ac,connectionRadius:Ic,isValidConnection:Oc,selectNodesOnDrag:oe,nodeDragThreshold:$c,connectionDragThreshold:Tc,onBeforeDelete:V,debug:Hc,ariaLabelConfig:Vc,zIndexMode:Xo}),I.jsx(Bp,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:_,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:s,connectionLineType:j,connectionLineStyle:X,connectionLineComponent:F,connectionLineContainerStyle:W,selectionKeyCode:G,selectionOnDrag:L,selectionMode:B,deleteKeyCode:Q,multiSelectionKeyCode:K,panActivationKeyCode:U,zoomActivationKeyCode:Z,onlyRenderVisibleElements:te,defaultViewport:de,translateExtent:ze,minZoom:Ce,maxZoom:Me,preventScrolling:Mn,zoomOnScroll:Ya,zoomOnPinch:Xa,zoomOnDoubleClick:qa,panOnScroll:Za,panOnScrollSpeed:Wa,panOnScrollMode:Ga,panOnDrag:Ka,autoPanOnSelection:Cc,onPaneClick:Ua,onPaneMouseEnter:Qa,onPaneMouseMove:Ja,onPaneMouseLeave:ec,onPaneScroll:tc,onPaneContextMenu:nc,paneClickDistance:oc,nodeClickDistance:rc,onSelectionContextMenu:O,onSelectionStart:R,onSelectionEnd:D,onReconnect:sc,onReconnectStart:ac,onReconnectEnd:cc,onEdgeContextMenu:lc,onEdgeDoubleClick:uc,onEdgeMouseEnter:dc,onEdgeMouseMove:fc,onEdgeMouseLeave:hc,reconnectRadius:gc,defaultMarkerColor:Fa,noDragClassName:yc,noWheelClassName:wc,noPanClassName:jo,rfId:On,disableKeyboardA11y:Bo,nodeExtent:In,viewport:Dc,onViewportChange:Rc,nodesDraggable:se}),I.jsx(mg,{onSelectionChange:M}),ic,I.jsx(dg,{proOptions:bc,position:vc}),I.jsx(ug,{rfId:On,disableKeyboardA11y:Bo})]})})}var qp=zs(Gp);function Kp(e){const[t,n]=T.useState(e),o=T.useCallback(r=>n(i=>Ls(r,i)),[]);return[t,n,o]}function Up({dimensions:e,lineWidth:t,variant:n,className:o}){return I.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ie(["react-flow__background-pattern",n,o])})}function Qp({radius:e,className:t}){return I.jsx("circle",{cx:e,cy:e,r:e,className:ie(["react-flow__background-pattern","dots",t])})}var De;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(De||(De={}));const Jp={[De.Dots]:1,[De.Lines]:1,[De.Cross]:6},e0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ua({id:e,variant:t=De.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:l,className:c,patternClassName:u}){const f=T.useRef(null),{transform:d,patternId:h}=ee(e0,re),g=o||Jp[t],w=t===De.Dots,m=t===De.Cross,p=Array.isArray(n)?n:[n,n],b=[p[0]*d[2]||1,p[1]*d[2]||1],y=g*d[2],x=Array.isArray(i)?i:[i,i],_=m?[y,y]:b,E=[x[0]*d[2]||1+_[0]/2,x[1]*d[2]||1+_[1]/2],S=`${h}${e||""}`;return I.jsxs("svg",{className:ie(["react-flow__background",c]),style:{...l,...Sn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:f,"data-testid":"rf__background",children:[I.jsx("pattern",{id:S,x:d[0]%b[0],y:d[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:w?I.jsx(Qp,{radius:y/2,className:u}):I.jsx(Up,{dimensions:_,lineWidth:r,variant:t,className:u})}),I.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}ua.displayName="Background";T.memo(ua);function t0(){return I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:I.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function n0(){return I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:I.jsx("path",{d:"M0 0h32v4.2H0z"})})}function o0(){return I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:I.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 r0(){return I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:I.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 i0(){return I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:I.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Wt({children:e,className:t,...n}){return I.jsx("button",{type:"button",className:ie(["react-flow__controls-button",t]),...n,children:e})}const s0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function da({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:l,className:c,children:u,position:f="bottom-left",orientation:d="vertical","aria-label":h}){const g=ne(),{isInteractive:w,minZoomReached:m,maxZoomReached:p,ariaLabelConfig:b}=ee(s0,re),{zoomIn:y,zoomOut:x,fitView:_}=Po(),E=()=>{y(),i?.()},S=()=>{x(),s?.()},C=()=>{_(r),a?.()},A=()=>{g.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},z=d==="horizontal"?"horizontal":"vertical";return I.jsxs(Nn,{className:ie(["react-flow__controls",z,c]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&I.jsxs(I.Fragment,{children:[I.jsx(Wt,{onClick:E,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:p,children:I.jsx(t0,{})}),I.jsx(Wt,{onClick:S,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:m,children:I.jsx(n0,{})})]}),n&&I.jsx(Wt,{className:"react-flow__controls-fitview",onClick:C,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:I.jsx(o0,{})}),o&&I.jsx(Wt,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:w?I.jsx(i0,{}):I.jsx(r0,{})}),u]})}da.displayName="Controls";const a0=T.memo(da);function c0({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:l,className:c,borderRadius:u,shapeRendering:f,selected:d,onClick:h}){const{background:g,backgroundColor:w}=i||{},m=s||g||w;return I.jsx("rect",{className:ie(["react-flow__minimap-node",{selected:d},c]),x:t,y:n,rx:u,ry:u,width:o,height:r,style:{fill:m,stroke:a,strokeWidth:l},shapeRendering:f,onClick:h?p=>h(p,e):void 0})}const l0=T.memo(c0),u0=e=>e.nodes.map(t=>t.id),Hn=e=>e instanceof Function?e:()=>e;function d0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=l0,onClick:s}){const a=ee(u0,re),l=Hn(t),c=Hn(e),u=Hn(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return I.jsx(I.Fragment,{children:a.map(d=>I.jsx(h0,{id:d,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:u,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:f},d))})}function f0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:l}){const{node:c,x:u,y:f,width:d,height:h}=ee(g=>{const w=g.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const m=w.internals.userNode,{x:p,y:b}=w.internals.positionAbsolute,{width:y,height:x}=Ne(m);return{node:m,x:p,y:b,width:y,height:x}},re);return!c||c.hidden||!cs(c)?null:I.jsx(a,{x:u,y:f,width:d,height:h,style:c.style,selected:!!c.selected,className:o(c),color:t(c),borderRadius:r,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:l,id:c.id})}const h0=T.memo(f0);var g0=T.memo(d0);const p0=200,m0=150,y0=e=>!e.hidden,w0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?is(Dt(e.nodeLookup,{filter:y0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Ur=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,x0=(e,t)=>Ur(e.viewBB,t.viewBB)&&Ur(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,v0="react-flow__minimap-desc";function fa({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:u,maskStrokeWidth:f,position:d="bottom-right",onClick:h,onNodeClick:g,pannable:w=!1,zoomable:m=!1,ariaLabel:p,inversePan:b,zoomStep:y=1,offsetScale:x=5}){const _=ne(),E=T.useRef(null),{boundingRect:S,viewBB:C,rfId:A,panZoom:z,translateExtent:P,flowWidth:$,flowHeight:M,ariaLabelConfig:v}=ee(w0,x0),N=e?.width??p0,k=e?.height??m0,O=S.width/N,R=S.height/k,D=Math.max(O,R),V=D*N,H=D*k,j=x*D,X=S.x-(V-S.width)/2-j,F=S.y-(H-S.height)/2-j,W=V+j*2,Q=H+j*2,G=`${v0}-${A}`,L=T.useRef(0),B=T.useRef();L.current=D,T.useEffect(()=>{if(E.current&&z)return B.current=wh({domNode:E.current,panZoom:z,getTransform:()=>_.getState().transform,getViewScale:()=>L.current}),()=>{B.current?.destroy()}},[z]),T.useEffect(()=>{B.current?.update({translateExtent:P,width:$,height:M,inversePan:b,pannable:w,zoomStep:y,zoomable:m})},[w,m,b,y,P,$,M]);const U=h?q=>{const[J,te]=B.current?.pointer(q)||[0,0];h(q,{x:J,y:te})}:void 0,K=g?T.useCallback((q,J)=>{const te=_.getState().nodeLookup.get(J).internals.userNode;g(q,te)},[]):void 0,Z=p??v["minimap.ariaLabel"];return I.jsx(Nn,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*D:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:ie(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:I.jsxs("svg",{width:N,height:k,viewBox:`${X} ${F} ${W} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:E,onClick:U,children:[Z&&I.jsx("title",{id:G,children:Z}),I.jsx(g0,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),I.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-j},${F-j}h${W+j*2}v${Q+j*2}h${-W-j*2}z
|
|
23
|
+
M${C.x},${C.y}h${C.width}v${C.height}h${-C.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}fa.displayName="MiniMap";T.memo(fa);const b0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E0={[it.Line]:"right",[it.Handle]:"bottom-right"};function _0({nodeId:e,position:t,variant:n=it.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:h=!0,shouldResize:g,onResizeStart:w,onResize:m,onResizeEnd:p}){const b=Fs(),y=typeof e=="string"?e:b,x=ne(),_=T.useRef(null),E=n===it.Handle,S=ee(T.useCallback(b0(E&&h),[E,h]),re),C=T.useRef(null),A=t??E0[n];T.useEffect(()=>{if(!(!_.current||!y))return C.current||(C.current=Ah({domNode:_.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:P,transform:$,snapGrid:M,snapToGrid:v,nodeOrigin:N,domNode:k}=x.getState();return{nodeLookup:P,transform:$,snapGrid:M,snapToGrid:v,nodeOrigin:N,paneDomNode:k}},onChange:(P,$)=>{const{triggerNodeChanges:M,nodeLookup:v,parentLookup:N,nodeOrigin:k}=x.getState(),O=[],R={x:P.x,y:P.y},D=v.get(y);if(D&&D.expandParent&&D.parentId){const V=D.origin??k,H=P.width??D.measured.width??0,j=P.height??D.measured.height??0,X={id:D.id,parentId:D.parentId,rect:{width:H,height:j,...ls({x:P.x??D.position.x,y:P.y??D.position.y},{width:H,height:j},D.parentId,v,V)}},F=Ao([X],v,N,k);O.push(...F),R.x=P.x?Math.max(V[0]*H,P.x):void 0,R.y=P.y?Math.max(V[1]*j,P.y):void 0}if(R.x!==void 0&&R.y!==void 0){const V={id:y,type:"position",position:{...R}};O.push(V)}if(P.width!==void 0&&P.height!==void 0){const H={id:y,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};O.push(H)}for(const V of $){const H={...V,type:"position"};O.push(H)}M(O)},onEnd:({width:P,height:$})=>{const M={id:y,type:"dimensions",resizing:!1,dimensions:{width:P,height:$}};x.getState().triggerNodeChanges([M])}})),C.current.update({controlPosition:A,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:u},keepAspectRatio:f,resizeDirection:d,onResizeStart:w,onResize:m,onResizeEnd:p,shouldResize:g}),()=>{C.current?.destroy()}},[A,a,l,c,u,f,w,m,p,g]);const z=A.split("-");return I.jsx("div",{className:ie(["react-flow__resize-control","nodrag",...z,n,o]),ref:_,style:{...r,scale:S,...s&&{[E?"backgroundColor":"borderColor"]:s}},children:i})}T.memo(_0);var ha=Object.defineProperty,N0=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S0=(e,t)=>{for(var n in t)ha(e,n,{get:t[n],enumerable:!0})},k0=(e,t,n)=>N0(e,t+"",n),ga={};S0(ga,{Graph:()=>ue,alg:()=>To,json:()=>ma,version:()=>I0});var C0=Object.defineProperty,pa=(e,t)=>{for(var n in t)C0(e,n,{get:t[n],enumerable:!0})},ue=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let o of this.successors(e))n.add(o);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([r,i])=>{e(r)&&t.setNode(r,i)}),Object.values(this._edgeObjs).forEach(r=>{t.hasNode(r.v)&&t.hasNode(r.w)&&t.setEdge(r,this.edge(r))});let n={},o=r=>{let i=this.parent(r);return!i||t.hasNode(i)?(n[r]=i??void 0,i??void 0):i in n?n[i]:o(i)};return this._isCompound&&t.nodes().forEach(r=>t.setParent(r,o(r))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,o)=>(t!==void 0?this.setEdge(n,o,t):this.setEdge(n,o),o)),this}setEdge(e,t,n,o){let r,i,s,a,l=!1;typeof e=="object"&&e!==null&&"v"in e?(r=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,l=!0)):(r=e,i=t,s=o,arguments.length>2&&(a=n,l=!0)),r=""+r,i=""+i,s!==void 0&&(s=""+s);let c=yt(this._isDirected,r,i,s);if(c in this._edgeLabels)return l&&(this._edgeLabels[c]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(r),this.setNode(i),this._edgeLabels[c]=l?a:this._defaultEdgeLabelFn(r,i,s);let u=M0(this._isDirected,r,i,s);return r=u.v,i=u.w,Object.freeze(u),this._edgeObjs[c]=u,Qr(this._preds[i],r),Qr(this._sucs[r],i),this._in[i][c]=u,this._out[r][c]=u,this._edgeCount++,this}edge(e,t,n){let o=arguments.length===1?Vn(this._isDirected,e):yt(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(e,t,n){let o=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof o!="object"?{label:o}:o}hasEdge(e,t,n){return(arguments.length===1?Vn(this._isDirected,e):yt(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let o=arguments.length===1?Vn(this._isDirected,e):yt(this._isDirected,e,t,n),r=this._edgeObjs[o];if(r){let i=r.v,s=r.w;delete this._edgeLabels[o],delete this._edgeObjs[o],Jr(this._preds[s],i),Jr(this._sucs[i],s),delete this._in[s][o],delete this._out[i][o],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let o=Object.values(e);return n?o.filter(r=>r.v===t&&r.w===n||r.v===n&&r.w===t):o}};function Qr(e,t){e[t]?e[t]++:e[t]=1}function Jr(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function yt(e,t,n,o){let r=""+t,i=""+n;if(!e&&r>i){let s=r;r=i,i=s}return r+""+i+""+(o===void 0?"\0":o)}function M0(e,t,n,o){let r=""+t,i=""+n;if(!e&&r>i){let a=r;r=i,i=a}let s={v:r,w:i};return o&&(s.name=o),s}function Vn(e,t){return yt(e,t.v,t.w,t.name)}var I0="4.0.1",ma={};pa(ma,{read:()=>$0,write:()=>O0});function O0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:A0(e),edges:P0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function A0(e){return e.nodes().map(t=>{let n=e.node(t),o=e.parent(t),r={v:t};return n!==void 0&&(r.value=n),o!==void 0&&(r.parent=o),r})}function P0(e){return e.edges().map(t=>{let n=e.edge(t),o={v:t.v,w:t.w};return t.name!==void 0&&(o.name=t.name),n!==void 0&&(o.value=n),o})}function $0(e){let t=new ue(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var To={};pa(To,{CycleException:()=>fn,bellmanFord:()=>ya,components:()=>R0,dijkstra:()=>dn,dijkstraAll:()=>j0,findCycles:()=>H0,floydWarshall:()=>B0,isAcyclic:()=>Y0,postorder:()=>Z0,preorder:()=>W0,prim:()=>G0,shortestPaths:()=>q0,tarjan:()=>xa,topsort:()=>va});var T0=()=>1;function ya(e,t,n,o){return D0(e,String(t),n||T0,o||function(r){return e.outEdges(r)})}function D0(e,t,n,o){let r={},i,s=0,a=e.nodes(),l=function(f){let d=n(f);r[f.v].distance+d<r[f.w].distance&&(r[f.w]={distance:r[f.v].distance+d,predecessor:f.v},i=!0)},c=function(){a.forEach(function(f){o(f).forEach(function(d){let h=d.v===f?d.v:d.w,g=h===d.v?d.w:d.v;l({v:h,w:g})})})};a.forEach(function(f){let d=f===t?0:Number.POSITIVE_INFINITY;r[f]={distance:d,predecessor:""}});let u=a.length;for(let f=1;f<u&&(i=!1,s++,c(),!!i);f++);if(s===u-1&&(i=!1,c(),i))throw new Error("The graph contains a negative weight cycle");return r}function R0(e){let t={},n=[],o;function r(i){i in t||(t[i]=!0,o.push(i),e.successors(i).forEach(r),e.predecessors(i).forEach(r))}return e.nodes().forEach(function(i){o=[],r(i),o.length&&n.push(o)}),n}var wa=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,o=String(e);if(!(o in n)){let r=this._arr,i=r.length;return n[o]=i,r.push({key:o,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let o=this._arr[n].priority;if(t>o)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${o} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){let t=this._arr,n=t[e].priority,o;for(;e!==0&&(o=e>>1,!(t[o].priority<n));)this._swap(e,o),e=o}_swap(e,t){let n=this._arr,o=this._keyIndices,r=n[e],i=n[t];n[e]=i,n[t]=r,o[i.key]=e,o[r.key]=t}},L0=()=>1;function dn(e,t,n,o){let r=function(i){return e.outEdges(i)};return z0(e,String(t),n||L0,o||r)}function z0(e,t,n,o){let r={},i=new wa,s,a,l=function(c){let u=c.v!==s?c.v:c.w,f=r[u],d=n(c),h=a.distance+d;if(d<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+c+" Weight: "+d);h<f.distance&&(f.distance=h,f.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(c){let u=c===t?0:Number.POSITIVE_INFINITY;r[c]={distance:u,predecessor:""},i.add(c,u)});i.size()>0&&(s=i.removeMin(),a=r[s],a.distance!==Number.POSITIVE_INFINITY);)o(s).forEach(l);return r}function j0(e,t,n){return e.nodes().reduce(function(o,r){return o[r]=dn(e,r,t,n),o},{})}function xa(e){let t=0,n=[],o={},r=[];function i(s){let a=o[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(l){l in o?o[l].onStack&&(a.lowlink=Math.min(a.lowlink,o[l].index)):(i(l),a.lowlink=Math.min(a.lowlink,o[l].lowlink))}),a.lowlink===a.index){let l=[],c;do c=n.pop(),o[c].onStack=!1,l.push(c);while(s!==c);r.push(l)}}return e.nodes().forEach(function(s){s in o||i(s)}),r}function H0(e){return xa(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var V0=()=>1;function B0(e,t,n){return F0(e,t||V0,n||function(o){return e.outEdges(o)})}function F0(e,t,n){let o={},r=e.nodes();return r.forEach(function(i){o[i]={},o[i][i]={distance:0,predecessor:""},r.forEach(function(s){i!==s&&(o[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(s){let a=s.v===i?s.w:s.v,l=t(s);o[i][a]={distance:l,predecessor:i}})}),r.forEach(function(i){let s=o[i];r.forEach(function(a){let l=o[a];r.forEach(function(c){let u=l[i],f=s[c],d=l[c],h=u.distance+f.distance;h<d.distance&&(d.distance=h,d.predecessor=f.predecessor)})})}),o}var fn=class extends Error{constructor(...e){super(...e)}};function va(e){let t={},n={},o=[];function r(i){if(i in n)throw new fn;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(r),delete n[i],o.push(i))}if(e.sinks().forEach(r),Object.keys(t).length!==e.nodeCount())throw new fn;return o}function Y0(e){try{va(e)}catch(t){if(t instanceof fn)return!1;throw t}return!0}function X0(e,t,n,o,r){Array.isArray(t)||(t=[t]);let i=a=>{var l;return(l=e.isDirected()?e.successors(a):e.neighbors(a))!=null?l:[]},s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);r=ba(e,a,n==="post",s,i,o,r)}),r}function ba(e,t,n,o,r,i,s){return t in o||(o[t]=!0,n||(s=i(s,t)),r(t).forEach(function(a){s=ba(e,a,n,o,r,i,s)}),n&&(s=i(s,t))),s}function Ea(e,t,n){return X0(e,t,n,function(o,r){return o.push(r),o},[])}function Z0(e,t){return Ea(e,t,"post")}function W0(e,t){return Ea(e,t,"pre")}function G0(e,t){let n=new ue,o={},r=new wa,i;function s(l){let c=l.v===i?l.w:l.v,u=r.priority(c);if(u!==void 0){let f=t(l);f<u&&(o[c]=i,r.decrease(c,f))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(l){r.add(l,Number.POSITIVE_INFINITY),n.setNode(l)}),r.decrease(e.nodes()[0],0);let a=!1;for(;r.size()>0;){if(i=r.removeMin(),i in o)n.setEdge(i,o[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(s)}return n}function q0(e,t,n,o){return K0(e,t,n,o??(r=>{let i=e.outEdges(r);return i??[]}))}function K0(e,t,n,o){if(n===void 0)return dn(e,t,n,o);let r=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=o(i[s]);for(let l=0;l<a.length;l++){let c=a[l],u=c.v===i[s]?c.v:c.w,f=u===c.v?c.w:c.v;n({v:u,w:f})<0&&(r=!0)}if(r)return ya(e,t,n,o)}return dn(e,t,n,o)}function ut(e,t,n,o){let r=o;for(;e.hasNode(r);)r=Do(o);return n.dummy=t,e.setNode(r,n),r}function U0(e){let t=new ue().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let o=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:o.weight+r.weight,minlen:Math.max(o.minlen,r.minlen)})}),t}function _a(e){let t=new ue({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 ei(e,t){let n=e.x,o=e.y,r=t.x-n,i=t.y-o,s=e.width/2,a=e.height/2;if(!r&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let l,c;return Math.abs(i)*s>Math.abs(r)*a?(i<0&&(a=-a),l=a*r/i,c=a):(r<0&&(s=-s),l=s,c=s*i/r),{x:n+l,y:o+c}}function zt(e){let t=Ot(Sa(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let o=e.node(n),r=o.rank;r!==void 0&&(t[r]||(t[r]=[]),t[r][o.order]=n)}),t}function Q0(e){let t=e.nodes().map(o=>{let r=e.node(o).rank;return r===void 0?Number.MAX_VALUE:r}),n=be(Math.min,t);e.nodes().forEach(o=>{let r=e.node(o);Object.hasOwn(r,"rank")&&(r.rank-=n)})}function J0(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=be(Math.min,t),o=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;o[a]||(o[a]=[]),o[a].push(s)});let r=0,i=e.graph().nodeRankFactor;Array.from(o).forEach((s,a)=>{s===void 0&&a%i!==0?--r:s!==void 0&&r&&s.forEach(l=>e.node(l).rank+=r)})}function ti(e,t,n,o){let r={width:0,height:0};return arguments.length>=4&&(r.rank=n,r.order=o),ut(e,"border",r,t)}function em(e,t=Na){let n=[];for(let o=0;o<e.length;o+=t){let r=e.slice(o,o+t);n.push(r)}return n}var Na=65535;function be(e,t){if(t.length>Na){let n=em(t);return e(...n.map(o=>e(...o)))}else return e(...t)}function Sa(e){let t=e.nodes().map(n=>{let o=e.node(n).rank;return o===void 0?Number.MIN_VALUE:o});return be(Math.max,t)}function tm(e,t){let n={lhs:[],rhs:[]};return e.forEach(o=>{t(o)?n.lhs.push(o):n.rhs.push(o)}),n}function nm(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function ka(e,t){return t()}var om=0;function Do(e){let t=++om;return e+(""+t)}function Ot(e,t,n=1){t==null&&(t=e,e=0);let o=i=>i<t;n<0&&(o=i=>t<i);let r=[];for(let i=e;o(i);i+=n)r.push(i);return r}function hn(e,t){let n={};for(let o of t)e[o]!==void 0&&(n[o]=e[o]);return n}function kn(e,t){let n;return typeof t=="string"?n=o=>o[t]:n=t,Object.entries(e).reduce((o,[r,i])=>(o[r]=n(i,r),o),{})}function rm(e,t){return e.reduce((n,o,r)=>(n[o]=t[r],n),{})}var Cn="\0";function Ca(e,t,n){var o,r,i,s,a,l;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let c=!0;t.edgeObj.w===n.edgeObj.w&&(c=!1);let u=c?(r=(o=e[t.edgeObj.v])==null?void 0:o.rank)!=null?r:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,f=Object.entries(e).find(w=>{var m,p;return((m=w[1].edgeObj)==null?void 0:m.v)===t.edgeObj.v&&((p=w[1].edgeObj)==null?void 0:p.w)===t.edgeObj.w&&w[1].rank===u}),d=Object.entries(e).find(w=>{var m,p;return((m=w[1].edgeObj)==null?void 0:m.v)===n.edgeObj.v&&((p=w[1].edgeObj)==null?void 0:p.w)===n.edgeObj.w&&w[1].rank===u});if(!f||!d)return 0;let h=(a=f[1].order)!=null?a:NaN,g=(l=d[1].order)!=null?l:NaN;return isNaN(h-g)?0:h-g}var im="3.1.0",sm=class{constructor(){k0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return ni(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&ni(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,am)),n=n._prev;return"["+e.join(", ")+"]"}};function ni(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function am(e,t){if(e!=="_next"&&e!=="_prev")return t}var cm=sm,lm=()=>1;function um(e,t){if(e.nodeCount()<=1)return[];let n=fm(e,t||lm);return dm(n.graph,n.buckets,n.zeroIdx).flatMap(o=>e.outEdges(o.v,o.w)||[])}function dm(e,t,n){var o;let r=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Bn(e,t,n,a);for(;a=i.dequeue();)Bn(e,t,n,a);if(e.nodeCount()){for(let l=t.length-2;l>0;--l)if(a=(o=t[l])==null?void 0:o.dequeue(),a){r=r.concat(Bn(e,t,n,a,!0)||[]);break}}}return r}function Bn(e,t,n,o,r){let i=[],s=r?i:void 0;return(e.inEdges(o.v)||[]).forEach(a=>{let l=e.edge(a),c=e.node(a.v);r&&i.push({v:a.v,w:a.w}),c.out-=l,fo(t,n,c)}),(e.outEdges(o.v)||[]).forEach(a=>{let l=e.edge(a),c=a.w,u=e.node(c);u.in-=l,fo(t,n,u)}),e.removeNode(o.v),s}function fm(e,t){let n=new ue,o=0,r=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let l=n.edge(a.v,a.w)||0,c=t(a),u=l+c;n.setEdge(a.v,a.w,u);let f=n.node(a.v),d=n.node(a.w);r=Math.max(r,f.out+=c),o=Math.max(o,d.in+=c)});let i=hm(r+o+3).map(()=>new cm),s=o+1;return n.nodes().forEach(a=>{fo(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function fo(e,t,n){var o,r,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(r=e[e.length-1])==null||r.enqueue(n):(o=e[0])==null||o.enqueue(n)}function hm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function gm(e,t){(e.graph().acyclicer==="greedy"?um(e,n(e)):pm(e,t??null)).forEach(o=>{let r=e.edge(o);e.removeEdge(o),r.forwardName=o.name,r.reversed=!0,e.setEdge(o.w,o.v,r,Do("rev"))});function n(o){return r=>o.edge(r).weight}}function pm(e,t){let n=[],o={},r={};function i(l){Object.hasOwn(r,l)||(r[l]=!0,o[l]=!0,e.outEdges(l).forEach(c=>{Object.hasOwn(o,c.w)?n.push(c):i(c.w)}),delete o[l])}function s(l){var c;Object.hasOwn(r,l)||(r[l]=!0,o[l]=!0,(c=e.outEdges(l))==null||c.forEach(u=>{var f,d;Object.hasOwn(o,u.w)||((f=t.node(l))==null?void 0:f.rank)>((d=t.node(u.w))==null?void 0:d.rank)&&ym(e,u.w,u)?n.push(u):s(u.w)}),delete o[l])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function mm(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}})}function ym(e,t,n){let o=new Set;function r(i){var s;if(e.sources().includes(i))return!0;o.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!o.has(a.v)&&r(a.v))return!0;return!1}return r(t)}function wm(e){e.graph().dummyChains=[],e.edges().forEach(t=>xm(e,t))}function xm(e,t){let n=t.v,o=e.node(n).rank,r=t.w,i=e.node(r).rank,s=t.name,a=e.edge(t),l=a.labelRank;if(i===o+1)return;e.removeEdge(t);let c,u,f;for(f=0,++o;o<i;++f,++o)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:o},c=ut(e,"edge",u,"_d"),o===l&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,c,{weight:a.weight},s),f===0&&e.graph().dummyChains.push(c),n=c;e.setEdge(n,r,{weight:a.weight},s)}function vm(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),o=n.edgeLabel,r;for(e.setEdge(n.edgeObj,o);n.dummy;)r=e.successors(t)[0],e.removeNode(t),o.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(o.x=n.x,o.y=n.y,o.width=n.width,o.height=n.height),t=r,n=e.node(t)})}function Ro(e){let t={};function n(o){let r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let i=e.outEdges(o),s=i?i.map(l=>l==null?Number.POSITIVE_INFINITY:n(l.w)-e.edge(l).minlen):[],a=be(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),r.rank=a}e.sources().forEach(n)}function lt(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ma=bm;function bm(e){let t=new ue({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let o=n[0],r=e.nodeCount();t.setNode(o,{});let i,s;for(;Em(t,e)<r&&(i=_m(t,e),!!i);)s=t.hasNode(i.v)?lt(e,i):-lt(e,i),Nm(t,e,s);return t}function Em(e,t){function n(o){let r=t.nodeEdges(o);r&&r.forEach(i=>{let s=i.v,a=o===s?i.w:s;!e.hasNode(a)&&!lt(t,i)&&(e.setNode(a,{}),e.setEdge(o,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function _m(e,t){return t.edges().reduce((n,o)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(r=lt(t,o)),r<n[0]?[r,o]:n},[Number.POSITIVE_INFINITY,null])[1]}function Nm(e,t,n){e.nodes().forEach(o=>t.node(o).rank+=n)}var{preorder:Sm,postorder:km}=To,Cm=Ge;Ge.initLowLimValues=zo;Ge.initCutValues=Lo;Ge.calcCutValue=Ia;Ge.leaveEdge=Aa;Ge.enterEdge=Pa;Ge.exchangeEdges=$a;function Ge(e){e=U0(e),Ro(e);let t=Ma(e);zo(t),Lo(t,e);let n,o;for(;n=Aa(t);)o=Pa(t,e,n),$a(t,e,n,o)}function Lo(e,t){let n=km(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(o=>Mm(e,t,o))}function Mm(e,t,n){let o=e.node(n).parent,r=e.edge(n,o);r.cutvalue=Ia(e,t,n)}function Ia(e,t,n){let o=e.node(n).parent,r=!0,i=t.edge(n,o),s=0;i||(r=!1,i=t.edge(o,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(l=>{let c=l.v===n,u=c?l.w:l.v;if(u!==o){let f=c===r,d=t.edge(l).weight;if(s+=f?d:-d,Om(e,n,u)){let h=e.edge(n,u).cutvalue;s+=f?-h:h}}}),s}function zo(e,t){arguments.length<2&&(t=e.nodes()[0]),Oa(e,{},1,t)}function Oa(e,t,n,o,r){let i=n,s=e.node(o);t[o]=!0;let a=e.neighbors(o);return a&&a.forEach(l=>{Object.hasOwn(t,l)||(n=Oa(e,t,n,l,o))}),s.low=i,s.lim=n++,r?s.parent=r:delete s.parent,n}function Aa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Pa(e,t,n){let o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);let i=e.node(o),s=e.node(r),a=i,l=!1;return i.lim>s.lim&&(a=s,l=!0),t.edges().filter(c=>l===oi(e,e.node(c.v),a)&&l!==oi(e,e.node(c.w),a)).reduce((c,u)=>lt(t,u)<lt(t,c)?u:c)}function $a(e,t,n,o){let r=n.v,i=n.w;e.removeEdge(r,i),e.setEdge(o.v,o.w,{}),zo(e),Lo(e,t),Im(e,t)}function Im(e,t){let n=e.nodes().find(r=>!e.node(r).parent);if(!n)return;let o=Sm(e,[n]);o=o.slice(1),o.forEach(r=>{let i=e.node(r).parent,s=t.edge(r,i),a=!1;s||(s=t.edge(i,r),a=!0),t.node(r).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function Om(e,t,n){return e.hasEdge(t,n)}function oi(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Am=Pm;function Pm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":ri(e);break;case"tight-tree":Tm(e);break;case"longest-path":$m(e);break;case"none":break;default:ri(e)}}var $m=Ro;function Tm(e){Ro(e),Ma(e)}function ri(e){Cm(e)}var Dm=Rm;function Rm(e){let t=zm(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(o=>{let r=e.node(o),i=r.edgeObj,s=Lm(e,t,i.v,i.w),a=s.path,l=s.lca,c=0,u=a[c],f=!0;for(;o!==i.w;){if(r=e.node(o),f){for(;(u=a[c])!==l&&e.node(u).maxRank<r.rank;)c++;u===l&&(f=!1)}if(!f){for(;c<a.length-1&&e.node(a[c+1]).minRank<=r.rank;)c++;u=a[c]}u!==void 0&&e.setParent(o,u),o=e.successors(o)[0]}})}function Lm(e,t,n,o){let r=[],i=[],s=Math.min(t[n].low,t[o].low),a=Math.max(t[n].lim,t[o].lim),l;l=n;do l=e.parent(l),r.push(l);while(l&&(t[l].low>s||a>t[l].lim));let c=l,u=o;for(;(u=e.parent(u))!==c;)i.push(u);return{path:r.concat(i.reverse()),lca:c}}function zm(e){let t={},n=0;function o(r){let i=n;e.children(r).forEach(o),t[r]={low:i,lim:n++}}return e.children(Cn).forEach(o),t}function jm(e){let t=ut(e,"root",{},"_root"),n=Hm(e),o=Object.values(n),r=be(Math.max,o)-1,i=2*r+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Vm(e)+1;e.children(Cn).forEach(a=>{Ta(e,t,i,s,r,n,a)}),e.graph().nodeRankFactor=i}function Ta(e,t,n,o,r,i,s){var a;let l=e.children(s);if(!l.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let c=ti(e,"_bt"),u=ti(e,"_bb"),f=e.node(s);e.setParent(c,s),f.borderTop=c,e.setParent(u,s),f.borderBottom=u,l.forEach(d=>{var h;Ta(e,t,n,o,r,i,d);let g=e.node(d),w=g.borderTop?g.borderTop:d,m=g.borderBottom?g.borderBottom:d,p=g.borderTop?o:2*o,b=w!==m?1:r-((h=i[s])!=null?h:0)+1;e.setEdge(c,w,{weight:p,minlen:b,nestingEdge:!0}),e.setEdge(m,u,{weight:p,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,c,{weight:0,minlen:r+((a=i[s])!=null?a:0)})}function Hm(e){let t={};function n(o,r){let i=e.children(o);i&&i.length&&i.forEach(s=>n(s,r+1)),t[o]=r}return e.children(Cn).forEach(o=>n(o,1)),t}function Vm(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Bm(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Fm=Ym;function Ym(e){function t(n){let o=e.children(n),r=e.node(n);if(o.length&&o.forEach(t),r&&Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let i=r.minRank,s=r.maxRank+1;i<s;++i)ii(e,"borderLeft","_bl",n,r,i),ii(e,"borderRight","_br",n,r,i)}}e.children(Cn).forEach(t)}function ii(e,t,n,o,r,i){let s={width:0,height:0,rank:i,borderType:t},a=r[t][i-1],l=ut(e,"border",s,n);r[t][i]=l,e.setParent(l,o),a&&e.setEdge(a,l,{weight:1})}function Xm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Da(e)}function Zm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Wm(e),(n==="lr"||n==="rl")&&(Gm(e),Da(e))}function Da(e){e.nodes().forEach(t=>si(e.node(t))),e.edges().forEach(t=>si(e.edge(t)))}function si(e){let t=e.width;e.width=e.height,e.height=t}function Wm(e){e.nodes().forEach(t=>Fn(e.node(t))),e.edges().forEach(t=>{var n;let o=e.edge(t);(n=o.points)==null||n.forEach(Fn),Object.hasOwn(o,"y")&&Fn(o)})}function Fn(e){e.y=-e.y}function Gm(e){e.nodes().forEach(t=>Yn(e.node(t))),e.edges().forEach(t=>{var n;let o=e.edge(t);(n=o.points)==null||n.forEach(Yn),Object.hasOwn(o,"x")&&Yn(o)})}function Yn(e){let t=e.x;e.x=e.y,e.y=t}function qm(e,t=null){let n={},o=e.nodes().filter(c=>!e.children(c).length),r=o.map(c=>e.node(c).rank),i=be(Math.max,r),s=Ot(i+1).map(()=>[]);function a(c){if(n[c])return;n[c]=!0;let u=e.node(c);s[u.rank].push(c);let f=e.successors(c);f&&[...f].sort((d,h)=>l(d,h)).forEach(a)}o.sort((c,u)=>e.node(c).rank-e.node(u).rank).forEach(a);function l(c,u){let f=e.node(c),d=e.node(u);return Ca(t,f,d)}return s}function Km(e,t){let n=0;for(let o=1;o<t.length;++o)n+=Um(e,t[o-1],t[o]);return n}function Um(e,t,n){let o=rm(n,n.map((c,u)=>u)),r=t.flatMap(c=>{let u=e.outEdges(c);return u?u.map(f=>({pos:o[f.w],weight:e.edge(f).weight})).sort((f,d)=>f.pos-d.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),l=0;return r.forEach(c=>{let u=c.pos+i;a[u]+=c.weight;let f=0;for(;u>0;)u%2&&(f+=a[u+1]),u=u-1>>1,a[u]+=c.weight;l+=c.weight*f}),l}function Qm(e,t=[]){return t.map(n=>{let o=e.inEdges(n);if(!o||!o.length)return{v:n};{let r=o.reduce((i,s)=>{let a=e.edge(s),l=e.node(s.v);return{sum:i.sum+a.weight*l.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:r.sum/r.weight,weight:r.weight}}})}function Jm(e,t){let n={};e.forEach((r,i)=>{let s={indegree:0,in:[],out:[],vs:[r.v],i};r.barycenter!==void 0&&(s.barycenter=r.barycenter,s.weight=r.weight),n[r.v]=s}),t.edges().forEach(r=>{let i=n[r.v],s=n[r.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let o=Object.values(n).filter(r=>!r.indegree);return ey(o)}function ey(e){let t=[];function n(r){return i=>{i.merged||(i.barycenter===void 0||r.barycenter===void 0||i.barycenter>=r.barycenter)&&ty(r,i)}}function o(r){return i=>{i.in.push(r),--i.indegree===0&&e.push(i)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(o(r))}return t.filter(r=>!r.merged).map(r=>hn(r,["vs","i","barycenter","weight"]))}function ty(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}function ny(e,t,n,o,r){let i={},s=null,a=null,l=r;typeof t=="boolean"?(l=t,i={}):t&&(i=t,s=n??null,a=o??null);let c=tm(e,p=>Object.hasOwn(p,"barycenter")),u=c.lhs,f=c.rhs.sort((p,b)=>b.i-p.i),d=[],h=0,g=0,w=0;u.sort(oy(a,s,!!l));for(let[p,b]of Object.entries(i)){let y=u.findIndex(x=>x.vs[0]===p);u.splice(y+1,0,b)}w=ai(d,f,w),u.forEach(p=>{w+=p.vs.length,d.push(p.vs),h+=p.barycenter*p.weight,g+=p.weight,w=ai(d,f,w)});let m={vs:d.flat(1)};return g&&(m.barycenter=h/g,m.weight=g),m}function ai(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}function oy(e,t,n){return(o,r)=>{if(o.barycenter<r.barycenter)return-1;if(o.barycenter>r.barycenter)return 1;if(e&&(typeof o.vs[0]=="string"||typeof r.vs[0]=="string")){let i=e.node(o.vs[0]),s=e.node(r.vs[0]),a=Ca(t,i,s);if(a!==0)return a}return n?r.i-o.i:o.i-r.i}}function Ra(e,t,n,o,r){var i,s,a,l,c,u,f,d,h,g,w;let m=null,p=r;typeof o=="boolean"?(p=o,m=null):o!==void 0&&(m=o);let b=e.children(t),y=e.node(t),x=y?y.borderLeft:void 0,_=y?y.borderRight:void 0,E={};x&&(b=b.filter($=>$!==x&&$!==_));let S=Qm(e,b);S.forEach($=>{if(e.children($.v).length){let{result:M}=Ra(e,$.v,n,m,p);E[$.v]=M,Object.hasOwn(M,"barycenter")&&iy($,M)}});let C=Jm(S,n);ry(C,E);let A={},z=!1;for(let $=0;$<C.length;$++)for(let M=$+1;M<C.length;M++)if(!(!C[$]||!C[M]||!((i=C[$])!=null&&i.barycenter)||!((s=C[M])!=null&&s.barycenter))&&((a=C[$])==null?void 0:a.barycenter)===C[M].barycenter){let v=(c=(l=C[$])==null?void 0:l.vs[0])!=null?c:"",N=(f=(u=C[M])==null?void 0:u.vs[0])!=null?f:"",k=e.node(v),O=e.node(N);if(k.dummy==="edge"&&O.dummy==="edge"&&((d=k.edgeObj)==null?void 0:d.v)===((h=O.edgeObj)==null?void 0:h.v)&&((g=k.edgeObj)==null?void 0:g.w)===((w=O.edgeObj)==null?void 0:w.w))if(k.edgeLabel.reversed){A[N]=C[$],C.splice($,1),$--;break}else A[v]=C[M],C.splice(M,1),M--;else z=!0}let P=ny(C,A,m,e,p);if(x&&_){P.vs=[x,P.vs,_].flat(1);let $=e.predecessors(x);if($&&$.length){let M=e.node($[0]),v=e.predecessors(_),N=e.node(v[0]);Object.hasOwn(P,"barycenter")||(P.barycenter=0,P.weight=0),P.barycenter=(P.barycenter*P.weight+M.order+N.order)/(P.weight+2),P.weight+=2}}return Object.defineProperty(P,"result",{value:P,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(P,"usedBias",{value:z,enumerable:!1,configurable:!0,writable:!0}),P}function ry(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(o=>t[o]?t[o].vs:o)})}function iy(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function sy(e,t,n,o){o||(o=e.nodes());let r=ay(e),i=new ue({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(s=>e.node(s));return o.forEach(s=>{let a=e.node(s),l=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,l||r);let c=e[n](s);c&&c.forEach(u=>{let f=u.v===s?u.w:u.v,d=i.edge(f,s),h=d!==void 0?d.weight:0;i.setEdge(f,s,{weight:e.edge(u).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function ay(e){let t;for(;e.hasNode(t=Do("_root")););return t}function cy(e,t,n){let o={},r;n.forEach(i=>{let s=e.parent(i),a,l;for(;s;){if(a=e.parent(s),a?(l=o[a],o[a]=s):(l=r,r=s),l&&l!==s){t.setEdge(l,s);return}s=a}})}function La(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,La);return}let o=Sa(e),r=ci(e,Ot(1,o+1),"inEdges"),i=ci(e,Ot(o-1,-1,-1),"outEdges"),s=qm(e,n);if(li(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,l,c=t.constraints||[];for(let u=0,f=0;f<4;++u,++f){ly(u%2?r:i,u%4>=2,c,n),s=zt(e);let d=Km(e,s);d<a?(f=0,l=Object.assign({},s),a=d):d===a&&(l=structuredClone(s))}li(e,l)}function ci(e,t,n){let o=new Map,r=(i,s)=>{o.has(i)||o.set(i,[]),o.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&r(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&r(a,i)}return t.map(function(i){return sy(e,i,n,o.get(i)||[])})}function ly(e,t,n,o){let r=!0,i=new ue;e.forEach(function(s){n.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:l,usedBias:c}=Ra(s,a,i,o,r);t&&c&&(r=!r),l.vs.forEach((u,f)=>s.node(u).order=f),cy(s,i,l.vs)})}function li(e,t){Object.values(t).forEach(n=>n.forEach((o,r)=>e.node(o).order=r))}function uy(e,t){let n={};function o(r,i){let s=0,a=0,l=r.length,c=i[i.length-1];return i.forEach((u,f)=>{let d=fy(e,u),h=d?e.node(d).order:l;(d||u===c)&&(i.slice(a,f+1).forEach(g=>{let w=e.predecessors(g);w&&w.forEach(m=>{let p=e.node(m),b=p.order;(b<s||h<b)&&!(p.dummy&&e.node(g).dummy)&&za(n,m,g)})}),a=f+1,s=h)}),i}return t.length&&t.reduce(o),n}function dy(e,t){let n={};function o(i,s,a,l,c){Ot(s,a).forEach(u=>{let f=i[u];if(f!==void 0&&e.node(f).dummy){let d=e.predecessors(f);d&&d.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<l||g.order>c)&&za(n,h,f)})}})}function r(i,s){let a=-1,l=-1,c=0;return s.forEach((u,f)=>{if(e.node(u).dummy==="border"){let d=e.predecessors(u);if(d&&d.length){let h=d[0];if(h===void 0)return;l=e.node(h).order,o(s,c,f,a,l),c=f,a=l}}o(s,c,s.length,l,i.length)}),s}return t.length&&t.reduce(r),n}function fy(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(o=>e.node(o).dummy)}}function za(e,t,n){if(t>n){let r=t;t=n,n=r}let o=e[t];o||(e[t]=o={}),o[n]=!0}function hy(e,t,n){if(t>n){let r=t;t=n,n=r}let o=e[t];return o!==void 0&&Object.hasOwn(o,n)}function gy(e,t,n,o,r){let i={},s={},a={};return t.forEach(l=>{l.forEach((c,u)=>{i[c]=c,s[c]=c,a[c]=u})}),t.forEach(l=>{let c=-1,u=-1,f=!1,d=l,h=l.findIndex(g=>r?.includes(g)||ui(g,e,r));h>0&&(d=[l[h],...l.slice(0,h),...l.slice(h+1)],f=!0),d.forEach(g=>{var w;let m=o(g);if(m&&m.length){r!=null&&r.includes(g)&&(m=m.filter(y=>ui(y,e,r)));let p=m.sort((y,x)=>{let _=a[y],E=a[x];return(_!==void 0?_:0)-(E!==void 0?E:0)}),b=(p.length-1)/2;for(let y=Math.floor(b),x=Math.ceil(b);y<=x;++y){let _=p[y];if(_===void 0)continue;let E=a[_];if(E!==void 0&&s[g]===g&&c<E&&a[_]!==u&&!hy(n,g,_)){let S=i[_];S!==void 0&&(s[_]=g,s[g]=i[g]=S,c=E,f&&(c=-1,u=(w=a[_])!=null?w:-1,f=!1))}}}})}),{root:i,align:s}}function py(e,t,n,o,r=!1){let i={},s=my(e,t,n,r),a=r?"borderLeft":"borderRight";function l(h,g){let w=s.nodes().slice(),m={},p=w.pop();for(;p;){if(m[p])h(p);else{m[p]=!0,w.push(p);for(let b of g(p))w.push(b)}p=w.pop()}}function c(h){let g=s.inEdges(h);g?i[h]=g.reduce((w,m)=>{var p;let b=(p=i[m.v])!=null?p:0,y=s.edge(m);return Math.max(w,b+(y!==void 0?y:0))},0):i[h]=0}function u(h){let g=s.outEdges(h),w=Number.POSITIVE_INFINITY;g&&(w=g.reduce((p,b)=>{let y=i[b.w],x=s.edge(b);return Math.min(p,(y!==void 0?y:0)-(x!==void 0?x:0))},Number.POSITIVE_INFINITY));let m=e.node(h);w!==Number.POSITIVE_INFINITY&&m.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,w))}function f(h){return s.predecessors(h)||[]}function d(h){return s.successors(h)||[]}return l(c,f),l(u,d),Object.keys(o).forEach(h=>{var g;let w=n[h];w!==void 0&&(i[h]=(g=i[w])!=null?g:0)}),i}function my(e,t,n,o){let r=new ue,i=e.graph(),s=by(i.nodesep,i.edgesep,o);return t.forEach(a=>{let l;a.forEach(c=>{let u=n[c];if(u!==void 0){if(r.setNode(u),l!==void 0){let f=n[l];if(f!==void 0){let d=r.edge(f,u);r.setEdge(f,u,Math.max(s(e,c,l),d||0))}}l=c}})}),r}function yy(e,t){return Object.values(t).reduce((n,o)=>{let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(o).forEach(([a,l])=>{let c=Ey(e,a)/2;r=Math.max(l+c,r),i=Math.min(l-c,i)});let s=r-i;return s<n[0]&&(n=[s,o]),n},[Number.POSITIVE_INFINITY,null])[1]}function wy(e,t){let n=Object.values(t),o=be(Math.min,n),r=be(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,l=e[a];if(!l||l===t)return;let c=Object.values(l),u=o-be(Math.min,c);s!=="l"&&(u=r-be(Math.max,c)),u&&(e[a]=kn(l,f=>f+u))})})}function xy(e,t=void 0){let n=e.ul;return n?kn(n,(o,r)=>{var i,s;if(t){let l=t.toLowerCase(),c=e[l];if(c&&c[r]!==void 0)return c[r]}let a=Object.values(e).map(l=>{let c=l[r];return c!==void 0?c:0}).sort((l,c)=>l-c);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function vy(e,t){let n=zt(e),o=Object.assign(uy(e,n),dy(e,n)),r={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(l=>{l==="r"&&(i=i.map(f=>Object.values(f).reverse()));let c=gy(e,i,o,f=>(a==="u"?e.predecessors(f):e.successors(f))||[],t),u=py(e,i,c.root,c.align,l==="r");l==="r"&&(u=kn(u,f=>-f)),r[a+l]=u})});let s=yy(e,r);return wy(r,s),xy(r,e.graph().align)}function by(e,t,n){return(o,r,i)=>{let s=o.node(r),a=o.node(i),l=0,c;if(l+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":c=-s.width/2;break;case"r":c=s.width/2;break}if(c&&(l+=n?c:-c),c=void 0,l+=(s.dummy?t:e)/2,l+=(a.dummy?t:e)/2,l+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":c=a.width/2;break;case"r":c=-a.width/2;break}return c&&(l+=n?c:-c),l}}function Ey(e,t){return e.node(t).width}function ui(e,t,n){var o;if(!n)return!1;let r=(o=t.node(e))==null?void 0:o.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),s=n.indexOf(r?.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function _y(e,t){e=_a(e),Ny(e),Object.entries(vy(e,t)).forEach(([n,o])=>e.node(n).x=o)}function Ny(e){let t=zt(e),n=e.graph(),o=n.ranksep,r=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((l,c)=>{var u;let f=(u=e.node(c).height)!=null?u:0;return l>f?l:f},0);s.forEach(l=>{let c=e.node(l);r==="top"?c.y=i+c.height/2:r==="bottom"?c.y=i+a-c.height/2:c.y=i+a/2}),i+=a+o})}var Xn=null,Zn=null;function Sy(e,t={}){return ja(e,ka,t),e}function di(e,t,n){let o=t;for(;o!==void 0;){let r=e.parent(o);if(r===n)return o;o=r}}function ja(e,t,n){let o=e.nodes().filter(m=>e.children(m).length),r={};o.forEach(m=>{let p=e.node(m);if(p&&p.rankdir){let b=new ue({multigraph:!0,compound:!0});b.setGraph({rankdir:p.rankdir});let y=e.children(m);y.forEach($=>{let M={...e.node($)};b.setNode($,M);let v=e.parent($);v&&v!==m&&y.includes(v)&&b.setParent($,v)});let x=new Set;e.edges().forEach($=>{let M=di(e,$.v,m),v=di(e,$.w,m);if(M&&v&&M!==v){let N=`${M}\0${v}`;x.has(N)||(x.add(N),b.setEdge(M,v,{...e.edge($)}))}}),ja(b,t,n);let _=pi(b);fi(_,t,n),hi(b,_);let E=1/0,S=1/0,C=-1/0,A=-1/0;b.nodes().forEach($=>{if($===m)return;let M=b.node($);M&&typeof M.x=="number"&&typeof M.y=="number"&&typeof M.width=="number"&&typeof M.height=="number"&&(E=Math.min(E,M.x-M.width/2),C=Math.max(C,M.x+M.width/2),S=Math.min(S,M.y-M.height/2),A=Math.max(A,M.y+M.height/2))}),(!isFinite(E)||!isFinite(S)||!isFinite(C)||!isFinite(A))&&(E=S=0,C=A=0);let z=C-E,P=A-S;r[m]={minX:E,minY:S,maxX:C,maxY:A,width:z,height:P,offsetX:E,offsetY:S},p._dagreClusterSubgraph=b}});let i=[],s=m=>{let p=[],b=(e.children(m)||[]).filter(y=>y!==m);for(;b.length>0;){let y=b.shift();p.push(y),(e.children(y)||[]).filter(x=>x!==y).forEach(x=>b.push(x))}return p},a=new Map;o.forEach(m=>{let p=e.node(m);p&&p.rankdir&&r[m]&&a.set(m,(e.children(m)||[]).filter(b=>b!==m))});let l=new Set([...a.values()].flat()),c=new Map;a.forEach((m,p)=>{l.has(p)||c.set(p,s(p))});let u=new Set([...c.values()].flat()),f=m=>{for(let[p,b]of c)if(b.includes(m))return p;return m},d=[];e.edges().forEach(m=>{(u.has(m.v)||u.has(m.w))&&d.push({edge:m,label:e.edge(m)})});let h=new Map;u.forEach(m=>{let p=e.parent(m);h.set(m,typeof p=="string"?p:void 0)}),c.forEach((m,p)=>{let b=e.node(p),y=[];m.forEach(E=>{let S=e.node(E);S&&(y.push({id:E,node:S,parent:h.get(E)}),e.removeNode(E))});let x=d.filter(({edge:E})=>m.includes(E.v)||m.includes(E.w)),_=r[p];b&&(i.push({clusterId:p,subgraph:b._dagreClusterSubgraph,bounds:_,children:m,removedNodes:y,removedEdges:x}),b.width=_.width,b.height=_.height)});let g=new Set;d.forEach(({edge:m,label:p})=>{let b=f(m.v),y=f(m.w);if(b!==y&&e.hasNode(b)&&e.hasNode(y)){let x=`${b}\0${y}`;g.has(x)||(g.add(x),e.setEdge(b,y,{...p,width:0,height:0}))}});let w=pi(e);fi(w,t,n),hi(e,w),g.forEach(m=>{let p=m.indexOf("\0"),b=m.slice(0,p),y=m.slice(p+1);e.hasEdge(b,y)&&e.removeEdge(b,y)}),i.forEach(({clusterId:m,subgraph:p,bounds:b,removedNodes:y,removedEdges:x})=>{var _,E;let S=e.node(m),C=(_=S?.x)!=null?_:0,A=(E=S?.y)!=null?E:0,z=(b.minX+b.maxX)/2,P=(b.minY+b.maxY)/2;y.forEach(({id:$,node:M,parent:v})=>{e.setNode($,M),v!==void 0&&e.setParent($,v)}),x.forEach(({edge:$,label:M})=>{e.setEdge($,M)}),p.nodes().forEach($=>{if($===m)return;let M=p.node($),v=e.node($);v&&M&&typeof M.x=="number"&&typeof M.y=="number"&&(v.x=C+(M.x-z),v.y=A+(M.y-P))}),delete S._dagreClusterSubgraph}),o.forEach(m=>{var p,b;let y=e.node(m),x=r[m];if(y&&y.rankdir&&y._dagreClusterSubgraph&&x){let _=y._dagreClusterSubgraph,E=(p=y.x)!=null?p:0,S=(b=y.y)!=null?b:0,C=(x.minX+x.maxX)/2,A=(x.minY+x.maxY)/2;_.nodes().forEach(z=>{if(z===m)return;let P=_.node(z),$=e.node(z);if($&&P&&typeof P.x=="number"&&typeof P.y=="number"){let M=P.x-C,v=P.y-A;$.x=E+M,$.y=S+v}}),delete y._dagreClusterSubgraph}})}function fi(e,t,n){n?.useDynamic===!1&&(Xn=null,Zn=null),t(" makeSpaceForEdgeLabels",()=>$y(e)),t(" removeSelfEdges",()=>By(e)),t(" acyclic",()=>gm(e,Xn)),t(" nestingGraph.run",()=>jm(e)),t(" rank",()=>Am(_a(e))),t(" injectEdgeLabelProxies",()=>Ty(e)),t(" removeEmptyRanks",()=>J0(e)),t(" nestingGraph.cleanup",()=>Bm(e)),t(" normalizeRanks",()=>Q0(e)),t(" assignRankMinMax",()=>Dy(e)),t(" removeEdgeLabelProxies",()=>Ry(e)),t(" normalize.run",()=>wm(e)),t(" parentDummyChains",()=>Dm(e)),t(" addBorderSegments",()=>Fm(e)),t(" order",()=>La(e,n,Zn)),t(" insertSelfEdges",()=>Fy(e)),t(" adjustCoordinateSystem",()=>Xm(e)),t(" position",()=>_y(e,n.corePath)),t(" positionSelfEdges",()=>Yy(e)),Zn=JSON.parse(JSON.stringify(e._nodes)),t(" removeBorderNodes",()=>Vy(e)),t(" normalize.undo",()=>vm(e)),t(" fixupEdgeLabelCoords",()=>jy(e)),t(" undoCoordinateSystem",()=>Zm(e)),t(" translateGraph",()=>Ly(e)),t(" assignNodeIntersects",()=>zy(e)),t(" reversePoints",()=>Hy(e)),t(" acyclic.undo",()=>mm(e)),Xn=e}function hi(e,t){e.nodes().forEach(n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.order=r.order,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))}),e.edges().forEach(n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var ky=["nodesep","edgesep","ranksep","marginx","marginy"],Cy={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},My=["acyclicer","ranker","rankdir","align","rankalign"],Iy=["width","height","rank"],gi={width:0,height:0},Oy=["minlen","weight","width","height","labeloffset"],Ay={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Py=["labelpos"];function pi(e){let t=new ue({multigraph:!0,compound:!0}),n=Gn(e.graph());return t.setGraph(Object.assign({},Cy,Wn(n,ky),hn(n,My))),e.nodes().forEach(o=>{let r=Gn(e.node(o)),i=Wn(r,Iy);Object.keys(gi).forEach(a=>{i[a]===void 0&&(i[a]=gi[a])}),t.setNode(o,i);let s=e.parent(o);s!==void 0&&t.setParent(o,s)}),e.edges().forEach(o=>{let r=Gn(e.edge(o));t.setEdge(o,Object.assign({},Ay,Wn(r,Oy),hn(r,Py)))}),t}function $y(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var o;let r=e.edge(n);r.minlen*=2,((o=r.labelpos)!=null?o:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Ty(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let o=e.node(t.v),r={rank:(e.node(t.w).rank-o.rank)/2+o.rank,e:t};ut(e,"edge-proxy",r,"_ep")}})}function Dy(e){let t=0;e.nodes().forEach(n=>{let o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,t=Math.max(t,o.maxRank))}),e.graph().maxRank=t}function Ry(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let o=n;e.edge(o.e).labelRank=n.rank,e.removeNode(t)}})}function Ly(e){let t=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,r=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function l(c){let u=c.x,f=c.y,d=c.width,h=c.height;t=Math.min(t,u-d/2),n=Math.max(n,u+d/2),o=Math.min(o,f-h/2),r=Math.max(r,f+h/2)}e.nodes().forEach(c=>l(e.node(c))),e.edges().forEach(c=>{let u=e.edge(c);Object.hasOwn(u,"x")&&l(u)}),t-=s,o-=a,e.nodes().forEach(c=>{let u=e.node(c);u.x-=t,u.y-=o}),e.edges().forEach(c=>{let u=e.edge(c);u.points.forEach(f=>{f.x-=t,f.y-=o}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=o)}),i.width=n-t+s,i.height=r-o+a}function zy(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),o=e.node(t.v),r=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=r,s=o),n.points.unshift(ei(o,i)),n.points.push(ei(r,s))})}function jy(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Hy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Vy(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),o=e.node(n.borderTop),r=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(r.y-o.y),n.x=i.x+n.width/2,n.y=o.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function By(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Fy(e){zt(e).forEach(t=>{let n=0;t.forEach((o,r)=>{let i=e.node(o);typeof i.rank!="number"&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(s=>{ut(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:r+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Yy(e){e.nodes().forEach(t=>{let n=e.node(t),o=r=>typeof r=="number"&&isFinite(r);if(n.dummy==="selfedge"){let r=n,i=e.node(r.e.v),s=o(i?.x)?i.x:0,a=o(i?.y)?i.y:0,l=o(i?.width)?i.width:0,c=o(i?.height)?i.height:0,u=o(n.x)?n.x:s,f=o(n.y)?n.y:a,d=l/2,h=c/2;r.edgeLabel.points=[{x:u+d,y:f-h},{x:u+d,y:f-h},{x:u,y:f},{x:u-d,y:f+h},{x:u-d,y:f+h},{x:u,y:f},{x:u,y:f}],r.edgeLabel.x=u,r.edgeLabel.y=f,e.setEdge(r.e,r.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(r=>{if(!Array.isArray(r.label.points)||r.label.points.length!==7){let i=o(n.x)?n.x:0,s=o(n.y)?n.y:0,a=o(n.width)?n.width:0,l=o(n.height)?n.height:0,c=a/2,u=l/2;r.label.points=[{x:i+c,y:s-u},{x:i+c,y:s-u},{x:i,y:s},{x:i-c,y:s+u},{x:i-c,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Wn(e,t){return kn(hn(e,t),Number)}function Gn(e){let t={};return e&&Object.entries(e).forEach(([n,o])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=o}),t}function Xy(e){let t=zt(e),n=new ue({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(o=>{n.setNode(o,{label:o}),n.setParent(o,"layer"+e.node(o).rank)}),e.edges().forEach(o=>n.setEdge(o.v,o.w,{},o.name)),t.forEach((o,r)=>{let i="layer"+r;n.setNode(i,{rank:"same"}),o.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Zy={graphlib:ga,version:im,layout:Sy,debug:Xy,util:{time:nm,notime:ka}},mi=Zy;/*! For license information please see dagre.esm.js.LEGAL.txt */function yi(e,t){return t!==null&&e!==null?`${e}: ${t}`:t!==null?t:e!==null?String(e):""}const Wy=(e,t)=>bi([...Kn(e),t]),Gy=(e,t,n)=>e!==null?e:t?"~":String(n);function qy(e){const t=[];for(const n of e)if(n.sel==="key")t.push(n.name);else if(n.sel==="index")t.push(n.n);else if(n.sel==="nullkey")t.push(null);else return null;return t}function Ky(e,t,n){let o,r,i;try{const u=Uc(e,f=>{throw new Error(f)});o=u.ordinal===!0,r=u.path.steps,i=u.path.base.scope}catch{return null}const s=qy(r);if(!s)return null;const a=Kn(t),l=i==="document"?Kn(n):i==="current"?a.slice(0,-1):i==="parent"?a.slice(0,-2):null,c=l?[...l,...s]:s;return!o&&c.length===0?null:{host:bi(o?c:c.slice(0,-1)),key:o?null:String(c[c.length-1])}}function Uy(e){const t=vi(e);return t?{self:t.kind==="omni"?t.value:void 0,entries:t.entries}:Array.isArray(e)?{self:void 0,entries:e.map(n=>({key:null,value:n}))}:e!==null&&typeof e=="object"?{self:void 0,entries:Object.entries(e).map(([n,o])=>({key:n,value:o}))}:{self:e,entries:[]}}function Qy(e){if(e==null)return null;if(typeof e=="object"){const n=e.$yamloverNum;return typeof n=="string"?{text:n,type:"number"}:null}const t=typeof e=="number"?"number":typeof e=="boolean"?"boolean":"string";return{text:String(e),type:t}}function Jy(e){const t=[],n=new Map,o=new Map,r=[],i=[],s=e.comments??{},a=e.path,l=(d,h)=>{const g=d;if(n.get(g))return g;const m=Qy(h),p=m===null?{id:g,path:d,label:"",kind:"empty"}:{id:g,path:d,label:m.text,kind:"value",valueType:m.type};return t.push(p),n.set(g,p),o.set(ft(d),g),g},c=(d,h,g)=>{const w=n.has(h),{self:m,entries:p}=Uy(d),b=l(h,m);if(w)return b;const y=s[g];for(const x of(Array.isArray(y)?void 0:y?.anchors)??[]){const _=Ky(x,h,a);_&&i.push({host:_.host,key:_.key,target:b})}return p.forEach((x,_)=>{const E=x.key!==null?x.key:x.keyNull===!0?null:_,S=`${g}/${encodeURIComponent(Gy(x.key,x.keyNull===!0,_))}`,C=x.key!==null?x.key:x.keyNull===!0?"~":null,A=x.anchor===!0?"anchor":"contain",z=Gc(x.value);if(z){r.push({source:b,target:null,targetPath:z.path??void 0,text:z.text,kind:"deref",key:C,ordinal:_});return}const P=qc(x.value);if(P){const M=l(P.path,P.value??P.title??null);r.push({source:b,target:M,kind:A,key:C,ordinal:_});return}const $=c(x.value,Wy(h,E),S);r.push({source:b,target:$,kind:A,key:C,ordinal:_})}),b};c(e.value,e.path,"");const u=(d,h)=>{if(d!==void 0){const w=o.get(ft(d));if(w)return w;const m={id:d,path:d,label:":"+Kc(d),kind:"stub"};return n.has(d)||(t.push(m),n.set(d,m),o.set(ft(d),d)),d}if(h===void 0)return null;const g=`$unresolved:${h}`;if(!n.has(g)){const w={id:g,path:null,label:h,kind:"stub"};t.push(w),n.set(g,w)}return g},f=[];r.forEach((d,h)=>{const g=d.source??u(d.sourcePath,void 0),w=d.target??u(d.targetPath,d.text);g===null||w===null||f.push({id:`e${h}`,source:g,target:w,kind:d.kind,key:d.key,ordinal:d.ordinal,label:yi(d.ordinal,d.key)})});for(const d of i){const h=ft(d.host),g=f.find(m=>m.target===d.target&&m.key===d.key&&ft(m.source)===h);if(g){g.kind="anchor";continue}const w=u(d.host,void 0);w!==null&&f.push({id:`a${f.length}`,source:w,target:d.target,kind:"anchor",key:d.key,ordinal:null,label:yi(null,d.key)})}return{nodes:t,edges:f}}const ew=["Control","Alt","Meta"],tw=e=>e.ctrlKey||e.altKey||e.metaKey,nw="12px ui-sans-serif, system-ui, -apple-system, sans-serif",Ha=10,ow=26,At=16,Va=(ow-At)/2,Ba=12,rw=180,qn=4/3,Jt=(()=>{let e;return t=>(e===void 0&&(e=document.createElement("canvas").getContext("2d")),e?(e.font=nw,Math.ceil(e.measureText(t).width)):t.length*7)})();function iw(e){const t=Jt(e);if(t<=rw)return[e];const n=e.split(/\s+/).filter(Boolean);if(n.length<2)return[e];const o=2*qn*Va-2*Ha,r=Math.max(1,Math.round((-o+Math.sqrt(o*o+4*qn*At*t))/(2*qn*At))),i=l=>{const c=[];let u="";for(const f of n){const d=u===""?f:u+" "+f;u!==""&&Jt(d)>l?(c.push(u),u=f):u=d}return u!==""&&c.push(u),c};let s=Math.max(t/r,...n.map(Jt)),a=i(s);for(;a.length>r;)s*=1.15,a=i(s);return a}const sw=(e,t)=>e.kind==="empty"?Ba:Math.max(...t.map(Jt))+2*Ha,aw=(e,t)=>e.kind==="empty"?Ba:t.length*At+2*Va,wi=(e,t)=>`${(e+1)/(t+1)*100}%`,cw=e=>e.kind==="stub"?"ref":e.valueType==="number"?"n":e.valueType==="boolean"?"b":"s";function lw({data:e}){const{node:t,lines:n,width:o,height:r,sources:i,targets:s,onNavigate:a}=e,l=t.path!==null;return I.jsxs("div",{className:`xyflow-node xyflow-node-${t.kind}${l?" xyflow-node-nav":""}`,style:{width:o,height:r},title:t.path?`${t.path} — double-click to open`:t.label,"data-node-path":t.path??void 0,onDoubleClick:l?c=>{c.stopPropagation(),a(t.path)}:void 0,children:[s.map((c,u)=>I.jsx(at,{id:c,type:"target",position:Y.Left,style:{top:wi(u,s.length)}},c)),t.kind==="empty"?null:I.jsx("span",{className:cw(t),style:{lineHeight:`${At}px`,textAlign:"center"},children:n.map((c,u)=>I.jsxs(T.Fragment,{children:[u>0&&I.jsx("br",{}),c]},u))}),i.map((c,u)=>I.jsx(at,{id:c,type:"source",position:Y.Right,style:{top:wi(u,i.length)}},c))]})}const uw={yamlover:lw};function dw({id:e,sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s,style:a,markerEnd:l,data:c}){const[u]=ko({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s}),f=c??{},d=f.kind??"contain",h=f.key??null,g=f.ordinal??null;return h===null&&g===null?I.jsx(ct,{id:e,path:u,style:a,markerEnd:l}):I.jsxs(I.Fragment,{children:[I.jsx(ct,{id:e,path:u,style:a,markerEnd:l}),I.jsx("text",{className:`xyflow-edge-label xyflow-edge-${d}${h===null?" xyflow-edge-ordinal":""}`,dy:-5,children:I.jsxs("textPath",{href:`#${e}`,startOffset:"45%",textAnchor:"middle",children:[g!==null?I.jsx("tspan",{className:"n",children:g}):null,g!==null&&h!==null?I.jsx("tspan",{className:"punct",children:": "}):null,h!==null?I.jsx("tspan",{className:"k",children:h}):null]})})]})}const fw={yamlover:dw},hw=e=>e.kind==="deref"?{strokeDasharray:"6 3",strokeWidth:1.4,stroke:"var(--fg)"}:e.kind==="anchor"?{strokeDasharray:"1 3 5 3",strokeWidth:1.4,stroke:"var(--fg)"}:e.key===null?{strokeWidth:.9,stroke:"var(--dim)"}:{strokeWidth:1.4,stroke:"var(--fg)"},gw=20,xi=12;function pw(e,t,n){const o=new Map,r=new Map;e.edges.forEach((u,f)=>{u.kind!=="contain"||o.has(u.target)||(o.set(u.target,u.source),r.set(u.target,u.ordinal??f))});const i=[...new Set(e.nodes.map(u=>t.get(u.id).x))].sort((u,f)=>u-f),s=new Map;let a=0;i.forEach((u,f)=>{f>0&&u-i[f-1]>gw&&a++,s.set(u,a)});const l=new Map;e.nodes.forEach(u=>{const f=s.get(t.get(u.id).x),d=l.get(f)??[];d.length===0&&l.set(f,d),d.push(u.id)});const c=new Set;for(const u of[...l.keys()].sort((f,d)=>f-d)){const f=l.get(u),d=m=>{const p=o.get(m);return p!==void 0&&c.has(p)?t.get(p).y:t.get(m).y},h=f.map(m=>t.get(m).y).sort((m,p)=>m-p),g=new Map(f.map((m,p)=>[m,p])),w=[...f].sort((m,p)=>d(m)-d(p)||(r.get(m)??0)-(r.get(p)??0)||g.get(m)-g.get(p));if(w.forEach((m,p)=>{t.get(m).y=h[p]}),n){let m=-1/0;for(const p of w){const b=t.get(p),y=n(p);b.y-y/2<m+xi&&(b.y=m+xi+y/2),m=b.y+y/2}}for(const m of f)c.add(m)}}function mw(e,t,n){e={nodes:e.nodes,edges:e.edges.map(d=>({...d,id:n+d.id}))};const o=new mi.graphlib.Graph;o.setDefaultEdgeLabel(()=>({})),o.setGraph({rankdir:"LR",nodesep:30,ranksep:150});const r=new Map(e.nodes.map(d=>[d.id,d.kind==="empty"?[]:iw(d.label)])),i=new Map(e.nodes.map(d=>[d.id,{width:sw(d,r.get(d.id)),height:aw(d,r.get(d.id))}]));e.nodes.forEach(d=>o.setNode(d.id,{...i.get(d.id)})),e.edges.forEach(d=>o.setEdge(d.source,d.target)),mi.layout(o);const s=new Map(e.nodes.map(d=>[d.id,{x:o.node(d.id)?.x??0,y:o.node(d.id)?.y??0}]));pw(e,s,d=>i.get(d).height);const a=d=>s.get(d)?.y??0,l=new Map(e.nodes.map(d=>[d.id,[]])),c=new Map(e.nodes.map(d=>[d.id,[]]));for(const d of[...e.edges].sort((h,g)=>a(h.target)-a(g.target)))l.get(d.source)?.push(d.id);for(const d of[...e.edges].sort((h,g)=>a(h.source)-a(g.source)))c.get(d.target)?.push(d.id);const u=e.nodes.map(d=>{const{width:h,height:g}=i.get(d.id),w=s.get(d.id);return{id:d.id,type:"yamlover",data:{node:d,lines:r.get(d.id),width:h,height:g,sources:l.get(d.id)??[],targets:c.get(d.id)??[],onNavigate:t},position:{x:w.x-h/2,y:w.y-g/2}}}),f=e.edges.map(d=>{const h=hw(d);return{id:d.id,source:d.source,target:d.target,sourceHandle:d.id,targetHandle:d.id,type:"yamlover",data:{kind:d.kind,key:d.key,ordinal:d.ordinal},style:h,markerEnd:{type:kt.ArrowClosed,color:h.stroke,width:14,height:14}}});return{nodes:u,edges:f}}function ho({node:e,onNavigate:t,className:n,interactive:o=!1,openPath:r}){const i=T.useRef(null),s=T.useRef(null);el(i,14,o);const a=T.useId().replace(/[^A-Za-z0-9_-]/g,""),l=T.useMemo(()=>mw(Jy(e),t,a),[e,t,a]),[c,u,f]=Kp(l.nodes);T.useEffect(()=>u(l.nodes),[l,u]);const d=h=>{const g=s.current;if(!g||h.button!==0||!tw(h))return;h.preventDefault(),h.stopPropagation();const w={x:h.clientX,y:h.clientY},m=g.getViewport(),p=y=>g.setViewport({x:m.x+y.clientX-w.x,y:m.y+y.clientY-w.y,zoom:m.zoom}),b=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",b)};return l.nodes.length===0?I.jsx("p",{className:"csv-empty",children:"nothing to draw"}):I.jsx("div",{ref:i,className:n,onMouseDownCapture:o?d:void 0,onDoubleClick:r?()=>t(r):void 0,title:r?"Double-click to open the graph on its own page":void 0,children:I.jsx(qp,{nodes:c,edges:l.edges,onNodesChange:o?f:void 0,nodeTypes:uw,edgeTypes:fw,fitView:!0,nodesDraggable:o,elementsSelectable:o,zoomOnDoubleClick:!1,...o?{onInit:h=>{s.current=h},panOnDrag:[2],panOnScroll:!0,zoomOnScroll:!1,zoomActivationKeyCode:ew,onPaneContextMenu:h=>h.preventDefault()}:{panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,preventScrolling:!1},children:o&&I.jsx(a0,{position:"top-left",showInteractive:!1})})})}function xw({node:e,onNavigate:t}){return I.jsx(ho,{node:e,onNavigate:t,className:"xyflow-view",interactive:!0})}function vw({chunk:e,onNavigate:t}){const[n,o]=T.useState(null),[r,i]=T.useState(null),s=vi(e.value)!=null||Array.isArray(e.value),a=Qc(s?null:e.path);if(T.useEffect(()=>{if(s)return;let l=!1;return Jc(e.path,null).then(c=>!l&&o(c)).catch(c=>!l&&i(c.message)),()=>{l=!0}},[e.path,s,a]),s){const l={path:e.path,type:e.type,format:e.format,concrete:null,documentPath:e.documentPath,title:null,description:null,value:e.value};return I.jsx(ho,{node:l,onNavigate:t,className:"xyflow-chunk",openPath:e.path})}return r?I.jsxs("p",{className:"csv-empty",children:["graph failed to load: ",r]}):n?I.jsx(ho,{node:n,onNavigate:t,className:"xyflow-chunk",openPath:e.path}):I.jsx("p",{className:"csv-empty",children:"…"})}export{vw as XyflowChunk,xw as XyflowView,pw as reseatInRelationOrder,iw as wrapLabel};
|