@a-company/paradigm 5.22.0 → 5.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ambient-WEPHBAJD.js → ambient-HYZR42NX.js} +1 -1
- package/dist/chunk-4DVT5IEY.js +2 -0
- package/dist/chunk-73R63P7K.js +2 -0
- package/dist/{chunk-QIGE36CB.js → chunk-FSOI3CCD.js} +79 -21
- package/dist/{compliance-TSXLXADI.js → compliance-NLG7KB73.js} +2 -2
- package/dist/{docs-RXPN6CK7.js → docs-UIYXJ3O3.js} +1 -1
- package/dist/{habits-LX5IWCZM.js → habits-GICVMTJL.js} +1 -1
- package/dist/{hooks-EFM2IK6E.js → hooks-E7HQQ57M.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/mcp.js +64 -41
- package/dist/{migrate-OMR5G5AF.js → migrate-WT56YYAM.js} +1 -1
- package/dist/platform-server-FXYBBH6E.js +25 -0
- package/dist/{project-type-SURTOIG7.js → project-type-4Y6CESWP.js} +1 -1
- package/dist/{roster-FLRZ5J42.js → roster-K2QILE7K.js} +1 -1
- package/dist/{serve-JE6UF5P2.js → serve-5W6KOA4R.js} +1 -1
- package/dist/{shift-ASDLMMK5.js → shift-TDOYQKR4.js} +2 -2
- package/dist/university-FJ7OCOA3.js +2 -0
- package/package.json +1 -1
- package/platform-ui/dist/assets/AmbientSection-BYjt75R1.js +1 -0
- package/platform-ui/dist/assets/{CanvasSection-DLW0s-Bu.js → CanvasSection-rKvA_vZj.js} +2 -2
- package/platform-ui/dist/assets/{DocsSection-BQ9Hi51g.js → DocsSection-CI9K73M-.js} +1 -1
- package/platform-ui/dist/assets/GitSection-DSGj_c6S.js +4 -0
- package/platform-ui/dist/assets/{GraphSection-0c9C-w7K.js → GraphSection-CawN7pC5.js} +2 -2
- package/platform-ui/dist/assets/LoreSection-oO5dCe6O.js +1 -0
- package/platform-ui/dist/assets/{SentinelSection-C4OoME9U.js → SentinelSection-DNgoYMH0.js} +1 -1
- package/platform-ui/dist/assets/SymphonySection-C0zfcqv3.js +1 -0
- package/platform-ui/dist/assets/TeamSection-Bzd3Dt9Q.js +1 -0
- package/platform-ui/dist/assets/UniversitySection-B3ltVfpt.css +1 -0
- package/platform-ui/dist/assets/UniversitySection-tBr62R0S.js +1 -0
- package/platform-ui/dist/assets/{index-DPpOdAtC.js → index-BaOmyn11.js} +12 -12
- package/platform-ui/dist/index.html +1 -1
- package/dist/chunk-AGVAHVUA.js +0 -2
- package/dist/chunk-RMOALQJN.js +0 -2
- package/dist/platform-server-2KXHGHFV.js +0 -25
- package/platform-ui/dist/assets/AmbientSection-DqQ2mfCO.js +0 -1
- package/platform-ui/dist/assets/GitSection-QQeUX6o3.js +0 -4
- package/platform-ui/dist/assets/LoreSection--t56kCj2.js +0 -1
- package/platform-ui/dist/assets/SymphonySection-B-rvsLxq.js +0 -1
- package/platform-ui/dist/assets/TeamSection-CBFmNEEo.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as aa,u as ca,R as la,r as k,j as v,c as ua}from"./index-DPpOdAtC.js";function se(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=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var da={value:()=>{}};function Qt(){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 zt(n)}function zt(e){this._=e}function fa(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}})}zt.prototype=Qt.prototype={constructor:zt,on:function(e,t){var n=this._,o=fa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=ha(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]=fo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=fo(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 zt(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 ha(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function fo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=da,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cn="http://www.w3.org/1999/xhtml";const ho={svg:"http://www.w3.org/2000/svg",xhtml:Cn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ho.hasOwnProperty(t)?{space:ho[t],local:e}:e}function ga(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(n,e)}}function pa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pr(e){var t=Jt(e);return(t.local?pa:ga)(t)}function ma(){}function On(e){return e==null?ma:function(){return this.querySelector(e)}}function ya(e){typeof e!="function"&&(e=On(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),c,l,f=0;f<s;++f)(c=i[f])&&(l=e.call(c,c.__data__,f,i))&&("__data__"in c&&(l.__data__=c.__data__),a[f]=l);return new ue(o,this._parents)}function xa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wa(){return[]}function mr(e){return e==null?wa:function(){return this.querySelectorAll(e)}}function va(e){return function(){return xa(e.apply(this,arguments))}}function ba(e){typeof e=="function"?e=va(e):e=mr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new ue(o,r)}function yr(e){return function(){return this.matches(e)}}function xr(e){return function(t){return t.matches(e)}}var _a=Array.prototype.find;function Na(e){return function(){return _a.call(this.children,e)}}function Ea(){return this.firstElementChild}function Sa(e){return this.select(e==null?Ea:Na(typeof e=="function"?e:xr(e)))}var Ca=Array.prototype.filter;function Ma(){return Array.from(this.children)}function ka(e){return function(){return Ca.call(this.children,e)}}function Ia(e){return this.selectAll(e==null?Ma:ka(typeof e=="function"?e:xr(e)))}function $a(e){typeof e!="function"&&(e=yr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new ue(o,this._parents)}function wr(e){return new Array(e.length)}function Aa(){return new ue(this._enter||this._groups.map(wr),this._parents)}function Ft(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ft.prototype={constructor:Ft,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 Ta(e){return function(){return e}}function La(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ft(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Pa(e,t,n,o,r,i,s){var a,c,l=new Map,f=t.length,u=i.length,d=new Array(f),g;for(a=0;a<f;++a)(c=t[a])&&(d[a]=g=s.call(c,c.__data__,a,t)+"",l.has(g)?r[a]=c:l.set(g,c));for(a=0;a<u;++a)g=s.call(e,i[a],a,i)+"",(c=l.get(g))?(o[a]=c,c.__data__=i[a],l.delete(g)):n[a]=new Ft(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function Da(e){return e.__data__}function za(e,t){if(!arguments.length)return Array.from(this,Da);var n=t?Pa:La,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ta(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var f=o[l],u=r[l],d=u.length,g=ja(e.call(f,f&&f.__data__,l,o)),h=g.length,x=a[l]=new Array(h),y=s[l]=new Array(h),m=c[l]=new Array(d);n(f,u,x,y,m,g,t);for(var N=0,p=0,w,M;N<h;++N)if(w=x[N]){for(N>=p&&(p=N+1);!(M=y[p])&&++p<h;);w._next=M||null}}return s=new ue(s,o),s._enter=a,s._exit=c,s}function ja(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ra(){return new ue(this._exit||this._groups.map(wr),this._parents)}function Ha(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 Oa(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),c=0;c<s;++c)for(var l=n[c],f=o[c],u=l.length,d=a[c]=new Array(u),g,h=0;h<u;++h)(g=l[h]||f[h])&&(d[h]=g);for(;c<r;++c)a[c]=n[c];return new ue(a,this._parents)}function Fa(){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 Va(e){e||(e=Ba);function t(u,d){return u&&d?e(u.__data__,d.__data__):!u-!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,c=r[i]=new Array(a),l,f=0;f<a;++f)(l=s[f])&&(c[f]=l);c.sort(t)}return new ue(r,this._parents).order()}function Ba(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ya(){return Array.from(this)}function Ga(){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 Wa(){let e=0;for(const t of this)++e;return e}function qa(){return!this.node()}function Ua(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 Ka(e){return function(){this.removeAttribute(e)}}function Za(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qa(e,t){return function(){this.setAttribute(e,t)}}function Ja(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ec(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tc(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 nc(e,t){var n=Jt(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?Za:Ka:typeof t=="function"?n.local?tc:ec:n.local?Ja:Qa)(n,t))}function vr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oc(e){return function(){this.style.removeProperty(e)}}function rc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ic(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function sc(e,t,n){return arguments.length>1?this.each((t==null?oc:typeof t=="function"?ic:rc)(e,t,n??"")):qe(this.node(),e)}function qe(e,t){return e.style.getPropertyValue(t)||vr(e).getComputedStyle(e,null).getPropertyValue(t)}function ac(e){return function(){delete this[e]}}function cc(e,t){return function(){this[e]=t}}function lc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uc(e,t){return arguments.length>1?this.each((t==null?ac:typeof t=="function"?lc:cc)(e,t)):this.node()[e]}function br(e){return e.trim().split(/^|\s+/)}function Fn(e){return e.classList||new _r(e)}function _r(e){this._node=e,this._names=br(e.getAttribute("class")||"")}_r.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 Nr(e,t){for(var n=Fn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Er(e,t){for(var n=Fn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function dc(e){return function(){Nr(this,e)}}function fc(e){return function(){Er(this,e)}}function hc(e,t){return function(){(t.apply(this,arguments)?Nr:Er)(this,e)}}function gc(e,t){var n=br(e+"");if(arguments.length<2){for(var o=Fn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?hc:t?dc:fc)(n,t))}function pc(){this.textContent=""}function mc(e){return function(){this.textContent=e}}function yc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xc(e){return arguments.length?this.each(e==null?pc:(typeof e=="function"?yc:mc)(e)):this.node().textContent}function wc(){this.innerHTML=""}function vc(e){return function(){this.innerHTML=e}}function bc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _c(e){return arguments.length?this.each(e==null?wc:(typeof e=="function"?bc:vc)(e)):this.node().innerHTML}function Nc(){this.nextSibling&&this.parentNode.appendChild(this)}function Ec(){return this.each(Nc)}function Sc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cc(){return this.each(Sc)}function Mc(e){var t=typeof e=="function"?e:pr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kc(){return null}function Ic(e,t){var n=typeof e=="function"?e:pr(e),o=t==null?kc:typeof t=="function"?t:On(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function $c(){var e=this.parentNode;e&&e.removeChild(this)}function Ac(){return this.each($c)}function Tc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Lc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pc(e){return this.select(e?Lc:Tc)}function Dc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function zc(e){return function(t){e.call(this,t,this.__data__)}}function jc(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 Rc(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 Hc(e,t,n){return function(){var o=this.__on,r,i=zc(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 Oc(e,t,n){var o=jc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,f;c<l;++c)for(r=0,f=a[c];r<i;++r)if((s=o[r]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Hc:Rc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function Sr(e,t,n){var o=vr(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 Fc(e,t){return function(){return Sr(this,e,t)}}function Vc(e,t){return function(){return Sr(this,e,t.apply(this,arguments))}}function Bc(e,t){return this.each((typeof t=="function"?Vc:Fc)(e,t))}function*Xc(){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 Cr=[null];function ue(e,t){this._groups=e,this._parents=t}function wt(){return new ue([[document.documentElement]],Cr)}function Yc(){return this}ue.prototype=wt.prototype={constructor:ue,select:ya,selectAll:ba,selectChild:Sa,selectChildren:Ia,filter:$a,data:za,enter:Aa,exit:Ra,join:Ha,merge:Oa,selection:Yc,order:Fa,sort:Va,call:Xa,nodes:Ya,node:Ga,size:Wa,empty:qa,each:Ua,attr:nc,style:sc,property:uc,classed:gc,text:xc,html:_c,raise:Ec,lower:Cc,append:Mc,insert:Ic,remove:Ac,clone:Pc,datum:Dc,on:Oc,dispatch:Bc,[Symbol.iterator]:Xc};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Cr)}function Gc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Gc(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 Wc={passive:!1},dt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Ge(e){e.preventDefault(),e.stopImmediatePropagation()}function Mr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Ge,dt);"onselectstart"in t?n.on("selectstart.drag",Ge,dt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function kr(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ge,dt),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 Mt=e=>()=>e;function Mn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:f}){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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:f}})}Mn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function qc(e){return!e.ctrlKey&&!e.button}function Uc(){return this.parentNode}function Kc(e,t){return t??{x:e.x,y:e.y}}function Zc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ir(){var e=qc,t=Uc,n=Kc,o=Zc,r={},i=Qt("start","drag","end"),s=0,a,c,l,f,u=0;function d(w){w.on("mousedown.drag",g).filter(o).on("touchstart.drag",y).on("touchmove.drag",m,Wc).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(w,M){if(!(f||!e.call(this,w,M))){var _=p(this,t.call(this,w,M),w,M,"mouse");_&&(le(w.view).on("mousemove.drag",h,dt).on("mouseup.drag",x,dt),Mr(w.view),pn(w),l=!1,a=w.clientX,c=w.clientY,_("start",w))}}function h(w){if(Ge(w),!l){var M=w.clientX-a,_=w.clientY-c;l=M*M+_*_>u}r.mouse("drag",w)}function x(w){le(w.view).on("mousemove.drag mouseup.drag",null),kr(w.view,l),Ge(w),r.mouse("end",w)}function y(w,M){if(e.call(this,w,M)){var _=w.changedTouches,C=t.call(this,w,M),T=_.length,D,O;for(D=0;D<T;++D)(O=p(this,C,w,M,_[D].identifier,_[D]))&&(pn(w),O("start",w,_[D]))}}function m(w){var M=w.changedTouches,_=M.length,C,T;for(C=0;C<_;++C)(T=r[M[C].identifier])&&(Ge(w),T("drag",w,M[C]))}function N(w){var M=w.changedTouches,_=M.length,C,T;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),C=0;C<_;++C)(T=r[M[C].identifier])&&(pn(w),T("end",w,M[C]))}function p(w,M,_,C,T,D){var O=i.copy(),$=fe(D||_,M),P,H,b;if((b=n.call(w,new Mn("beforestart",{sourceEvent:_,target:d,identifier:T,active:s,x:$[0],y:$[1],dx:0,dy:0,dispatch:O}),C))!=null)return P=b.x-$[0]||0,H=b.y-$[1]||0,function A(E,L,I){var S=$,z;switch(E){case"start":r[T]=A,z=s++;break;case"end":delete r[T],--s;case"drag":$=fe(I||L,M),z=s;break}O.call(E,w,new Mn(E,{sourceEvent:L,subject:b,target:d,identifier:T,active:z,x:$[0]+P,y:$[1]+H,dx:$[0]-S[0],dy:$[1]-S[1],dispatch:O}),C)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Mt(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:Mt(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Mt(w),d):n},d.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Mt(!!w),d):o},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,d):Math.sqrt(u)},d}function Vn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function $r(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function vt(){}var ft=.7,Vt=1/ft,We="\\s*([+-]?\\d+)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Qc=/^#([0-9a-f]{3,8})$/,Jc=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),el=new RegExp(`^rgb\\(${xe},${xe},${xe}\\)$`),tl=new RegExp(`^rgba\\(${We},${We},${We},${ht}\\)$`),nl=new RegExp(`^rgba\\(${xe},${xe},${xe},${ht}\\)$`),ol=new RegExp(`^hsl\\(${ht},${xe},${xe}\\)$`),rl=new RegExp(`^hsla\\(${ht},${xe},${xe},${ht}\\)$`),go={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};Vn(vt,je,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:po,formatHex:po,formatHex8:il,formatHsl:sl,formatRgb:mo,toString:mo});function po(){return this.rgb().formatHex()}function il(){return this.rgb().formatHex8()}function sl(){return Ar(this).formatHsl()}function mo(){return this.rgb().formatRgb()}function je(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Qc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?yo(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kt(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=Jc.exec(e))?new ce(t[1],t[2],t[3],1):(t=el.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tl.exec(e))?kt(t[1],t[2],t[3],t[4]):(t=nl.exec(e))?kt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ol.exec(e))?vo(t[1],t[2]/100,t[3]/100,1):(t=rl.exec(e))?vo(t[1],t[2]/100,t[3]/100,t[4]):go.hasOwnProperty(e)?yo(go[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function yo(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function kt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function al(e){return e instanceof vt||(e=je(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function kn(e,t,n,o){return arguments.length===1?al(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Vn(ce,kn,$r(vt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Bt(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:xo,formatHex:xo,formatHex8:cl,formatRgb:wo,toString:wo}));function xo(){return`#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}`}function cl(){return`#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}${Pe((isNaN(this.opacity)?1:this.opacity)*255)}`}function wo(){const e=Bt(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Bt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Pe(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function vo(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 Ar(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=je(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,c=(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/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function ll(e,t,n,o){return arguments.length===1?Ar(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}Vn(he,ll,$r(vt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,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 ce(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new he(bo(this.h),It(this.s),It(this.l),Bt(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=Bt(this.opacity);return`${e===1?"hsl(":"hsla("}${bo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function bo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Bn=e=>()=>e;function ul(e,t){return function(n){return e+n*t}}function dl(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 fl(e){return(e=+e)==1?Tr:function(t,n){return n-t?dl(t,n,e):Bn(isNaN(t)?n:t)}}function Tr(e,t){var n=t-e;return n?ul(e,n):Bn(isNaN(e)?t:e)}const Xt=function e(t){var n=fl(t);function o(r,i){var s=n((r=kn(r)).r,(i=kn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=Tr(r.opacity,i.opacity);return function(f){return r.r=s(f),r.g=a(f),r.b=c(f),r.opacity=l(f),r+""}}return o.gamma=e,o}(1);function hl(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 gl(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pl(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]=lt(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 ml(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function ye(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yl(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]=lt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var In=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp(In.source,"g");function xl(e){return function(){return e}}function wl(e){return function(t){return e(t)+""}}function Lr(e,t){var n=In.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=In.exec(e))&&(r=yn.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,c.push({i:s,x:ye(o,r)})),n=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?wl(c[0].x):xl(t):(t=c.length,function(l){for(var f=0,u;f<t;++f)a[(u=c[f]).i]=u.x(l);return a.join("")})}function lt(e,t){var n=typeof t,o;return t==null||n==="boolean"?Bn(t):(n==="number"?ye:n==="string"?(o=je(t))?(t=o,Xt):Lr:t instanceof je?Xt:t instanceof Date?ml:gl(t)?hl:Array.isArray(t)?pl:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yl:ye)(e,t)}var _o=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pr(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*_o,skewX:Math.atan(c)*_o,scaleX:s,scaleY:a}}var $t;function vl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:Pr(t.a,t.b,t.c,t.d,t.e,t.f)}function bl(e){return e==null||($t||($t=document.createElementNS("http://www.w3.org/2000/svg","g")),$t.setAttribute("transform",e),!(e=$t.transform.baseVal.consolidate()))?$n:(e=e.matrix,Pr(e.a,e.b,e.c,e.d,e.e,e.f))}function Dr(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,f,u,d,g,h){if(l!==u||f!==d){var x=g.push("translate(",null,t,null,n);h.push({i:x-4,x:ye(l,u)},{i:x-2,x:ye(f,d)})}else(u||d)&&g.push("translate("+u+t+d+n)}function s(l,f,u,d){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),d.push({i:u.push(r(u)+"rotate(",null,o)-2,x:ye(l,f)})):f&&u.push(r(u)+"rotate("+f+o)}function a(l,f,u,d){l!==f?d.push({i:u.push(r(u)+"skewX(",null,o)-2,x:ye(l,f)}):f&&u.push(r(u)+"skewX("+f+o)}function c(l,f,u,d,g,h){if(l!==u||f!==d){var x=g.push(r(g)+"scale(",null,",",null,")");h.push({i:x-4,x:ye(l,u)},{i:x-2,x:ye(f,d)})}else(u!==1||d!==1)&&g.push(r(g)+"scale("+u+","+d+")")}return function(l,f){var u=[],d=[];return l=e(l),f=e(f),i(l.translateX,l.translateY,f.translateX,f.translateY,u,d),s(l.rotate,f.rotate,u,d),a(l.skewX,f.skewX,u,d),c(l.scaleX,l.scaleY,f.scaleX,f.scaleY,u,d),l=f=null,function(g){for(var h=-1,x=d.length,y;++h<x;)u[(y=d[h]).i]=y.x(g);return u.join("")}}}var _l=Dr(vl,"px, ","px)","deg)"),Nl=Dr(bl,", ",")",")"),El=1e-12;function No(e){return((e=Math.exp(e))+1/e)/2}function Sl(e){return((e=Math.exp(e))-1/e)/2}function Cl(e){return((e=Math.exp(2*e))-1)/(e+1)}const jt=function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],f=s[0],u=s[1],d=s[2],g=f-a,h=u-c,x=g*g+h*h,y,m;if(x<El)m=Math.log(d/l)/t,y=function(C){return[a+C*g,c+C*h,l*Math.exp(t*C*m)]};else{var N=Math.sqrt(x),p=(d*d-l*l+o*x)/(2*l*n*N),w=(d*d-l*l-o*x)/(2*d*n*N),M=Math.log(Math.sqrt(p*p+1)-p),_=Math.log(Math.sqrt(w*w+1)-w);m=(_-M)/t,y=function(C){var T=C*m,D=No(M),O=l/(n*N)*(D*Cl(t*T+M)-Sl(M));return[a+O*g,c+O*h,l*D/No(t*T+M)]}}return y.duration=m*1e3*t/Math.SQRT2,y}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r}(Math.SQRT2,2,4);var Ue=0,at=0,it=0,zr=1e3,Yt,ct,Gt=0,Re=0,en=0,gt=typeof performance=="object"&&performance.now?performance:Date,jr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xn(){return Re||(jr(Ml),Re=gt.now()+en)}function Ml(){Re=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=Rr.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Xn():+n)+(t==null?0:+t),!this._next&&ct!==this&&(ct?ct._next=this:Yt=this,ct=this),this._call=e,this._time=n,An()},stop:function(){this._call&&(this._call=null,this._time=1/0,An())}};function Rr(e,t,n){var o=new Wt;return o.restart(e,t,n),o}function kl(){Xn(),++Ue;for(var e=Yt,t;e;)(t=Re-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ue}function Eo(){Re=(Gt=gt.now())+en,Ue=at=0;try{kl()}finally{Ue=0,$l(),Re=0}}function Il(){var e=gt.now(),t=e-Gt;t>zr&&(en-=t,Gt=e)}function $l(){for(var e,t=Yt,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:Yt=n);ct=e,An(o)}function An(e){if(!Ue){at&&(at=clearTimeout(at));var t=e-Re;t>24?(e<1/0&&(at=setTimeout(Eo,e-gt.now()-en)),it&&(it=clearInterval(it))):(it||(Gt=gt.now(),it=setInterval(Il,zr)),Ue=1,jr(Eo))}}function So(e,t,n){var o=new Wt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Al=Qt("start","end","cancel","interrupt"),Tl=[],Hr=0,Co=1,Tn=2,Rt=3,Mo=4,Ln=5,Ht=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Ll(e,n,{name:t,index:o,group:r,on:Al,tween:Tl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Hr})}function Yn(e,t){var n=me(e,t);if(n.state>Hr)throw new Error("too late; already scheduled");return n}function ve(e,t){var n=me(e,t);if(n.state>Rt)throw new Error("too late; already running");return n}function me(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ll(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Rr(i,0,n.time);function i(l){n.state=Co,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var f,u,d,g;if(n.state!==Co)return c();for(f in o)if(g=o[f],g.name===n.name){if(g.state===Rt)return So(s);g.state===Mo?(g.state=Ht,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete o[f]):+f<t&&(g.state=Ht,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete o[f])}if(So(function(){n.state===Rt&&(n.state=Mo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Rt,r=new Array(d=n.tween.length),f=0,u=-1;f<d;++f)(g=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=g);r.length=u+1}}function a(l){for(var f=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Ln,1),u=-1,d=r.length;++u<d;)r[u].call(e,f);n.state===Ln&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ht,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Ot(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>Tn&&o.state<Ln,o.state=Ht,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Pl(e){return this.each(function(){Ot(this,e)})}function Dl(e,t){var n,o;return function(){var r=ve(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 zl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=ve(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function jl(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=me(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?Dl:zl)(n,e,t))}function Gn(e,t,n){var o=e._id;return e.each(function(){var r=ve(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return me(r,o).value[t]}}function Or(e,t){var n;return(typeof t=="number"?ye:t instanceof je?Xt:(n=je(t))?(t=n,Xt):Lr)(e,t)}function Rl(e){return function(){this.removeAttribute(e)}}function Hl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ol(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 Fl(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 Vl(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Bl(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Xl(e,t){var n=Jt(e),o=n==="transform"?Nl:Or;return this.attrTween(e,typeof t=="function"?(n.local?Bl:Vl)(n,o,Gn(this,"attr."+e,t)):t==null?(n.local?Hl:Rl)(n):(n.local?Fl:Ol)(n,o,t))}function Yl(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Gl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Wl(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Gl(e,i)),n}return r._value=t,r}function ql(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Yl(e,i)),n}return r._value=t,r}function Ul(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=Jt(e);return this.tween(n,(o.local?Wl:ql)(o,t))}function Kl(e,t){return function(){Yn(this,e).delay=+t.apply(this,arguments)}}function Zl(e,t){return t=+t,function(){Yn(this,e).delay=t}}function Ql(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kl:Zl)(t,e)):me(this.node(),t).delay}function Jl(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function eu(e,t){return t=+t,function(){ve(this,e).duration=t}}function tu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jl:eu)(t,e)):me(this.node(),t).duration}function nu(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function ou(e){var t=this._id;return arguments.length?this.each(nu(t,e)):me(this.node(),t).ease}function ru(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ve(this,e).ease=n}}function iu(e){if(typeof e!="function")throw new Error;return this.each(ru(this._id,e))}function su(e){typeof e!="function"&&(e=yr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Ee(o,this._parents,this._name,this._id)}function au(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 c=t[a],l=n[a],f=c.length,u=s[a]=new Array(f),d,g=0;g<f;++g)(d=c[g]||l[g])&&(u[g]=d);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function cu(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 lu(e,t,n){var o,r,i=cu(t)?Yn:ve;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function uu(e,t){var n=this._id;return arguments.length<2?me(this.node(),n).on.on(e):this.each(lu(n,e,t))}function du(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fu(){return this.on("end.remove",du(this._id))}function hu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=On(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),f,u,d=0;d<c;++d)(f=a[d])&&(u=e.call(f,f.__data__,d,a))&&("__data__"in f&&(u.__data__=f.__data__),l[d]=u,tn(l[d],t,n,d,l,me(f,n)));return new Ee(i,this._parents,t,n)}function gu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,f,u=0;u<l;++u)if(f=c[u]){for(var d=e.call(f,f.__data__,u,c),g,h=me(f,n),x=0,y=d.length;x<y;++x)(g=d[x])&&tn(g,t,n,x,d,h);i.push(d),s.push(f)}return new Ee(i,s,t,n)}var pu=wt.prototype.constructor;function mu(){return new pu(this._groups,this._parents)}function yu(e,t){var n,o,r;return function(){var i=qe(this,e),s=(this.style.removeProperty(e),qe(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Fr(e){return function(){this.style.removeProperty(e)}}function xu(e,t,n){var o,r=n+"",i;return function(){var s=qe(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function wu(e,t,n){var o,r,i;return function(){var s=qe(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),qe(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function vu(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=ve(this,e),l=c.on,f=c.value[i]==null?a||(a=Fr(t)):void 0;(l!==n||r!==f)&&(o=(n=l).copy()).on(s,r=f),c.on=o}}function bu(e,t,n){var o=(e+="")=="transform"?_l:Or;return t==null?this.styleTween(e,yu(e,o)).on("end.style."+e,Fr(e)):typeof t=="function"?this.styleTween(e,wu(e,o,Gn(this,"style."+e,t))).each(vu(this._id,e)):this.styleTween(e,xu(e,o,t),n).on("end.style."+e,null)}function _u(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Nu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&_u(e,s,n)),o}return i._value=t,i}function Eu(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,Nu(e,t,n??""))}function Su(e){return function(){this.textContent=e}}function Cu(e){return function(){var t=e(this);this.textContent=t??""}}function Mu(e){return this.tween("text",typeof e=="function"?Cu(Gn(this,"text",e)):Su(e==null?"":e+""))}function ku(e){return function(t){this.textContent=e.call(this,t)}}function Iu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ku(r)),t}return o._value=e,o}function $u(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,Iu(e))}function Au(){for(var e=this._name,t=this._id,n=Vr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var f=me(c,t);tn(c,e,n,l,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ee(o,this._parents,e,n)}function Tu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=ve(this,o),f=l.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Lu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Vr(){return++Lu}var _e=wt.prototype;Ee.prototype={constructor:Ee,select:hu,selectAll:gu,selectChild:_e.selectChild,selectChildren:_e.selectChildren,filter:su,merge:au,selection:mu,transition:Au,call:_e.call,nodes:_e.nodes,node:_e.node,size:_e.size,empty:_e.empty,each:_e.each,on:uu,attr:Xl,attrTween:Ul,style:bu,styleTween:Eu,text:Mu,textTween:$u,remove:fu,tween:jl,delay:Ql,duration:tu,ease:ou,easeVarying:iu,end:Tu,[Symbol.iterator]:_e[Symbol.iterator]};function Pu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Du={time:null,delay:0,duration:250,ease:Pu};function zu(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 ju(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Vr(),(n=Du).time=Xn(),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,c,l=0;l<a;++l)(c=s[l])&&tn(c,e,t,l,s,n||zu(c,t));return new Ee(o,this._parents,e,t)}wt.prototype.interrupt=Pl;wt.prototype.transition=ju;const At=e=>()=>e;function Ru(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 Ne(e,t,n){this.k=e,this.x=t,this.y=n}Ne.prototype={constructor:Ne,scale:function(e){return e===1?this:new Ne(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ne(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 nn=new Ne(1,0,0);Br.prototype=Ne.prototype;function Br(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function st(e){e.preventDefault(),e.stopImmediatePropagation()}function Hu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ou(){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 ko(){return this.__zoom||nn}function Fu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Vu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bu(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 Xr(){var e=Hu,t=Ou,n=Bu,o=Fu,r=Vu,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=jt,l=Qt("start","zoom","end"),f,u,d,g=500,h=150,x=0,y=10;function m(b){b.property("__zoom",ko).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",$).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(b,A,E,L){var I=b.selection?b.selection():b;I.property("__zoom",ko),b!==I?M(b,A,E,L):I.interrupt().each(function(){_(this,arguments).event(L).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},m.scaleBy=function(b,A,E,L){m.scaleTo(b,function(){var I=this.__zoom.k,S=typeof A=="function"?A.apply(this,arguments):A;return I*S},E,L)},m.scaleTo=function(b,A,E,L){m.transform(b,function(){var I=t.apply(this,arguments),S=this.__zoom,z=E==null?w(I):typeof E=="function"?E.apply(this,arguments):E,R=S.invert(z),j=typeof A=="function"?A.apply(this,arguments):A;return n(p(N(S,j),z,R),I,s)},E,L)},m.translateBy=function(b,A,E,L){m.transform(b,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),s)},null,L)},m.translateTo=function(b,A,E,L,I){m.transform(b,function(){var S=t.apply(this,arguments),z=this.__zoom,R=L==null?w(S):typeof L=="function"?L.apply(this,arguments):L;return n(nn.translate(R[0],R[1]).scale(z.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof E=="function"?-E.apply(this,arguments):-E),S,s)},L,I)};function N(b,A){return A=Math.max(i[0],Math.min(i[1],A)),A===b.k?b:new Ne(A,b.x,b.y)}function p(b,A,E){var L=A[0]-E[0]*b.k,I=A[1]-E[1]*b.k;return L===b.x&&I===b.y?b:new Ne(b.k,L,I)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function M(b,A,E,L){b.on("start.zoom",function(){_(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(L).end()}).tween("zoom",function(){var I=this,S=arguments,z=_(I,S).event(L),R=t.apply(I,S),j=E==null?w(R):typeof E=="function"?E.apply(I,S):E,V=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),B=I.__zoom,Y=typeof A=="function"?A.apply(I,S):A,U=c(B.invert(j).concat(V/B.k),Y.invert(j).concat(V/Y.k));return function(W){if(W===1)W=Y;else{var F=U(W),G=V/F[2];W=new Ne(G,j[0]-F[0]*G,j[1]-F[1]*G)}z.zoom(null,W)}})}function _(b,A,E){return!E&&b.__zooming||new C(b,A)}function C(b,A){this.that=b,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,A),this.taps=0}C.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,A){return this.mouse&&b!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var A=le(this.that).datum();l.call(b,this.that,new Ru(b,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),A)}};function T(b,...A){if(!e.apply(this,arguments))return;var E=_(this,A).event(b),L=this.__zoom,I=Math.max(i[0],Math.min(i[1],L.k*Math.pow(2,o.apply(this,arguments)))),S=fe(b);if(E.wheel)(E.mouse[0][0]!==S[0]||E.mouse[0][1]!==S[1])&&(E.mouse[1]=L.invert(E.mouse[0]=S)),clearTimeout(E.wheel);else{if(L.k===I)return;E.mouse=[S,L.invert(S)],Ot(this),E.start()}st(b),E.wheel=setTimeout(z,h),E.zoom("mouse",n(p(N(L,I),E.mouse[0],E.mouse[1]),E.extent,s));function z(){E.wheel=null,E.end()}}function D(b,...A){if(d||!e.apply(this,arguments))return;var E=b.currentTarget,L=_(this,A,!0).event(b),I=le(b.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",V,!0),S=fe(b,E),z=b.clientX,R=b.clientY;Mr(b.view),xn(b),L.mouse=[S,this.__zoom.invert(S)],Ot(this),L.start();function j(B){if(st(B),!L.moved){var Y=B.clientX-z,U=B.clientY-R;L.moved=Y*Y+U*U>x}L.event(B).zoom("mouse",n(p(L.that.__zoom,L.mouse[0]=fe(B,E),L.mouse[1]),L.extent,s))}function V(B){I.on("mousemove.zoom mouseup.zoom",null),kr(B.view,L.moved),st(B),L.event(B).end()}}function O(b,...A){if(e.apply(this,arguments)){var E=this.__zoom,L=fe(b.changedTouches?b.changedTouches[0]:b,this),I=E.invert(L),S=E.k*(b.shiftKey?.5:2),z=n(p(N(E,S),L,I),t.apply(this,A),s);st(b),a>0?le(this).transition().duration(a).call(M,z,L,b):le(this).call(m.transform,z,L,b)}}function $(b,...A){if(e.apply(this,arguments)){var E=b.touches,L=E.length,I=_(this,A,b.changedTouches.length===L).event(b),S,z,R,j;for(xn(b),z=0;z<L;++z)R=E[z],j=fe(R,this),j=[j,this.__zoom.invert(j),R.identifier],I.touch0?!I.touch1&&I.touch0[2]!==j[2]&&(I.touch1=j,I.taps=0):(I.touch0=j,S=!0,I.taps=1+!!f);f&&(f=clearTimeout(f)),S&&(I.taps<2&&(u=j[0],f=setTimeout(function(){f=null},g)),Ot(this),I.start())}}function P(b,...A){if(this.__zooming){var E=_(this,A).event(b),L=b.changedTouches,I=L.length,S,z,R,j;for(st(b),S=0;S<I;++S)z=L[S],R=fe(z,this),E.touch0&&E.touch0[2]===z.identifier?E.touch0[0]=R:E.touch1&&E.touch1[2]===z.identifier&&(E.touch1[0]=R);if(z=E.that.__zoom,E.touch1){var V=E.touch0[0],B=E.touch0[1],Y=E.touch1[0],U=E.touch1[1],W=(W=Y[0]-V[0])*W+(W=Y[1]-V[1])*W,F=(F=U[0]-B[0])*F+(F=U[1]-B[1])*F;z=N(z,Math.sqrt(W/F)),R=[(V[0]+Y[0])/2,(V[1]+Y[1])/2],j=[(B[0]+U[0])/2,(B[1]+U[1])/2]}else if(E.touch0)R=E.touch0[0],j=E.touch0[1];else return;E.zoom("touch",n(p(z,R,j),E.extent,s))}}function H(b,...A){if(this.__zooming){var E=_(this,A).event(b),L=b.changedTouches,I=L.length,S,z;for(xn(b),d&&clearTimeout(d),d=setTimeout(function(){d=null},g),S=0;S<I;++S)z=L[S],E.touch0&&E.touch0[2]===z.identifier?delete E.touch0:E.touch1&&E.touch1[2]===z.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(z=fe(z,this),Math.hypot(u[0]-z[0],u[1]-z[1])<y)){var R=le(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return m.wheelDelta=function(b){return arguments.length?(o=typeof b=="function"?b:At(+b),m):o},m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:At(!!b),m):e},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:At(!!b),m):r},m.extent=function(b){return arguments.length?(t=typeof b=="function"?b:At([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),m):t},m.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],m):[i[0],i[1]]},m.translateExtent=function(b){return arguments.length?(s[0][0]=+b[0][0],s[1][0]=+b[1][0],s[0][1]=+b[0][1],s[1][1]=+b[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(b){return arguments.length?(n=b,m):n},m.duration=function(b){return arguments.length?(a=+b,m):a},m.interpolate=function(b){return arguments.length?(c=b,m):c},m.on=function(){var b=l.on.apply(l,arguments);return b===l?m:b},m.clickDistance=function(b){return arguments.length?(x=(b=+b)*b,m):Math.sqrt(x)},m.tapDistance=function(b){return arguments.length?(y=+b,m):y},m}const we={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{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."},pt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yr=["Enter"," ","Escape"],Gr={"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 Ke;(function(e){e.Strict="strict",e.Loose="loose"})(Ke||(Ke={}));var ze;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ze||(ze={}));var Ze;(function(e){e.Partial="partial",e.Full="full"})(Ze||(Ze={}));const Wr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Io={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function qr(e){return e===null?null:e?"valid":"invalid"}const Ur=e=>"id"in e&&"source"in e&&"target"in e,Xu=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bt=(e,t=[0,0])=>{const{width:n,height:o}=Se(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Yu=(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):Wn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},_t=(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=on(n,Ut(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},qn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const l of e.values()){const{measured:f,selectable:u=!0,hidden:d=!1}=l;if(s&&!u||d)continue;const g=f.width??l.width??l.initialWidth??null,h=f.height??l.height??l.initialHeight??null,x=mt(a,Je(l)),y=(g??0)*(h??0),m=i&&x>0;(!l.internals.handleBounds||m||x>=y||l.dragging)&&c.push(l)}return c},Gu=(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 Wu(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function qu({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=Wu(e,s),c=_t(a),l=Un(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await o.setViewport(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Kr({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:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",we.error005());else{const g=a.measured.width,h=a.measured.height;g&&h&&(u=[[c,l],[c+g,l+h]])}else a&&et(s.extent)&&(u=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=et(u)?He(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",we.error015())),{position:{x:d.x-c+(s.measured.width??0)*f[0],y:d.y-l+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function Uu({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 g=i.has(d.id),h=!g&&d.parentId&&s.find(x=>x.id===d.parentId);(g||h)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),f=Gu(s,c);for(const d of c)a.has(d.id)&&!f.find(h=>h.id===d.id)&&f.push(d);if(!r)return{edges:f,nodes:s};const u=await r({nodes:s,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:s}:{edges:[],nodes:[]}:u}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Zr(e,t,n){const{width:o,height:r}=Se(n),{x:i,y:s}=n.internals.positionAbsolute;return He(e,[[i,s],[i+o,s+r]],t)}const $o=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Qr=(e,t,n=15,o=40)=>{const r=$o(e.x,o,t.width-o)*n,i=$o(e.y,o,t.height-o)*n;return[r,i]},on=(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)}),Pn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Je=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=Wn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:o,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=Wn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:o,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:o+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Jr=(e,t)=>rn(on(Pn(e),Pn(t))),mt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Ao=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Ku=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?Nt(a,s):a},Kt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Be(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Zu(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Be(e,n),r=Be(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Be(e.top??e.y??0,n),r=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),s=Be(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 Qu(e,t,n,o,r,i){const{x:s,y:a}=Kt(e,[t,n,o]),{x:c,y:l}=Kt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=r-c,u=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(u)}}const Un=(e,t,n,o,r,i)=>{const s=Zu(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),f=Qe(l,o,r),u=e.x+e.width/2,d=e.y+e.height/2,g=t/2-u*f,h=n/2-d*f,x=Qu(e,g,h,f,t,n),y={left:Math.min(x.left-s.left,0),top:Math.min(x.top-s.top,0),right:Math.min(x.right-s.right,0),bottom:Math.min(x.bottom-s.bottom,0)};return{x:g-y.left+y.right,y:h-y.top+y.bottom,zoom:f}},yt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function Se(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function ei(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ti(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 To(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Ju(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function ed(e){return{...Gr,...e||{}}}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=pe(e),a=Et({x:i-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},o),{x:c,y:l}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Kn=e=>({width:e.offsetWidth,height:e.offsetHeight}),ni=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},td=["INPUT","SELECT","TEXTAREA"];function oi(e){var o,r;const t=((r=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:td.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ri=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=ri(e),o=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Lo=(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,...Kn(s)}})};function ii({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,f=Math.abs(c-e),u=Math.abs(l-t);return[c,l,f,u]}function Tt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Po({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Tt(t-o,i),n];case X.Right:return[t+Tt(o-t,i),n];case X.Top:return[t,n-Tt(n-r,i)];case X.Bottom:return[t,n+Tt(r-n,i)]}}function si({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Po({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,f]=Po({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,d,g,h]=ii({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${o},${r}`,u,d,g,h]}function ai({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 nd({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 od({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(Ut(e),Ut(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 mt(s,rn(i))>0}const rd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,id=(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)),sd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||rd;let r;return Ur(e)?r={...e}:r={...e,id:o(e)},id(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function ci({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=ai({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Do={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},ad=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},zo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Do[t],c=Do[o],l={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},u=ad({source:l,sourcePosition:t,target:f}),d=u.x!==0?"x":"y",g=u[d];let h=[],x,y;const m={x:0,y:0},N={x:0,y:0},[,,p,w]=ai({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(x=r.x??l.x+(f.x-l.x)*s,y=r.y??(l.y+f.y)/2):(x=r.x??(l.x+f.x)/2,y=r.y??l.y+(f.y-l.y)*s);const _=[{x,y:l.y},{x,y:f.y}],C=[{x:l.x,y},{x:f.x,y}];a[d]===g?h=d==="x"?_:C:h=d==="x"?C:_}else{const _=[{x:l.x,y:f.y}],C=[{x:f.x,y:l.y}];if(d==="x"?h=a.x===g?C:_:h=a.y===g?_:C,t===o){const P=Math.abs(e[d]-n[d]);if(P<=i){const H=Math.min(i-1,i-P);a[d]===g?m[d]=(l[d]>e[d]?-1:1)*H:N[d]=(f[d]>n[d]?-1:1)*H}}if(t!==o){const P=d==="x"?"y":"x",H=a[d]===c[P],b=l[P]>f[P],A=l[P]<f[P];(a[d]===1&&(!H&&b||H&&A)||a[d]!==1&&(!H&&A||H&&b))&&(h=d==="x"?_:C)}const T={x:l.x+m.x,y:l.y+m.y},D={x:f.x+N.x,y:f.y+N.y},O=Math.max(Math.abs(T.x-h[0].x),Math.abs(D.x-h[0].x)),$=Math.max(Math.abs(T.y-h[0].y),Math.abs(D.y-h[0].y));O>=$?(x=(T.x+D.x)/2,y=h[0].y):(x=h[0].x,y=(T.y+D.y)/2)}return[[e,{x:l.x+m.x,y:l.y+m.y},...h,{x:f.x+N.x,y:f.y+N.y},n],x,y,p,w]}function ld(e,t,n,o){const r=Math.min(zo(e,t)/2,zo(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 l=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Dn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:f=.5}){const[u,d,g,h,x]=cd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:f});return[u.reduce((m,N,p)=>{let w="";return p>0&&p<u.length-1?w=ld(u[p-1],N,u[p+1],s):w=`${p===0?"M":"L"}${N.x} ${N.y}`,m+=w,m},""),d,g,h,x]}function jo(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ud(e){var u;const{sourceNode:t,targetNode:n}=e;if(!jo(t)||!jo(n))return null;const o=t.internals.handleBounds||Ro(t.handles),r=n.internals.handleBounds||Ro(n.handles),i=Ho((o==null?void 0:o.source)??[],e.sourceHandle),s=Ho(e.connectionMode===Ke.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!s)return(u=e.onError)==null||u.call(e,"008",we.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||X.Bottom,c=(s==null?void 0:s.position)||X.Top,l=Oe(t,i,a),f=Oe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Ro(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 Oe(e,t,n=X.Left,o=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Se(e);if(o)return{x:r+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function Ho(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function zn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function dd(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(c=>{if(c&&typeof c=="object"){const l=zn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const li=1e3,fd=10,Zn={nodeOrigin:[0,0],nodeExtent:pt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hd={...Zn,checkEquality:!0};function Qn(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function gd(e,t,n){const o=Qn(Zn,n);for(const r of e.values())if(r.parentId)eo(r,e,t,o);else{const i=bt(r,o.nodeOrigin),s=et(r.extent)?r.extent:o.nodeExtent,a=He(i,s,Se(r));r.internals.positionAbsolute=a}}function pd(e,t){if(!e.handles)return e.measured?t==null?void 0: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 Jn(e){return e==="manual"}function jn(e,t,n,o={}){var l,f;const r=Qn(hd,o),i={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Jn(r.zIndexMode)?li:0;let c=e.length>0;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===(d==null?void 0:d.internals.userNode))t.set(u.id,d);else{const g=bt(u,r.nodeOrigin),h=et(u.extent)?u.extent:r.nodeExtent,x=He(g,h,Se(u));d={...r.defaults,...u,measured:{width:(l=u.measured)==null?void 0:l.width,height:(f=u.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:pd(u,d),z:ui(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&eo(d,t,n,o,i)}return c}function md(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 eo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=Qn(Zn,o),l=e.parentId,f=t.get(l);if(!f){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}md(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*fd),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const u=i&&!Jn(c)?li:0,{x:d,y:g,z:h}=yd(e,f,s,a,u,c),{positionAbsolute:x}=e.internals,y=d!==x.x||g!==x.y;(y||h!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:d,y:g}:x,z:h}})}function ui(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return Jn(n)?o:o+(e.selected?t:0)}function yd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Se(e),l=bt(e,n),f=et(e.extent)?He(l,e.extent,c):l;let u=He({x:s+f.x,y:a+f.y},o,c);e.extent==="parent"&&(u=Zr(u,c,t));const d=ui(e,r,i),g=t.internals.z??0;return{x:u.x,y:u.y,z:g>=d?g+1:d}}function to(e,t,n,o=[0,0]){var s;const r=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),f=Jr(l,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const f=c.internals.positionAbsolute,u=Se(c),d=c.origin??o,g=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,h=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,x=Math.max(u.width,Math.round(a.width)),y=Math.max(u.height,Math.round(a.height)),m=(x-u.width)*d[0],N=(y-u.height)*d[1];(g>0||h>0||m||N)&&(r.push({id:l,type:"position",position:{x:c.position.x-g+m,y:c.position.y-h+N}}),(p=n.get(l))==null||p.forEach(w=>{e.some(M=>M.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+g,y:w.position.y+h}})})),(u.width<a.width||u.height<a.height||g||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:x+(g?d[0]*g-m:0),height:y+(h?d[1]*h-N:0)}})}),r}function xd(e,t,n,o,r,i,s){const a=o==null?void 0:o.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],f=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const g of e.values()){const h=t.get(g.id);if(!h)continue;if(h.hidden){t.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),c=!0;continue}const x=Kn(g.nodeElement),y=h.measured.width!==x.width||h.measured.height!==x.height;if(!!(x.width&&x.height&&(y||!h.internals.handleBounds||g.force))){const N=g.nodeElement.getBoundingClientRect(),p=et(h.extent)?h.extent:i;let{positionAbsolute:w}=h.internals;h.parentId&&h.extent==="parent"?w=Zr(w,x,t.get(h.parentId)):p&&(w=He(w,p,x));const M={...h,measured:x,internals:{...h.internals,positionAbsolute:w,handleBounds:{source:Lo("source",g.nodeElement,N,u,h.id),target:Lo("target",g.nodeElement,N,u,h.id)}}};t.set(h.id,M),h.parentId&&eo(M,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,y&&(l.push({id:h.id,type:"dimensions",dimensions:x}),h.expandParent&&h.parentId&&d.push({id:h.id,parentId:h.parentId,rect:Je(M,r)}))}}if(d.length>0){const g=to(d,t,n,r);l.push(...g)}return{changes:l,updatedInternals:c}}async function wd({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Oo(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 c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function di(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,f=`${i}-${a}--${r}-${s}`;Oo("source",c,f,e,r,s),Oo("target",c,l,e,i,a),t.set(o.id,o)}}function fi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:fi(n,t):!1}function Fo(e,t,n){var r;let o=e;do{if((r=o==null?void 0:o.matches)!=null&&r.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function vd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!fi(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 wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var s,a,c;const r=[];for(const[l,f]of t){const u=(s=n.get(l))==null?void 0:s.internals.userNode;u&&r.push({...u,position:f.position,dragging:o})}if(!e)return[r[0],r];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:o}:r[0],r]}function bd({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=Nt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _d({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},f=null,u=!1,d=null,g=!1,h=!1,x=null;function y({noDragClassName:N,handleSelector:p,domNode:w,isSelectable:M,nodeId:_,nodeClickDistance:C=0}){d=le(w);function T({x:P,y:H}){const{nodeLookup:b,nodeExtent:A,snapGrid:E,snapToGrid:L,nodeOrigin:I,onNodeDrag:S,onSelectionDrag:z,onError:R,updateNodePositions:j}=t();i={x:P,y:H};let V=!1;const B=a.size>1,Y=B&&A?Pn(_t(a)):null,U=B&&L?bd({dragItems:a,snapGrid:E,x:P,y:H}):null;for(const[W,F]of a){if(!b.has(W))continue;let G={x:P-F.distance.x,y:H-F.distance.y};L&&(G=U?{x:Math.round(G.x+U.x),y:Math.round(G.y+U.y)}:Nt(G,E));let Q=null;if(B&&A&&!F.extent&&Y){const{positionAbsolute:q}=F.internals,te=q.x-Y.x+A[0][0],oe=q.x+F.measured.width-Y.x2+A[1][0],ee=q.y-Y.y+A[0][1],ae=q.y+F.measured.height-Y.y2+A[1][1];Q=[[te,ee],[oe,ae]]}const{position:Z,positionAbsolute:K}=Kr({nodeId:W,nextPosition:G,nodeLookup:b,nodeExtent:Q||A,nodeOrigin:I,onError:R});V=V||F.position.x!==Z.x||F.position.y!==Z.y,F.position=Z,F.internals.positionAbsolute=K}if(h=h||V,!!V&&(j(a,!0),x&&(o||S||!_&&z))){const[W,F]=wn({nodeId:_,dragItems:a,nodeLookup:b});o==null||o(x,a,W,F),S==null||S(x,W,F),_||z==null||z(x,F)}}async function D(){if(!f)return;const{transform:P,panBy:H,autoPanSpeed:b,autoPanOnNodeDrag:A}=t();if(!A){c=!1,cancelAnimationFrame(s);return}const[E,L]=Qr(l,f,b);(E!==0||L!==0)&&(i.x=(i.x??0)-E/P[2],i.y=(i.y??0)-L/P[2],await H({x:E,y:L})&&T(i)),s=requestAnimationFrame(D)}function O(P){var B;const{nodeLookup:H,multiSelectionActive:b,nodesDraggable:A,transform:E,snapGrid:L,snapToGrid:I,selectNodesOnDrag:S,onNodeDragStart:z,onSelectionDragStart:R,unselectNodesAndEdges:j}=t();u=!0,(!S||!M)&&!b&&_&&((B=H.get(_))!=null&&B.selected||j()),M&&S&&_&&(e==null||e(_));const V=ut(P.sourceEvent,{transform:E,snapGrid:L,snapToGrid:I,containerBounds:f});if(i=V,a=vd(H,A,V,_),a.size>0&&(n||z||!_&&R)){const[Y,U]=wn({nodeId:_,dragItems:a,nodeLookup:H});n==null||n(P.sourceEvent,a,Y,U),z==null||z(P.sourceEvent,Y,U),_||R==null||R(P.sourceEvent,U)}}const $=Ir().clickDistance(C).on("start",P=>{const{domNode:H,nodeDragThreshold:b,transform:A,snapGrid:E,snapToGrid:L}=t();f=(H==null?void 0:H.getBoundingClientRect())||null,g=!1,h=!1,x=P.sourceEvent,b===0&&O(P),i=ut(P.sourceEvent,{transform:A,snapGrid:E,snapToGrid:L,containerBounds:f}),l=pe(P.sourceEvent,f)}).on("drag",P=>{const{autoPanOnNodeDrag:H,transform:b,snapGrid:A,snapToGrid:E,nodeDragThreshold:L,nodeLookup:I}=t(),S=ut(P.sourceEvent,{transform:b,snapGrid:A,snapToGrid:E,containerBounds:f});if(x=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||_&&!I.has(_))&&(g=!0),!g){if(!c&&H&&u&&(c=!0,D()),!u){const z=pe(P.sourceEvent,f),R=z.x-l.x,j=z.y-l.y;Math.sqrt(R*R+j*j)>L&&O(P)}(i.x!==S.xSnapped||i.y!==S.ySnapped)&&a&&u&&(l=pe(P.sourceEvent,f),T(S))}}).on("end",P=>{if(!(!u||g)&&(c=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:H,updateNodePositions:b,onNodeDragStop:A,onSelectionDragStop:E}=t();if(h&&(b(a,!1),h=!1),r||A||!_&&E){const[L,I]=wn({nodeId:_,dragItems:a,nodeLookup:H,dragging:!1});r==null||r(P.sourceEvent,a,L,I),A==null||A(P.sourceEvent,L,I),_||E==null||E(P.sourceEvent,I)}}}).filter(P=>{const H=P.target;return!P.button&&(!N||!Fo(H,`.${N}`,w))&&(!p||Fo(H,p,w))});d.call($)}function m(){d==null||d.on(".drag",null)}return{update:y,destroy:m}}function Nd(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())mt(r,Je(i))>0&&o.push(i);return o}const Ed=250;function Sd(e,t,n,o){var a,c;let r=[],i=1/0;const s=Nd(e,n,t+Ed);for(const l of s){const f=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of f){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:d,y:g}=Oe(l,u,u.position,!0),h=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(g-e.y,2));h>t||(h<i?(r=[{...u,x:d,y:g}],i=h):h===i&&r.push({...u,x:d,y:g}))}}if(!r.length)return null;if(r.length>1){const l=o.type==="source"?"target":"source";return r.find(f=>f.type===l)??r[0]}return r[0]}function hi(e,t,n,o,r,i=!1){var l,f,u;const s=o.get(e);if(!s)return null;const a=r==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((u=s.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...Oe(s,c,c.position,!0)}:c}function gi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Cd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const pi=()=>!0;function Md(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:f,flowId:u,panBy:d,cancelConnection:g,onConnectStart:h,onConnect:x,onConnectEnd:y,isValidConnection:m=pi,onReconnectEnd:N,updateConnection:p,getTransform:w,getFromHandle:M,autoPanSpeed:_,dragThreshold:C=1,handleDomNode:T}){const D=ni(e.target);let O=0,$;const{x:P,y:H}=pe(e),b=gi(i,T),A=a==null?void 0:a.getBoundingClientRect();let E=!1;if(!A||!b)return;const L=hi(r,b,o,c,t);if(!L)return;let I=pe(e,A),S=!1,z=null,R=!1,j=null;function V(){if(!f||!A)return;const[Z,K]=Qr(I,A,_);d({x:Z,y:K}),O=requestAnimationFrame(V)}const B={...L,nodeId:r,type:b,position:L.position},Y=c.get(r);let W={inProgress:!0,isValid:null,from:Oe(Y,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:I,toHandle:null,toPosition:Io[B.position],toNode:null,pointer:I};function F(){E=!0,p(W),h==null||h(e,{nodeId:r,handleId:o,handleType:b})}C===0&&F();function G(Z){if(!E){const{x:ae,y:Ce}=pe(Z),be=ae-P,Te=Ce-H;if(!(be*be+Te*Te>C*C))return;F()}if(!M()||!B){Q(Z);return}const K=w();I=pe(Z,A),$=Sd(Et(I,K,!1,[1,1]),n,c,B),S||(V(),S=!0);const q=mi(Z,{handle:$,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:D,lib:l,flowId:u,nodeLookup:c});j=q.handleDomNode,z=q.connection,R=Cd(!!$,q.isValid);const te=c.get(r),oe=te?Oe(te,B,X.Left,!0):W.from,ee={...W,from:oe,isValid:R,to:q.toHandle&&R?Kt({x:q.toHandle.x,y:q.toHandle.y},K):I,toHandle:q.toHandle,toPosition:R&&q.toHandle?q.toHandle.position:Io[B.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:I};p(ee),W=ee}function Q(Z){if(!("touches"in Z&&Z.touches.length>0)){if(E){($||j)&&z&&R&&(x==null||x(z));const{inProgress:K,...q}=W,te={...q,toPosition:W.toHandle?W.toPosition:null};y==null||y(Z,te),i&&(N==null||N(Z,te))}g(),cancelAnimationFrame(O),S=!1,R=!1,z=null,j=null,D.removeEventListener("mousemove",G),D.removeEventListener("mouseup",Q),D.removeEventListener("touchmove",G),D.removeEventListener("touchend",Q)}}D.addEventListener("mousemove",G),D.addEventListener("mouseup",Q),D.addEventListener("touchmove",G),D.addEventListener("touchend",Q)}function mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=pi,nodeLookup:f}){const u=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:g,y:h}=pe(e),x=s.elementFromPoint(g,h),y=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:d,m={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const N=gi(void 0,y),p=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),M=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!p||!N)return m;const C={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=C;const D=M&&_&&(n===Ke.Strict?u&&N==="source"||!u&&N==="target":p!==o||w!==r);m.isValid=D&&l(C),m.toHandle=hi(p,N,w,f,n,!0)}return m}const Rn={onPointerDown:Md,isValid:mi};function kd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:c,height:l,zoomStep:f=1,pannable:u=!0,zoomable:d=!0,inversePan:g=!1}){const h=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),M=p.sourceEvent.ctrlKey&&yt()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,C=w[2]*Math.pow(2,_*M);t.scaleTo(C)};let x=[0,0];const y=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(x=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const M=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],_=[M[0]-x[0],M[1]-x[1]];x=M;const C=o()*Math.max(w[2],Math.log(w[2]))*(g?-1:1),T={x:w[0]-_[0]*C,y:w[1]-_[1]*C},D=[[0,0],[c,l]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},D,a)},N=Xr().on("start",y).on("zoom",u?m:null).on("zoom.wheel",d?h:null);r.call(N,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),yi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Id=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=Id,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},xi=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function $d({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return f=>{if(Xe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&s){const y=fe(f),m=xi(f),N=u*Math.pow(2,m);o.scaleTo(n,N,y,f);return}const d=f.deltaMode===1?20:1;let g=r===ze.Vertical?0:f.deltaX*d,h=r===ze.Horizontal?0:f.deltaY*d;!yt()&&f.shiftKey&&r!==ze.Vertical&&(g=f.deltaY*d,h=0),o.translateBy(n,-(g/u)*i,-(h/u)*i,{internal:!0});const x=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,x),e.panScrollTimeout=setTimeout(()=>{l==null||l(f,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(f,x))}}function Ad({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Xe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Td({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var i,s,a;if((i=o.sourceEvent)!=null&&i.internal)return;const r=sn(o.transform);e.mouseButton=((s=o.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=o.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,r))}}function Ld({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&yi(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!((a=i.sourceEvent)!=null&&a.internal)&&(r==null||r(i.sourceEvent,sn(i.transform)))}}function Pd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&yi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=sn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function Dd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:f}){return u=>{var y;const d=e||t,g=n&&u.ctrlKey,h=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Xe(u,`${l}-flow__node`)||Xe(u,`${l}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||f&&!h||Xe(u,a)&&h||Xe(u,c)&&(!h||r&&h&&!e)||!n&&u.ctrlKey&&h)return!1;if(!n&&u.type==="touchstart"&&((y=u.touches)==null?void 0:y.length)>1)return u.preventDefault(),!1;if(!d&&!r&&!g&&h||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||h)&&x}}function zd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),u=Xr().scaleExtent([t,n]).translateExtent(o),d=le(e).call(u);N({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[f.width,f.height]],o);const g=d.on("wheel.zoom"),h=d.on("dblclick.zoom");u.wheelDelta(xi);function x($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).transform(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function y({noWheelClassName:$,noPanClassName:P,onPaneContextMenu:H,userSelectionActive:b,panOnScroll:A,panOnDrag:E,panOnScrollMode:L,panOnScrollSpeed:I,preventScrolling:S,zoomOnPinch:z,zoomOnScroll:R,zoomOnDoubleClick:j,zoomActivationKeyPressed:V,lib:B,onTransformChange:Y,connectionInProgress:U,paneClickDistance:W,selectionOnDrag:F}){b&&!l.isZoomingOrPanning&&m();const G=A&&!V&&!b;u.clickDistance(F?1/0:!ge(W)||W<0?0:W);const Q=G?$d({zoomPanValues:l,noWheelClassName:$,d3Selection:d,d3Zoom:u,panOnScrollMode:L,panOnScrollSpeed:I,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Ad({noWheelClassName:$,preventScrolling:S,d3ZoomHandler:g});if(d.on("wheel.zoom",Q,{passive:!1}),!b){const K=Td({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});u.on("start",K);const q=Ld({zoomPanValues:l,panOnDrag:E,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:Y});u.on("zoom",q);const te=Pd({zoomPanValues:l,panOnDrag:E,panOnScroll:A,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:c});u.on("end",te)}const Z=Dd({zoomActivationKeyPressed:V,panOnDrag:E,zoomOnScroll:R,panOnScroll:A,zoomOnDoubleClick:j,zoomOnPinch:z,userSelectionActive:b,noPanClassName:P,noWheelClassName:$,lib:B,connectionInProgress:U});u.filter(Z),j?d.on("dblclick.zoom",h):d.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function N($,P,H){const b=vn($),A=u==null?void 0:u.constrain()(b,P,H);return A&&await x(A),new Promise(E=>E(A))}async function p($,P){const H=vn($);return await x(H,P),new Promise(b=>b(H))}function w($){if(d){const P=vn($),H=d.property("__zoom");(H.k!==$.zoom||H.x!==$.x||H.y!==$.y)&&(u==null||u.transform(d,P,null,{sync:!0}))}}function M(){const $=d?Br(d.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function _($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).scaleTo(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function C($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).scaleBy(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function T($){u==null||u.scaleExtent($)}function D($){u==null||u.translateExtent($)}function O($){const P=!ge($)||$<0?0:$;u==null||u.clickDistance(P)}return{update:y,destroy:m,setViewport:p,setViewportConstrained:N,getViewport:M,scaleTo:_,scaleBy:C,setScaleExtent:T,setTranslateExtent:D,syncViewport:w,setClickDistance:O}}var Fe;(function(e){e.Line="line",e.Handle="handle"})(Fe||(Fe={}));const jd=["top-left","top-right","bottom-left","bottom-right"],Rd=["top","right","bottom","left"];function Hd({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function Vo(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 Me(e,t){return Math.max(0,t-e)}function ke(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Bo(e,t){return e?!t:t}function Od(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:f,isVertical:u}=t,d=f&&u,{xSnapped:g,ySnapped:h}=n,{minWidth:x,maxWidth:y,minHeight:m,maxHeight:N}=o,{x:p,y:w,width:M,height:_,aspectRatio:C}=e;let T=Math.floor(f?g-e.pointerX:0),D=Math.floor(u?h-e.pointerY:0);const O=M+(c?-T:T),$=_+(l?-D:D),P=-i[0]*M,H=-i[1]*_;let b=Lt(O,x,y),A=Lt($,m,N);if(s){let I=0,S=0;c&&T<0?I=Me(p+T+P,s[0][0]):!c&&T>0&&(I=ke(p+O+P,s[1][0])),l&&D<0?S=Me(w+D+H,s[0][1]):!l&&D>0&&(S=ke(w+$+H,s[1][1])),b=Math.max(b,I),A=Math.max(A,S)}if(a){let I=0,S=0;c&&T>0?I=ke(p+T,a[0][0]):!c&&T<0&&(I=Me(p+O,a[1][0])),l&&D>0?S=ke(w+D,a[0][1]):!l&&D<0&&(S=Me(w+$,a[1][1])),b=Math.max(b,I),A=Math.max(A,S)}if(r){if(f){const I=Lt(O/C,m,N)*C;if(b=Math.max(b,I),s){let S=0;!c&&!l||c&&!l&&d?S=ke(w+H+O/C,s[1][1])*C:S=Me(w+H+(c?T:-T)/C,s[0][1])*C,b=Math.max(b,S)}if(a){let S=0;!c&&!l||c&&!l&&d?S=Me(w+O/C,a[1][1])*C:S=ke(w+(c?T:-T)/C,a[0][1])*C,b=Math.max(b,S)}}if(u){const I=Lt($*C,x,y)/C;if(A=Math.max(A,I),s){let S=0;!c&&!l||l&&!c&&d?S=ke(p+$*C+P,s[1][0])/C:S=Me(p+(l?D:-D)*C+P,s[0][0])/C,A=Math.max(A,S)}if(a){let S=0;!c&&!l||l&&!c&&d?S=Me(p+$*C,a[1][0])/C:S=ke(p+(l?D:-D)*C,a[0][0])/C,A=Math.max(A,S)}}}D=D+(D<0?A:-A),T=T+(T<0?b:-b),r&&(d?O>$*C?D=(Bo(c,l)?-T:T)/C:T=(Bo(c,l)?-D:D)*C:f?(D=T/C,l=c):(T=D*C,c=l));const E=c?p+T:p,L=l?w+D:w;return{width:M+(c?-T:T),height:_+(l?-D:D),x:i[0]*T*(c?-1:1)+E,y:i[1]*D*(l?-1:1)+L}}const wi={width:0,height:0,x:0,y:0},Fd={...wi,pointerX:0,pointerY:0,aspectRatio:1};function Vd(e){return[[0,0],[e.measured.width,e.measured.height]]}function Bd(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,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Xd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Vo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:f,keepAspectRatio:u,resizeDirection:d,onResizeStart:g,onResize:h,onResizeEnd:x,shouldResize:y}){let m={...wi},N={...Fd};s={boundaries:f,resizeDirection:d,keepAspectRatio:u,controlDirection:Vo(l)};let p,w=null,M=[],_,C,T,D=!1;const O=Ir().on("start",$=>{const{nodeLookup:P,transform:H,snapGrid:b,snapToGrid:A,nodeOrigin:E,paneDomNode:L}=n();if(p=P.get(t),!p)return;w=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:I,ySnapped:S}=ut($.sourceEvent,{transform:H,snapGrid:b,snapToGrid:A,containerBounds:w});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},N={...m,pointerX:I,pointerY:S,aspectRatio:m.width/m.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=P.get(p.parentId),C=_&&p.extent==="parent"?Vd(_):void 0),M=[],T=void 0;for(const[z,R]of P)if(R.parentId===t&&(M.push({id:z,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const j=Bd(R,p,R.origin??E);T?T=[[Math.min(j[0][0],T[0][0]),Math.min(j[0][1],T[0][1])],[Math.max(j[1][0],T[1][0]),Math.max(j[1][1],T[1][1])]]:T=j}g==null||g($,{...m})}).on("drag",$=>{const{transform:P,snapGrid:H,snapToGrid:b,nodeOrigin:A}=n(),E=ut($.sourceEvent,{transform:P,snapGrid:H,snapToGrid:b,containerBounds:w}),L=[];if(!p)return;const{x:I,y:S,width:z,height:R}=m,j={},V=p.origin??A,{width:B,height:Y,x:U,y:W}=Od(N,s.controlDirection,E,s.boundaries,s.keepAspectRatio,V,C,T),F=B!==z,G=Y!==R,Q=U!==I&&F,Z=W!==S&&G;if(!Q&&!Z&&!F&&!G)return;if((Q||Z||V[0]===1||V[1]===1)&&(j.x=Q?U:m.x,j.y=Z?W:m.y,m.x=j.x,m.y=j.y,M.length>0)){const oe=U-I,ee=W-S;for(const ae of M)ae.position={x:ae.position.x-oe+V[0]*(B-z),y:ae.position.y-ee+V[1]*(Y-R)},L.push(ae)}if((F||G)&&(j.width=F&&(!s.resizeDirection||s.resizeDirection==="horizontal")?B:m.width,j.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=j.width,m.height=j.height),_&&p.expandParent){const oe=V[0]*(j.width??0);j.x&&j.x<oe&&(m.x=oe,N.x=N.x-(j.x-oe));const ee=V[1]*(j.height??0);j.y&&j.y<ee&&(m.y=ee,N.y=N.y-(j.y-ee))}const K=Hd({width:m.width,prevWidth:z,height:m.height,prevHeight:R,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...m,direction:K};(y==null?void 0:y($,q))!==!1&&(D=!0,h==null||h($,q),o(j,L))}).on("end",$=>{D&&(x==null||x($,{...m}),r==null||r({...m}),D=!1)});i.call(O)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const{useDebugValue:Yd}=la,{useSyncExternalStoreWithSelector:Gd}=ca,Wd=e=>e;function vi(e,t=Wd,n){const o=Gd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Yd(o),o}const Xo=(e,t)=>{const n=aa(e),o=(r,i=t)=>vi(n,r,i);return Object.assign(o,n),o},qd=(e,t)=>e?Xo(e,t):Xo;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 an=k.createContext(null),Ud=an.Provider,bi=we.error001();function J(e,t){const n=k.useContext(an);if(n===null)throw new Error(bi);return vi(n,e,t)}function ie(){const e=k.useContext(an);if(e===null)throw new Error(bi);return k.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Yo={display:"none"},Kd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_i="react-flow__node-desc",Ni="react-flow__edge-desc",Zd="react-flow__aria-live",Qd=e=>e.ariaLiveMessage,Jd=e=>e.ariaLabelConfig;function ef({rfId:e}){const t=J(Qd);return v.jsx("div",{id:`${Zd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Kd,children:t})}function tf({rfId:e,disableKeyboardA11y:t}){const n=J(Jd);return v.jsxs(v.Fragment,{children:[v.jsx("div",{id:`${_i}-${e}`,style:Yo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),v.jsx("div",{id:`${Ni}-${e}`,style:Yo,children:n["edge.a11yDescription.default"]}),!t&&v.jsx(ef,{rfId:e})]})}const cn=k.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return v.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});cn.displayName="Panel";function nf({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:v.jsx(cn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:v.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const of=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}},Pt=e=>e.id;function rf(e,t){return re(e.selectedNodes.map(Pt),t.selectedNodes.map(Pt))&&re(e.selectedEdges.map(Pt),t.selectedEdges.map(Pt))}function sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=J(of,rf);return k.useEffect(()=>{const r={nodes:n,edges:o};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const af=e=>!!e.onSelectionChangeHandlers;function cf({onSelectionChange:e}){const t=J(af);return e||t?v.jsx(sf,{onSelectionChange:e}):null}const Ei=[0,0],lf={x:0,y:0,zoom:1},uf=["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"],Go=[...uf,"rfId"],df=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}),Wo={translateExtent:pt,nodeOrigin:Ei,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ff(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(df,re),l=ie();k.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Wo,a()}),[]);const f=k.useRef(Wo);return k.useEffect(()=>{for(const u of Go){const d=e[u],g=f.current[u];d!==g&&(typeof e[u]>"u"||(u==="nodes"?t(d):u==="edges"?n(d):u==="minZoom"?o(d):u==="maxZoom"?r(d):u==="translateExtent"?i(d):u==="nodeExtent"?s(d):u==="ariaLabelConfig"?l.setState({ariaLabelConfig:ed(d)}):u==="fitView"?l.setState({fitViewQueued:d}):u==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[u]:d})))}f.current=e},Go.map(u=>e[u])),null}function qo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function hf(e){var o;const[t,n]=k.useState(e==="system"?null:e);return k.useEffect(()=>{if(e!=="system"){n(e);return}const r=qo(),i=()=>n(r!=null&&r.matches?"dark":"light");return i(),r==null||r.addEventListener("change",i),()=>{r==null||r.removeEventListener("change",i)}},[e]),t!==null?t:(o=qo())!=null&&o.matches?"dark":"light"}const Uo=typeof document<"u"?document:null;function xt(e=null,t={target:Uo,actInsideInputWithModifier:!0}){const[n,o]=k.useState(!1),r=k.useRef(!1),i=k.useRef(new Set([])),[s,a]=k.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
1
|
+
import{a as aa,u as ca,R as la,r as k,j as v,c as ua}from"./index-BaOmyn11.js";function se(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=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var da={value:()=>{}};function Qt(){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 zt(n)}function zt(e){this._=e}function fa(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}})}zt.prototype=Qt.prototype={constructor:zt,on:function(e,t){var n=this._,o=fa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=ha(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]=fo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=fo(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 zt(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 ha(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function fo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=da,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cn="http://www.w3.org/1999/xhtml";const ho={svg:"http://www.w3.org/2000/svg",xhtml:Cn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ho.hasOwnProperty(t)?{space:ho[t],local:e}:e}function ga(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(n,e)}}function pa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pr(e){var t=Jt(e);return(t.local?pa:ga)(t)}function ma(){}function On(e){return e==null?ma:function(){return this.querySelector(e)}}function ya(e){typeof e!="function"&&(e=On(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),c,l,f=0;f<s;++f)(c=i[f])&&(l=e.call(c,c.__data__,f,i))&&("__data__"in c&&(l.__data__=c.__data__),a[f]=l);return new ue(o,this._parents)}function xa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wa(){return[]}function mr(e){return e==null?wa:function(){return this.querySelectorAll(e)}}function va(e){return function(){return xa(e.apply(this,arguments))}}function ba(e){typeof e=="function"?e=va(e):e=mr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new ue(o,r)}function yr(e){return function(){return this.matches(e)}}function xr(e){return function(t){return t.matches(e)}}var _a=Array.prototype.find;function Na(e){return function(){return _a.call(this.children,e)}}function Ea(){return this.firstElementChild}function Sa(e){return this.select(e==null?Ea:Na(typeof e=="function"?e:xr(e)))}var Ca=Array.prototype.filter;function Ma(){return Array.from(this.children)}function ka(e){return function(){return Ca.call(this.children,e)}}function Ia(e){return this.selectAll(e==null?Ma:ka(typeof e=="function"?e:xr(e)))}function $a(e){typeof e!="function"&&(e=yr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new ue(o,this._parents)}function wr(e){return new Array(e.length)}function Aa(){return new ue(this._enter||this._groups.map(wr),this._parents)}function Ft(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ft.prototype={constructor:Ft,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 Ta(e){return function(){return e}}function La(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ft(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Pa(e,t,n,o,r,i,s){var a,c,l=new Map,f=t.length,u=i.length,d=new Array(f),g;for(a=0;a<f;++a)(c=t[a])&&(d[a]=g=s.call(c,c.__data__,a,t)+"",l.has(g)?r[a]=c:l.set(g,c));for(a=0;a<u;++a)g=s.call(e,i[a],a,i)+"",(c=l.get(g))?(o[a]=c,c.__data__=i[a],l.delete(g)):n[a]=new Ft(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function Da(e){return e.__data__}function za(e,t){if(!arguments.length)return Array.from(this,Da);var n=t?Pa:La,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ta(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var f=o[l],u=r[l],d=u.length,g=ja(e.call(f,f&&f.__data__,l,o)),h=g.length,x=a[l]=new Array(h),y=s[l]=new Array(h),m=c[l]=new Array(d);n(f,u,x,y,m,g,t);for(var N=0,p=0,w,M;N<h;++N)if(w=x[N]){for(N>=p&&(p=N+1);!(M=y[p])&&++p<h;);w._next=M||null}}return s=new ue(s,o),s._enter=a,s._exit=c,s}function ja(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ra(){return new ue(this._exit||this._groups.map(wr),this._parents)}function Ha(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 Oa(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),c=0;c<s;++c)for(var l=n[c],f=o[c],u=l.length,d=a[c]=new Array(u),g,h=0;h<u;++h)(g=l[h]||f[h])&&(d[h]=g);for(;c<r;++c)a[c]=n[c];return new ue(a,this._parents)}function Fa(){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 Va(e){e||(e=Ba);function t(u,d){return u&&d?e(u.__data__,d.__data__):!u-!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,c=r[i]=new Array(a),l,f=0;f<a;++f)(l=s[f])&&(c[f]=l);c.sort(t)}return new ue(r,this._parents).order()}function Ba(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ya(){return Array.from(this)}function Ga(){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 Wa(){let e=0;for(const t of this)++e;return e}function qa(){return!this.node()}function Ua(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 Ka(e){return function(){this.removeAttribute(e)}}function Za(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qa(e,t){return function(){this.setAttribute(e,t)}}function Ja(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ec(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tc(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 nc(e,t){var n=Jt(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?Za:Ka:typeof t=="function"?n.local?tc:ec:n.local?Ja:Qa)(n,t))}function vr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oc(e){return function(){this.style.removeProperty(e)}}function rc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ic(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function sc(e,t,n){return arguments.length>1?this.each((t==null?oc:typeof t=="function"?ic:rc)(e,t,n??"")):qe(this.node(),e)}function qe(e,t){return e.style.getPropertyValue(t)||vr(e).getComputedStyle(e,null).getPropertyValue(t)}function ac(e){return function(){delete this[e]}}function cc(e,t){return function(){this[e]=t}}function lc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uc(e,t){return arguments.length>1?this.each((t==null?ac:typeof t=="function"?lc:cc)(e,t)):this.node()[e]}function br(e){return e.trim().split(/^|\s+/)}function Fn(e){return e.classList||new _r(e)}function _r(e){this._node=e,this._names=br(e.getAttribute("class")||"")}_r.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 Nr(e,t){for(var n=Fn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Er(e,t){for(var n=Fn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function dc(e){return function(){Nr(this,e)}}function fc(e){return function(){Er(this,e)}}function hc(e,t){return function(){(t.apply(this,arguments)?Nr:Er)(this,e)}}function gc(e,t){var n=br(e+"");if(arguments.length<2){for(var o=Fn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?hc:t?dc:fc)(n,t))}function pc(){this.textContent=""}function mc(e){return function(){this.textContent=e}}function yc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xc(e){return arguments.length?this.each(e==null?pc:(typeof e=="function"?yc:mc)(e)):this.node().textContent}function wc(){this.innerHTML=""}function vc(e){return function(){this.innerHTML=e}}function bc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _c(e){return arguments.length?this.each(e==null?wc:(typeof e=="function"?bc:vc)(e)):this.node().innerHTML}function Nc(){this.nextSibling&&this.parentNode.appendChild(this)}function Ec(){return this.each(Nc)}function Sc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cc(){return this.each(Sc)}function Mc(e){var t=typeof e=="function"?e:pr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kc(){return null}function Ic(e,t){var n=typeof e=="function"?e:pr(e),o=t==null?kc:typeof t=="function"?t:On(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function $c(){var e=this.parentNode;e&&e.removeChild(this)}function Ac(){return this.each($c)}function Tc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Lc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pc(e){return this.select(e?Lc:Tc)}function Dc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function zc(e){return function(t){e.call(this,t,this.__data__)}}function jc(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 Rc(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 Hc(e,t,n){return function(){var o=this.__on,r,i=zc(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 Oc(e,t,n){var o=jc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,f;c<l;++c)for(r=0,f=a[c];r<i;++r)if((s=o[r]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Hc:Rc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function Sr(e,t,n){var o=vr(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 Fc(e,t){return function(){return Sr(this,e,t)}}function Vc(e,t){return function(){return Sr(this,e,t.apply(this,arguments))}}function Bc(e,t){return this.each((typeof t=="function"?Vc:Fc)(e,t))}function*Xc(){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 Cr=[null];function ue(e,t){this._groups=e,this._parents=t}function wt(){return new ue([[document.documentElement]],Cr)}function Yc(){return this}ue.prototype=wt.prototype={constructor:ue,select:ya,selectAll:ba,selectChild:Sa,selectChildren:Ia,filter:$a,data:za,enter:Aa,exit:Ra,join:Ha,merge:Oa,selection:Yc,order:Fa,sort:Va,call:Xa,nodes:Ya,node:Ga,size:Wa,empty:qa,each:Ua,attr:nc,style:sc,property:uc,classed:gc,text:xc,html:_c,raise:Ec,lower:Cc,append:Mc,insert:Ic,remove:Ac,clone:Pc,datum:Dc,on:Oc,dispatch:Bc,[Symbol.iterator]:Xc};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Cr)}function Gc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Gc(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 Wc={passive:!1},dt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Ge(e){e.preventDefault(),e.stopImmediatePropagation()}function Mr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Ge,dt);"onselectstart"in t?n.on("selectstart.drag",Ge,dt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function kr(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ge,dt),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 Mt=e=>()=>e;function Mn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:f}){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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:f}})}Mn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function qc(e){return!e.ctrlKey&&!e.button}function Uc(){return this.parentNode}function Kc(e,t){return t??{x:e.x,y:e.y}}function Zc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ir(){var e=qc,t=Uc,n=Kc,o=Zc,r={},i=Qt("start","drag","end"),s=0,a,c,l,f,u=0;function d(w){w.on("mousedown.drag",g).filter(o).on("touchstart.drag",y).on("touchmove.drag",m,Wc).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(w,M){if(!(f||!e.call(this,w,M))){var _=p(this,t.call(this,w,M),w,M,"mouse");_&&(le(w.view).on("mousemove.drag",h,dt).on("mouseup.drag",x,dt),Mr(w.view),pn(w),l=!1,a=w.clientX,c=w.clientY,_("start",w))}}function h(w){if(Ge(w),!l){var M=w.clientX-a,_=w.clientY-c;l=M*M+_*_>u}r.mouse("drag",w)}function x(w){le(w.view).on("mousemove.drag mouseup.drag",null),kr(w.view,l),Ge(w),r.mouse("end",w)}function y(w,M){if(e.call(this,w,M)){var _=w.changedTouches,C=t.call(this,w,M),T=_.length,D,O;for(D=0;D<T;++D)(O=p(this,C,w,M,_[D].identifier,_[D]))&&(pn(w),O("start",w,_[D]))}}function m(w){var M=w.changedTouches,_=M.length,C,T;for(C=0;C<_;++C)(T=r[M[C].identifier])&&(Ge(w),T("drag",w,M[C]))}function N(w){var M=w.changedTouches,_=M.length,C,T;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),C=0;C<_;++C)(T=r[M[C].identifier])&&(pn(w),T("end",w,M[C]))}function p(w,M,_,C,T,D){var O=i.copy(),$=fe(D||_,M),P,H,b;if((b=n.call(w,new Mn("beforestart",{sourceEvent:_,target:d,identifier:T,active:s,x:$[0],y:$[1],dx:0,dy:0,dispatch:O}),C))!=null)return P=b.x-$[0]||0,H=b.y-$[1]||0,function A(E,L,I){var S=$,z;switch(E){case"start":r[T]=A,z=s++;break;case"end":delete r[T],--s;case"drag":$=fe(I||L,M),z=s;break}O.call(E,w,new Mn(E,{sourceEvent:L,subject:b,target:d,identifier:T,active:z,x:$[0]+P,y:$[1]+H,dx:$[0]-S[0],dy:$[1]-S[1],dispatch:O}),C)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Mt(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:Mt(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Mt(w),d):n},d.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Mt(!!w),d):o},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,d):Math.sqrt(u)},d}function Vn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function $r(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function vt(){}var ft=.7,Vt=1/ft,We="\\s*([+-]?\\d+)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Qc=/^#([0-9a-f]{3,8})$/,Jc=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),el=new RegExp(`^rgb\\(${xe},${xe},${xe}\\)$`),tl=new RegExp(`^rgba\\(${We},${We},${We},${ht}\\)$`),nl=new RegExp(`^rgba\\(${xe},${xe},${xe},${ht}\\)$`),ol=new RegExp(`^hsl\\(${ht},${xe},${xe}\\)$`),rl=new RegExp(`^hsla\\(${ht},${xe},${xe},${ht}\\)$`),go={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};Vn(vt,je,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:po,formatHex:po,formatHex8:il,formatHsl:sl,formatRgb:mo,toString:mo});function po(){return this.rgb().formatHex()}function il(){return this.rgb().formatHex8()}function sl(){return Ar(this).formatHsl()}function mo(){return this.rgb().formatRgb()}function je(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Qc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?yo(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kt(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=Jc.exec(e))?new ce(t[1],t[2],t[3],1):(t=el.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tl.exec(e))?kt(t[1],t[2],t[3],t[4]):(t=nl.exec(e))?kt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ol.exec(e))?vo(t[1],t[2]/100,t[3]/100,1):(t=rl.exec(e))?vo(t[1],t[2]/100,t[3]/100,t[4]):go.hasOwnProperty(e)?yo(go[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function yo(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function kt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function al(e){return e instanceof vt||(e=je(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function kn(e,t,n,o){return arguments.length===1?al(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Vn(ce,kn,$r(vt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Bt(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:xo,formatHex:xo,formatHex8:cl,formatRgb:wo,toString:wo}));function xo(){return`#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}`}function cl(){return`#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}${Pe((isNaN(this.opacity)?1:this.opacity)*255)}`}function wo(){const e=Bt(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Bt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Pe(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function vo(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 Ar(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=je(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,c=(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/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function ll(e,t,n,o){return arguments.length===1?Ar(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}Vn(he,ll,$r(vt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,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 ce(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new he(bo(this.h),It(this.s),It(this.l),Bt(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=Bt(this.opacity);return`${e===1?"hsl(":"hsla("}${bo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function bo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Bn=e=>()=>e;function ul(e,t){return function(n){return e+n*t}}function dl(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 fl(e){return(e=+e)==1?Tr:function(t,n){return n-t?dl(t,n,e):Bn(isNaN(t)?n:t)}}function Tr(e,t){var n=t-e;return n?ul(e,n):Bn(isNaN(e)?t:e)}const Xt=function e(t){var n=fl(t);function o(r,i){var s=n((r=kn(r)).r,(i=kn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=Tr(r.opacity,i.opacity);return function(f){return r.r=s(f),r.g=a(f),r.b=c(f),r.opacity=l(f),r+""}}return o.gamma=e,o}(1);function hl(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 gl(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pl(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]=lt(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 ml(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function ye(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yl(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]=lt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var In=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp(In.source,"g");function xl(e){return function(){return e}}function wl(e){return function(t){return e(t)+""}}function Lr(e,t){var n=In.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=In.exec(e))&&(r=yn.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,c.push({i:s,x:ye(o,r)})),n=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?wl(c[0].x):xl(t):(t=c.length,function(l){for(var f=0,u;f<t;++f)a[(u=c[f]).i]=u.x(l);return a.join("")})}function lt(e,t){var n=typeof t,o;return t==null||n==="boolean"?Bn(t):(n==="number"?ye:n==="string"?(o=je(t))?(t=o,Xt):Lr:t instanceof je?Xt:t instanceof Date?ml:gl(t)?hl:Array.isArray(t)?pl:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yl:ye)(e,t)}var _o=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pr(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*_o,skewX:Math.atan(c)*_o,scaleX:s,scaleY:a}}var $t;function vl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:Pr(t.a,t.b,t.c,t.d,t.e,t.f)}function bl(e){return e==null||($t||($t=document.createElementNS("http://www.w3.org/2000/svg","g")),$t.setAttribute("transform",e),!(e=$t.transform.baseVal.consolidate()))?$n:(e=e.matrix,Pr(e.a,e.b,e.c,e.d,e.e,e.f))}function Dr(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,f,u,d,g,h){if(l!==u||f!==d){var x=g.push("translate(",null,t,null,n);h.push({i:x-4,x:ye(l,u)},{i:x-2,x:ye(f,d)})}else(u||d)&&g.push("translate("+u+t+d+n)}function s(l,f,u,d){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),d.push({i:u.push(r(u)+"rotate(",null,o)-2,x:ye(l,f)})):f&&u.push(r(u)+"rotate("+f+o)}function a(l,f,u,d){l!==f?d.push({i:u.push(r(u)+"skewX(",null,o)-2,x:ye(l,f)}):f&&u.push(r(u)+"skewX("+f+o)}function c(l,f,u,d,g,h){if(l!==u||f!==d){var x=g.push(r(g)+"scale(",null,",",null,")");h.push({i:x-4,x:ye(l,u)},{i:x-2,x:ye(f,d)})}else(u!==1||d!==1)&&g.push(r(g)+"scale("+u+","+d+")")}return function(l,f){var u=[],d=[];return l=e(l),f=e(f),i(l.translateX,l.translateY,f.translateX,f.translateY,u,d),s(l.rotate,f.rotate,u,d),a(l.skewX,f.skewX,u,d),c(l.scaleX,l.scaleY,f.scaleX,f.scaleY,u,d),l=f=null,function(g){for(var h=-1,x=d.length,y;++h<x;)u[(y=d[h]).i]=y.x(g);return u.join("")}}}var _l=Dr(vl,"px, ","px)","deg)"),Nl=Dr(bl,", ",")",")"),El=1e-12;function No(e){return((e=Math.exp(e))+1/e)/2}function Sl(e){return((e=Math.exp(e))-1/e)/2}function Cl(e){return((e=Math.exp(2*e))-1)/(e+1)}const jt=function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],f=s[0],u=s[1],d=s[2],g=f-a,h=u-c,x=g*g+h*h,y,m;if(x<El)m=Math.log(d/l)/t,y=function(C){return[a+C*g,c+C*h,l*Math.exp(t*C*m)]};else{var N=Math.sqrt(x),p=(d*d-l*l+o*x)/(2*l*n*N),w=(d*d-l*l-o*x)/(2*d*n*N),M=Math.log(Math.sqrt(p*p+1)-p),_=Math.log(Math.sqrt(w*w+1)-w);m=(_-M)/t,y=function(C){var T=C*m,D=No(M),O=l/(n*N)*(D*Cl(t*T+M)-Sl(M));return[a+O*g,c+O*h,l*D/No(t*T+M)]}}return y.duration=m*1e3*t/Math.SQRT2,y}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r}(Math.SQRT2,2,4);var Ue=0,at=0,it=0,zr=1e3,Yt,ct,Gt=0,Re=0,en=0,gt=typeof performance=="object"&&performance.now?performance:Date,jr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xn(){return Re||(jr(Ml),Re=gt.now()+en)}function Ml(){Re=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=Rr.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Xn():+n)+(t==null?0:+t),!this._next&&ct!==this&&(ct?ct._next=this:Yt=this,ct=this),this._call=e,this._time=n,An()},stop:function(){this._call&&(this._call=null,this._time=1/0,An())}};function Rr(e,t,n){var o=new Wt;return o.restart(e,t,n),o}function kl(){Xn(),++Ue;for(var e=Yt,t;e;)(t=Re-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ue}function Eo(){Re=(Gt=gt.now())+en,Ue=at=0;try{kl()}finally{Ue=0,$l(),Re=0}}function Il(){var e=gt.now(),t=e-Gt;t>zr&&(en-=t,Gt=e)}function $l(){for(var e,t=Yt,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:Yt=n);ct=e,An(o)}function An(e){if(!Ue){at&&(at=clearTimeout(at));var t=e-Re;t>24?(e<1/0&&(at=setTimeout(Eo,e-gt.now()-en)),it&&(it=clearInterval(it))):(it||(Gt=gt.now(),it=setInterval(Il,zr)),Ue=1,jr(Eo))}}function So(e,t,n){var o=new Wt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Al=Qt("start","end","cancel","interrupt"),Tl=[],Hr=0,Co=1,Tn=2,Rt=3,Mo=4,Ln=5,Ht=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Ll(e,n,{name:t,index:o,group:r,on:Al,tween:Tl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Hr})}function Yn(e,t){var n=me(e,t);if(n.state>Hr)throw new Error("too late; already scheduled");return n}function ve(e,t){var n=me(e,t);if(n.state>Rt)throw new Error("too late; already running");return n}function me(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ll(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Rr(i,0,n.time);function i(l){n.state=Co,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var f,u,d,g;if(n.state!==Co)return c();for(f in o)if(g=o[f],g.name===n.name){if(g.state===Rt)return So(s);g.state===Mo?(g.state=Ht,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete o[f]):+f<t&&(g.state=Ht,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete o[f])}if(So(function(){n.state===Rt&&(n.state=Mo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Rt,r=new Array(d=n.tween.length),f=0,u=-1;f<d;++f)(g=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=g);r.length=u+1}}function a(l){for(var f=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Ln,1),u=-1,d=r.length;++u<d;)r[u].call(e,f);n.state===Ln&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ht,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Ot(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>Tn&&o.state<Ln,o.state=Ht,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Pl(e){return this.each(function(){Ot(this,e)})}function Dl(e,t){var n,o;return function(){var r=ve(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 zl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=ve(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function jl(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=me(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?Dl:zl)(n,e,t))}function Gn(e,t,n){var o=e._id;return e.each(function(){var r=ve(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return me(r,o).value[t]}}function Or(e,t){var n;return(typeof t=="number"?ye:t instanceof je?Xt:(n=je(t))?(t=n,Xt):Lr)(e,t)}function Rl(e){return function(){this.removeAttribute(e)}}function Hl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ol(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 Fl(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 Vl(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Bl(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Xl(e,t){var n=Jt(e),o=n==="transform"?Nl:Or;return this.attrTween(e,typeof t=="function"?(n.local?Bl:Vl)(n,o,Gn(this,"attr."+e,t)):t==null?(n.local?Hl:Rl)(n):(n.local?Fl:Ol)(n,o,t))}function Yl(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Gl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Wl(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Gl(e,i)),n}return r._value=t,r}function ql(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Yl(e,i)),n}return r._value=t,r}function Ul(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=Jt(e);return this.tween(n,(o.local?Wl:ql)(o,t))}function Kl(e,t){return function(){Yn(this,e).delay=+t.apply(this,arguments)}}function Zl(e,t){return t=+t,function(){Yn(this,e).delay=t}}function Ql(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kl:Zl)(t,e)):me(this.node(),t).delay}function Jl(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function eu(e,t){return t=+t,function(){ve(this,e).duration=t}}function tu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jl:eu)(t,e)):me(this.node(),t).duration}function nu(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function ou(e){var t=this._id;return arguments.length?this.each(nu(t,e)):me(this.node(),t).ease}function ru(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ve(this,e).ease=n}}function iu(e){if(typeof e!="function")throw new Error;return this.each(ru(this._id,e))}function su(e){typeof e!="function"&&(e=yr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Ee(o,this._parents,this._name,this._id)}function au(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 c=t[a],l=n[a],f=c.length,u=s[a]=new Array(f),d,g=0;g<f;++g)(d=c[g]||l[g])&&(u[g]=d);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function cu(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 lu(e,t,n){var o,r,i=cu(t)?Yn:ve;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function uu(e,t){var n=this._id;return arguments.length<2?me(this.node(),n).on.on(e):this.each(lu(n,e,t))}function du(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fu(){return this.on("end.remove",du(this._id))}function hu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=On(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),f,u,d=0;d<c;++d)(f=a[d])&&(u=e.call(f,f.__data__,d,a))&&("__data__"in f&&(u.__data__=f.__data__),l[d]=u,tn(l[d],t,n,d,l,me(f,n)));return new Ee(i,this._parents,t,n)}function gu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,f,u=0;u<l;++u)if(f=c[u]){for(var d=e.call(f,f.__data__,u,c),g,h=me(f,n),x=0,y=d.length;x<y;++x)(g=d[x])&&tn(g,t,n,x,d,h);i.push(d),s.push(f)}return new Ee(i,s,t,n)}var pu=wt.prototype.constructor;function mu(){return new pu(this._groups,this._parents)}function yu(e,t){var n,o,r;return function(){var i=qe(this,e),s=(this.style.removeProperty(e),qe(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Fr(e){return function(){this.style.removeProperty(e)}}function xu(e,t,n){var o,r=n+"",i;return function(){var s=qe(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function wu(e,t,n){var o,r,i;return function(){var s=qe(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),qe(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function vu(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=ve(this,e),l=c.on,f=c.value[i]==null?a||(a=Fr(t)):void 0;(l!==n||r!==f)&&(o=(n=l).copy()).on(s,r=f),c.on=o}}function bu(e,t,n){var o=(e+="")=="transform"?_l:Or;return t==null?this.styleTween(e,yu(e,o)).on("end.style."+e,Fr(e)):typeof t=="function"?this.styleTween(e,wu(e,o,Gn(this,"style."+e,t))).each(vu(this._id,e)):this.styleTween(e,xu(e,o,t),n).on("end.style."+e,null)}function _u(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Nu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&_u(e,s,n)),o}return i._value=t,i}function Eu(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,Nu(e,t,n??""))}function Su(e){return function(){this.textContent=e}}function Cu(e){return function(){var t=e(this);this.textContent=t??""}}function Mu(e){return this.tween("text",typeof e=="function"?Cu(Gn(this,"text",e)):Su(e==null?"":e+""))}function ku(e){return function(t){this.textContent=e.call(this,t)}}function Iu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ku(r)),t}return o._value=e,o}function $u(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,Iu(e))}function Au(){for(var e=this._name,t=this._id,n=Vr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var f=me(c,t);tn(c,e,n,l,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ee(o,this._parents,e,n)}function Tu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=ve(this,o),f=l.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Lu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Vr(){return++Lu}var _e=wt.prototype;Ee.prototype={constructor:Ee,select:hu,selectAll:gu,selectChild:_e.selectChild,selectChildren:_e.selectChildren,filter:su,merge:au,selection:mu,transition:Au,call:_e.call,nodes:_e.nodes,node:_e.node,size:_e.size,empty:_e.empty,each:_e.each,on:uu,attr:Xl,attrTween:Ul,style:bu,styleTween:Eu,text:Mu,textTween:$u,remove:fu,tween:jl,delay:Ql,duration:tu,ease:ou,easeVarying:iu,end:Tu,[Symbol.iterator]:_e[Symbol.iterator]};function Pu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Du={time:null,delay:0,duration:250,ease:Pu};function zu(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 ju(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Vr(),(n=Du).time=Xn(),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,c,l=0;l<a;++l)(c=s[l])&&tn(c,e,t,l,s,n||zu(c,t));return new Ee(o,this._parents,e,t)}wt.prototype.interrupt=Pl;wt.prototype.transition=ju;const At=e=>()=>e;function Ru(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 Ne(e,t,n){this.k=e,this.x=t,this.y=n}Ne.prototype={constructor:Ne,scale:function(e){return e===1?this:new Ne(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ne(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 nn=new Ne(1,0,0);Br.prototype=Ne.prototype;function Br(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function st(e){e.preventDefault(),e.stopImmediatePropagation()}function Hu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ou(){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 ko(){return this.__zoom||nn}function Fu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Vu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bu(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 Xr(){var e=Hu,t=Ou,n=Bu,o=Fu,r=Vu,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=jt,l=Qt("start","zoom","end"),f,u,d,g=500,h=150,x=0,y=10;function m(b){b.property("__zoom",ko).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",$).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(b,A,E,L){var I=b.selection?b.selection():b;I.property("__zoom",ko),b!==I?M(b,A,E,L):I.interrupt().each(function(){_(this,arguments).event(L).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},m.scaleBy=function(b,A,E,L){m.scaleTo(b,function(){var I=this.__zoom.k,S=typeof A=="function"?A.apply(this,arguments):A;return I*S},E,L)},m.scaleTo=function(b,A,E,L){m.transform(b,function(){var I=t.apply(this,arguments),S=this.__zoom,z=E==null?w(I):typeof E=="function"?E.apply(this,arguments):E,R=S.invert(z),j=typeof A=="function"?A.apply(this,arguments):A;return n(p(N(S,j),z,R),I,s)},E,L)},m.translateBy=function(b,A,E,L){m.transform(b,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),s)},null,L)},m.translateTo=function(b,A,E,L,I){m.transform(b,function(){var S=t.apply(this,arguments),z=this.__zoom,R=L==null?w(S):typeof L=="function"?L.apply(this,arguments):L;return n(nn.translate(R[0],R[1]).scale(z.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof E=="function"?-E.apply(this,arguments):-E),S,s)},L,I)};function N(b,A){return A=Math.max(i[0],Math.min(i[1],A)),A===b.k?b:new Ne(A,b.x,b.y)}function p(b,A,E){var L=A[0]-E[0]*b.k,I=A[1]-E[1]*b.k;return L===b.x&&I===b.y?b:new Ne(b.k,L,I)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function M(b,A,E,L){b.on("start.zoom",function(){_(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(L).end()}).tween("zoom",function(){var I=this,S=arguments,z=_(I,S).event(L),R=t.apply(I,S),j=E==null?w(R):typeof E=="function"?E.apply(I,S):E,V=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),B=I.__zoom,Y=typeof A=="function"?A.apply(I,S):A,U=c(B.invert(j).concat(V/B.k),Y.invert(j).concat(V/Y.k));return function(W){if(W===1)W=Y;else{var F=U(W),G=V/F[2];W=new Ne(G,j[0]-F[0]*G,j[1]-F[1]*G)}z.zoom(null,W)}})}function _(b,A,E){return!E&&b.__zooming||new C(b,A)}function C(b,A){this.that=b,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,A),this.taps=0}C.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,A){return this.mouse&&b!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var A=le(this.that).datum();l.call(b,this.that,new Ru(b,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),A)}};function T(b,...A){if(!e.apply(this,arguments))return;var E=_(this,A).event(b),L=this.__zoom,I=Math.max(i[0],Math.min(i[1],L.k*Math.pow(2,o.apply(this,arguments)))),S=fe(b);if(E.wheel)(E.mouse[0][0]!==S[0]||E.mouse[0][1]!==S[1])&&(E.mouse[1]=L.invert(E.mouse[0]=S)),clearTimeout(E.wheel);else{if(L.k===I)return;E.mouse=[S,L.invert(S)],Ot(this),E.start()}st(b),E.wheel=setTimeout(z,h),E.zoom("mouse",n(p(N(L,I),E.mouse[0],E.mouse[1]),E.extent,s));function z(){E.wheel=null,E.end()}}function D(b,...A){if(d||!e.apply(this,arguments))return;var E=b.currentTarget,L=_(this,A,!0).event(b),I=le(b.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",V,!0),S=fe(b,E),z=b.clientX,R=b.clientY;Mr(b.view),xn(b),L.mouse=[S,this.__zoom.invert(S)],Ot(this),L.start();function j(B){if(st(B),!L.moved){var Y=B.clientX-z,U=B.clientY-R;L.moved=Y*Y+U*U>x}L.event(B).zoom("mouse",n(p(L.that.__zoom,L.mouse[0]=fe(B,E),L.mouse[1]),L.extent,s))}function V(B){I.on("mousemove.zoom mouseup.zoom",null),kr(B.view,L.moved),st(B),L.event(B).end()}}function O(b,...A){if(e.apply(this,arguments)){var E=this.__zoom,L=fe(b.changedTouches?b.changedTouches[0]:b,this),I=E.invert(L),S=E.k*(b.shiftKey?.5:2),z=n(p(N(E,S),L,I),t.apply(this,A),s);st(b),a>0?le(this).transition().duration(a).call(M,z,L,b):le(this).call(m.transform,z,L,b)}}function $(b,...A){if(e.apply(this,arguments)){var E=b.touches,L=E.length,I=_(this,A,b.changedTouches.length===L).event(b),S,z,R,j;for(xn(b),z=0;z<L;++z)R=E[z],j=fe(R,this),j=[j,this.__zoom.invert(j),R.identifier],I.touch0?!I.touch1&&I.touch0[2]!==j[2]&&(I.touch1=j,I.taps=0):(I.touch0=j,S=!0,I.taps=1+!!f);f&&(f=clearTimeout(f)),S&&(I.taps<2&&(u=j[0],f=setTimeout(function(){f=null},g)),Ot(this),I.start())}}function P(b,...A){if(this.__zooming){var E=_(this,A).event(b),L=b.changedTouches,I=L.length,S,z,R,j;for(st(b),S=0;S<I;++S)z=L[S],R=fe(z,this),E.touch0&&E.touch0[2]===z.identifier?E.touch0[0]=R:E.touch1&&E.touch1[2]===z.identifier&&(E.touch1[0]=R);if(z=E.that.__zoom,E.touch1){var V=E.touch0[0],B=E.touch0[1],Y=E.touch1[0],U=E.touch1[1],W=(W=Y[0]-V[0])*W+(W=Y[1]-V[1])*W,F=(F=U[0]-B[0])*F+(F=U[1]-B[1])*F;z=N(z,Math.sqrt(W/F)),R=[(V[0]+Y[0])/2,(V[1]+Y[1])/2],j=[(B[0]+U[0])/2,(B[1]+U[1])/2]}else if(E.touch0)R=E.touch0[0],j=E.touch0[1];else return;E.zoom("touch",n(p(z,R,j),E.extent,s))}}function H(b,...A){if(this.__zooming){var E=_(this,A).event(b),L=b.changedTouches,I=L.length,S,z;for(xn(b),d&&clearTimeout(d),d=setTimeout(function(){d=null},g),S=0;S<I;++S)z=L[S],E.touch0&&E.touch0[2]===z.identifier?delete E.touch0:E.touch1&&E.touch1[2]===z.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(z=fe(z,this),Math.hypot(u[0]-z[0],u[1]-z[1])<y)){var R=le(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return m.wheelDelta=function(b){return arguments.length?(o=typeof b=="function"?b:At(+b),m):o},m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:At(!!b),m):e},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:At(!!b),m):r},m.extent=function(b){return arguments.length?(t=typeof b=="function"?b:At([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),m):t},m.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],m):[i[0],i[1]]},m.translateExtent=function(b){return arguments.length?(s[0][0]=+b[0][0],s[1][0]=+b[1][0],s[0][1]=+b[0][1],s[1][1]=+b[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(b){return arguments.length?(n=b,m):n},m.duration=function(b){return arguments.length?(a=+b,m):a},m.interpolate=function(b){return arguments.length?(c=b,m):c},m.on=function(){var b=l.on.apply(l,arguments);return b===l?m:b},m.clickDistance=function(b){return arguments.length?(x=(b=+b)*b,m):Math.sqrt(x)},m.tapDistance=function(b){return arguments.length?(y=+b,m):y},m}const we={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{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."},pt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yr=["Enter"," ","Escape"],Gr={"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 Ke;(function(e){e.Strict="strict",e.Loose="loose"})(Ke||(Ke={}));var ze;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ze||(ze={}));var Ze;(function(e){e.Partial="partial",e.Full="full"})(Ze||(Ze={}));const Wr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Io={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function qr(e){return e===null?null:e?"valid":"invalid"}const Ur=e=>"id"in e&&"source"in e&&"target"in e,Xu=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bt=(e,t=[0,0])=>{const{width:n,height:o}=Se(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Yu=(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):Wn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},_t=(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=on(n,Ut(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},qn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const l of e.values()){const{measured:f,selectable:u=!0,hidden:d=!1}=l;if(s&&!u||d)continue;const g=f.width??l.width??l.initialWidth??null,h=f.height??l.height??l.initialHeight??null,x=mt(a,Je(l)),y=(g??0)*(h??0),m=i&&x>0;(!l.internals.handleBounds||m||x>=y||l.dragging)&&c.push(l)}return c},Gu=(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 Wu(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function qu({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=Wu(e,s),c=_t(a),l=Un(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await o.setViewport(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Kr({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:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",we.error005());else{const g=a.measured.width,h=a.measured.height;g&&h&&(u=[[c,l],[c+g,l+h]])}else a&&et(s.extent)&&(u=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=et(u)?He(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",we.error015())),{position:{x:d.x-c+(s.measured.width??0)*f[0],y:d.y-l+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function Uu({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 g=i.has(d.id),h=!g&&d.parentId&&s.find(x=>x.id===d.parentId);(g||h)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),f=Gu(s,c);for(const d of c)a.has(d.id)&&!f.find(h=>h.id===d.id)&&f.push(d);if(!r)return{edges:f,nodes:s};const u=await r({nodes:s,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:s}:{edges:[],nodes:[]}:u}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Zr(e,t,n){const{width:o,height:r}=Se(n),{x:i,y:s}=n.internals.positionAbsolute;return He(e,[[i,s],[i+o,s+r]],t)}const $o=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Qr=(e,t,n=15,o=40)=>{const r=$o(e.x,o,t.width-o)*n,i=$o(e.y,o,t.height-o)*n;return[r,i]},on=(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)}),Pn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Je=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=Wn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:o,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=Wn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:o,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:o+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Jr=(e,t)=>rn(on(Pn(e),Pn(t))),mt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Ao=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Ku=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?Nt(a,s):a},Kt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Be(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Zu(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Be(e,n),r=Be(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Be(e.top??e.y??0,n),r=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),s=Be(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 Qu(e,t,n,o,r,i){const{x:s,y:a}=Kt(e,[t,n,o]),{x:c,y:l}=Kt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=r-c,u=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(u)}}const Un=(e,t,n,o,r,i)=>{const s=Zu(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),f=Qe(l,o,r),u=e.x+e.width/2,d=e.y+e.height/2,g=t/2-u*f,h=n/2-d*f,x=Qu(e,g,h,f,t,n),y={left:Math.min(x.left-s.left,0),top:Math.min(x.top-s.top,0),right:Math.min(x.right-s.right,0),bottom:Math.min(x.bottom-s.bottom,0)};return{x:g-y.left+y.right,y:h-y.top+y.bottom,zoom:f}},yt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function Se(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function ei(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ti(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 To(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Ju(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function ed(e){return{...Gr,...e||{}}}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=pe(e),a=Et({x:i-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},o),{x:c,y:l}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Kn=e=>({width:e.offsetWidth,height:e.offsetHeight}),ni=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},td=["INPUT","SELECT","TEXTAREA"];function oi(e){var o,r;const t=((r=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:td.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ri=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=ri(e),o=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Lo=(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,...Kn(s)}})};function ii({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,f=Math.abs(c-e),u=Math.abs(l-t);return[c,l,f,u]}function Tt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Po({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Tt(t-o,i),n];case X.Right:return[t+Tt(o-t,i),n];case X.Top:return[t,n-Tt(n-r,i)];case X.Bottom:return[t,n+Tt(r-n,i)]}}function si({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Po({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,f]=Po({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,d,g,h]=ii({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${o},${r}`,u,d,g,h]}function ai({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 nd({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 od({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(Ut(e),Ut(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 mt(s,rn(i))>0}const rd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,id=(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)),sd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||rd;let r;return Ur(e)?r={...e}:r={...e,id:o(e)},id(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function ci({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=ai({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Do={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},ad=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},zo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Do[t],c=Do[o],l={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},u=ad({source:l,sourcePosition:t,target:f}),d=u.x!==0?"x":"y",g=u[d];let h=[],x,y;const m={x:0,y:0},N={x:0,y:0},[,,p,w]=ai({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(x=r.x??l.x+(f.x-l.x)*s,y=r.y??(l.y+f.y)/2):(x=r.x??(l.x+f.x)/2,y=r.y??l.y+(f.y-l.y)*s);const _=[{x,y:l.y},{x,y:f.y}],C=[{x:l.x,y},{x:f.x,y}];a[d]===g?h=d==="x"?_:C:h=d==="x"?C:_}else{const _=[{x:l.x,y:f.y}],C=[{x:f.x,y:l.y}];if(d==="x"?h=a.x===g?C:_:h=a.y===g?_:C,t===o){const P=Math.abs(e[d]-n[d]);if(P<=i){const H=Math.min(i-1,i-P);a[d]===g?m[d]=(l[d]>e[d]?-1:1)*H:N[d]=(f[d]>n[d]?-1:1)*H}}if(t!==o){const P=d==="x"?"y":"x",H=a[d]===c[P],b=l[P]>f[P],A=l[P]<f[P];(a[d]===1&&(!H&&b||H&&A)||a[d]!==1&&(!H&&A||H&&b))&&(h=d==="x"?_:C)}const T={x:l.x+m.x,y:l.y+m.y},D={x:f.x+N.x,y:f.y+N.y},O=Math.max(Math.abs(T.x-h[0].x),Math.abs(D.x-h[0].x)),$=Math.max(Math.abs(T.y-h[0].y),Math.abs(D.y-h[0].y));O>=$?(x=(T.x+D.x)/2,y=h[0].y):(x=h[0].x,y=(T.y+D.y)/2)}return[[e,{x:l.x+m.x,y:l.y+m.y},...h,{x:f.x+N.x,y:f.y+N.y},n],x,y,p,w]}function ld(e,t,n,o){const r=Math.min(zo(e,t)/2,zo(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 l=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Dn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:f=.5}){const[u,d,g,h,x]=cd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:f});return[u.reduce((m,N,p)=>{let w="";return p>0&&p<u.length-1?w=ld(u[p-1],N,u[p+1],s):w=`${p===0?"M":"L"}${N.x} ${N.y}`,m+=w,m},""),d,g,h,x]}function jo(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ud(e){var u;const{sourceNode:t,targetNode:n}=e;if(!jo(t)||!jo(n))return null;const o=t.internals.handleBounds||Ro(t.handles),r=n.internals.handleBounds||Ro(n.handles),i=Ho((o==null?void 0:o.source)??[],e.sourceHandle),s=Ho(e.connectionMode===Ke.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!s)return(u=e.onError)==null||u.call(e,"008",we.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||X.Bottom,c=(s==null?void 0:s.position)||X.Top,l=Oe(t,i,a),f=Oe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Ro(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 Oe(e,t,n=X.Left,o=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Se(e);if(o)return{x:r+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function Ho(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function zn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function dd(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(c=>{if(c&&typeof c=="object"){const l=zn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const li=1e3,fd=10,Zn={nodeOrigin:[0,0],nodeExtent:pt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hd={...Zn,checkEquality:!0};function Qn(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function gd(e,t,n){const o=Qn(Zn,n);for(const r of e.values())if(r.parentId)eo(r,e,t,o);else{const i=bt(r,o.nodeOrigin),s=et(r.extent)?r.extent:o.nodeExtent,a=He(i,s,Se(r));r.internals.positionAbsolute=a}}function pd(e,t){if(!e.handles)return e.measured?t==null?void 0: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 Jn(e){return e==="manual"}function jn(e,t,n,o={}){var l,f;const r=Qn(hd,o),i={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Jn(r.zIndexMode)?li:0;let c=e.length>0;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===(d==null?void 0:d.internals.userNode))t.set(u.id,d);else{const g=bt(u,r.nodeOrigin),h=et(u.extent)?u.extent:r.nodeExtent,x=He(g,h,Se(u));d={...r.defaults,...u,measured:{width:(l=u.measured)==null?void 0:l.width,height:(f=u.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:pd(u,d),z:ui(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&eo(d,t,n,o,i)}return c}function md(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 eo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=Qn(Zn,o),l=e.parentId,f=t.get(l);if(!f){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}md(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*fd),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const u=i&&!Jn(c)?li:0,{x:d,y:g,z:h}=yd(e,f,s,a,u,c),{positionAbsolute:x}=e.internals,y=d!==x.x||g!==x.y;(y||h!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:d,y:g}:x,z:h}})}function ui(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return Jn(n)?o:o+(e.selected?t:0)}function yd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Se(e),l=bt(e,n),f=et(e.extent)?He(l,e.extent,c):l;let u=He({x:s+f.x,y:a+f.y},o,c);e.extent==="parent"&&(u=Zr(u,c,t));const d=ui(e,r,i),g=t.internals.z??0;return{x:u.x,y:u.y,z:g>=d?g+1:d}}function to(e,t,n,o=[0,0]){var s;const r=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),f=Jr(l,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const f=c.internals.positionAbsolute,u=Se(c),d=c.origin??o,g=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,h=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,x=Math.max(u.width,Math.round(a.width)),y=Math.max(u.height,Math.round(a.height)),m=(x-u.width)*d[0],N=(y-u.height)*d[1];(g>0||h>0||m||N)&&(r.push({id:l,type:"position",position:{x:c.position.x-g+m,y:c.position.y-h+N}}),(p=n.get(l))==null||p.forEach(w=>{e.some(M=>M.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+g,y:w.position.y+h}})})),(u.width<a.width||u.height<a.height||g||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:x+(g?d[0]*g-m:0),height:y+(h?d[1]*h-N:0)}})}),r}function xd(e,t,n,o,r,i,s){const a=o==null?void 0:o.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],f=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const g of e.values()){const h=t.get(g.id);if(!h)continue;if(h.hidden){t.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),c=!0;continue}const x=Kn(g.nodeElement),y=h.measured.width!==x.width||h.measured.height!==x.height;if(!!(x.width&&x.height&&(y||!h.internals.handleBounds||g.force))){const N=g.nodeElement.getBoundingClientRect(),p=et(h.extent)?h.extent:i;let{positionAbsolute:w}=h.internals;h.parentId&&h.extent==="parent"?w=Zr(w,x,t.get(h.parentId)):p&&(w=He(w,p,x));const M={...h,measured:x,internals:{...h.internals,positionAbsolute:w,handleBounds:{source:Lo("source",g.nodeElement,N,u,h.id),target:Lo("target",g.nodeElement,N,u,h.id)}}};t.set(h.id,M),h.parentId&&eo(M,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,y&&(l.push({id:h.id,type:"dimensions",dimensions:x}),h.expandParent&&h.parentId&&d.push({id:h.id,parentId:h.parentId,rect:Je(M,r)}))}}if(d.length>0){const g=to(d,t,n,r);l.push(...g)}return{changes:l,updatedInternals:c}}async function wd({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Oo(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 c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function di(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,f=`${i}-${a}--${r}-${s}`;Oo("source",c,f,e,r,s),Oo("target",c,l,e,i,a),t.set(o.id,o)}}function fi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:fi(n,t):!1}function Fo(e,t,n){var r;let o=e;do{if((r=o==null?void 0:o.matches)!=null&&r.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function vd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!fi(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 wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var s,a,c;const r=[];for(const[l,f]of t){const u=(s=n.get(l))==null?void 0:s.internals.userNode;u&&r.push({...u,position:f.position,dragging:o})}if(!e)return[r[0],r];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:o}:r[0],r]}function bd({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=Nt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _d({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},f=null,u=!1,d=null,g=!1,h=!1,x=null;function y({noDragClassName:N,handleSelector:p,domNode:w,isSelectable:M,nodeId:_,nodeClickDistance:C=0}){d=le(w);function T({x:P,y:H}){const{nodeLookup:b,nodeExtent:A,snapGrid:E,snapToGrid:L,nodeOrigin:I,onNodeDrag:S,onSelectionDrag:z,onError:R,updateNodePositions:j}=t();i={x:P,y:H};let V=!1;const B=a.size>1,Y=B&&A?Pn(_t(a)):null,U=B&&L?bd({dragItems:a,snapGrid:E,x:P,y:H}):null;for(const[W,F]of a){if(!b.has(W))continue;let G={x:P-F.distance.x,y:H-F.distance.y};L&&(G=U?{x:Math.round(G.x+U.x),y:Math.round(G.y+U.y)}:Nt(G,E));let Q=null;if(B&&A&&!F.extent&&Y){const{positionAbsolute:q}=F.internals,te=q.x-Y.x+A[0][0],oe=q.x+F.measured.width-Y.x2+A[1][0],ee=q.y-Y.y+A[0][1],ae=q.y+F.measured.height-Y.y2+A[1][1];Q=[[te,ee],[oe,ae]]}const{position:Z,positionAbsolute:K}=Kr({nodeId:W,nextPosition:G,nodeLookup:b,nodeExtent:Q||A,nodeOrigin:I,onError:R});V=V||F.position.x!==Z.x||F.position.y!==Z.y,F.position=Z,F.internals.positionAbsolute=K}if(h=h||V,!!V&&(j(a,!0),x&&(o||S||!_&&z))){const[W,F]=wn({nodeId:_,dragItems:a,nodeLookup:b});o==null||o(x,a,W,F),S==null||S(x,W,F),_||z==null||z(x,F)}}async function D(){if(!f)return;const{transform:P,panBy:H,autoPanSpeed:b,autoPanOnNodeDrag:A}=t();if(!A){c=!1,cancelAnimationFrame(s);return}const[E,L]=Qr(l,f,b);(E!==0||L!==0)&&(i.x=(i.x??0)-E/P[2],i.y=(i.y??0)-L/P[2],await H({x:E,y:L})&&T(i)),s=requestAnimationFrame(D)}function O(P){var B;const{nodeLookup:H,multiSelectionActive:b,nodesDraggable:A,transform:E,snapGrid:L,snapToGrid:I,selectNodesOnDrag:S,onNodeDragStart:z,onSelectionDragStart:R,unselectNodesAndEdges:j}=t();u=!0,(!S||!M)&&!b&&_&&((B=H.get(_))!=null&&B.selected||j()),M&&S&&_&&(e==null||e(_));const V=ut(P.sourceEvent,{transform:E,snapGrid:L,snapToGrid:I,containerBounds:f});if(i=V,a=vd(H,A,V,_),a.size>0&&(n||z||!_&&R)){const[Y,U]=wn({nodeId:_,dragItems:a,nodeLookup:H});n==null||n(P.sourceEvent,a,Y,U),z==null||z(P.sourceEvent,Y,U),_||R==null||R(P.sourceEvent,U)}}const $=Ir().clickDistance(C).on("start",P=>{const{domNode:H,nodeDragThreshold:b,transform:A,snapGrid:E,snapToGrid:L}=t();f=(H==null?void 0:H.getBoundingClientRect())||null,g=!1,h=!1,x=P.sourceEvent,b===0&&O(P),i=ut(P.sourceEvent,{transform:A,snapGrid:E,snapToGrid:L,containerBounds:f}),l=pe(P.sourceEvent,f)}).on("drag",P=>{const{autoPanOnNodeDrag:H,transform:b,snapGrid:A,snapToGrid:E,nodeDragThreshold:L,nodeLookup:I}=t(),S=ut(P.sourceEvent,{transform:b,snapGrid:A,snapToGrid:E,containerBounds:f});if(x=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||_&&!I.has(_))&&(g=!0),!g){if(!c&&H&&u&&(c=!0,D()),!u){const z=pe(P.sourceEvent,f),R=z.x-l.x,j=z.y-l.y;Math.sqrt(R*R+j*j)>L&&O(P)}(i.x!==S.xSnapped||i.y!==S.ySnapped)&&a&&u&&(l=pe(P.sourceEvent,f),T(S))}}).on("end",P=>{if(!(!u||g)&&(c=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:H,updateNodePositions:b,onNodeDragStop:A,onSelectionDragStop:E}=t();if(h&&(b(a,!1),h=!1),r||A||!_&&E){const[L,I]=wn({nodeId:_,dragItems:a,nodeLookup:H,dragging:!1});r==null||r(P.sourceEvent,a,L,I),A==null||A(P.sourceEvent,L,I),_||E==null||E(P.sourceEvent,I)}}}).filter(P=>{const H=P.target;return!P.button&&(!N||!Fo(H,`.${N}`,w))&&(!p||Fo(H,p,w))});d.call($)}function m(){d==null||d.on(".drag",null)}return{update:y,destroy:m}}function Nd(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())mt(r,Je(i))>0&&o.push(i);return o}const Ed=250;function Sd(e,t,n,o){var a,c;let r=[],i=1/0;const s=Nd(e,n,t+Ed);for(const l of s){const f=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of f){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:d,y:g}=Oe(l,u,u.position,!0),h=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(g-e.y,2));h>t||(h<i?(r=[{...u,x:d,y:g}],i=h):h===i&&r.push({...u,x:d,y:g}))}}if(!r.length)return null;if(r.length>1){const l=o.type==="source"?"target":"source";return r.find(f=>f.type===l)??r[0]}return r[0]}function hi(e,t,n,o,r,i=!1){var l,f,u;const s=o.get(e);if(!s)return null;const a=r==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((u=s.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...Oe(s,c,c.position,!0)}:c}function gi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Cd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const pi=()=>!0;function Md(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:f,flowId:u,panBy:d,cancelConnection:g,onConnectStart:h,onConnect:x,onConnectEnd:y,isValidConnection:m=pi,onReconnectEnd:N,updateConnection:p,getTransform:w,getFromHandle:M,autoPanSpeed:_,dragThreshold:C=1,handleDomNode:T}){const D=ni(e.target);let O=0,$;const{x:P,y:H}=pe(e),b=gi(i,T),A=a==null?void 0:a.getBoundingClientRect();let E=!1;if(!A||!b)return;const L=hi(r,b,o,c,t);if(!L)return;let I=pe(e,A),S=!1,z=null,R=!1,j=null;function V(){if(!f||!A)return;const[Z,K]=Qr(I,A,_);d({x:Z,y:K}),O=requestAnimationFrame(V)}const B={...L,nodeId:r,type:b,position:L.position},Y=c.get(r);let W={inProgress:!0,isValid:null,from:Oe(Y,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:I,toHandle:null,toPosition:Io[B.position],toNode:null,pointer:I};function F(){E=!0,p(W),h==null||h(e,{nodeId:r,handleId:o,handleType:b})}C===0&&F();function G(Z){if(!E){const{x:ae,y:Ce}=pe(Z),be=ae-P,Te=Ce-H;if(!(be*be+Te*Te>C*C))return;F()}if(!M()||!B){Q(Z);return}const K=w();I=pe(Z,A),$=Sd(Et(I,K,!1,[1,1]),n,c,B),S||(V(),S=!0);const q=mi(Z,{handle:$,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:D,lib:l,flowId:u,nodeLookup:c});j=q.handleDomNode,z=q.connection,R=Cd(!!$,q.isValid);const te=c.get(r),oe=te?Oe(te,B,X.Left,!0):W.from,ee={...W,from:oe,isValid:R,to:q.toHandle&&R?Kt({x:q.toHandle.x,y:q.toHandle.y},K):I,toHandle:q.toHandle,toPosition:R&&q.toHandle?q.toHandle.position:Io[B.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:I};p(ee),W=ee}function Q(Z){if(!("touches"in Z&&Z.touches.length>0)){if(E){($||j)&&z&&R&&(x==null||x(z));const{inProgress:K,...q}=W,te={...q,toPosition:W.toHandle?W.toPosition:null};y==null||y(Z,te),i&&(N==null||N(Z,te))}g(),cancelAnimationFrame(O),S=!1,R=!1,z=null,j=null,D.removeEventListener("mousemove",G),D.removeEventListener("mouseup",Q),D.removeEventListener("touchmove",G),D.removeEventListener("touchend",Q)}}D.addEventListener("mousemove",G),D.addEventListener("mouseup",Q),D.addEventListener("touchmove",G),D.addEventListener("touchend",Q)}function mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=pi,nodeLookup:f}){const u=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:g,y:h}=pe(e),x=s.elementFromPoint(g,h),y=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:d,m={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const N=gi(void 0,y),p=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),M=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!p||!N)return m;const C={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=C;const D=M&&_&&(n===Ke.Strict?u&&N==="source"||!u&&N==="target":p!==o||w!==r);m.isValid=D&&l(C),m.toHandle=hi(p,N,w,f,n,!0)}return m}const Rn={onPointerDown:Md,isValid:mi};function kd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:c,height:l,zoomStep:f=1,pannable:u=!0,zoomable:d=!0,inversePan:g=!1}){const h=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),M=p.sourceEvent.ctrlKey&&yt()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,C=w[2]*Math.pow(2,_*M);t.scaleTo(C)};let x=[0,0];const y=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(x=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const M=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],_=[M[0]-x[0],M[1]-x[1]];x=M;const C=o()*Math.max(w[2],Math.log(w[2]))*(g?-1:1),T={x:w[0]-_[0]*C,y:w[1]-_[1]*C},D=[[0,0],[c,l]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},D,a)},N=Xr().on("start",y).on("zoom",u?m:null).on("zoom.wheel",d?h:null);r.call(N,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),yi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Id=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=Id,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},xi=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function $d({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return f=>{if(Xe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&s){const y=fe(f),m=xi(f),N=u*Math.pow(2,m);o.scaleTo(n,N,y,f);return}const d=f.deltaMode===1?20:1;let g=r===ze.Vertical?0:f.deltaX*d,h=r===ze.Horizontal?0:f.deltaY*d;!yt()&&f.shiftKey&&r!==ze.Vertical&&(g=f.deltaY*d,h=0),o.translateBy(n,-(g/u)*i,-(h/u)*i,{internal:!0});const x=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,x),e.panScrollTimeout=setTimeout(()=>{l==null||l(f,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(f,x))}}function Ad({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Xe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Td({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var i,s,a;if((i=o.sourceEvent)!=null&&i.internal)return;const r=sn(o.transform);e.mouseButton=((s=o.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=o.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,r))}}function Ld({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&yi(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!((a=i.sourceEvent)!=null&&a.internal)&&(r==null||r(i.sourceEvent,sn(i.transform)))}}function Pd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&yi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=sn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function Dd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:f}){return u=>{var y;const d=e||t,g=n&&u.ctrlKey,h=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Xe(u,`${l}-flow__node`)||Xe(u,`${l}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||f&&!h||Xe(u,a)&&h||Xe(u,c)&&(!h||r&&h&&!e)||!n&&u.ctrlKey&&h)return!1;if(!n&&u.type==="touchstart"&&((y=u.touches)==null?void 0:y.length)>1)return u.preventDefault(),!1;if(!d&&!r&&!g&&h||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||h)&&x}}function zd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),u=Xr().scaleExtent([t,n]).translateExtent(o),d=le(e).call(u);N({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[f.width,f.height]],o);const g=d.on("wheel.zoom"),h=d.on("dblclick.zoom");u.wheelDelta(xi);function x($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).transform(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function y({noWheelClassName:$,noPanClassName:P,onPaneContextMenu:H,userSelectionActive:b,panOnScroll:A,panOnDrag:E,panOnScrollMode:L,panOnScrollSpeed:I,preventScrolling:S,zoomOnPinch:z,zoomOnScroll:R,zoomOnDoubleClick:j,zoomActivationKeyPressed:V,lib:B,onTransformChange:Y,connectionInProgress:U,paneClickDistance:W,selectionOnDrag:F}){b&&!l.isZoomingOrPanning&&m();const G=A&&!V&&!b;u.clickDistance(F?1/0:!ge(W)||W<0?0:W);const Q=G?$d({zoomPanValues:l,noWheelClassName:$,d3Selection:d,d3Zoom:u,panOnScrollMode:L,panOnScrollSpeed:I,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Ad({noWheelClassName:$,preventScrolling:S,d3ZoomHandler:g});if(d.on("wheel.zoom",Q,{passive:!1}),!b){const K=Td({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});u.on("start",K);const q=Ld({zoomPanValues:l,panOnDrag:E,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:Y});u.on("zoom",q);const te=Pd({zoomPanValues:l,panOnDrag:E,panOnScroll:A,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:c});u.on("end",te)}const Z=Dd({zoomActivationKeyPressed:V,panOnDrag:E,zoomOnScroll:R,panOnScroll:A,zoomOnDoubleClick:j,zoomOnPinch:z,userSelectionActive:b,noPanClassName:P,noWheelClassName:$,lib:B,connectionInProgress:U});u.filter(Z),j?d.on("dblclick.zoom",h):d.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function N($,P,H){const b=vn($),A=u==null?void 0:u.constrain()(b,P,H);return A&&await x(A),new Promise(E=>E(A))}async function p($,P){const H=vn($);return await x(H,P),new Promise(b=>b(H))}function w($){if(d){const P=vn($),H=d.property("__zoom");(H.k!==$.zoom||H.x!==$.x||H.y!==$.y)&&(u==null||u.transform(d,P,null,{sync:!0}))}}function M(){const $=d?Br(d.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function _($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).scaleTo(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function C($,P){return d?new Promise(H=>{u==null||u.interpolate((P==null?void 0:P.interpolate)==="linear"?lt:jt).scaleBy(bn(d,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),$)}):Promise.resolve(!1)}function T($){u==null||u.scaleExtent($)}function D($){u==null||u.translateExtent($)}function O($){const P=!ge($)||$<0?0:$;u==null||u.clickDistance(P)}return{update:y,destroy:m,setViewport:p,setViewportConstrained:N,getViewport:M,scaleTo:_,scaleBy:C,setScaleExtent:T,setTranslateExtent:D,syncViewport:w,setClickDistance:O}}var Fe;(function(e){e.Line="line",e.Handle="handle"})(Fe||(Fe={}));const jd=["top-left","top-right","bottom-left","bottom-right"],Rd=["top","right","bottom","left"];function Hd({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function Vo(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 Me(e,t){return Math.max(0,t-e)}function ke(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Bo(e,t){return e?!t:t}function Od(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:f,isVertical:u}=t,d=f&&u,{xSnapped:g,ySnapped:h}=n,{minWidth:x,maxWidth:y,minHeight:m,maxHeight:N}=o,{x:p,y:w,width:M,height:_,aspectRatio:C}=e;let T=Math.floor(f?g-e.pointerX:0),D=Math.floor(u?h-e.pointerY:0);const O=M+(c?-T:T),$=_+(l?-D:D),P=-i[0]*M,H=-i[1]*_;let b=Lt(O,x,y),A=Lt($,m,N);if(s){let I=0,S=0;c&&T<0?I=Me(p+T+P,s[0][0]):!c&&T>0&&(I=ke(p+O+P,s[1][0])),l&&D<0?S=Me(w+D+H,s[0][1]):!l&&D>0&&(S=ke(w+$+H,s[1][1])),b=Math.max(b,I),A=Math.max(A,S)}if(a){let I=0,S=0;c&&T>0?I=ke(p+T,a[0][0]):!c&&T<0&&(I=Me(p+O,a[1][0])),l&&D>0?S=ke(w+D,a[0][1]):!l&&D<0&&(S=Me(w+$,a[1][1])),b=Math.max(b,I),A=Math.max(A,S)}if(r){if(f){const I=Lt(O/C,m,N)*C;if(b=Math.max(b,I),s){let S=0;!c&&!l||c&&!l&&d?S=ke(w+H+O/C,s[1][1])*C:S=Me(w+H+(c?T:-T)/C,s[0][1])*C,b=Math.max(b,S)}if(a){let S=0;!c&&!l||c&&!l&&d?S=Me(w+O/C,a[1][1])*C:S=ke(w+(c?T:-T)/C,a[0][1])*C,b=Math.max(b,S)}}if(u){const I=Lt($*C,x,y)/C;if(A=Math.max(A,I),s){let S=0;!c&&!l||l&&!c&&d?S=ke(p+$*C+P,s[1][0])/C:S=Me(p+(l?D:-D)*C+P,s[0][0])/C,A=Math.max(A,S)}if(a){let S=0;!c&&!l||l&&!c&&d?S=Me(p+$*C,a[1][0])/C:S=ke(p+(l?D:-D)*C,a[0][0])/C,A=Math.max(A,S)}}}D=D+(D<0?A:-A),T=T+(T<0?b:-b),r&&(d?O>$*C?D=(Bo(c,l)?-T:T)/C:T=(Bo(c,l)?-D:D)*C:f?(D=T/C,l=c):(T=D*C,c=l));const E=c?p+T:p,L=l?w+D:w;return{width:M+(c?-T:T),height:_+(l?-D:D),x:i[0]*T*(c?-1:1)+E,y:i[1]*D*(l?-1:1)+L}}const wi={width:0,height:0,x:0,y:0},Fd={...wi,pointerX:0,pointerY:0,aspectRatio:1};function Vd(e){return[[0,0],[e.measured.width,e.measured.height]]}function Bd(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,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Xd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Vo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:f,keepAspectRatio:u,resizeDirection:d,onResizeStart:g,onResize:h,onResizeEnd:x,shouldResize:y}){let m={...wi},N={...Fd};s={boundaries:f,resizeDirection:d,keepAspectRatio:u,controlDirection:Vo(l)};let p,w=null,M=[],_,C,T,D=!1;const O=Ir().on("start",$=>{const{nodeLookup:P,transform:H,snapGrid:b,snapToGrid:A,nodeOrigin:E,paneDomNode:L}=n();if(p=P.get(t),!p)return;w=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:I,ySnapped:S}=ut($.sourceEvent,{transform:H,snapGrid:b,snapToGrid:A,containerBounds:w});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},N={...m,pointerX:I,pointerY:S,aspectRatio:m.width/m.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=P.get(p.parentId),C=_&&p.extent==="parent"?Vd(_):void 0),M=[],T=void 0;for(const[z,R]of P)if(R.parentId===t&&(M.push({id:z,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const j=Bd(R,p,R.origin??E);T?T=[[Math.min(j[0][0],T[0][0]),Math.min(j[0][1],T[0][1])],[Math.max(j[1][0],T[1][0]),Math.max(j[1][1],T[1][1])]]:T=j}g==null||g($,{...m})}).on("drag",$=>{const{transform:P,snapGrid:H,snapToGrid:b,nodeOrigin:A}=n(),E=ut($.sourceEvent,{transform:P,snapGrid:H,snapToGrid:b,containerBounds:w}),L=[];if(!p)return;const{x:I,y:S,width:z,height:R}=m,j={},V=p.origin??A,{width:B,height:Y,x:U,y:W}=Od(N,s.controlDirection,E,s.boundaries,s.keepAspectRatio,V,C,T),F=B!==z,G=Y!==R,Q=U!==I&&F,Z=W!==S&&G;if(!Q&&!Z&&!F&&!G)return;if((Q||Z||V[0]===1||V[1]===1)&&(j.x=Q?U:m.x,j.y=Z?W:m.y,m.x=j.x,m.y=j.y,M.length>0)){const oe=U-I,ee=W-S;for(const ae of M)ae.position={x:ae.position.x-oe+V[0]*(B-z),y:ae.position.y-ee+V[1]*(Y-R)},L.push(ae)}if((F||G)&&(j.width=F&&(!s.resizeDirection||s.resizeDirection==="horizontal")?B:m.width,j.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=j.width,m.height=j.height),_&&p.expandParent){const oe=V[0]*(j.width??0);j.x&&j.x<oe&&(m.x=oe,N.x=N.x-(j.x-oe));const ee=V[1]*(j.height??0);j.y&&j.y<ee&&(m.y=ee,N.y=N.y-(j.y-ee))}const K=Hd({width:m.width,prevWidth:z,height:m.height,prevHeight:R,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...m,direction:K};(y==null?void 0:y($,q))!==!1&&(D=!0,h==null||h($,q),o(j,L))}).on("end",$=>{D&&(x==null||x($,{...m}),r==null||r({...m}),D=!1)});i.call(O)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const{useDebugValue:Yd}=la,{useSyncExternalStoreWithSelector:Gd}=ca,Wd=e=>e;function vi(e,t=Wd,n){const o=Gd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Yd(o),o}const Xo=(e,t)=>{const n=aa(e),o=(r,i=t)=>vi(n,r,i);return Object.assign(o,n),o},qd=(e,t)=>e?Xo(e,t):Xo;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 an=k.createContext(null),Ud=an.Provider,bi=we.error001();function J(e,t){const n=k.useContext(an);if(n===null)throw new Error(bi);return vi(n,e,t)}function ie(){const e=k.useContext(an);if(e===null)throw new Error(bi);return k.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Yo={display:"none"},Kd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_i="react-flow__node-desc",Ni="react-flow__edge-desc",Zd="react-flow__aria-live",Qd=e=>e.ariaLiveMessage,Jd=e=>e.ariaLabelConfig;function ef({rfId:e}){const t=J(Qd);return v.jsx("div",{id:`${Zd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Kd,children:t})}function tf({rfId:e,disableKeyboardA11y:t}){const n=J(Jd);return v.jsxs(v.Fragment,{children:[v.jsx("div",{id:`${_i}-${e}`,style:Yo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),v.jsx("div",{id:`${Ni}-${e}`,style:Yo,children:n["edge.a11yDescription.default"]}),!t&&v.jsx(ef,{rfId:e})]})}const cn=k.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return v.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});cn.displayName="Panel";function nf({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:v.jsx(cn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:v.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const of=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}},Pt=e=>e.id;function rf(e,t){return re(e.selectedNodes.map(Pt),t.selectedNodes.map(Pt))&&re(e.selectedEdges.map(Pt),t.selectedEdges.map(Pt))}function sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=J(of,rf);return k.useEffect(()=>{const r={nodes:n,edges:o};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const af=e=>!!e.onSelectionChangeHandlers;function cf({onSelectionChange:e}){const t=J(af);return e||t?v.jsx(sf,{onSelectionChange:e}):null}const Ei=[0,0],lf={x:0,y:0,zoom:1},uf=["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"],Go=[...uf,"rfId"],df=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}),Wo={translateExtent:pt,nodeOrigin:Ei,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ff(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(df,re),l=ie();k.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Wo,a()}),[]);const f=k.useRef(Wo);return k.useEffect(()=>{for(const u of Go){const d=e[u],g=f.current[u];d!==g&&(typeof e[u]>"u"||(u==="nodes"?t(d):u==="edges"?n(d):u==="minZoom"?o(d):u==="maxZoom"?r(d):u==="translateExtent"?i(d):u==="nodeExtent"?s(d):u==="ariaLabelConfig"?l.setState({ariaLabelConfig:ed(d)}):u==="fitView"?l.setState({fitViewQueued:d}):u==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[u]:d})))}f.current=e},Go.map(u=>e[u])),null}function qo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function hf(e){var o;const[t,n]=k.useState(e==="system"?null:e);return k.useEffect(()=>{if(e!=="system"){n(e);return}const r=qo(),i=()=>n(r!=null&&r.matches?"dark":"light");return i(),r==null||r.addEventListener("change",i),()=>{r==null||r.removeEventListener("change",i)}},[e]),t!==null?t:(o=qo())!=null&&o.matches?"dark":"light"}const Uo=typeof document<"u"?document:null;function xt(e=null,t={target:Uo,actInsideInputWithModifier:!0}){const[n,o]=k.useState(!1),r=k.useRef(!1),i=k.useRef(new Set([])),[s,a]=k.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
5
5
|
+`).split(`
|
|
6
6
|
`)),f=l.reduce((u,d)=>u.concat(...d),[]);return[l,f]}return[[],[]]},[e]);return k.useEffect(()=>{const c=(t==null?void 0:t.target)??Uo,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=g=>{var y,m;if(r.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!r.current||r.current&&!l)&&oi(g))return!1;const x=Zo(g.code,a);if(i.current.add(g[x]),Ko(s,i.current,!1)){const N=((m=(y=g.composedPath)==null?void 0:y.call(g))==null?void 0:m[0])||g.target,p=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(r.current||!p)&&g.preventDefault(),o(!0)}},u=g=>{const h=Zo(g.code,a);Ko(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(g[h]),g.key==="Meta"&&i.current.clear(),r.current=!1},d=()=>{i.current.clear(),o(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function Ko(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function Zo(e,t){return t.includes(e)?"code":"key"}const gf=()=>{const e=ie();return k.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!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),Promise.resolve(!0)):Promise.resolve(!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(),c=Un(t,o,r,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},f=n.snapGrid??r,u=n.snapToGrid??i;return Et(l,o,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Kt(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Si(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 c of s)pf(c,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 pf(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 Ci(e,t){return Si(e,t)}function Mi(e,t){return Si(e,t)}function Le(e,t){return{id:e,type:"select",selected:t}}function Ye(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(Le(i.id,s)))}return o}function Qo({items:e=[],lookup:t}){var r;const n=[],o=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((r=a==null?void 0:a.internals)==null?void 0:r.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)o.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Jo(e){return{id:e.id,type:"remove"}}const er=e=>Xu(e),mf=e=>Ur(e);function ki(e){return k.forwardRef(e)}const yf=typeof window<"u"?k.useLayoutEffect:k.useEffect;function tr(e){const[t,n]=k.useState(BigInt(0)),[o]=k.useState(()=>xf(()=>n(r=>r+BigInt(1))));return yf(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function xf(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ii=k.createContext(null);function wf({children:e}){const t=ie(),n=k.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:f,onNodesChange:u,nodeLookup:d,fitViewQueued:g,onNodesChangeMiddlewareMap:h}=t.getState();let x=c;for(const m of a)x=typeof m=="function"?m(x):m;let y=Qo({items:x,lookup:d});for(const m of h.values())y=m(y);f&&l(x),y.length>0?u==null||u(y):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:N,setNodes:p}=t.getState();m&&p(N)})},[]),o=tr(n),r=k.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:d}=t.getState();let g=c;for(const h of a)g=typeof h=="function"?h(g):h;f?l(g):u&&u(Qo({items:g,lookup:d}))},[]),i=tr(r),s=k.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return v.jsx(Ii.Provider,{value:s,children:e})}function vf(){const e=k.useContext(Ii);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const bf=e=>!!e.panZoom;function ln(){const e=gf(),t=ie(),n=vf(),o=J(bf),r=k.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),s=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},c=u=>{var m,N;const{nodeLookup:d,nodeOrigin:g}=t.getState(),h=er(u)?u:d.get(u.id),x=h.parentId?ti(h.position,h.measured,h.parentId,d,g):h.position,y={...h,position:x,width:((m=h.measured)==null?void 0:m.width)??h.width,height:((N=h.measured)==null?void 0:N.height)??h.height};return Je(y)},l=(u,d,g={replace:!1})=>{s(h=>h.map(x=>{if(x.id===u){const y=typeof d=="function"?d(x):d;return g.replace&&er(y)?y:{...x,...y}}return x}))},f=(u,d,g={replace:!1})=>{a(h=>h.map(x=>{if(x.id===u){const y=typeof d=="function"?d(x):d;return g.replace&&mf(y)?y:{...x,...y}}return x}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var d;return(d=i(u))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(d=>({...d}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:s,setEdges:a,addNodes:u=>{const d=Array.isArray(u)?u:[u];n.nodeQueue.push(g=>[...g,...d])},addEdges:u=>{const d=Array.isArray(u)?u:[u];n.edgeQueue.push(g=>[...g,...d])},toObject:()=>{const{nodes:u=[],edges:d=[],transform:g}=t.getState(),[h,x,y]=g;return{nodes:u.map(m=>({...m})),edges:d.map(m=>({...m})),viewport:{x:h,y:x,zoom:y}}},deleteElements:async({nodes:u=[],edges:d=[]})=>{const{nodes:g,edges:h,onNodesDelete:x,onEdgesDelete:y,triggerNodeChanges:m,triggerEdgeChanges:N,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:M,edges:_}=await Uu({nodesToRemove:u,edgesToRemove:d,nodes:g,edges:h,onBeforeDelete:w}),C=_.length>0,T=M.length>0;if(C){const D=_.map(Jo);y==null||y(_),N(D)}if(T){const D=M.map(Jo);x==null||x(M),m(D)}return(T||C)&&(p==null||p({nodes:M,edges:_})),{deletedNodes:M,deletedEdges:_}},getIntersectingNodes:(u,d=!0,g)=>{const h=Ao(u),x=h?u:c(u),y=g!==void 0;return x?(g||t.getState().nodes).filter(m=>{const N=t.getState().nodeLookup.get(m.id);if(N&&!h&&(m.id===u.id||!N.internals.positionAbsolute))return!1;const p=Je(y?m:N),w=mt(p,x);return d&&w>0||w>=p.width*p.height||w>=x.width*x.height}):[]},isNodeIntersecting:(u,d,g=!0)=>{const x=Ao(u)?u:c(u);if(!x)return!1;const y=mt(x,d);return g&&y>0||y>=d.width*d.height||y>=x.width*x.height},updateNode:l,updateNodeData:(u,d,g={replace:!1})=>{l(u,h=>{const x=typeof d=="function"?d(h):d;return g.replace?{...h,data:x}:{...h,data:{...h.data,...x}}},g)},updateEdge:f,updateEdgeData:(u,d,g={replace:!1})=>{f(u,h=>{const x=typeof d=="function"?d(h):d;return g.replace?{...h,data:x}:{...h,data:{...h.data,...x}}},g)},getNodesBounds:u=>{const{nodeLookup:d,nodeOrigin:g}=t.getState();return Yu(u,{nodeLookup:d,nodeOrigin:g})},getHandleConnections:({type:u,id:d,nodeId:g})=>{var h;return Array.from(((h=t.getState().connectionLookup.get(`${g}-${u}${d?`-${d}`:""}`))==null?void 0:h.values())??[])},getNodeConnections:({type:u,handleId:d,nodeId:g})=>{var h;return Array.from(((h=t.getState().connectionLookup.get(`${g}${u?d?`-${u}-${d}`:`-${u}`:""}`))==null?void 0:h.values())??[])},fitView:async u=>{const d=t.getState().fitViewResolver??Ju();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:d}),n.nodeQueue.push(g=>[...g]),d.promise}}},[]);return k.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const nr=e=>e.selected,_f=typeof window<"u"?window:void 0;function Nf({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ie(),{deleteElements:o}=ln(),r=xt(e,{actInsideInputWithModifier:!1}),i=xt(t,{target:_f});k.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(nr),edges:s.filter(nr)}),n.setState({nodesSelectionActive:!1})}},[r]),k.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Ef(e){const t=ie();k.useEffect(()=>{const n=()=>{var r,i,s,a;if(!e.current||!(((i=(r=e.current).checkVisibility)==null?void 0:i.call(r))??!0))return!1;const o=Kn(e.current);(o.height===0||o.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",we.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 un={position:"absolute",width:"100%",height:"100%",top:0,left:0},Sf=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Cf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=ze.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:f,maxZoom:u,zoomActivationKeyCode:d,preventScrolling:g=!0,children:h,noWheelClassName:x,noPanClassName:y,onViewportChange:m,isControlledViewport:N,paneClickDistance:p,selectionOnDrag:w}){const M=ie(),_=k.useRef(null),{userSelectionActive:C,lib:T,connectionInProgress:D}=J(Sf,re),O=xt(d),$=k.useRef();Ef(_);const P=k.useCallback(H=>{m==null||m({x:H[0],y:H[1],zoom:H[2]}),N||M.setState({transform:H})},[m,N]);return k.useEffect(()=>{if(_.current){$.current=zd({domNode:_.current,minZoom:f,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:E=>M.setState(L=>L.paneDragging===E?L:{paneDragging:E}),onPanZoomStart:(E,L)=>{const{onViewportChangeStart:I,onMoveStart:S}=M.getState();S==null||S(E,L),I==null||I(L)},onPanZoom:(E,L)=>{const{onViewportChange:I,onMove:S}=M.getState();S==null||S(E,L),I==null||I(L)},onPanZoomEnd:(E,L)=>{const{onViewportChangeEnd:I,onMoveEnd:S}=M.getState();S==null||S(E,L),I==null||I(L)}});const{x:H,y:b,zoom:A}=$.current.getViewport();return M.setState({panZoom:$.current,transform:[H,b,A],domNode:_.current.closest(".react-flow")}),()=>{var E;(E=$.current)==null||E.destroy()}}},[]),k.useEffect(()=>{var H;(H=$.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:y,userSelectionActive:C,noWheelClassName:x,lib:T,onTransformChange:P,connectionInProgress:D,selectionOnDrag:w,paneClickDistance:p})},[e,t,n,o,r,i,s,a,O,g,y,C,x,T,P,D,w,p]),v.jsx("div",{className:"react-flow__renderer",ref:_,style:un,children:h})}const Mf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function kf(){const{userSelectionActive:e,userSelectionRect:t}=J(Mf,re);return e&&t?v.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 _n=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},If=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function $f({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ze.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:d,onPaneMouseLeave:g,children:h}){const x=ie(),{userSelectionActive:y,elementsSelectable:m,dragging:N,connectionInProgress:p}=J(If,re),w=m&&(e||y),M=k.useRef(null),_=k.useRef(),C=k.useRef(new Set),T=k.useRef(new Set),D=k.useRef(!1),O=I=>{if(D.current||p){D.current=!1;return}c==null||c(I),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},$=I=>{if(Array.isArray(o)&&(o!=null&&o.includes(2))){I.preventDefault();return}l==null||l(I)},P=f?I=>f(I):void 0,H=I=>{D.current&&(I.stopPropagation(),D.current=!1)},b=I=>{var Y,U;const{domNode:S}=x.getState();if(_.current=S==null?void 0:S.getBoundingClientRect(),!_.current)return;const z=I.target===M.current;if(!z&&!!I.target.closest(".nokey")||!e||!(i&&z||t)||I.button!==0||!I.isPrimary)return;(U=(Y=I.target)==null?void 0:Y.setPointerCapture)==null||U.call(Y,I.pointerId),D.current=!1;const{x:V,y:B}=pe(I.nativeEvent,_.current);x.setState({userSelectionRect:{width:0,height:0,startX:V,startY:B,x:V,y:B}}),z||(I.stopPropagation(),I.preventDefault())},A=I=>{const{userSelectionRect:S,transform:z,nodeLookup:R,edgeLookup:j,connectionLookup:V,triggerNodeChanges:B,triggerEdgeChanges:Y,defaultEdgeOptions:U,resetSelectedElements:W}=x.getState();if(!_.current||!S)return;const{x:F,y:G}=pe(I.nativeEvent,_.current),{startX:Q,startY:Z}=S;if(!D.current){const ee=t?0:r;if(Math.hypot(F-Q,G-Z)<=ee)return;W(),s==null||s(I)}D.current=!0;const K={startX:Q,startY:Z,x:F<Q?F:Q,y:G<Z?G:Z,width:Math.abs(F-Q),height:Math.abs(G-Z)},q=C.current,te=T.current;C.current=new Set(qn(R,K,z,n===Ze.Partial,!0).map(ee=>ee.id)),T.current=new Set;const oe=(U==null?void 0:U.selectable)??!0;for(const ee of C.current){const ae=V.get(ee);if(ae)for(const{edgeId:Ce}of ae.values()){const be=j.get(Ce);be&&(be.selectable??oe)&&T.current.add(Ce)}}if(!To(q,C.current)){const ee=Ye(R,C.current,!0);B(ee)}if(!To(te,T.current)){const ee=Ye(j,T.current);Y(ee)}x.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},E=I=>{var S,z;I.button===0&&((z=(S=I.target)==null?void 0:S.releasePointerCapture)==null||z.call(S,I.pointerId),!y&&I.target===M.current&&x.getState().userSelectionRect&&(O==null||O(I)),x.setState({userSelectionActive:!1,userSelectionRect:null}),D.current&&(a==null||a(I),x.setState({nodesSelectionActive:C.current.size>0})))},L=o===!0||Array.isArray(o)&&o.includes(0);return v.jsxs("div",{className:se(["react-flow__pane",{draggable:L,dragging:N,selection:e}]),onClick:w?void 0:_n(O,M),onContextMenu:_n($,M),onWheel:_n(P,M),onPointerEnter:w?void 0:u,onPointerMove:w?A:d,onPointerUp:w?E:void 0,onPointerDownCapture:w?b:void 0,onClickCapture:w?H:void 0,onPointerLeave:g,ref:M,style:un,children:[h,v.jsx(kf,{})]})}function Hn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",we.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var f;return(f=o==null?void 0:o.current)==null?void 0:f.blur()})):r([e])}function $i({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=ie(),[c,l]=k.useState(!1),f=k.useRef();return k.useEffect(()=>{f.current=_d({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Hn({id:u,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),k.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,o,t,i,e,r,s]),c}const Af=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ai(){const e=ie();return k.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:f}=e.getState(),u=new Map,d=Af(s),g=r?i[0]:5,h=r?i[1]:5,x=n.direction.x*g*n.factor,y=n.direction.y*h*n.factor;for(const[,m]of l){if(!d(m))continue;let N={x:m.internals.positionAbsolute.x+x,y:m.internals.positionAbsolute.y+y};r&&(N=Nt(N,i));const{position:p,positionAbsolute:w}=Kr({nodeId:m.id,nextPosition:N,nodeLookup:l,nodeExtent:o,nodeOrigin:f,onError:a});m.position=p,m.internals.positionAbsolute=w,u.set(m.id,m)}c(u)},[])}const no=k.createContext(null),Tf=no.Provider;no.Consumer;const Ti=()=>k.useContext(no),Lf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Pf=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:c,isValid:l}=s,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:f,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:i===Ke.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:f&&l}};function Df({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:f,onTouchStart:u,...d},g){var A,E;const h=s||null,x=e==="target",y=ie(),m=Ti(),{connectOnClick:N,noPanClassName:p,rfId:w}=J(Lf,re),{connectingFrom:M,connectingTo:_,clickConnecting:C,isPossibleEndHandle:T,connectionInProcess:D,clickConnectionInProcess:O,valid:$}=J(Pf(m,h,e),re);m||(E=(A=y.getState()).onError)==null||E.call(A,"010",we.error010());const P=L=>{const{defaultEdgeOptions:I,onConnect:S,hasDefaultEdges:z}=y.getState(),R={...I,...L};if(z){const{edges:j,setEdges:V}=y.getState();V(sd(R,j))}S==null||S(R),a==null||a(R)},H=L=>{if(!m)return;const I=ri(L.nativeEvent);if(r&&(I&&L.button===0||!I)){const S=y.getState();Rn.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:S.autoPanOnConnect,connectionMode:S.connectionMode,connectionRadius:S.connectionRadius,domNode:S.domNode,nodeLookup:S.nodeLookup,lib:S.lib,isTarget:x,handleId:h,nodeId:m,flowId:S.rfId,panBy:S.panBy,cancelConnection:S.cancelConnection,onConnectStart:S.onConnectStart,onConnectEnd:(...z)=>{var R,j;return(j=(R=y.getState()).onConnectEnd)==null?void 0:j.call(R,...z)},updateConnection:S.updateConnection,onConnect:P,isValidConnection:n||((...z)=>{var R,j;return((j=(R=y.getState()).isValidConnection)==null?void 0:j.call(R,...z))??!0}),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:S.autoPanSpeed,dragThreshold:S.connectionDragThreshold})}I?f==null||f(L):u==null||u(L)},b=L=>{const{onClickConnectStart:I,onClickConnectEnd:S,connectionClickStartHandle:z,connectionMode:R,isValidConnection:j,lib:V,rfId:B,nodeLookup:Y,connection:U}=y.getState();if(!m||!z&&!r)return;if(!z){I==null||I(L.nativeEvent,{nodeId:m,handleId:h,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:m,type:e,id:h}});return}const W=ni(L.target),F=n||j,{connection:G,isValid:Q}=Rn.isValid(L.nativeEvent,{handle:{nodeId:m,id:h,type:e},connectionMode:R,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:F,flowId:B,doc:W,lib:V,nodeLookup:Y});Q&&G&&P(G);const Z=structuredClone(U);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,S==null||S(L,Z),y.setState({connectionClickStartHandle:null})};return v.jsx("div",{"data-handleid":h,"data-nodeid":m,"data-handlepos":t,"data-id":`${w}-${m}-${h}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!x,target:x,connectable:o,connectablestart:r,connectableend:i,clickconnecting:C,connectingfrom:M,connectingto:_,valid:$,connectionindicator:o&&(!D||T)&&(D||O?i:r)}]),onMouseDown:H,onTouchStart:H,onClick:N?b:void 0,ref:g,...d,children:c})}const Ae=k.memo(ki(Df));function zf({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return v.jsxs(v.Fragment,{children:[e==null?void 0:e.label,v.jsx(Ae,{type:"source",position:n,isConnectable:t})]})}function jf({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:o=X.Bottom}){return v.jsxs(v.Fragment,{children:[v.jsx(Ae,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,v.jsx(Ae,{type:"source",position:o,isConnectable:t})]})}function Rf(){return null}function Hf({data:e,isConnectable:t,targetPosition:n=X.Top}){return v.jsxs(v.Fragment,{children:[v.jsx(Ae,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Zt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},or={input:zf,default:jf,output:Hf,group:Rf};function Of(e){var t,n,o,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((o=e.style)==null?void 0:o.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const Ff=e=>{const{width:t,height:n,x:o,y:r}=_t(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 Vf({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ie(),{width:r,height:i,transformString:s,userSelectionActive:a}=J(Ff,re),c=Ai(),l=k.useRef(null);k.useEffect(()=>{var g;n||(g=l.current)==null||g.focus({preventScroll:!0})},[n]);const f=!a&&r!==null&&i!==null;if($i({nodeRef:l,disabled:!f}),!f)return null;const u=e?g=>{const h=o.getState().nodes.filter(x=>x.selected);e(g,h)}:void 0,d=g=>{Object.prototype.hasOwnProperty.call(Zt,g.key)&&(g.preventDefault(),c({direction:Zt[g.key],factor:g.shiftKey?4:1}))};return v.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:v.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:i}})})}const rr=typeof window<"u"?window:void 0,Bf=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Li({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:f,selectionMode:u,onSelectionStart:d,onSelectionEnd:g,multiSelectionKeyCode:h,panActivationKeyCode:x,zoomActivationKeyCode:y,elementsSelectable:m,zoomOnScroll:N,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:M,panOnScrollMode:_,zoomOnDoubleClick:C,panOnDrag:T,defaultViewport:D,translateExtent:O,minZoom:$,maxZoom:P,preventScrolling:H,onSelectionContextMenu:b,noWheelClassName:A,noPanClassName:E,disableKeyboardA11y:L,onViewportChange:I,isControlledViewport:S}){const{nodesSelectionActive:z,userSelectionActive:R}=J(Bf,re),j=xt(l,{target:rr}),V=xt(x,{target:rr}),B=V||T,Y=V||w,U=f&&B!==!0,W=j||R||U;return Nf({deleteKeyCode:c,multiSelectionKeyCode:h}),v.jsx(Cf,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:N,zoomOnPinch:p,panOnScroll:Y,panOnScrollSpeed:M,panOnScrollMode:_,zoomOnDoubleClick:C,panOnDrag:!j&&B,defaultViewport:D,translateExtent:O,minZoom:$,maxZoom:P,zoomActivationKeyCode:y,preventScrolling:H,noWheelClassName:A,noPanClassName:E,onViewportChange:I,isControlledViewport:S,paneClickDistance:a,selectionOnDrag:U,children:v.jsxs($f,{onSelectionStart:d,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:B,isSelecting:!!W,selectionMode:u,selectionKeyPressed:j,paneClickDistance:a,selectionOnDrag:U,children:[e,z&&v.jsx(Vf,{onSelectionContextMenu:b,noPanClassName:E,disableKeyboardA11y:L})]})})}Li.displayName="FlowRenderer";const Xf=k.memo(Li),Yf=e=>t=>e?qn(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 Gf(e){return J(k.useCallback(Yf(e),[e]),re)}const Wf=e=>e.updateNodeInternals;function qf(){const e=J(Wf),[t]=k.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 k.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Uf({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=ie(),i=k.useRef(null),s=k.useRef(null),a=k.useRef(e.sourcePosition),c=k.useRef(e.targetPosition),l=k.useRef(t),f=n&&!!e.internals.handleBounds;return k.useEffect(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&(o==null||o.unobserve(s.current)),o==null||o.observe(i.current),s.current=i.current)},[f,e.hidden]),k.useEffect(()=>()=>{s.current&&(o==null||o.unobserve(s.current),s.current=null)},[]),k.useEffect(()=>{if(i.current){const u=l.current!==t,d=a.current!==e.sourcePosition,g=c.current!==e.targetPosition;(u||d||g)&&(l.current=t,a.current=e.sourcePosition,c.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 Kf({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:f,resizeObserver:u,noDragClassName:d,noPanClassName:g,disableKeyboardA11y:h,rfId:x,nodeTypes:y,nodeClickDistance:m,onError:N}){const{node:p,internals:w,isParent:M}=J(F=>{const G=F.nodeLookup.get(e),Q=F.parentLookup.has(e);return{node:G,internals:G.internals,isParent:Q}},re);let _=p.type||"default",C=(y==null?void 0:y[_])||or[_];C===void 0&&(N==null||N("003",we.error003(_)),_="default",C=(y==null?void 0:y.default)||or.default);const T=!!(p.draggable||a&&typeof p.draggable>"u"),D=!!(p.selectable||c&&typeof p.selectable>"u"),O=!!(p.connectable||l&&typeof p.connectable>"u"),$=!!(p.focusable||f&&typeof p.focusable>"u"),P=ie(),H=ei(p),b=Uf({node:p,nodeType:_,hasDimensions:H,resizeObserver:u}),A=$i({nodeRef:b,disabled:p.hidden||!T,noDragClassName:d,handleSelector:p.dragHandle,nodeId:e,isSelectable:D,nodeClickDistance:m}),E=Ai();if(p.hidden)return null;const L=Se(p),I=Of(p),S=D||T||t||n||o||r,z=n?F=>n(F,{...w.userNode}):void 0,R=o?F=>o(F,{...w.userNode}):void 0,j=r?F=>r(F,{...w.userNode}):void 0,V=i?F=>i(F,{...w.userNode}):void 0,B=s?F=>s(F,{...w.userNode}):void 0,Y=F=>{const{selectNodesOnDrag:G,nodeDragThreshold:Q}=P.getState();D&&(!G||!T||Q>0)&&Hn({id:e,store:P,nodeRef:b}),t&&t(F,{...w.userNode})},U=F=>{if(!(oi(F.nativeEvent)||h)){if(Yr.includes(F.key)&&D){const G=F.key==="Escape";Hn({id:e,store:P,unselect:G,nodeRef:b})}else if(T&&p.selected&&Object.prototype.hasOwnProperty.call(Zt,F.key)){F.preventDefault();const{ariaLabelConfig:G}=P.getState();P.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:F.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),E({direction:Zt[F.key],factor:F.shiftKey?4:1})}}},W=()=>{var te;if(h||!((te=b.current)!=null&&te.matches(":focus-visible")))return;const{transform:F,width:G,height:Q,autoPanOnNodeFocus:Z,setCenter:K}=P.getState();if(!Z)return;qn(new Map([[e,p]]),{x:0,y:0,width:G,height:Q},F,!0).length>0||K(p.position.x+L.width/2,p.position.y+L.height/2,{zoom:F[2]})};return v.jsx("div",{className:se(["react-flow__node",`react-flow__node-${_}`,{[g]:T},p.className,{selected:p.selected,selectable:D,parent:M,draggable:T,dragging:A}]),ref:b,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:S?"all":"none",visibility:H?"visible":"hidden",...p.style,...I},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:R,onMouseLeave:j,onContextMenu:V,onClick:Y,onDoubleClick:B,onKeyDown:$?U:void 0,tabIndex:$?0:void 0,onFocus:$?W:void 0,role:p.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":h?void 0:`${_i}-${x}`,"aria-label":p.ariaLabel,...p.domAttributes,children:v.jsx(Tf,{value:e,children:v.jsx(C,{id:e,data:p.data,type:_,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:D,draggable:T,deletable:p.deletable??!0,isConnectable:O,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:A,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...L})})})}var Zf=k.memo(Kf);const Qf=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Pi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=J(Qf,re),s=Gf(e.onlyRenderVisibleElements),a=qf();return v.jsx("div",{className:"react-flow__nodes",style:un,children:s.map(c=>v.jsx(Zf,{id:c,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:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}Pi.displayName="NodeRenderer";const Jf=k.memo(Pi);function eh(e){return J(k.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&&od({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),re)}const th=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return v.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},nh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return v.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ir={[qt.Arrow]:th,[qt.ArrowClosed]:nh};function oh(e){const t=ie();return k.useMemo(()=>{var r,i;return Object.prototype.hasOwnProperty.call(ir,e)?ir[e]:((i=(r=t.getState()).onError)==null||i.call(r,"009",we.error009(e)),null)},[e])}const rh=({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 c=oh(t);return c?v.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:v.jsx(c,{color:n,strokeWidth:s})}):null},Di=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),o=J(i=>i.defaultEdgeOptions),r=k.useMemo(()=>dd(n,{id:t,defaultColor:e,defaultMarkerStart:o==null?void 0:o.markerStart,defaultMarkerEnd:o==null?void 0:o.markerEnd}),[n,o,t,e]);return r.length?v.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:v.jsx("defs",{children:r.map(i=>v.jsx(rh,{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};Di.displayName="MarkerDefinitions";var ih=k.memo(Di);function zi({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...f}){const[u,d]=k.useState({x:1,y:0,width:0,height:0}),g=se(["react-flow__edge-textwrapper",l]),h=k.useRef(null);return k.useEffect(()=>{if(h.current){const x=h.current.getBBox();d({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?v.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:g,visibility:u.width?"visible":"hidden",...f,children:[r&&v.jsx("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),v.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:h,style:o,children:n}),c]}):null}zi.displayName="EdgeText";const sh=k.memo(zi);function dn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...f}){return v.jsxs(v.Fragment,{children:[v.jsx("path",{...f,d:e,fill:"none",className:se(["react-flow__edge-path",f.className])}),l?v.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&ge(t)&&ge(n)?v.jsx(sh,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function sr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===X.Left||e===X.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function ji({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top}){const[s,a]=sr({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=sr({pos:i,x1:o,y1:r,x2:e,y2:t}),[f,u,d,g]=ii({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${o},${r}`,f,u,d,g]}function Ri(e){return k.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:g,style:h,markerEnd:x,markerStart:y,interactionWidth:m})=>{const[N,p,w]=ji({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),M=e.isInternal?void 0:t;return v.jsx(dn,{id:M,path:N,labelX:p,labelY:w,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:g,style:h,markerEnd:x,markerStart:y,interactionWidth:m})})}const ah=Ri({isInternal:!1}),Hi=Ri({isInternal:!0});ah.displayName="SimpleBezierEdge";Hi.displayName="SimpleBezierEdgeInternal";function Oi(e){return k.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:u,style:d,sourcePosition:g=X.Bottom,targetPosition:h=X.Top,markerEnd:x,markerStart:y,pathOptions:m,interactionWidth:N})=>{const[p,w,M]=Dn({sourceX:n,sourceY:o,sourcePosition:g,targetX:r,targetY:i,targetPosition:h,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),_=e.isInternal?void 0:t;return v.jsx(dn,{id:_,path:p,labelX:w,labelY:M,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:x,markerStart:y,interactionWidth:N})})}const Fi=Oi({isInternal:!1}),Vi=Oi({isInternal:!0});Fi.displayName="SmoothStepEdge";Vi.displayName="SmoothStepEdgeInternal";function Bi(e){return k.memo(({id:t,...n})=>{var r;const o=e.isInternal?void 0:t;return v.jsx(Fi,{...n,id:o,pathOptions:k.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const ch=Bi({isInternal:!1}),Xi=Bi({isInternal:!0});ch.displayName="StepEdge";Xi.displayName="StepEdgeInternal";function Yi(e){return k.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:g,markerStart:h,interactionWidth:x})=>{const[y,m,N]=ci({sourceX:n,sourceY:o,targetX:r,targetY:i}),p=e.isInternal?void 0:t;return v.jsx(dn,{id:p,path:y,labelX:m,labelY:N,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:g,markerStart:h,interactionWidth:x})})}const lh=Yi({isInternal:!1}),Gi=Yi({isInternal:!0});lh.displayName="StraightEdge";Gi.displayName="StraightEdgeInternal";function Wi(e){return k.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:g,style:h,markerEnd:x,markerStart:y,pathOptions:m,interactionWidth:N})=>{const[p,w,M]=si({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),_=e.isInternal?void 0:t;return v.jsx(dn,{id:_,path:p,labelX:w,labelY:M,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:g,style:h,markerEnd:x,markerStart:y,interactionWidth:N})})}const uh=Wi({isInternal:!1}),qi=Wi({isInternal:!0});uh.displayName="BezierEdge";qi.displayName="BezierEdgeInternal";const ar={default:qi,straight:Gi,step:Xi,smoothstep:Vi,simplebezier:Hi},cr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},dh=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,fh=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,lr="react-flow__edgeupdater";function ur({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return v.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:se([lr,`${lr}-${a}`]),cx:dh(t,o,e),cy:fh(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function hh({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:f,onReconnectEnd:u,setReconnecting:d,setUpdateHover:g}){const h=ie(),x=(w,M)=>{if(w.button!==0)return;const{autoPanOnConnect:_,domNode:C,connectionMode:T,connectionRadius:D,lib:O,onConnectStart:$,cancelConnection:P,nodeLookup:H,rfId:b,panBy:A,updateConnection:E}=h.getState(),L=M.type==="target",I=(R,j)=>{d(!1),u==null||u(R,n,M.type,j)},S=R=>l==null?void 0:l(n,R),z=(R,j)=>{d(!0),f==null||f(w,n,M.type),$==null||$(R,j)};Rn.onPointerDown(w.nativeEvent,{autoPanOnConnect:_,connectionMode:T,connectionRadius:D,domNode:C,handleId:M.id,nodeId:M.nodeId,nodeLookup:H,isTarget:L,edgeUpdaterType:M.type,lib:O,flowId:b,cancelConnection:P,panBy:A,isValidConnection:(...R)=>{var j,V;return((V=(j=h.getState()).isValidConnection)==null?void 0:V.call(j,...R))??!0},onConnect:S,onConnectStart:z,onConnectEnd:(...R)=>{var j,V;return(V=(j=h.getState()).onConnectEnd)==null?void 0:V.call(j,...R)},onReconnectEnd:I,updateConnection:E,getTransform:()=>h.getState().transform,getFromHandle:()=>h.getState().connection.fromHandle,dragThreshold:h.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>g(!0),p=()=>g(!1);return v.jsxs(v.Fragment,{children:[(e===!0||e==="source")&&v.jsx(ur,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:y,onMouseEnter:N,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&v.jsx(ur,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:N,onMouseOut:p,type:"target"})]})}function gh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:g,rfId:h,edgeTypes:x,noPanClassName:y,onError:m,disableKeyboardA11y:N}){let p=J(K=>K.edgeLookup.get(e));const w=J(K=>K.defaultEdgeOptions);p=w?{...w,...p}:p;let M=p.type||"default",_=(x==null?void 0:x[M])||ar[M];_===void 0&&(m==null||m("011",we.error011(M)),M="default",_=(x==null?void 0:x.default)||ar.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),T=typeof u<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),D=!!(p.selectable||o&&typeof p.selectable>"u"),O=k.useRef(null),[$,P]=k.useState(!1),[H,b]=k.useState(!1),A=ie(),{zIndex:E,sourceX:L,sourceY:I,targetX:S,targetY:z,sourcePosition:R,targetPosition:j}=J(k.useCallback(K=>{const q=K.nodeLookup.get(p.source),te=K.nodeLookup.get(p.target);if(!q||!te)return{zIndex:p.zIndex,...cr};const oe=ud({id:e,sourceNode:q,targetNode:te,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:K.connectionMode,onError:m});return{zIndex:nd({selected:p.selected,zIndex:p.zIndex,sourceNode:q,targetNode:te,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...oe||cr}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),re),V=k.useMemo(()=>p.markerStart?`url('#${zn(p.markerStart,h)}')`:void 0,[p.markerStart,h]),B=k.useMemo(()=>p.markerEnd?`url('#${zn(p.markerEnd,h)}')`:void 0,[p.markerEnd,h]);if(p.hidden||L===null||I===null||S===null||z===null)return null;const Y=K=>{var ee;const{addSelectedEdges:q,unselectNodesAndEdges:te,multiSelectionActive:oe}=A.getState();D&&(A.setState({nodesSelectionActive:!1}),p.selected&&oe?(te({nodes:[],edges:[p]}),(ee=O.current)==null||ee.blur()):q([e])),r&&r(K,p)},U=i?K=>{i(K,{...p})}:void 0,W=s?K=>{s(K,{...p})}:void 0,F=a?K=>{a(K,{...p})}:void 0,G=c?K=>{c(K,{...p})}:void 0,Q=l?K=>{l(K,{...p})}:void 0,Z=K=>{var q;if(!N&&Yr.includes(K.key)&&D){const{unselectNodesAndEdges:te,addSelectedEdges:oe}=A.getState();K.key==="Escape"?((q=O.current)==null||q.blur(),te({edges:[p]})):oe([e])}};return v.jsx("svg",{style:{zIndex:E},children:v.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${M}`,p.className,y,{selected:p.selected,animated:p.animated,inactive:!D&&!r,updating:$,selectable:D}]),onClick:Y,onDoubleClick:U,onContextMenu:W,onMouseEnter:F,onMouseMove:G,onMouseLeave:Q,onKeyDown:C?Z:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${Ni}-${h}`:void 0,ref:O,...p.domAttributes,children:[!H&&v.jsx(_,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:D,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:L,sourceY:I,targetX:S,targetY:z,sourcePosition:R,targetPosition:j,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:B,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),T&&v.jsx(hh,{edge:p,isReconnectable:T,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:g,sourceX:L,sourceY:I,targetX:S,targetY:z,sourcePosition:R,targetPosition:j,setUpdateHover:P,setReconnecting:b})]})})}var ph=k.memo(gh);const mh=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ui({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:d,onReconnectStart:g,onReconnectEnd:h,disableKeyboardA11y:x}){const{edgesFocusable:y,edgesReconnectable:m,elementsSelectable:N,onError:p}=J(mh,re),w=eh(t);return v.jsxs("div",{className:"react-flow__edges",children:[v.jsx(ih,{defaultColor:e,rfId:n}),w.map(M=>v.jsx(ph,{id:M,edgesFocusable:y,edgesReconnectable:m,elementsSelectable:N,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:f,reconnectRadius:u,onDoubleClick:d,onReconnectStart:g,onReconnectEnd:h,rfId:n,onError:p,edgeTypes:o,disableKeyboardA11y:x},M))]})}Ui.displayName="EdgeRenderer";const yh=k.memo(Ui),xh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function wh({children:e}){const t=J(xh);return v.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function vh(e){const t=ln(),n=k.useRef(!1);k.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const bh=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function _h(e){const t=J(bh),n=ie();return k.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Nh(e){return e.connection.inProgress?{...e.connection,to:Et(e.connection.to,e.transform)}:{...e.connection}}function Eh(e){return Nh}function Sh(e){const t=Eh();return J(t,re)}const Ch=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Mh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:c}=J(Ch,re);return!(i&&r&&c)?null:v.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:v.jsx("g",{className:se(["react-flow__connection",qr(a)]),children:v.jsx(Ki,{style:t,type:n,CustomComponent:o,isValid:a})})})}const Ki=({style:e,type:t=Ie.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:f,toHandle:u,toPosition:d,pointer:g}=Sh();if(!r)return;if(n)return v.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:d,connectionStatus:qr(o),toNode:f,toHandle:u,pointer:g});let h="";const x={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:d};switch(t){case Ie.Bezier:[h]=si(x);break;case Ie.SimpleBezier:[h]=ji(x);break;case Ie.Step:[h]=Dn({...x,borderRadius:0});break;case Ie.SmoothStep:[h]=Dn(x);break;default:[h]=ci(x)}return v.jsx("path",{d:h,fill:"none",className:"react-flow__connection-path",style:e})};Ki.displayName="ConnectionLine";const kh={};function dr(e=kh){k.useRef(e),ie(),k.useEffect(()=>{},[e])}function Ih(){ie(),k.useRef(!1),k.useEffect(()=>{},[])}function Zi({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:d,onSelectionEnd:g,connectionLineType:h,connectionLineStyle:x,connectionLineComponent:y,connectionLineContainerStyle:m,selectionKeyCode:N,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:M,panActivationKeyCode:_,zoomActivationKeyCode:C,deleteKeyCode:T,onlyRenderVisibleElements:D,elementsSelectable:O,defaultViewport:$,translateExtent:P,minZoom:H,maxZoom:b,preventScrolling:A,defaultMarkerColor:E,zoomOnScroll:L,zoomOnPinch:I,panOnScroll:S,panOnScrollSpeed:z,panOnScrollMode:R,zoomOnDoubleClick:j,panOnDrag:V,onPaneClick:B,onPaneMouseEnter:Y,onPaneMouseMove:U,onPaneMouseLeave:W,onPaneScroll:F,onPaneContextMenu:G,paneClickDistance:Q,nodeClickDistance:Z,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ee,onReconnect:ae,onReconnectStart:Ce,onReconnectEnd:be,noDragClassName:Te,noWheelClassName:tt,noPanClassName:nt,disableKeyboardA11y:ot,nodeExtent:fn,rfId:St,viewport:Ve,onViewportChange:rt}){return dr(e),dr(t),Ih(),vh(n),_h(Ve),v.jsx(Xf,{onPaneClick:B,onPaneMouseEnter:Y,onPaneMouseMove:U,onPaneMouseLeave:W,onPaneContextMenu:G,onPaneScroll:F,paneClickDistance:Q,deleteKeyCode:T,selectionKeyCode:N,selectionOnDrag:p,selectionMode:w,onSelectionStart:d,onSelectionEnd:g,multiSelectionKeyCode:M,panActivationKeyCode:_,zoomActivationKeyCode:C,elementsSelectable:O,zoomOnScroll:L,zoomOnPinch:I,zoomOnDoubleClick:j,panOnScroll:S,panOnScrollSpeed:z,panOnScrollMode:R,panOnDrag:V,defaultViewport:$,translateExtent:P,minZoom:H,maxZoom:b,onSelectionContextMenu:u,preventScrolling:A,noDragClassName:Te,noWheelClassName:tt,noPanClassName:nt,disableKeyboardA11y:ot,onViewportChange:rt,isControlledViewport:!!Ve,children:v.jsxs(wh,{children:[v.jsx(yh,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:ae,onReconnectStart:Ce,onReconnectEnd:be,onlyRenderVisibleElements:D,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ee,defaultMarkerColor:E,noPanClassName:nt,disableKeyboardA11y:ot,rfId:St}),v.jsx(Mh,{style:x,type:h,component:y,containerStyle:m}),v.jsx("div",{className:"react-flow__edgelabel-renderer"}),v.jsx(Jf,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:f,nodeClickDistance:Z,onlyRenderVisibleElements:D,noPanClassName:nt,noDragClassName:Te,disableKeyboardA11y:ot,nodeExtent:fn,rfId:St}),v.jsx("div",{className:"react-flow__viewport-portal"})]})})}Zi.displayName="GraphView";const $h=k.memo(Zi),fr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:f,nodeExtent:u,zIndexMode:d="basic"}={})=>{const g=new Map,h=new Map,x=new Map,y=new Map,m=o??t??[],N=n??e??[],p=f??[0,0],w=u??pt;di(x,y,m);const M=jn(N,g,h,{nodeOrigin:p,nodeExtent:w,zIndexMode:d});let _=[0,0,1];if(s&&r&&i){const C=_t(g,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:T,y:D,zoom:O}=Un(C,r,i,c,l,(a==null?void 0:a.padding)??.1);_=[T,D,O]}return{rfId:"1",width:r??0,height:i??0,transform:_,nodes:N,nodesInitialized:M,nodeLookup:g,parentLookup:h,edges:m,edgeLookup:y,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:pt,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ke.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Wr},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ku,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Gr,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Ah=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:f,nodeExtent:u,zIndexMode:d})=>qd((g,h)=>{async function x(){const{nodeLookup:y,panZoom:m,fitViewOptions:N,fitViewResolver:p,width:w,height:M,minZoom:_,maxZoom:C}=h();m&&(await qu({nodes:y,width:w,height:M,panZoom:m,minZoom:_,maxZoom:C},N),p==null||p.resolve(!0),g({fitViewResolver:null}))}return{...fr({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:y=>{const{nodeLookup:m,parentLookup:N,nodeOrigin:p,elevateNodesOnSelect:w,fitViewQueued:M,zIndexMode:_}=h(),C=jn(y,m,N,{nodeOrigin:p,nodeExtent:u,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:_});M&&C?(x(),g({nodes:y,nodesInitialized:C,fitViewQueued:!1,fitViewOptions:void 0})):g({nodes:y,nodesInitialized:C})},setEdges:y=>{const{connectionLookup:m,edgeLookup:N}=h();di(m,N,y),g({edges:y})},setDefaultNodesAndEdges:(y,m)=>{if(y){const{setNodes:N}=h();N(y),g({hasDefaultNodes:!0})}if(m){const{setEdges:N}=h();N(m),g({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:m,nodeLookup:N,parentLookup:p,domNode:w,nodeOrigin:M,nodeExtent:_,debug:C,fitViewQueued:T,zIndexMode:D}=h(),{changes:O,updatedInternals:$}=xd(y,N,p,w,M,_,D);$&&(gd(N,p,{nodeOrigin:M,nodeExtent:_,zIndexMode:D}),T?(x(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),(O==null?void 0:O.length)>0&&(C&&console.log("React Flow: trigger node changes",O),m==null||m(O)))},updateNodePositions:(y,m=!1)=>{const N=[];let p=[];const{nodeLookup:w,triggerNodeChanges:M,connection:_,updateConnection:C,onNodesChangeMiddlewareMap:T}=h();for(const[D,O]of y){const $=w.get(D),P=!!($!=null&&$.expandParent&&($!=null&&$.parentId)&&(O!=null&&O.position)),H={id:D,type:"position",position:P?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:m};if($&&_.inProgress&&_.fromNode.id===$.id){const b=Oe($,_.fromHandle,X.Left,!0);C({..._,from:b})}P&&$.parentId&&N.push({id:D,parentId:$.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),p.push(H)}if(N.length>0){const{parentLookup:D,nodeOrigin:O}=h(),$=to(N,w,D,O);p.push(...$)}for(const D of T.values())p=D(p);M(p)},triggerNodeChanges:y=>{const{onNodesChange:m,setNodes:N,nodes:p,hasDefaultNodes:w,debug:M}=h();if(y!=null&&y.length){if(w){const _=Ci(y,p);N(_)}M&&console.log("React Flow: trigger node changes",y),m==null||m(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:m,setEdges:N,edges:p,hasDefaultEdges:w,debug:M}=h();if(y!=null&&y.length){if(w){const _=Mi(y,p);N(_)}M&&console.log("React Flow: trigger edge changes",y),m==null||m(y)}},addSelectedNodes:y=>{const{multiSelectionActive:m,edgeLookup:N,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:M}=h();if(m){const _=y.map(C=>Le(C,!0));w(_);return}w(Ye(p,new Set([...y]),!0)),M(Ye(N))},addSelectedEdges:y=>{const{multiSelectionActive:m,edgeLookup:N,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:M}=h();if(m){const _=y.map(C=>Le(C,!0));M(_);return}M(Ye(N,new Set([...y]))),w(Ye(p,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:m}={})=>{const{edges:N,nodes:p,nodeLookup:w,triggerNodeChanges:M,triggerEdgeChanges:_}=h(),C=y||p,T=m||N,D=[];for(const $ of C){if(!$.selected)continue;const P=w.get($.id);P&&(P.selected=!1),D.push(Le($.id,!1))}const O=[];for(const $ of T)$.selected&&O.push(Le($.id,!1));M(D),_(O)},setMinZoom:y=>{const{panZoom:m,maxZoom:N}=h();m==null||m.setScaleExtent([y,N]),g({minZoom:y})},setMaxZoom:y=>{const{panZoom:m,minZoom:N}=h();m==null||m.setScaleExtent([N,y]),g({maxZoom:y})},setTranslateExtent:y=>{var m;(m=h().panZoom)==null||m.setTranslateExtent(y),g({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:m,triggerNodeChanges:N,triggerEdgeChanges:p,elementsSelectable:w}=h();if(!w)return;const M=m.reduce((C,T)=>T.selected?[...C,Le(T.id,!1)]:C,[]),_=y.reduce((C,T)=>T.selected?[...C,Le(T.id,!1)]:C,[]);N(M),p(_)},setNodeExtent:y=>{const{nodes:m,nodeLookup:N,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:M,nodeExtent:_,zIndexMode:C}=h();y[0][0]===_[0][0]&&y[0][1]===_[0][1]&&y[1][0]===_[1][0]&&y[1][1]===_[1][1]||(jn(m,N,p,{nodeOrigin:w,nodeExtent:y,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:C}),g({nodeExtent:y}))},panBy:y=>{const{transform:m,width:N,height:p,panZoom:w,translateExtent:M}=h();return wd({delta:y,panZoom:w,transform:m,translateExtent:M,width:N,height:p})},setCenter:async(y,m,N)=>{const{width:p,height:w,maxZoom:M,panZoom:_}=h();if(!_)return Promise.resolve(!1);const C=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await _.setViewport({x:p/2-y*C,y:w/2-m*C,zoom:C},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...Wr}})},updateConnection:y=>{g({connection:y})},reset:()=>g({...fr()})}},Object.is);function Qi({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:f,nodeExtent:u,zIndexMode:d,children:g}){const[h]=k.useState(()=>Ah({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d}));return v.jsx(Ud,{value:h,children:v.jsx(wf,{children:g})})}function Th({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:g}){return k.useContext(an)?v.jsx(v.Fragment,{children:e}):v.jsx(Qi,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:g,children:e})}const Lh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Ph({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:f,onMoveStart:u,onMoveEnd:d,onConnect:g,onConnectStart:h,onConnectEnd:x,onClickConnectStart:y,onClickConnectEnd:m,onNodeMouseEnter:N,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:_,onNodeDragStart:C,onNodeDrag:T,onNodeDragStop:D,onNodesDelete:O,onEdgesDelete:$,onDelete:P,onSelectionChange:H,onSelectionDragStart:b,onSelectionDrag:A,onSelectionDragStop:E,onSelectionContextMenu:L,onSelectionStart:I,onSelectionEnd:S,onBeforeDelete:z,connectionMode:R,connectionLineType:j=Ie.Bezier,connectionLineStyle:V,connectionLineComponent:B,connectionLineContainerStyle:Y,deleteKeyCode:U="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:F=!1,selectionMode:G=Ze.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:Z=yt()?"Meta":"Control",zoomActivationKeyCode:K=yt()?"Meta":"Control",snapToGrid:q,snapGrid:te,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:ee,nodesDraggable:ae,autoPanOnNodeFocus:Ce,nodesConnectable:be,nodesFocusable:Te,nodeOrigin:tt=Ei,edgesFocusable:nt,edgesReconnectable:ot,elementsSelectable:fn=!0,defaultViewport:St=lf,minZoom:Ve=.5,maxZoom:rt=2,translateExtent:oo=pt,preventScrolling:rs=!0,nodeExtent:hn,defaultMarkerColor:is="#b1b1b7",zoomOnScroll:ss=!0,zoomOnPinch:as=!0,panOnScroll:cs=!1,panOnScrollSpeed:ls=.5,panOnScrollMode:us=ze.Free,zoomOnDoubleClick:ds=!0,panOnDrag:fs=!0,onPaneClick:hs,onPaneMouseEnter:gs,onPaneMouseMove:ps,onPaneMouseLeave:ms,onPaneScroll:ys,onPaneContextMenu:xs,paneClickDistance:ws=1,nodeClickDistance:vs=0,children:bs,onReconnect:_s,onReconnectStart:Ns,onReconnectEnd:Es,onEdgeContextMenu:Ss,onEdgeDoubleClick:Cs,onEdgeMouseEnter:Ms,onEdgeMouseMove:ks,onEdgeMouseLeave:Is,reconnectRadius:$s=10,onNodesChange:As,onEdgesChange:Ts,noDragClassName:Ls="nodrag",noWheelClassName:Ps="nowheel",noPanClassName:ro="nopan",fitView:io,fitViewOptions:so,connectOnClick:Ds,attributionPosition:zs,proOptions:js,defaultEdgeOptions:Rs,elevateNodesOnSelect:Hs=!0,elevateEdgesOnSelect:Os=!1,disableKeyboardA11y:ao=!1,autoPanOnConnect:Fs,autoPanOnNodeDrag:Vs,autoPanSpeed:Bs,connectionRadius:Xs,isValidConnection:Ys,onError:Gs,style:Ws,id:co,nodeDragThreshold:qs,connectionDragThreshold:Us,viewport:Ks,onViewportChange:Zs,width:Qs,height:Js,colorMode:ea="light",debug:ta,onScroll:Ct,ariaLabelConfig:na,zIndexMode:lo="basic",...oa},ra){const gn=co||"1",ia=hf(ea),sa=k.useCallback(uo=>{uo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ct==null||Ct(uo)},[Ct]);return v.jsx("div",{"data-testid":"rf__wrapper",...oa,onScroll:sa,style:{...Ws,...Lh},ref:ra,className:se(["react-flow",r,ia]),id:co,role:"application",children:v.jsxs(Th,{nodes:e,edges:t,width:Qs,height:Js,fitView:io,fitViewOptions:so,minZoom:Ve,maxZoom:rt,nodeOrigin:tt,nodeExtent:hn,zIndexMode:lo,children:[v.jsx($h,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:N,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:s,connectionLineType:j,connectionLineStyle:V,connectionLineComponent:B,connectionLineContainerStyle:Y,selectionKeyCode:W,selectionOnDrag:F,selectionMode:G,deleteKeyCode:U,multiSelectionKeyCode:Z,panActivationKeyCode:Q,zoomActivationKeyCode:K,onlyRenderVisibleElements:oe,defaultViewport:St,translateExtent:oo,minZoom:Ve,maxZoom:rt,preventScrolling:rs,zoomOnScroll:ss,zoomOnPinch:as,zoomOnDoubleClick:ds,panOnScroll:cs,panOnScrollSpeed:ls,panOnScrollMode:us,panOnDrag:fs,onPaneClick:hs,onPaneMouseEnter:gs,onPaneMouseMove:ps,onPaneMouseLeave:ms,onPaneScroll:ys,onPaneContextMenu:xs,paneClickDistance:ws,nodeClickDistance:vs,onSelectionContextMenu:L,onSelectionStart:I,onSelectionEnd:S,onReconnect:_s,onReconnectStart:Ns,onReconnectEnd:Es,onEdgeContextMenu:Ss,onEdgeDoubleClick:Cs,onEdgeMouseEnter:Ms,onEdgeMouseMove:ks,onEdgeMouseLeave:Is,reconnectRadius:$s,defaultMarkerColor:is,noDragClassName:Ls,noWheelClassName:Ps,noPanClassName:ro,rfId:gn,disableKeyboardA11y:ao,nodeExtent:hn,viewport:Ks,onViewportChange:Zs}),v.jsx(ff,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:g,onConnectStart:h,onConnectEnd:x,onClickConnectStart:y,onClickConnectEnd:m,nodesDraggable:ae,autoPanOnNodeFocus:Ce,nodesConnectable:be,nodesFocusable:Te,edgesFocusable:nt,edgesReconnectable:ot,elementsSelectable:fn,elevateNodesOnSelect:Hs,elevateEdgesOnSelect:Os,minZoom:Ve,maxZoom:rt,nodeExtent:hn,onNodesChange:As,onEdgesChange:Ts,snapToGrid:q,snapGrid:te,connectionMode:R,translateExtent:oo,connectOnClick:Ds,defaultEdgeOptions:Rs,fitView:io,fitViewOptions:so,onNodesDelete:O,onEdgesDelete:$,onDelete:P,onNodeDragStart:C,onNodeDrag:T,onNodeDragStop:D,onSelectionDrag:A,onSelectionDragStart:b,onSelectionDragStop:E,onMove:f,onMoveStart:u,onMoveEnd:d,noPanClassName:ro,nodeOrigin:tt,rfId:gn,autoPanOnConnect:Fs,autoPanOnNodeDrag:Vs,autoPanSpeed:Bs,onError:Gs,connectionRadius:Xs,isValidConnection:Ys,selectNodesOnDrag:ee,nodeDragThreshold:qs,connectionDragThreshold:Us,onBeforeDelete:z,debug:ta,ariaLabelConfig:na,zIndexMode:lo}),v.jsx(cf,{onSelectionChange:H}),bs,v.jsx(nf,{proOptions:js,position:zs}),v.jsx(tf,{rfId:gn,disableKeyboardA11y:ao})]})})}var Dh=ki(Ph);function zh({dimensions:e,lineWidth:t,variant:n,className:o}){return v.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,o])})}function jh({radius:e,className:t}){return v.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var $e;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})($e||($e={}));const Rh={[$e.Dots]:1,[$e.Lines]:1,[$e.Cross]:6},Hh=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ji({id:e,variant:t=$e.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:f}){const u=k.useRef(null),{transform:d,patternId:g}=J(Hh,re),h=o||Rh[t],x=t===$e.Dots,y=t===$e.Cross,m=Array.isArray(n)?n:[n,n],N=[m[0]*d[2]||1,m[1]*d[2]||1],p=h*d[2],w=Array.isArray(i)?i:[i,i],M=y?[p,p]:N,_=[w[0]*d[2]||1+M[0]/2,w[1]*d[2]||1+M[1]/2],C=`${g}${e||""}`;return v.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...un,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[v.jsx("pattern",{id:C,x:d[0]%N[0],y:d[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:x?v.jsx(jh,{radius:p/2,className:f}):v.jsx(zh,{dimensions:M,lineWidth:r,variant:t,className:f})}),v.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}Ji.displayName="Background";const Oh=k.memo(Ji);function Fh(){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:v.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Vh(){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:v.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Bh(){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:v.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 Xh(){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:v.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 Yh(){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:v.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 Dt({children:e,className:t,...n}){return v.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const Gh=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function es({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:f,position:u="bottom-left",orientation:d="vertical","aria-label":g}){const h=ie(),{isInteractive:x,minZoomReached:y,maxZoomReached:m,ariaLabelConfig:N}=J(Gh,re),{zoomIn:p,zoomOut:w,fitView:M}=ln(),_=()=>{p(),i==null||i()},C=()=>{w(),s==null||s()},T=()=>{M(r),a==null||a()},D=()=>{h.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},O=d==="horizontal"?"horizontal":"vertical";return v.jsxs(cn,{className:se(["react-flow__controls",O,l]),position:u,style:e,"data-testid":"rf__controls","aria-label":g??N["controls.ariaLabel"],children:[t&&v.jsxs(v.Fragment,{children:[v.jsx(Dt,{onClick:_,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:m,children:v.jsx(Fh,{})}),v.jsx(Dt,{onClick:C,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:y,children:v.jsx(Vh,{})})]}),n&&v.jsx(Dt,{className:"react-flow__controls-fitview",onClick:T,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:v.jsx(Bh,{})}),o&&v.jsx(Dt,{className:"react-flow__controls-interactive",onClick:D,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:x?v.jsx(Yh,{}):v.jsx(Xh,{})}),f]})}es.displayName="Controls";const Wh=k.memo(es);function qh({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:f,shapeRendering:u,selected:d,onClick:g}){const{background:h,backgroundColor:x}=i||{},y=s||h||x;return v.jsx("rect",{className:se(["react-flow__minimap-node",{selected:d},l]),x:t,y:n,rx:f,ry:f,width:o,height:r,style:{fill:y,stroke:a,strokeWidth:c},shapeRendering:u,onClick:g?m=>g(m,e):void 0})}const Uh=k.memo(qh),Kh=e=>e.nodes.map(t=>t.id),Nn=e=>e instanceof Function?e:()=>e;function Zh({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=Uh,onClick:s}){const a=J(Kh,re),c=Nn(t),l=Nn(e),f=Nn(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return v.jsx(v.Fragment,{children:a.map(d=>v.jsx(Jh,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:u},d))})}function Qh({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:f,y:u,width:d,height:g}=J(h=>{const x=h.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const y=x.internals.userNode,{x:m,y:N}=x.internals.positionAbsolute,{width:p,height:w}=Se(y);return{node:y,x:m,y:N,width:p,height:w}},re);return!l||l.hidden||!ei(l)?null:v.jsx(a,{x:f,y:u,width:d,height:g,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const Jh=k.memo(Qh);var eg=k.memo(Zh);const tg=200,ng=150,og=e=>!e.hidden,rg=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?Jr(_t(e.nodeLookup,{filter:og}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ig="react-flow__minimap-desc";function ts({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:f,maskStrokeWidth:u,position:d="bottom-right",onClick:g,onNodeClick:h,pannable:x=!1,zoomable:y=!1,ariaLabel:m,inversePan:N,zoomStep:p=1,offsetScale:w=5}){const M=ie(),_=k.useRef(null),{boundingRect:C,viewBB:T,rfId:D,panZoom:O,translateExtent:$,flowWidth:P,flowHeight:H,ariaLabelConfig:b}=J(rg,re),A=(e==null?void 0:e.width)??tg,E=(e==null?void 0:e.height)??ng,L=C.width/A,I=C.height/E,S=Math.max(L,I),z=S*A,R=S*E,j=w*S,V=C.x-(z-C.width)/2-j,B=C.y-(R-C.height)/2-j,Y=z+j*2,U=R+j*2,W=`${ig}-${D}`,F=k.useRef(0),G=k.useRef();F.current=S,k.useEffect(()=>{if(_.current&&O)return G.current=kd({domNode:_.current,panZoom:O,getTransform:()=>M.getState().transform,getViewScale:()=>F.current}),()=>{var q;(q=G.current)==null||q.destroy()}},[O]),k.useEffect(()=>{var q;(q=G.current)==null||q.update({translateExtent:$,width:P,height:H,inversePan:N,pannable:x,zoomStep:p,zoomable:y})},[x,y,N,p,$,P,H]);const Q=g?q=>{var ee;const[te,oe]=((ee=G.current)==null?void 0:ee.pointer(q))||[0,0];g(q,{x:te,y:oe})}:void 0,Z=h?k.useCallback((q,te)=>{const oe=M.getState().nodeLookup.get(te).internals.userNode;h(q,oe)},[]):void 0,K=m??b["minimap.ariaLabel"];return v.jsx(cn,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*S: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:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:v.jsxs("svg",{width:A,height:E,viewBox:`${V} ${B} ${Y} ${U}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":W,ref:_,onClick:Q,children:[K&&v.jsx("title",{id:W,children:K}),v.jsx(eg,{onClick:Z,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),v.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-j},${B-j}h${Y+j*2}v${U+j*2}h${-Y-j*2}z
|
|
7
7
|
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ts.displayName="MiniMap";const sg=k.memo(ts),ag=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,cg={[Fe.Line]:"right",[Fe.Handle]:"bottom-right"};function lg({nodeId:e,position:t,variant:n=Fe.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:d,autoScale:g=!0,shouldResize:h,onResizeStart:x,onResize:y,onResizeEnd:m}){const N=Ti(),p=typeof e=="string"?e:N,w=ie(),M=k.useRef(null),_=n===Fe.Handle,C=J(k.useCallback(ag(_&&g),[_,g]),re),T=k.useRef(null),D=t??cg[n];k.useEffect(()=>{if(!(!M.current||!p))return T.current||(T.current=Xd({domNode:M.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:$,transform:P,snapGrid:H,snapToGrid:b,nodeOrigin:A,domNode:E}=w.getState();return{nodeLookup:$,transform:P,snapGrid:H,snapToGrid:b,nodeOrigin:A,paneDomNode:E}},onChange:($,P)=>{const{triggerNodeChanges:H,nodeLookup:b,parentLookup:A,nodeOrigin:E}=w.getState(),L=[],I={x:$.x,y:$.y},S=b.get(p);if(S&&S.expandParent&&S.parentId){const z=S.origin??E,R=$.width??S.measured.width??0,j=$.height??S.measured.height??0,V={id:S.id,parentId:S.parentId,rect:{width:R,height:j,...ti({x:$.x??S.position.x,y:$.y??S.position.y},{width:R,height:j},S.parentId,b,z)}},B=to([V],b,A,E);L.push(...B),I.x=$.x?Math.max(z[0]*R,$.x):void 0,I.y=$.y?Math.max(z[1]*j,$.y):void 0}if(I.x!==void 0&&I.y!==void 0){const z={id:p,type:"position",position:{...I}};L.push(z)}if($.width!==void 0&&$.height!==void 0){const R={id:p,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};L.push(R)}for(const z of P){const R={...z,type:"position"};L.push(R)}H(L)},onEnd:({width:$,height:P})=>{const H={id:p,type:"dimensions",resizing:!1,dimensions:{width:$,height:P}};w.getState().triggerNodeChanges([H])}})),T.current.update({controlPosition:D,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:f},keepAspectRatio:u,resizeDirection:d,onResizeStart:x,onResize:y,onResizeEnd:m,shouldResize:h}),()=>{var $;($=T.current)==null||$.destroy()}},[D,a,c,l,f,u,x,y,m,h]);const O=D.split("-");return v.jsx("div",{className:se(["react-flow__resize-control","nodrag",...O,n,o]),ref:M,style:{...r,scale:C,...s&&{[_?"backgroundColor":"borderColor"]:s}},children:i})}const hr=k.memo(lg);function ug({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:o,lineClassName:r,lineStyle:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,autoScale:d=!0,shouldResize:g,onResizeStart:h,onResize:x,onResizeEnd:y}){return t?v.jsxs(v.Fragment,{children:[Rd.map(m=>v.jsx(hr,{className:r,style:i,nodeId:e,position:m,variant:Fe.Line,color:s,minWidth:a,minHeight:c,maxWidth:l,maxHeight:f,onResizeStart:h,keepAspectRatio:u,autoScale:d,shouldResize:g,onResize:x,onResizeEnd:y},m)),jd.map(m=>v.jsx(hr,{className:n,style:o,nodeId:e,position:m,color:s,minWidth:a,minHeight:c,maxWidth:l,maxHeight:f,onResizeStart:h,keepAspectRatio:u,autoScale:d,shouldResize:g,onResize:x,onResizeEnd:y},m))]}):null}const ns={component:"var(--p-symbol-node-component)",flow:"var(--p-symbol-node-flow)",gate:"var(--p-symbol-node-gate)",signal:"var(--p-symbol-node-signal)",aspect:"var(--p-symbol-node-aspect)"},os={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},dg={component:"Components",flow:"Flows",gate:"Gates",signal:"Signals",aspect:"Aspects"},En="paradigm-graph-state",fg=500;let Sn=null;function de(e){Sn&&clearTimeout(Sn),Sn=setTimeout(()=>e.saveToLocalStorage(),fg)}const ne=ua((e,t)=>({symbols:[],nodes:[],edges:[],graphName:"Untitled Graph",exportOpen:!1,loadDialogOpen:!1,fetchSymbols:async()=>{try{const o=await(await fetch("/api/symbols")).json();e({symbols:o.symbols||[]})}catch(n){console.error("Failed to fetch symbols:",n)}},onNodesChange:n=>{e(o=>({nodes:Ci(n,o.nodes)})),de(t())},onEdgesChange:n=>{e(o=>({edges:Mi(n,o.edges)})),de(t())},onConnect:n=>{const r={id:`e-${n.source}-${n.target}`,source:n.source,target:n.target,type:"default",data:{label:""}};e(i=>({edges:[...i.edges,r]})),de(t())},addSymbolToCanvas:(n,o)=>{const{nodes:r}=t();if(r.some(a=>a.id===`sym-${n.id}`))return;const i=os[n.category]||"#",s={id:`sym-${n.id}`,type:"symbolNode",position:o,data:{type:"symbol",symbol:n,label:`${i}${n.name}`}};e(a=>({nodes:[...a.nodes,s]})),de(t())},removeSelected:()=>{e(n=>{const o=new Set(n.nodes.filter(s=>s.selected).map(s=>s.id)),r=new Set(n.nodes.filter(s=>s.parentId&&o.has(s.parentId)).map(s=>s.id)),i=new Set([...o,...r]);return{nodes:n.nodes.filter(s=>!i.has(s.id)),edges:n.edges.filter(s=>!i.has(s.source)&&!i.has(s.target)&&!s.selected)}}),de(t())},groupSelected:n=>{const{nodes:o}=t(),r=o.filter(h=>h.selected&&h.type!=="groupNode");if(r.length<1)return;const i=40,s=50;let a=1/0,c=1/0,l=-1/0,f=-1/0;for(const h of r)a=Math.min(a,h.position.x),c=Math.min(c,h.position.y),l=Math.max(l,h.position.x+200),f=Math.max(f,h.position.y+60);const u=`group-${Date.now()}`,d={id:u,type:"groupNode",position:{x:a-i,y:c-i-s},style:{width:l-a+i*2+200,height:f-c+i*2+s+60},data:{type:"group",label:n}},g=o.map(h=>h.selected&&h.type!=="groupNode"?{...h,parentId:u,position:{x:h.position.x-(a-i),y:h.position.y-(c-i-s)},selected:!1}:{...h,selected:!1});e({nodes:[d,...g]}),de(t())},ungroupSelected:()=>{const{nodes:n}=t(),o=n.filter(s=>s.selected&&s.type==="groupNode");if(o.length===0)return;const r=new Set(o.map(s=>s.id)),i=n.filter(s=>!r.has(s.id)).map(s=>{if(s.parentId&&r.has(s.parentId)){const a=o.find(c=>c.id===s.parentId);return{...s,parentId:void 0,position:a?{x:s.position.x+a.position.x,y:s.position.y+a.position.y}:s.position}}return s});e({nodes:i}),de(t())},addNodeToGroup:(n,o)=>{const{nodes:r}=t(),i=r.find(c=>c.id===n),s=r.find(c=>c.id===o);if(!i||!s||i.parentId===o)return;const a=r.map(c=>c.id===n?{...c,parentId:o,position:{x:c.position.x-s.position.x,y:c.position.y-s.position.y}}:c);e({nodes:a}),de(t())},removeNodeFromGroup:n=>{const{nodes:o}=t(),r=o.find(a=>a.id===n);if(!r||!r.parentId)return;const i=o.find(a=>a.id===r.parentId),s=o.map(a=>a.id===n?{...a,parentId:void 0,position:i?{x:a.position.x+i.position.x,y:a.position.y+i.position.y}:a.position}:a);e({nodes:s}),de(t())},updateGroupLabel:(n,o)=>{e(r=>({nodes:r.nodes.map(i=>i.id===n?{...i,data:{...i.data,label:o}}:i)})),de(t())},updateEdgeLabel:(n,o)=>{e(r=>({edges:r.edges.map(i=>i.id===n?{...i,label:o,data:{...i.data,label:o}}:i)})),de(t())},setGraphName:n=>{e({graphName:n}),de(t())},setExportOpen:n=>e({exportOpen:n}),setLoadDialogOpen:n=>e({loadDialogOpen:n}),saveToLocalStorage:()=>{const{nodes:n,edges:o,graphName:r}=t(),i={version:"1.0",name:r,projectId:window.location.hostname,lastModified:new Date().toISOString(),nodes:n,edges:o};try{localStorage.setItem(En,JSON.stringify(i))}catch(s){console.error("Failed to save to localStorage:",s)}},loadFromLocalStorage:()=>{try{const n=localStorage.getItem(En);if(!n)return;const o=JSON.parse(n);e({nodes:o.nodes||[],edges:o.edges||[],graphName:o.name||"Untitled Graph"})}catch(n){console.error("Failed to load from localStorage:",n)}},exportToFile:()=>{const{nodes:n,edges:o,graphName:r}=t(),i={version:"1.0",name:r,projectId:window.location.hostname,lastModified:new Date().toISOString(),nodes:n,edges:o},s=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),a=URL.createObjectURL(s),c=document.createElement("a");c.href=a,c.download=`${r.toLowerCase().replace(/\s+/g,"-")}.graph.json`,c.click(),URL.revokeObjectURL(a)},importFromFile:n=>{e({nodes:n.nodes||[],edges:n.edges||[],graphName:n.name||"Imported Graph"}),t().saveToLocalStorage()},exportToMarkdown:()=>{var f;const{nodes:n,edges:o,graphName:r}=t(),i=n.filter(u=>u.type==="groupNode"),s=n.filter(u=>u.type==="symbolNode"),a=[`## Paradigm Graph: ${r}`,""];if(i.length>0){a.push("### Groups");for(const u of i){const d=u.data.label;a.push(`[${d}]`);const g=s.filter(h=>h.parentId===u.id);for(const h of g){const x=h.data,y=x.symbol.description?` — ${x.symbol.description}`:"";a.push(` - ${x.label}${y}`)}a.push("")}}const c=o.filter(u=>i.some(d=>d.id===u.source)&&i.some(d=>d.id===u.target));if(c.length>0){a.push("### Links");for(const u of c){const d=i.find(h=>h.id===u.source),g=i.find(h=>h.id===u.target);if(d&&g){const h=d.data.label,x=g.data.label;a.push(`[${h}] → [${x}]`);const y=u.label||((f=u.data)==null?void 0:f.label);y&&a.push(` "${y}"`)}}a.push("")}const l=s.filter(u=>!u.parentId);if(l.length>0){a.push("### Ungrouped Symbols");for(const u of l){const d=u.data,g=d.symbol.description?` — ${d.symbol.description}`:"";a.push(`- ${d.label}${g}`)}a.push("")}if(s.length>0){a.push("### Symbol Reference");for(const u of s){const d=u.data,g=d.symbol.description?` — ${d.symbol.description}`:"",h=d.symbol.path?` (${d.symbol.path})`:"";a.push(`${d.symbol.category}: ${d.label}${g}${h}`)}a.push("")}return a.join(`
|
|
8
|
-
`)},newGraph:()=>{e({nodes:[],edges:[],graphName:"Untitled Graph"}),localStorage.removeItem(En)}})),gr=["component","flow","gate","signal","aspect"];function hg(){const e=ne(l=>l.symbols),[t,n]=k.useState(""),[o,r]=k.useState({}),i=k.useMemo(()=>{if(!t.trim())return e;const l=t.toLowerCase();return e.filter(f=>f.name.toLowerCase().includes(l)||(f.description||"").toLowerCase().includes(l)||(f.tags||[]).some(u=>u.toLowerCase().includes(l)))},[e,t]),s=k.useMemo(()=>{const l={};for(const f of gr)l[f]=[];for(const f of i){const u=f.category||"component";l[u]||(l[u]=[]),l[u].push(f)}return l},[i]),a=k.useCallback(l=>{r(f=>({...f,[l]:!f[l]}))},[]),c=k.useCallback((l,f)=>{l.dataTransfer.setData("application/paradigm-symbol",JSON.stringify(f)),l.dataTransfer.effectAllowed="move"},[]);return v.jsxs("div",{className:"symbol-panel",children:[v.jsxs("div",{className:"symbol-panel__header",children:[v.jsx("h2",{children:"Symbols"}),v.jsx("span",{className:"symbol-panel__count",children:e.length})]}),v.jsx("input",{className:"symbol-panel__search",type:"text",placeholder:"Search symbols...",value:t,onChange:l=>n(l.target.value)}),v.jsx("div",{className:"symbol-panel__list",children:gr.map(l=>{const f=s[l]||[];if(f.length===0)return null;const u=ns[l],d=o[l];return v.jsxs("div",{className:"symbol-panel__section",children:[v.jsxs("button",{className:"symbol-panel__section-header",onClick:()=>a(l),style:{color:u},children:[v.jsx("span",{className:"symbol-panel__section-arrow",children:d?"▸":"▾"}),v.jsx("span",{children:dg[l]}),v.jsx("span",{className:"symbol-panel__section-count",children:f.length})]}),!d&&v.jsx("div",{className:"symbol-panel__section-items",children:f.map(g=>v.jsxs("div",{className:"symbol-panel__item",draggable:!0,onDragStart:h=>c(h,g),style:{borderLeftColor:u},children:[v.jsxs("span",{className:"symbol-panel__item-name",style:{color:u},children:[os[l],g.name]}),g.description&&v.jsx("span",{className:"symbol-panel__item-desc",children:g.description.length>40?g.description.slice(0,37)+"...":g.description})]},g.id))})]},l)})})]})}function gg({data:e}){const t=e,n=ns[t.symbol.category]||"#86efac",o=t.symbol.description||"",r=o.length>60?o.slice(0,57)+"...":o;return v.jsxs("div",{className:"symbol-node",style:{borderLeftColor:n},children:[v.jsx(Ae,{type:"target",position:X.Left}),v.jsx("div",{className:"symbol-node__name",style:{color:n},children:t.label}),r&&v.jsx("div",{className:"symbol-node__desc",children:r}),v.jsx(Ae,{type:"source",position:X.Right})]})}const pg=k.memo(gg);function mg({id:e,data:t,selected:n}){const o=t,r=ne(d=>d.updateGroupLabel),[i,s]=k.useState(!1),[a,c]=k.useState(o.label),l=k.useCallback(()=>{c(o.label),s(!0)},[o.label]),f=k.useCallback(()=>{s(!1),a.trim()&&r(e,a.trim())},[e,a,r]),u=k.useCallback(d=>{d.key==="Enter"?d.target.blur():d.key==="Escape"&&(c(o.label),s(!1))},[o.label]);return v.jsxs("div",{className:"group-node",children:[v.jsx(ug,{minWidth:200,minHeight:100,isVisible:n,lineClassName:"group-node__resizer-line",handleClassName:"group-node__resizer-handle"}),v.jsx(Ae,{type:"target",position:X.Left,className:"group-handle"}),v.jsx("div",{className:"group-node__header",onDoubleClick:l,children:i?v.jsx("input",{className:"group-node__input",value:a,onChange:d=>c(d.target.value),onBlur:f,onKeyDown:u,autoFocus:!0}):v.jsx("span",{className:"group-node__label",children:o.label})}),v.jsx(Ae,{type:"source",position:X.Right,className:"group-handle"})]})}const yg=k.memo(mg),xg={symbolNode:pg,groupNode:yg};function wg(){const e=ne(y=>y.nodes),t=ne(y=>y.edges),n=ne(y=>y.onNodesChange),o=ne(y=>y.onEdgesChange),r=ne(y=>y.onConnect),i=ne(y=>y.addSymbolToCanvas),s=ne(y=>y.addNodeToGroup),a=ne(y=>y.removeSelected),c=ne(y=>y.groupSelected),l=ne(y=>y.setExportOpen),f=k.useRef(null),u=k.useRef(null),{getIntersectingNodes:d}=ln(),g=k.useCallback(y=>{y.preventDefault(),y.dataTransfer.dropEffect="move"},[]),h=k.useCallback(y=>{y.preventDefault();const m=y.dataTransfer.getData("application/paradigm-symbol");if(m)try{const N=JSON.parse(m);if(!u.current)return;const p=u.current.screenToFlowPosition({x:y.clientX,y:y.clientY});i(N,p)}catch{}},[i]),x=k.useCallback((y,m)=>{if(m.type!=="symbolNode"||m.parentId)return;const p=d(m).find(w=>w.type==="groupNode");p&&s(m.id,p.id)},[d,s]);return k.useEffect(()=>{const y=m=>{if(m.key==="Delete"||m.key==="Backspace"){if(m.target instanceof HTMLInputElement||m.target instanceof HTMLTextAreaElement)return;a()}if((m.metaKey||m.ctrlKey)&&m.key==="g"){m.preventDefault();const N=prompt("Group label:");N&&c(N)}(m.metaKey||m.ctrlKey)&&m.key==="e"&&(m.preventDefault(),l(!0))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,c,l]),v.jsx("div",{className:"canvas-wrapper",ref:f,children:v.jsxs(Dh,{nodes:e,edges:t,onNodesChange:n,onEdgesChange:o,onConnect:r,onInit:y=>{u.current=y},onDrop:h,onDragOver:g,onNodeDragStop:x,nodeTypes:xg,selectionOnDrag:!0,panOnDrag:[1,2],selectionMode:Ze.Partial,multiSelectionKeyCode:"Meta",fitView:!0,snapToGrid:!0,snapGrid:[16,16],deleteKeyCode:null,className:"paradigm-flow",children:[v.jsx(Oh,{color:"#1e293b",gap:16}),v.jsx(Wh,{}),v.jsx(sg,{nodeColor:y=>y.type==="groupNode"?"#334155":"#86efac",style:{background:"#0f172a"}})]})})}function vg(){const e=ne(h=>h.graphName),t=ne(h=>h.setGraphName),n=ne(h=>h.nodes),o=ne(h=>h.groupSelected),r=ne(h=>h.ungroupSelected),i=ne(h=>h.removeNodeFromGroup),s=ne(h=>h.setExportOpen),a=ne(h=>h.setLoadDialogOpen),c=ne(h=>h.exportToFile),l=ne(h=>h.newGraph),f=k.useCallback(()=>{const h=prompt("Group label:");h&&o(h)},[o]),u=k.useCallback(()=>{const h=n.filter(x=>x.selected&&x.parentId);for(const x of h)i(x.id)},[n,i]),d=k.useCallback(()=>{confirm("Start a new graph? Current graph will be cleared.")&&l()},[l]),g=n.some(h=>h.selected&&h.parentId);return v.jsxs("div",{className:"toolbar",children:[v.jsx("input",{className:"toolbar__name",value:e,onChange:h=>t(h.target.value),title:"Graph name"}),v.jsxs("div",{className:"toolbar__actions",children:[v.jsx("button",{className:"toolbar__btn",onClick:f,title:"Group selected (Ctrl+G)",children:"Group"}),v.jsx("button",{className:"toolbar__btn",onClick:r,title:"Ungroup selected",children:"Ungroup"}),g&&v.jsx("button",{className:"toolbar__btn",onClick:u,title:"Remove selected from group",children:"Remove from Group"}),v.jsx("div",{className:"toolbar__divider"}),v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:()=>s(!0),title:"Export markdown (Ctrl+E)",children:"Export"}),v.jsx("button",{className:"toolbar__btn",onClick:c,title:"Save as .graph.json",children:"Save"}),v.jsx("button",{className:"toolbar__btn",onClick:()=>a(!0),title:"Load .graph.json or paste JSON",children:"Load"}),v.jsx("button",{className:"toolbar__btn",onClick:d,title:"New empty graph",children:"New"})]})]})}function bg(){const e=ne(c=>c.exportOpen),t=ne(c=>c.setExportOpen),n=ne(c=>c.exportToMarkdown),o=ne(c=>c.graphName),r=k.useRef(null),i=e?n():"",s=k.useCallback(async()=>{var c;try{await navigator.clipboard.writeText(i),r.current&&r.current.select()}catch{(c=r.current)==null||c.select(),document.execCommand("copy")}},[i]),a=k.useCallback(()=>{const c=new Blob([i],{type:"text/markdown"}),l=URL.createObjectURL(c),f=document.createElement("a");f.href=l,f.download=`${o.toLowerCase().replace(/\s+/g,"-")}.md`,f.click(),URL.revokeObjectURL(l)},[i,o]);return k.useEffect(()=>{if(!e)return;const c=l=>{l.key==="Escape"&&t(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,t]),e?v.jsx("div",{className:"export-overlay",onClick:()=>t(!1),children:v.jsxs("div",{className:"export-dialog",onClick:c=>c.stopPropagation(),children:[v.jsxs("div",{className:"export-dialog__header",children:[v.jsx("h3",{children:"Export Markdown"}),v.jsx("button",{className:"export-dialog__close",onClick:()=>t(!1),children:"×"})]}),v.jsx("textarea",{ref:r,className:"export-dialog__content",value:i,readOnly:!0,rows:20}),v.jsxs("div",{className:"export-dialog__actions",children:[v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:s,children:"Copy to Clipboard"}),v.jsx("button",{className:"toolbar__btn",onClick:a,children:"Download .md"})]})]})}):null}function _g(){const e=ne(_=>_.loadDialogOpen),t=ne(_=>_.setLoadDialogOpen),n=ne(_=>_.importFromFile),o=k.useRef(null),[r,i]=k.useState(""),[s,a]=k.useState(null),[c,l]=k.useState(null),[f,u]=k.useState([]),[d,g]=k.useState(!1),h=k.useCallback(()=>{i(""),a(null),l(null)},[]),x=k.useCallback(()=>{t(!1),h()},[t,h]);k.useEffect(()=>{e&&(g(!0),fetch("/api/graphs").then(_=>_.json()).then(_=>u(_.graphs||[])).catch(()=>u([])).finally(()=>g(!1)))},[e]);const y=k.useCallback(async _=>{try{const T=await(await fetch(`/api/graphs/${_}`)).json();n(T),x()}catch{a({type:"error",message:`Failed to load graph "${_}".`})}},[n,x]),m=k.useCallback(()=>{var _,C;try{const T=JSON.parse(r);if(!T.version||!Array.isArray(T.nodes)){a({type:"error",message:'Invalid graph: missing "version" or "nodes" array.'}),l(null);return}l(T);const D=((_=T.nodes)==null?void 0:_.length)||0,O=((C=T.edges)==null?void 0:C.length)||0;a({type:"success",message:`Valid graph: ${D} nodes, ${O} edges.`})}catch{a({type:"error",message:"Invalid JSON."}),l(null)}},[r]),N=k.useCallback(()=>{c&&(n(c),x())},[c,n,x]),p=k.useCallback(_=>{var D;const C=(D=_.target.files)==null?void 0:D[0];if(!C)return;const T=new FileReader;T.onload=()=>{try{const O=JSON.parse(T.result);n(O),x()}catch{a({type:"error",message:"Invalid graph file."})}},T.readAsText(C),_.target.value=""},[n,x]);if(k.useEffect(()=>{if(!e)return;const _=C=>{C.key==="Escape"&&x()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e,x]),!e)return null;function w(_){return _<1024?`${_} B`:`${(_/1024).toFixed(1)} KB`}function M(_){return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}return v.jsx("div",{className:"export-overlay",onClick:x,children:v.jsxs("div",{className:"export-dialog load-dialog",onClick:_=>_.stopPropagation(),children:[v.jsxs("div",{className:"export-dialog__header",children:[v.jsx("h3",{children:"Load Graph"}),v.jsx("button",{className:"export-dialog__close",onClick:x,children:"×"})]}),v.jsxs("div",{className:"load-dialog__body",children:[(f.length>0||d)&&v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Saved Graphs"}),d?v.jsx("div",{className:"load-dialog__loading",children:"Loading..."}):v.jsx("div",{className:"load-dialog__graph-list",children:f.map(_=>v.jsxs("button",{className:"load-dialog__graph-item",onClick:()=>y(_.slug),children:[v.jsx("span",{className:"load-dialog__graph-name",children:_.name}),v.jsxs("span",{className:"load-dialog__graph-meta",children:[_.nodes," nodes, ",_.edges," edges · ",w(_.size)," · ",M(_.modified)]})]},_.slug))})]}),f.length>0&&v.jsx("div",{className:"load-dialog__divider",children:v.jsx("span",{children:"or"})}),v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Upload File"}),v.jsx("button",{className:"toolbar__btn",onClick:()=>{var _;return(_=o.current)==null?void 0:_.click()},children:"Choose .graph.json"}),v.jsx("input",{ref:o,type:"file",accept:".json,.graph.json",style:{display:"none"},onChange:p})]}),v.jsx("div",{className:"load-dialog__divider",children:v.jsx("span",{children:"or"})}),v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Paste JSON"}),v.jsx("textarea",{className:"export-dialog__content",value:r,onChange:_=>{i(_.target.value),a(null),l(null)},placeholder:"Paste GraphState JSON here...",rows:8})]}),s&&v.jsx("div",{className:`load-dialog__status load-dialog__status--${s.type}`,children:s.message})]}),v.jsxs("div",{className:"export-dialog__actions",children:[v.jsx("button",{className:"toolbar__btn",onClick:m,disabled:!r.trim(),children:"Validate"}),v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:N,disabled:!c,children:"Apply"})]})]})})}function Eg(){const e=ne(n=>n.fetchSymbols),t=ne(n=>n.loadFromLocalStorage);return k.useEffect(()=>{e(),t()},[e,t]),v.jsx(Qi,{children:v.jsxs("div",{className:"app",style:{height:"100%"},children:[v.jsx(hg,{}),v.jsxs("div",{className:"app__main",children:[v.jsx(vg,{}),v.jsx(wg,{})]}),v.jsx(bg,{}),v.jsx(_g,{})]})})}export{Eg as default};
|
|
8
|
+
`)},newGraph:()=>{e({nodes:[],edges:[],graphName:"Untitled Graph"}),localStorage.removeItem(En)}})),gr=["component","flow","gate","signal","aspect"];function hg(){const e=ne(l=>l.symbols),[t,n]=k.useState(""),[o,r]=k.useState({}),i=k.useMemo(()=>{if(!t.trim())return e;const l=t.toLowerCase();return e.filter(f=>f.name.toLowerCase().includes(l)||(f.description||"").toLowerCase().includes(l)||(f.tags||[]).some(u=>u.toLowerCase().includes(l)))},[e,t]),s=k.useMemo(()=>{const l={};for(const f of gr)l[f]=[];for(const f of i){const u=f.category||"component";l[u]||(l[u]=[]),l[u].push(f)}return l},[i]),a=k.useCallback(l=>{r(f=>({...f,[l]:!f[l]}))},[]),c=k.useCallback((l,f)=>{l.dataTransfer.setData("application/paradigm-symbol",JSON.stringify(f)),l.dataTransfer.effectAllowed="move"},[]);return v.jsxs("div",{className:"symbol-panel",children:[v.jsxs("div",{className:"symbol-panel__header",children:[v.jsx("h2",{children:"Symbols"}),v.jsx("span",{className:"symbol-panel__count",children:e.length})]}),v.jsx("input",{className:"symbol-panel__search",type:"text",placeholder:"Search symbols...",value:t,onChange:l=>n(l.target.value)}),v.jsx("div",{className:"symbol-panel__list",children:gr.map(l=>{const f=s[l]||[];if(f.length===0)return null;const u=ns[l],d=o[l];return v.jsxs("div",{className:"symbol-panel__section",children:[v.jsxs("button",{className:"symbol-panel__section-header",onClick:()=>a(l),style:{color:u},children:[v.jsx("span",{className:"symbol-panel__section-arrow",children:d?"▸":"▾"}),v.jsx("span",{children:dg[l]}),v.jsx("span",{className:"symbol-panel__section-count",children:f.length})]}),!d&&v.jsx("div",{className:"symbol-panel__section-items",children:f.map(g=>v.jsxs("div",{className:"symbol-panel__item",draggable:!0,onDragStart:h=>c(h,g),style:{borderLeftColor:u},children:[v.jsxs("span",{className:"symbol-panel__item-name",style:{color:u},children:[os[l],g.name]}),g.description&&v.jsx("span",{className:"symbol-panel__item-desc",children:g.description.length>40?g.description.slice(0,37)+"...":g.description})]},g.id))})]},l)})})]})}function gg({data:e}){const t=e,n=ns[t.symbol.category]||"var(--p-symbol-node-component)",o=t.symbol.description||"",r=o.length>60?o.slice(0,57)+"...":o;return v.jsxs("div",{className:"symbol-node",style:{borderLeftColor:n},children:[v.jsx(Ae,{type:"target",position:X.Left}),v.jsx("div",{className:"symbol-node__name",style:{color:n},children:t.label}),r&&v.jsx("div",{className:"symbol-node__desc",children:r}),v.jsx(Ae,{type:"source",position:X.Right})]})}const pg=k.memo(gg);function mg({id:e,data:t,selected:n}){const o=t,r=ne(d=>d.updateGroupLabel),[i,s]=k.useState(!1),[a,c]=k.useState(o.label),l=k.useCallback(()=>{c(o.label),s(!0)},[o.label]),f=k.useCallback(()=>{s(!1),a.trim()&&r(e,a.trim())},[e,a,r]),u=k.useCallback(d=>{d.key==="Enter"?d.target.blur():d.key==="Escape"&&(c(o.label),s(!1))},[o.label]);return v.jsxs("div",{className:"group-node",children:[v.jsx(ug,{minWidth:200,minHeight:100,isVisible:n,lineClassName:"group-node__resizer-line",handleClassName:"group-node__resizer-handle"}),v.jsx(Ae,{type:"target",position:X.Left,className:"group-handle"}),v.jsx("div",{className:"group-node__header",onDoubleClick:l,children:i?v.jsx("input",{className:"group-node__input",value:a,onChange:d=>c(d.target.value),onBlur:f,onKeyDown:u,autoFocus:!0}):v.jsx("span",{className:"group-node__label",children:o.label})}),v.jsx(Ae,{type:"source",position:X.Right,className:"group-handle"})]})}const yg=k.memo(mg),xg={symbolNode:pg,groupNode:yg};function wg(){const e=ne(y=>y.nodes),t=ne(y=>y.edges),n=ne(y=>y.onNodesChange),o=ne(y=>y.onEdgesChange),r=ne(y=>y.onConnect),i=ne(y=>y.addSymbolToCanvas),s=ne(y=>y.addNodeToGroup),a=ne(y=>y.removeSelected),c=ne(y=>y.groupSelected),l=ne(y=>y.setExportOpen),f=k.useRef(null),u=k.useRef(null),{getIntersectingNodes:d}=ln(),g=k.useCallback(y=>{y.preventDefault(),y.dataTransfer.dropEffect="move"},[]),h=k.useCallback(y=>{y.preventDefault();const m=y.dataTransfer.getData("application/paradigm-symbol");if(m)try{const N=JSON.parse(m);if(!u.current)return;const p=u.current.screenToFlowPosition({x:y.clientX,y:y.clientY});i(N,p)}catch{}},[i]),x=k.useCallback((y,m)=>{if(m.type!=="symbolNode"||m.parentId)return;const p=d(m).find(w=>w.type==="groupNode");p&&s(m.id,p.id)},[d,s]);return k.useEffect(()=>{const y=m=>{if(m.key==="Delete"||m.key==="Backspace"){if(m.target instanceof HTMLInputElement||m.target instanceof HTMLTextAreaElement)return;a()}if((m.metaKey||m.ctrlKey)&&m.key==="g"){m.preventDefault();const N=prompt("Group label:");N&&c(N)}(m.metaKey||m.ctrlKey)&&m.key==="e"&&(m.preventDefault(),l(!0))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,c,l]),v.jsx("div",{className:"canvas-wrapper",ref:f,children:v.jsxs(Dh,{nodes:e,edges:t,onNodesChange:n,onEdgesChange:o,onConnect:r,onInit:y=>{u.current=y},onDrop:h,onDragOver:g,onNodeDragStop:x,nodeTypes:xg,selectionOnDrag:!0,panOnDrag:[1,2],selectionMode:Ze.Partial,multiSelectionKeyCode:"Meta",fitView:!0,snapToGrid:!0,snapGrid:[16,16],deleteKeyCode:null,className:"paradigm-flow",children:[v.jsx(Oh,{color:"var(--p-bg-tertiary)",gap:16}),v.jsx(Wh,{}),v.jsx(sg,{nodeColor:y=>y.type==="groupNode"?"var(--p-bg-hover)":"var(--p-symbol-node-component)",style:{background:"var(--p-bg-primary)"}})]})})}function vg(){const e=ne(h=>h.graphName),t=ne(h=>h.setGraphName),n=ne(h=>h.nodes),o=ne(h=>h.groupSelected),r=ne(h=>h.ungroupSelected),i=ne(h=>h.removeNodeFromGroup),s=ne(h=>h.setExportOpen),a=ne(h=>h.setLoadDialogOpen),c=ne(h=>h.exportToFile),l=ne(h=>h.newGraph),f=k.useCallback(()=>{const h=prompt("Group label:");h&&o(h)},[o]),u=k.useCallback(()=>{const h=n.filter(x=>x.selected&&x.parentId);for(const x of h)i(x.id)},[n,i]),d=k.useCallback(()=>{confirm("Start a new graph? Current graph will be cleared.")&&l()},[l]),g=n.some(h=>h.selected&&h.parentId);return v.jsxs("div",{className:"toolbar",children:[v.jsx("input",{className:"toolbar__name",value:e,onChange:h=>t(h.target.value),title:"Graph name"}),v.jsxs("div",{className:"toolbar__actions",children:[v.jsx("button",{className:"toolbar__btn",onClick:f,title:"Group selected (Ctrl+G)",children:"Group"}),v.jsx("button",{className:"toolbar__btn",onClick:r,title:"Ungroup selected",children:"Ungroup"}),g&&v.jsx("button",{className:"toolbar__btn",onClick:u,title:"Remove selected from group",children:"Remove from Group"}),v.jsx("div",{className:"toolbar__divider"}),v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:()=>s(!0),title:"Export markdown (Ctrl+E)",children:"Export"}),v.jsx("button",{className:"toolbar__btn",onClick:c,title:"Save as .graph.json",children:"Save"}),v.jsx("button",{className:"toolbar__btn",onClick:()=>a(!0),title:"Load .graph.json or paste JSON",children:"Load"}),v.jsx("button",{className:"toolbar__btn",onClick:d,title:"New empty graph",children:"New"})]})]})}function bg(){const e=ne(c=>c.exportOpen),t=ne(c=>c.setExportOpen),n=ne(c=>c.exportToMarkdown),o=ne(c=>c.graphName),r=k.useRef(null),i=e?n():"",s=k.useCallback(async()=>{var c;try{await navigator.clipboard.writeText(i),r.current&&r.current.select()}catch{(c=r.current)==null||c.select(),document.execCommand("copy")}},[i]),a=k.useCallback(()=>{const c=new Blob([i],{type:"text/markdown"}),l=URL.createObjectURL(c),f=document.createElement("a");f.href=l,f.download=`${o.toLowerCase().replace(/\s+/g,"-")}.md`,f.click(),URL.revokeObjectURL(l)},[i,o]);return k.useEffect(()=>{if(!e)return;const c=l=>{l.key==="Escape"&&t(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,t]),e?v.jsx("div",{className:"export-overlay",onClick:()=>t(!1),children:v.jsxs("div",{className:"export-dialog",onClick:c=>c.stopPropagation(),children:[v.jsxs("div",{className:"export-dialog__header",children:[v.jsx("h3",{children:"Export Markdown"}),v.jsx("button",{className:"export-dialog__close",onClick:()=>t(!1),children:"×"})]}),v.jsx("textarea",{ref:r,className:"export-dialog__content",value:i,readOnly:!0,rows:20}),v.jsxs("div",{className:"export-dialog__actions",children:[v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:s,children:"Copy to Clipboard"}),v.jsx("button",{className:"toolbar__btn",onClick:a,children:"Download .md"})]})]})}):null}function _g(){const e=ne(_=>_.loadDialogOpen),t=ne(_=>_.setLoadDialogOpen),n=ne(_=>_.importFromFile),o=k.useRef(null),[r,i]=k.useState(""),[s,a]=k.useState(null),[c,l]=k.useState(null),[f,u]=k.useState([]),[d,g]=k.useState(!1),h=k.useCallback(()=>{i(""),a(null),l(null)},[]),x=k.useCallback(()=>{t(!1),h()},[t,h]);k.useEffect(()=>{e&&(g(!0),fetch("/api/graphs").then(_=>_.json()).then(_=>u(_.graphs||[])).catch(()=>u([])).finally(()=>g(!1)))},[e]);const y=k.useCallback(async _=>{try{const T=await(await fetch(`/api/graphs/${_}`)).json();n(T),x()}catch{a({type:"error",message:`Failed to load graph "${_}".`})}},[n,x]),m=k.useCallback(()=>{var _,C;try{const T=JSON.parse(r);if(!T.version||!Array.isArray(T.nodes)){a({type:"error",message:'Invalid graph: missing "version" or "nodes" array.'}),l(null);return}l(T);const D=((_=T.nodes)==null?void 0:_.length)||0,O=((C=T.edges)==null?void 0:C.length)||0;a({type:"success",message:`Valid graph: ${D} nodes, ${O} edges.`})}catch{a({type:"error",message:"Invalid JSON."}),l(null)}},[r]),N=k.useCallback(()=>{c&&(n(c),x())},[c,n,x]),p=k.useCallback(_=>{var D;const C=(D=_.target.files)==null?void 0:D[0];if(!C)return;const T=new FileReader;T.onload=()=>{try{const O=JSON.parse(T.result);n(O),x()}catch{a({type:"error",message:"Invalid graph file."})}},T.readAsText(C),_.target.value=""},[n,x]);if(k.useEffect(()=>{if(!e)return;const _=C=>{C.key==="Escape"&&x()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e,x]),!e)return null;function w(_){return _<1024?`${_} B`:`${(_/1024).toFixed(1)} KB`}function M(_){return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}return v.jsx("div",{className:"export-overlay",onClick:x,children:v.jsxs("div",{className:"export-dialog load-dialog",onClick:_=>_.stopPropagation(),children:[v.jsxs("div",{className:"export-dialog__header",children:[v.jsx("h3",{children:"Load Graph"}),v.jsx("button",{className:"export-dialog__close",onClick:x,children:"×"})]}),v.jsxs("div",{className:"load-dialog__body",children:[(f.length>0||d)&&v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Saved Graphs"}),d?v.jsx("div",{className:"load-dialog__loading",children:"Loading..."}):v.jsx("div",{className:"load-dialog__graph-list",children:f.map(_=>v.jsxs("button",{className:"load-dialog__graph-item",onClick:()=>y(_.slug),children:[v.jsx("span",{className:"load-dialog__graph-name",children:_.name}),v.jsxs("span",{className:"load-dialog__graph-meta",children:[_.nodes," nodes, ",_.edges," edges · ",w(_.size)," · ",M(_.modified)]})]},_.slug))})]}),f.length>0&&v.jsx("div",{className:"load-dialog__divider",children:v.jsx("span",{children:"or"})}),v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Upload File"}),v.jsx("button",{className:"toolbar__btn",onClick:()=>{var _;return(_=o.current)==null?void 0:_.click()},children:"Choose .graph.json"}),v.jsx("input",{ref:o,type:"file",accept:".json,.graph.json",style:{display:"none"},onChange:p})]}),v.jsx("div",{className:"load-dialog__divider",children:v.jsx("span",{children:"or"})}),v.jsxs("div",{className:"load-dialog__section",children:[v.jsx("label",{className:"load-dialog__label",children:"Paste JSON"}),v.jsx("textarea",{className:"export-dialog__content",value:r,onChange:_=>{i(_.target.value),a(null),l(null)},placeholder:"Paste GraphState JSON here...",rows:8})]}),s&&v.jsx("div",{className:`load-dialog__status load-dialog__status--${s.type}`,children:s.message})]}),v.jsxs("div",{className:"export-dialog__actions",children:[v.jsx("button",{className:"toolbar__btn",onClick:m,disabled:!r.trim(),children:"Validate"}),v.jsx("button",{className:"toolbar__btn toolbar__btn--primary",onClick:N,disabled:!c,children:"Apply"})]})]})})}function Eg(){const e=ne(n=>n.fetchSymbols),t=ne(n=>n.loadFromLocalStorage);return k.useEffect(()=>{e(),t()},[e,t]),v.jsx(Qi,{children:v.jsxs("div",{className:"app",style:{height:"100%"},children:[v.jsx(hg,{}),v.jsxs("div",{className:"app__main",children:[v.jsx(vg,{}),v.jsx(wg,{})]}),v.jsx(bg,{}),v.jsx(_g,{})]})})}export{Eg as default};
|