@xyflow/react 12.0.3 → 12.1.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/base.css +2 -2
- package/dist/esm/additional-components/Background/Background.d.ts.map +1 -1
- package/dist/esm/additional-components/Background/types.d.ts +1 -1
- package/dist/esm/additional-components/Background/types.d.ts.map +1 -1
- package/dist/esm/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
- package/dist/esm/components/Handle/index.d.ts.map +1 -1
- package/dist/esm/container/Pane/index.d.ts.map +1 -1
- package/dist/esm/hooks/useConnection.d.ts +1 -1
- package/dist/esm/hooks/useConnection.d.ts.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +86 -66
- package/dist/esm/index.mjs +86 -66
- package/dist/esm/store/index.d.ts.map +1 -1
- package/dist/esm/types/edges.d.ts +2 -2
- package/dist/esm/types/edges.d.ts.map +1 -1
- package/dist/esm/types/store.d.ts +3 -1
- package/dist/esm/types/store.d.ts.map +1 -1
- package/dist/style.css +2 -2
- package/dist/umd/additional-components/Background/Background.d.ts.map +1 -1
- package/dist/umd/additional-components/Background/types.d.ts +1 -1
- package/dist/umd/additional-components/Background/types.d.ts.map +1 -1
- package/dist/umd/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
- package/dist/umd/components/Handle/index.d.ts.map +1 -1
- package/dist/umd/container/Pane/index.d.ts.map +1 -1
- package/dist/umd/hooks/useConnection.d.ts +1 -1
- package/dist/umd/hooks/useConnection.d.ts.map +1 -1
- package/dist/umd/index.d.ts +3 -1
- package/dist/umd/index.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/store/index.d.ts.map +1 -1
- package/dist/umd/types/edges.d.ts +2 -2
- package/dist/umd/types/edges.d.ts.map +1 -1
- package/dist/umd/types/store.d.ts +3 -1
- package/dist/umd/types/store.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFlow={},e.jsxRuntime,e.React,e.ReactDOM)}(this,(function(e,t,n,o){"use strict";function r(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=r(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var i={value:()=>{}};function s(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new a(o)}function a(e){this._=e}function l(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function c(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=i,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}a.prototype=s.prototype={constructor:a,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++s<a;)if(n=(e=i[s]).type)r[n]=c(r[n],e.name,t);else if(null==t)for(n in r)r[n]=c(r[n],e.name,null);return this}for(;++s<a;)if((n=(e=i[s]).type)&&(n=l(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new a(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},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)}};var u="http://www.w3.org/1999/xhtml",d={svg:"http://www.w3.org/2000/svg",xhtml:u,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function h(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),d.hasOwnProperty(t)?{space:d[t],local:e}:e}function f(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===u&&t.documentElement.namespaceURI===u?t.createElement(e):t.createElementNS(n,e)}}function g(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function p(e){var t=h(e);return(t.local?g:f)(t)}function m(){}function y(e){return null==e?m:function(){return this.querySelector(e)}}function v(){return[]}function x(e){return null==e?v:function(){return this.querySelectorAll(e)}}function w(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function b(e){return function(){return this.matches(e)}}function S(e){return function(t){return t.matches(e)}}var C=Array.prototype.find;function E(){return this.firstElementChild}var k=Array.prototype.filter;function _(){return Array.from(this.children)}function M(e){return new Array(e.length)}function N(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function P(e,t,n,o,r,i){for(var s,a=0,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],o[a]=s):n[a]=new N(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function z(e,t,n,o,r,i,s){var a,l,c,u=new Map,d=t.length,h=i.length,f=new Array(d);for(a=0;a<d;++a)(l=t[a])&&(f[a]=c=s.call(l,l.__data__,a,t)+"",u.has(c)?r[a]=l:u.set(c,l));for(a=0;a<h;++a)c=s.call(e,i[a],a,i)+"",(l=u.get(c))?(o[a]=l,l.__data__=i[a],u.delete(c)):n[a]=new N(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&u.get(f[a])===l&&(r[a]=l)}function O(e){return e.__data__}function I(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function A(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function R(e){return function(){this.removeAttribute(e)}}function D(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $(e,t){return function(){this.setAttribute(e,t)}}function L(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function T(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function V(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function j(e){return function(){this.style.removeProperty(e)}}function H(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Z(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function X(e,t){return e.style.getPropertyValue(t)||V(e).getComputedStyle(e,null).getPropertyValue(t)}function Y(e){return function(){delete this[e]}}function W(e,t){return function(){this[e]=t}}function F(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function K(e){return e.trim().split(/^|\s+/)}function G(e){return e.classList||new q(e)}function q(e){this._node=e,this._names=K(e.getAttribute("class")||"")}function U(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Q(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function J(e){return function(){U(this,e)}}function ee(e){return function(){Q(this,e)}}function te(e,t){return function(){(t.apply(this,arguments)?U:Q)(this,e)}}function ne(){this.textContent=""}function oe(e){return function(){this.textContent=e}}function re(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function ie(){this.innerHTML=""}function se(e){return function(){this.innerHTML=e}}function ae(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function le(){this.nextSibling&&this.parentNode.appendChild(this)}function ce(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ue(){return null}function de(){var e=this.parentNode;e&&e.removeChild(this)}function he(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ge(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function pe(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function me(e,t,n){var o=V(e),r=o.CustomEvent;"function"==typeof r?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 ye(e,t){return function(){return me(this,e,t)}}function ve(e,t){return function(){return me(this,e,t.apply(this,arguments))}}N.prototype={constructor:N,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)}},q.prototype={add:function(e){this._names.indexOf(e)<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}};var xe=[null];function we(e,t){this._groups=e,this._parents=t}function be(){return new we([[document.documentElement]],xe)}function Se(e){return"string"==typeof e?new we([[document.querySelector(e)]],[document.documentElement]):new we([[e]],xe)}function Ce(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(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())).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]}we.prototype=be.prototype={constructor:we,select:function(e){"function"!=typeof e&&(e=y(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s,a=t[r],l=a.length,c=o[r]=new Array(l),u=0;u<l;++u)(i=a[u])&&(s=e.call(i,i.__data__,u,a))&&("__data__"in i&&(s.__data__=i.__data__),c[u]=s);return new we(o,this._parents)},selectAll:function(e){e="function"==typeof e?w(e):x(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s,a=t[i],l=a.length,c=0;c<l;++c)(s=a[c])&&(o.push(e.call(s,s.__data__,c,a)),r.push(s));return new we(o,r)},selectChild:function(e){return this.select(null==e?E:function(e){return function(){return C.call(this.children,e)}}("function"==typeof e?e:S(e)))},selectChildren:function(e){return this.selectAll(null==e?_:function(e){return function(){return k.call(this.children,e)}}("function"==typeof e?e:S(e)))},filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s=t[r],a=s.length,l=o[r]=[],c=0;c<a;++c)(i=s[c])&&e.call(i,i.__data__,c,s)&&l.push(i);return new we(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,O);var n,o=t?z:P,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var s=i.length,a=new Array(s),l=new Array(s),c=new Array(s),u=0;u<s;++u){var d=r[u],h=i[u],f=h.length,g=I(e.call(d,d&&d.__data__,u,r)),p=g.length,m=l[u]=new Array(p),y=a[u]=new Array(p);o(d,h,m,y,c[u]=new Array(f),g,t);for(var v,x,w=0,b=0;w<p;++w)if(v=m[w]){for(w>=b&&(b=w+1);!(x=y[b])&&++b<p;);v._next=x||null}}return(a=new we(a,r))._enter=l,a._exit=c,a},enter:function(){return new we(this._enter||this._groups.map(M),this._parents)},exit:function(){return new we(this._exit||this._groups.map(M),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c,u=n[l],d=o[l],h=u.length,f=a[l]=new Array(h),g=0;g<h;++g)(c=u[g]||d[g])&&(f[g]=c);for(;l<r;++l)a[l]=n[l];return new we(a,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,s=r[i];--i>=0;)(o=r[i])&&(s&&4^o.compareDocumentPosition(s)&&s.parentNode.insertBefore(o,s),s=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=A);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s,a=n[i],l=a.length,c=r[i]=new Array(l),u=0;u<l;++u)(s=a[u])&&(c[u]=s);c.sort(t)}return new we(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){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},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],s=0,a=i.length;s<a;++s)(r=i[s])&&e.call(r,r.__data__,s,i);return this},attr:function(e,t){var n=h(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?D:R:"function"==typeof t?n.local?B:T:n.local?L:$)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?j:"function"==typeof t?Z:H)(e,t,null==n?"":n)):X(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Y:"function"==typeof t?F:W)(e,t)):this.node()[e]},classed:function(e,t){var n=K(e+"");if(arguments.length<2){for(var o=G(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?te:t?J:ee)(n,t))},text:function(e){return arguments.length?this.each(null==e?ne:("function"==typeof e?re:oe)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?ie:("function"==typeof e?ae:se)(e)):this.node().innerHTML},raise:function(){return this.each(le)},lower:function(){return this.each(ce)},append:function(e){var t="function"==typeof e?e:p(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:p(e),o=null==t?ue:"function"==typeof t?t:y(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(de)},clone:function(e){return this.select(e?fe:he)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),s=i.length;if(!(arguments.length<2)){for(a=t?pe:ge,o=0;o<s;++o)this.each(a(i[o],t,n));return this}var a=this.node().__on;if(a)for(var l,c=0,u=a.length;c<u;++c)for(o=0,l=a[c];o<s;++o)if((r=i[o]).type===l.type&&r.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?ve:ye)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,s=r.length;i<s;++i)(o=r[i])&&(yield o)}};const Ee={passive:!1},ke={capture:!0,passive:!1};function _e(e){e.stopImmediatePropagation()}function Me(e){e.preventDefault(),e.stopImmediatePropagation()}function Ne(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",Me,ke);"onselectstart"in t?n.on("selectstart.drag",Me,ke):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pe(e,t){var n=e.document.documentElement,o=Se(e).on("dragstart.drag",null);t&&(o.on("click.drag",Me,ke),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ze=e=>()=>e;function Oe(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Ie(e){return!e.ctrlKey&&!e.button}function Ae(){return this.parentNode}function Re(e,t){return null==t?{x:e.x,y:e.y}:t}function De(){return navigator.maxTouchPoints||"ontouchstart"in this}function $e(){var e,t,n,o,r=Ie,i=Ae,a=Re,l=De,c={},u=s("start","drag","end"),d=0,h=0;function f(e){e.on("mousedown.drag",g).filter(l).on("touchstart.drag",y).on("touchmove.drag",v,Ee).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(s,a){if(!o&&r.call(this,s,a)){var l=w(this,i.call(this,s,a),s,a,"mouse");l&&(Se(s.view).on("mousemove.drag",p,ke).on("mouseup.drag",m,ke),Ne(s.view),_e(s),n=!1,e=s.clientX,t=s.clientY,l("start",s))}}function p(o){if(Me(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>h}c.mouse("drag",o)}function m(e){Se(e.view).on("mousemove.drag mouseup.drag",null),Pe(e.view,n),Me(e),c.mouse("end",e)}function y(e,t){if(r.call(this,e,t)){var n,o,s=e.changedTouches,a=i.call(this,e,t),l=s.length;for(n=0;n<l;++n)(o=w(this,a,e,t,s[n].identifier,s[n]))&&(_e(e),o("start",e,s[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=c[o[t].identifier])&&(Me(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=c[r[t].identifier])&&(_e(e),n("end",e,r[t]))}function w(e,t,n,o,r,i){var s,l,h,g=u.copy(),p=Ce(i||n,t);if(null!=(h=a.call(e,new Oe("beforestart",{sourceEvent:n,target:f,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return s=h.x-p[0]||0,l=h.y-p[1]||0,function n(i,a,u){var m,y=p;switch(i){case"start":c[r]=n,m=d++;break;case"end":delete c[r],--d;case"drag":p=Ce(u||a,t),m=d}g.call(i,e,new Oe(i,{sourceEvent:a,subject:h,target:f,identifier:r,active:m,x:p[0]+s,y:p[1]+l,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return f.filter=function(e){return arguments.length?(r="function"==typeof e?e:ze(!!e),f):r},f.container=function(e){return arguments.length?(i="function"==typeof e?e:ze(e),f):i},f.subject=function(e){return arguments.length?(a="function"==typeof e?e:ze(e),f):a},f.touchable=function(e){return arguments.length?(l="function"==typeof e?e:ze(!!e),f):l},f.on=function(){var e=u.on.apply(u,arguments);return e===u?f:e},f.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,f):Math.sqrt(h)},f}function Le(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Be(){}Oe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Ve=.7,je=1/Ve,He="\\s*([+-]?\\d+)\\s*",Ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ye=/^#([0-9a-f]{3,8})$/,We=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Fe=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),Ke=new RegExp(`^rgba\\(${He},${He},${He},${Ze}\\)$`),Ge=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Ze}\\)$`),qe=new RegExp(`^hsl\\(${Ze},${Xe},${Xe}\\)$`),Ue=new RegExp(`^hsla\\(${Ze},${Xe},${Xe},${Ze}\\)$`),Qe={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};function Je(){return this.rgb().formatHex()}function et(){return this.rgb().formatRgb()}function tt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ye.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?nt(t):3===n?new it(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?ot(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?ot(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=We.exec(e))?new it(t[1],t[2],t[3],1):(t=Fe.exec(e))?new it(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ke.exec(e))?ot(t[1],t[2],t[3],t[4]):(t=Ge.exec(e))?ot(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=qe.exec(e))?dt(t[1],t[2]/100,t[3]/100,1):(t=Ue.exec(e))?dt(t[1],t[2]/100,t[3]/100,t[4]):Qe.hasOwnProperty(e)?nt(Qe[e]):"transparent"===e?new it(NaN,NaN,NaN,0):null}function nt(e){return new it(e>>16&255,e>>8&255,255&e,1)}function ot(e,t,n,o){return o<=0&&(e=t=n=NaN),new it(e,t,n,o)}function rt(e,t,n,o){return 1===arguments.length?((r=e)instanceof Be||(r=tt(r)),r?new it((r=r.rgb()).r,r.g,r.b,r.opacity):new it):new it(e,t,n,null==o?1:o);var r}function it(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function st(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function at(){const e=lt(this.opacity);return`${1===e?"rgb(":"rgba("}${ct(this.r)}, ${ct(this.g)}, ${ct(this.b)}${1===e?")":`, ${e})`}`}function lt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return((e=ct(e))<16?"0":"")+e.toString(16)}function dt(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,n,o)}function ht(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof Be||(e=tt(e)),!e)return new ft;if(e instanceof ft)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,l=(i+r)/2;return a?(s=t===i?(n-o)/a+6*(n<o):n===i?(o-t)/a+2:(t-n)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new ft(s,a,l,e.opacity)}function ft(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function gt(e){return(e=(e||0)%360)<0?e+360:e}function pt(e){return Math.max(0,Math.min(1,e||0))}function mt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}Le(Be,tt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Je,formatHex:Je,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ht(this).formatHsl()},formatRgb:et,toString:et}),Le(it,rt,Te(Be,{brighter(e){return e=null==e?je:Math.pow(je,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?Ve:Math.pow(Ve,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it(ct(this.r),ct(this.g),ct(this.b),lt(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:st,formatHex:st,formatHex8:function(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:at,toString:at})),Le(ft,(function(e,t,n,o){return 1===arguments.length?ht(e):new ft(e,t,n,null==o?1:o)}),Te(Be,{brighter(e){return e=null==e?je:Math.pow(je,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?Ve:Math.pow(Ve,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),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 it(mt(e>=240?e-240:e+120,r,o),mt(e,r,o),mt(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ft(gt(this.h),pt(this.s),pt(this.l),lt(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=lt(this.opacity);return`${1===e?"hsl(":"hsla("}${gt(this.h)}, ${100*pt(this.s)}%, ${100*pt(this.l)}%${1===e?")":`, ${e})`}`}}));var yt=e=>()=>e;function vt(e){return 1==(e=+e)?xt:function(t,n){return n-t?function(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)}}(t,n,e):yt(isNaN(t)?n:t)}}function xt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):yt(isNaN(e)?t:e)}var wt=function e(t){var n=vt(t);function o(e,t){var o=n((e=rt(e)).r,(t=rt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),s=xt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=s(t),e+""}}return o.gamma=e,o}(1);function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var St=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ct=new RegExp(St.source,"g");function Et(e,t){var n,o,r,i=St.lastIndex=Ct.lastIndex=0,s=-1,a=[],l=[];for(e+="",t+="";(n=St.exec(e))&&(o=Ct.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),a[s]?a[s]+=r:a[++s]=r),(n=n[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,l.push({i:s,x:bt(n,o)})),i=Ct.lastIndex;return i<t.length&&(r=t.slice(i),a[s]?a[s]+=r:a[++s]=r),a.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,o=0;o<t;++o)a[(n=l[o]).i]=n.x(e);return a.join("")})}var kt,_t=180/Math.PI,Mt={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nt(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*_t,skewX:Math.atan(l)*_t,scaleX:s,scaleY:a}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,s){var a=[],l=[];return i=e(i),s=e(s),function(e,o,r,i,s,a){if(e!==r||o!==i){var l=s.push("translate(",null,t,null,n);a.push({i:l-4,x:bt(e,r)},{i:l-2,x:bt(o,i)})}else(r||i)&&s.push("translate("+r+t+i+n)}(i.translateX,i.translateY,s.translateX,s.translateY,a,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:bt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,s.rotate,a,l),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:bt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,s.skewX,a,l),function(e,t,n,o,i,s){if(e!==n||t!==o){var a=i.push(r(i)+"scale(",null,",",null,")");s.push({i:a-4,x:bt(e,n)},{i:a-2,x:bt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,s.scaleX,s.scaleY,a,l),i=s=null,function(e){for(var t,n=-1,o=l.length;++n<o;)a[(t=l[n]).i]=t.x(e);return a.join("")}}}var zt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mt:Nt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ot=Pt((function(e){return null==e?Mt:(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),(e=kt.transform.baseVal.consolidate())?Nt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):Mt)}),", ",")",")");function It(e){return((e=Math.exp(e))+1/e)/2}var At,Rt,Dt=function e(t,n,o){function r(e,r){var i,s,a=e[0],l=e[1],c=e[2],u=r[0],d=r[1],h=r[2],f=u-a,g=d-l,p=f*f+g*g;if(p<1e-12)s=Math.log(h/c)/t,i=function(e){return[a+e*f,l+e*g,c*Math.exp(t*e*s)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);s=(w-x)/t,i=function(e){var o,r=e*s,i=It(x),u=c/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[a+u*f,l+u*g,c*i/It(t*r+x)]}}return i.duration=1e3*s*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),$t=0,Lt=0,Tt=0,Bt=1e3,Vt=0,jt=0,Ht=0,Zt="object"==typeof performance&&performance.now?performance:Date,Xt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yt(){return jt||(Xt(Wt),jt=Zt.now()+Ht)}function Wt(){jt=0}function Ft(){this._call=this._time=this._next=null}function Kt(e,t,n){var o=new Ft;return o.restart(e,t,n),o}function Gt(){jt=(Vt=Zt.now())+Ht,$t=Lt=0;try{!function(){Yt(),++$t;for(var e,t=At;t;)(e=jt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--$t}()}finally{$t=0,function(){var e,t,n=At,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:At=t);Rt=e,Ut(o)}(),jt=0}}function qt(){var e=Zt.now(),t=e-Vt;t>Bt&&(Ht-=t,Vt=e)}function Ut(e){$t||(Lt&&(Lt=clearTimeout(Lt)),e-jt>24?(e<1/0&&(Lt=setTimeout(Gt,e-Zt.now()-Ht)),Tt&&(Tt=clearInterval(Tt))):(Tt||(Vt=Zt.now(),Tt=setInterval(qt,Bt)),$t=1,Xt(Gt)))}function Qt(e,t,n){var o=new Ft;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Ft.prototype=Kt.prototype={constructor:Ft,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Yt():+n)+(null==t?0:+t),this._next||Rt===this||(Rt?Rt._next=this:At=this,Rt=this),this._call=e,this._time=n,Ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ut())}};var Jt=s("start","end","cancel","interrupt"),en=[],tn=0,nn=1,on=2,rn=3,sn=4,an=5,ln=6;function cn(e,t,n,o,r,i){var s=e.__transition;if(s){if(n in s)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=nn,n.timer.restart(s,n.delay,n.time),n.delay<=e&&s(e-n.delay)}function s(i){var c,u,d,h;if(n.state!==nn)return l();for(c in r)if((h=r[c]).name===n.name){if(h.state===rn)return Qt(s);h.state===sn?(h.state=ln,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=ln,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(Qt((function(){n.state===rn&&(n.state=sn,n.timer.restart(a,n.delay,n.time),a(i))})),n.state=on,n.on.call("start",e,e.__data__,n.index,n.group),n.state===on){for(n.state=rn,o=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=an,1),i=-1,s=o.length;++i<s;)o[i].call(e,r);n.state===an&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var o in n.state=ln,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Kt(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Jt,tween:en,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:tn})}function un(e,t){var n=hn(e,t);if(n.state>tn)throw new Error("too late; already scheduled");return n}function dn(e,t){var n=hn(e,t);if(n.state>rn)throw new Error("too late; already running");return n}function hn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function fn(e,t){var n,o,r,i=e.__transition,s=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>on&&n.state<an,n.state=ln,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):s=!1;s&&delete e.__transition}}function gn(e,t){var n,o;return function(){var r=dn(this,e),i=r.tween;if(i!==n)for(var s=0,a=(o=n=i).length;s<a;++s)if(o[s].name===t){(o=o.slice()).splice(s,1);break}r.tween=o}}function pn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=dn(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function mn(e,t,n){var o=e._id;return e.each((function(){var e=dn(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return hn(e,o).value[t]}}function yn(e,t){var n;return("number"==typeof t?bt:t instanceof tt?wt:(n=tt(t))?(t=n,wt):Et)(e,t)}function vn(e){return function(){this.removeAttribute(e)}}function xn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wn(e,t,n){var o,r,i=n+"";return function(){var s=this.getAttribute(e);return s===i?null:s===o?r:r=t(o=s,n)}}function bn(e,t,n){var o,r,i=n+"";return function(){var s=this.getAttributeNS(e.space,e.local);return s===i?null:s===o?r:r=t(o=s,n)}}function Sn(e,t,n){var o,r,i;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttribute(e))===(a=l+"")?null:s===o&&a===r?i:(r=a,i=t(o=s,l));this.removeAttribute(e)}}function Cn(e,t,n){var o,r,i;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttributeNS(e.space,e.local))===(a=l+"")?null:s===o&&a===r?i:(r=a,i=t(o=s,l));this.removeAttributeNS(e.space,e.local)}}function En(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function kn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){return function(){un(this,e).delay=+t.apply(this,arguments)}}function Mn(e,t){return t=+t,function(){un(this,e).delay=t}}function Nn(e,t){return function(){dn(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){dn(this,e).duration=t}}var zn=be.prototype.constructor;function On(e){return function(){this.style.removeProperty(e)}}var In=0;function An(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Rn(){return++In}var Dn=be.prototype;An.prototype={constructor:An,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=y(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a,l,c=o[s],u=c.length,d=i[s]=new Array(u),h=0;h<u;++h)(a=c[h])&&(l=e.call(a,a.__data__,h,c))&&("__data__"in a&&(l.__data__=a.__data__),d[h]=l,cn(d[h],t,n,h,d,hn(a,n)));return new An(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=x(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l,c=o[a],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var h,f=e.call(l,l.__data__,d,c),g=hn(l,n),p=0,m=f.length;p<m;++p)(h=f[p])&&cn(h,t,n,p,f,g);i.push(f),s.push(l)}return new An(i,s,t,n)},selectChild:Dn.selectChild,selectChildren:Dn.selectChildren,filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s=t[r],a=s.length,l=o[r]=[],c=0;c<a;++c)(i=s[c])&&e.call(i,i.__data__,c,s)&&l.push(i);return new An(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l,c=t[a],u=n[a],d=c.length,h=s[a]=new Array(d),f=0;f<d;++f)(l=c[f]||u[f])&&(h[f]=l);for(;a<o;++a)s[a]=t[a];return new An(s,this._parents,this._name,this._id)},selection:function(){return new zn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Rn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s,a=o[i],l=a.length,c=0;c<l;++c)if(s=a[c]){var u=hn(s,t);cn(s,e,n,c,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new An(o,this._parents,e,n)},call:Dn.call,nodes:Dn.nodes,node:Dn.node,size:Dn.size,empty:Dn.empty,each:Dn.each,on:function(e,t){var n=this._id;return arguments.length<2?hn(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?un:dn;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}(n,e,t))},attr:function(e,t){var n=h(e),o="transform"===n?Ot:yn;return this.attrTween(e,"function"==typeof t?(n.local?Cn:Sn)(n,o,mn(this,"attr."+e,t)):null==t?(n.local?xn:vn)(n):(n.local?bn:wn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=h(e);return this.tween(n,(o.local?En:kn)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?zt:yn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=X(this,e),s=(this.style.removeProperty(e),X(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}(e,o)).on("end.style."+e,On(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var s=X(this,e),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(e),l=a=X(this,e)),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}(e,o,mn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,s="style."+t,a="end."+s;return function(){var l=dn(this,e),c=l.on,u=null==l.value[s]?i||(i=On(t)):void 0;c===n&&r===u||(o=(n=c).copy()).on(a,r=u),l.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var s=X(this,e);return s===i?null:s===o?r:r=t(o=s,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(mn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=hn(this.node(),n).tween,i=0,s=r.length;i<s;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?gn:pn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?_n:Mn)(t,e)):hn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Nn:Pn)(t,e)):hn(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){dn(this,e).ease=t}}(t,e)):hn(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;dn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,s){var a={value:s},l={value:function(){0==--r&&i()}};n.each((function(){var n=dn(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:Dn[Symbol.iterator]};var $n={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Ln(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}be.prototype.interrupt=function(e){return this.each((function(){fn(this,e)}))},be.prototype.transition=function(e){var t,n;e instanceof An?(t=e._id,e=e._name):(t=Rn(),(n=$n).time=Yt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s,a=o[i],l=a.length,c=0;c<l;++c)(s=a[c])&&cn(s,e,t,c,a,n||Ln(s,t));return new An(o,this._parents,e,t)};var Tn=e=>()=>e;function Bn(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 Vn(e,t,n){this.k=e,this.x=t,this.y=n}Vn.prototype={constructor:Vn,scale:function(e){return 1===e?this:new Vn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new Vn(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 jn=new Vn(1,0,0);function Hn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return jn;return e.__zoom}function Zn(e){e.stopImmediatePropagation()}function Xn(e){e.preventDefault(),e.stopImmediatePropagation()}function Yn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Wn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).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 Fn(){return this.__zoom||jn}function Kn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gn(){return navigator.maxTouchPoints||"ontouchstart"in this}function qn(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 Un(){var e,t,n,o=Yn,r=Wn,i=qn,a=Kn,l=Gn,c=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],d=250,h=Dt,f=s("start","zoom","end"),g=500,p=150,m=0,y=10;function v(e){e.property("__zoom",Fn).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",M).filter(l).on("touchstart.zoom",N).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(e,t){return(t=Math.max(c[0],Math.min(c[1],t)))===e.k?e:new Vn(t,e.x,e.y)}function w(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new Vn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function S(e,t,n,o){e.on("start.zoom",(function(){C(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){C(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,s=C(e,i).event(o),a=r.apply(e,i),l=null==n?b(a):"function"==typeof n?n.apply(e,i):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,i):t,f=h(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=f(e),n=c/t[2];e=new Vn(n,l[0]-t[0]*n,l[1]-t[1]*n)}s.zoom(null,e)}}))}function C(e,t,n){return!n&&e.__zooming||new E(e,t)}function E(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=C(this,t).event(e),r=this.__zoom,s=Math.max(c[0],Math.min(c[1],r.k*Math.pow(2,a.apply(this,arguments)))),l=Ce(e);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[l,r.invert(l)],fn(this),n.start()}Xn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),p),n.zoom("mouse",i(w(x(r,s),n.mouse[0],n.mouse[1]),n.extent,u))}}function _(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,s=C(this,t,!0).event(e),a=Se(e.view).on("mousemove.zoom",(function(e){if(Xn(e),!s.moved){var t=e.clientX-c,n=e.clientY-d;s.moved=t*t+n*n>m}s.event(e).zoom("mouse",i(w(s.that.__zoom,s.mouse[0]=Ce(e,r),s.mouse[1]),s.extent,u))}),!0).on("mouseup.zoom",(function(e){a.on("mousemove.zoom mouseup.zoom",null),Pe(e.view,s.moved),Xn(e),s.event(e).end()}),!0),l=Ce(e,r),c=e.clientX,d=e.clientY;Ne(e.view),Zn(e),s.mouse=[l,this.__zoom.invert(l)],fn(this),s.start()}}function M(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,s=Ce(e.changedTouches?e.changedTouches[0]:e,this),a=n.invert(s),l=n.k*(e.shiftKey?.5:2),c=i(w(x(n,l),s,a),r.apply(this,t),u);Xn(e),d>0?Se(this).transition().duration(d).call(S,c,s,e):Se(this).call(v.transform,c,s,e)}}function N(n,...r){if(o.apply(this,arguments)){var i,s,a,l,c=n.touches,u=c.length,d=C(this,r,n.changedTouches.length===u).event(n);for(Zn(n),s=0;s<u;++s)l=[l=Ce(a=c[s],this),this.__zoom.invert(l),a.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),g)),fn(this),d.start())}}function P(e,...t){if(this.__zooming){var n,o,r,s,a=C(this,t).event(e),l=e.changedTouches,c=l.length;for(Xn(e),n=0;n<c;++n)r=Ce(o=l[n],this),a.touch0&&a.touch0[2]===o.identifier?a.touch0[0]=r:a.touch1&&a.touch1[2]===o.identifier&&(a.touch1[0]=r);if(o=a.that.__zoom,a.touch1){var d=a.touch0[0],h=a.touch0[1],f=a.touch1[0],g=a.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=x(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],s=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!a.touch0)return;r=a.touch0[0],s=a.touch0[1]}a.zoom("touch",i(w(o,r,s),a.extent,u))}}function z(e,...o){if(this.__zooming){var r,i,s=C(this,o).event(e),a=e.changedTouches,l=a.length;for(Zn(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),g),r=0;r<l;++r)i=a[r],s.touch0&&s.touch0[2]===i.identifier?delete s.touch0:s.touch1&&s.touch1[2]===i.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(i=Ce(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<y)){var c=Se(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return v.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Fn),e!==r?S(e,t,n,o):r.interrupt().each((function(){C(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},v.scaleBy=function(e,t,n,o){v.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},v.scaleTo=function(e,t,n,o){v.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,s=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,a=o.invert(s),l="function"==typeof t?t.apply(this,arguments):t;return i(w(x(o,l),s,a),e,u)}),n,o)},v.translateBy=function(e,t,n,o){v.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),u)}),null,o)},v.translateTo=function(e,t,n,o,s){v.transform(e,(function(){var e=r.apply(this,arguments),s=this.__zoom,a=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(jn.translate(a[0],a[1]).scale(s.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,u)}),o,s)},E.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Se(this.that).datum();f.call(e,this.that,new Bn(e,{sourceEvent:this.sourceEvent,target:v,type:e,transform:this.that.__zoom,dispatch:f}),t)}},v.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:Tn(+e),v):a},v.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),v):o},v.touchable=function(e){return arguments.length?(l="function"==typeof e?e:Tn(!!e),v):l},v.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),v):r},v.scaleExtent=function(e){return arguments.length?(c[0]=+e[0],c[1]=+e[1],v):[c[0],c[1]]},v.translateExtent=function(e){return arguments.length?(u[0][0]=+e[0][0],u[1][0]=+e[1][0],u[0][1]=+e[0][1],u[1][1]=+e[1][1],v):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},v.constrain=function(e){return arguments.length?(i=e,v):i},v.duration=function(e){return arguments.length?(d=+e,v):d},v.interpolate=function(e){return arguments.length?(h=e,v):h},v.on=function(){var e=f.on.apply(f,arguments);return e===f?v:e},v.clickDistance=function(e){return arguments.length?(m=(e=+e)*e,v):Math.sqrt(m)},v.tapDistance=function(e){return arguments.length?(y=+e,v):y},v}Hn.prototype=Vn.prototype;const Qn={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: "${n?o:n}", 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.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"];var to,no,oo;e.ConnectionMode=void 0,(to=e.ConnectionMode||(e.ConnectionMode={})).Strict="strict",to.Loose="loose",e.PanOnScrollMode=void 0,(no=e.PanOnScrollMode||(e.PanOnScrollMode={})).Free="free",no.Vertical="vertical",no.Horizontal="horizontal",e.SelectionMode=void 0,(oo=e.SelectionMode||(e.SelectionMode={})).Partial="partial",oo.Full="full";const ro={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var io,so,ao;e.ConnectionLineType=void 0,(io=e.ConnectionLineType||(e.ConnectionLineType={})).Bezier="default",io.Straight="straight",io.Step="step",io.SmoothStep="smoothstep",io.SimpleBezier="simplebezier",e.MarkerType=void 0,(so=e.MarkerType||(e.MarkerType={})).Arrow="arrow",so.ArrowClosed="arrowclosed",e.Position=void 0,(ao=e.Position||(e.Position={})).Left="left",ao.Top="top",ao.Right="right",ao.Bottom="bottom";const lo={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top};function co(e,t){if(!e&&!t)return!0;if(!e||!t||e.size!==t.size)return!1;if(!e.size&&!t.size)return!0;for(const n of e.keys())if(!t.has(n))return!1;return!0}function uo(e,t,n){if(!n)return;const o=[];e.forEach(((e,n)=>{t?.has(n)||o.push(e)})),o.length&&n(o)}function ho(e){return null===e?null:e?"valid":"invalid"}const fo=e=>"id"in e&&"source"in e&&"target"in e,go=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),po=(e,t=[0,0])=>{const{width:n,height:o}=Ho(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},mo=(e,t={})=>{if(0===e.size)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach((e=>{if(void 0===t.filter||t.filter(e)){const t=zo(e);n=_o(n,t)}})),No(n)},yo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Lo(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const[,t]of e){const{measured:e,selectable:n=!0,hidden:o=!1}=t,r=e.width??t.width??t.initialWidth??null,c=e.height??t.height??t.initialHeight??null;if(s&&!n||o)continue;const u=Io(a,Po(t));(null===r||null===c||i&&u>0||u>=(r??0)*(c??0)||t.dragging)&&l.push(t)}return l},vo=(e,t)=>{const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))};function xo(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map((e=>e.id))):null;return e.forEach((e=>{!(e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden))||o&&!o.has(e.id)||n.set(e.id,e)})),n}async function wo({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(0===e.size)return Promise.resolve(!1);const a=mo(e),l=Bo(a,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration}),Promise.resolve(!0)}function bo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let d=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.measured?.width??0),t[1][1]-(e.measured?.height??0)]]:t}(s,s.extent||r);if("parent"!==s.extent||s.expandParent)a&&jo(s.extent)&&(d=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);else if(a){const e=s.measured.width,t=s.measured.height,n=a.measured.width,o=a.measured.height;e&&t&&n&&o&&(d=[[l,c],[l+n-e,c+o-t]])}else i?.("005",Qn.error005());const h=jo(d)?Co(t,d):t;return{position:{x:h.x-l+s.measured.width*u[0],y:h.y-c+s.measured.height*u[1]},positionAbsolute:h}}const So=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Co=(e={x:0,y:0},t)=>({x:So(e.x,t[0][0],t[1][0]),y:So(e.y,t[0][1],t[1][1])}),Eo=(e,t,n)=>e<t?So(Math.abs(e-t),1,t)/t:e>n?-So(Math.abs(e-n),1,t)/t:0,ko=(e,t,n=15,o=40)=>[Eo(e.x,o,t.width-o)*n,Eo(e.y,o,t.height-o)*n],_o=(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)}),Mo=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),No=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Po=(e,t=[0,0])=>{const{x:n,y:o}=go(e)?e.internals.positionAbsolute:po(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},zo=(e,t=[0,0])=>{const{x:n,y:o}=go(e)?e.internals.positionAbsolute:po(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Oo=(e,t)=>No(_o(Mo(e),Mo(t))),Io=(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=>Ro(e.width)&&Ro(e.height)&&Ro(e.x)&&Ro(e.y),Ro=e=>!isNaN(e)&&isFinite(e),Do=(e,t)=>{},$o=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Lo=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?$o(a,s):a},To=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),Bo=(e,t,n,o,r,i)=>{const s=t/(e.width*(1+i)),a=n/(e.height*(1+i)),l=Math.min(s,a),c=So(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Vo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function jo(e){return void 0!==e&&"parent"!==e}function Ho(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Zo(e){return void 0!==(e.measured?.width??e.width??e.initialWidth)&&void 0!==(e.measured?.height??e.height??e.initialHeight)}function Xo(e,t={width:0,height:0},n,o,r){let i=n;const s={...e};for(;i;){const e=o.get(i);if(i=e?.parentId,e){const n=e.origin||r;s.x+=e.internals.positionAbsolute.x-(t.width??0)*n[0],s.y+=e.internals.positionAbsolute.y-(t.height??0)*n[1]}}return s}function Yo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o}){const{x:r,y:i}=Uo(e),s=Lo({x:r,y:i},o),{x:a,y:l}=n?$o(s,t):s;return{xSnapped:a,ySnapped:l,...s}}const Wo=e=>({width:e.offsetWidth,height:e.offsetHeight}),Fo=e=>e.getRootNode?.()||window?.document,Ko=["INPUT","SELECT","TEXTAREA"];function Go(e){const t=e.composedPath?.()?.[0]||e.target;return Ko.includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}const qo=e=>"clientX"in e,Uo=(e,t)=>{const n=qo(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return i&&i.length?Array.from(i).map((t=>{const i=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:r,position:t.getAttribute("data-handlepos"),x:(i.left-n.left)/o,y:(i.top-n.top)/o,...Wo(t)}})):null};function Jo({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=.125*e+.375*r+.375*s+.125*n,c=.125*t+.375*i+.375*a+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}function er(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function tr({pos:t,x1:n,y1:o,x2:r,y2:i,c:s}){switch(t){case e.Position.Left:return[n-er(n-r,s),o];case e.Position.Right:return[n+er(r-n,s),o];case e.Position.Top:return[n,o-er(o-i,s)];case e.Position.Bottom:return[n,o+er(i-o,s)]}}function nr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top,curvature:a=.25}){const[l,c]=tr({pos:o,x1:t,y1:n,x2:r,y2:i,c:a}),[u,d]=tr({pos:s,x1:r,y1:i,x2:t,y2:n,c:a}),[h,f,g,p]=Jo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${t},${n} C${l},${c} ${u},${d} ${r},${i}`,h,f,g,p]}function or({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;return[i,o<t?o+s:o-s,r,s]}function rr({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=_o(zo(e),zo(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 Io(s,No(i))>0}const ir=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,sr=(e,t)=>{if(!e.source||!e.target)return t;let n;return n=fo(e)?{...e}:{...e,id:ir(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:(null===n.sourceHandle&&delete n.sourceHandle,null===n.targetHandle&&delete n.targetHandle,t.concat(n))};function ar({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=or({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const lr={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},cr=({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1},ur=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20}){const[d,h,f,g,p]=function({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:s}){const a=lr[n],l=lr[r],c={x:t.x+a.x*s,y:t.y+a.y*s},u={x:o.x+l.x*s,y:o.y+l.y*s},d=cr({source:c,sourcePosition:n,target:u}),h=0!==d.x?"x":"y",f=d[h];let g,p,m=[];const y={x:0,y:0},v={x:0,y:0},[x,w,b,S]=or({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(a[h]*l[h]==-1){g=i.x??x,p=i.y??w;const e=[{x:g,y:c.y},{x:g,y:u.y}],t=[{x:c.x,y:p},{x:u.x,y:p}];m=a[h]===f?"x"===h?e:t:"x"===h?t:e}else{const e=[{x:c.x,y:u.y}],i=[{x:u.x,y:c.y}];if(m="x"===h?a.x===f?i:e:a.y===f?e:i,n===r){const e=Math.abs(t[h]-o[h]);if(e<=s){const n=Math.min(s-1,s-e);a[h]===f?y[h]=(c[h]>t[h]?-1:1)*n:v[h]=(u[h]>o[h]?-1:1)*n}}if(n!==r){const t="x"===h?"y":"x",n=a[h]===l[t],o=c[t]>u[t],r=c[t]<u[t];(1===a[h]&&(!n&&o||n&&r)||1!==a[h]&&(!n&&r||n&&o))&&(m="x"===h?e:i)}const d={x:c.x+y.x,y:c.y+y.y},x={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(x.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(x.y-m[0].y))?(g=(d.x+x.x)/2,p=m[0].y):(g=m[0].x,p=(d.y+x.y)/2)}return[[t,{x:c.x+y.x,y:c.y+y.y},...m,{x:u.x+v.x,y:u.y+v.y},o],g,p,b,S]}({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:s,center:{x:l,y:c},offset:u});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(ur(e,t)/2,ur(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)return`L ${i+r*(e.x<n.x?-1:1)},${s}Q ${i},${s} ${i},${s+r*(e.y<n.y?1:-1)}`;const a=e.x<n.x?1:-1;return`L ${i},${s+r*(e.y<n.y?-1:1)}Q ${i},${s} ${i+r*a},${s}`}(d[n-1],t,d[n+1],a):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),h,f,g,p]}function hr(e){return e&&!(!e.internals.handleBounds&&!e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fr(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,"source"===o.type?t.push(o):"target"===o.type&&n.push(o);return{source:t,target:n}}function gr(t,n,o=e.Position.Left,r=!1){const i=(n?.x??0)+t.internals.positionAbsolute.x,s=(n?.y??0)+t.internals.positionAbsolute.y,{width:a,height:l}=n??Ho(t);if(r)return{x:i+a/2,y:s+l/2};switch(n?.position??o){case e.Position.Top:return{x:i+a/2,y:s};case e.Position.Right:return{x:i+a,y:s+l/2};case e.Position.Bottom:return{x:i+a/2,y:s+l};case e.Position.Left:return{x:i,y:s+l/2}}}function pr(e,t){return e&&(t?e.find((e=>e.id===t)):e[0])||null}function mr(e,t){if(!e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`}function yr(t,n,o,r,i){let s=.5;"start"===i?s=0:"end"===i&&(s=1);let a=[(t.x+t.width*s)*n.zoom+n.x,t.y*n.zoom+n.y-r],l=[-100*s,-100];switch(o){case e.Position.Right:a=[(t.x+t.width)*n.zoom+n.x+r,(t.y+t.height*s)*n.zoom+n.y],l=[0,-100*s];break;case e.Position.Bottom:a[1]=(t.y+t.height)*n.zoom+n.y+r,l[1]=0;break;case e.Position.Left:a=[t.x*n.zoom+n.x-r,(t.y+t.height*s)*n.zoom+n.y],l=[-100,-100*s]}return`translate(${a[0]}px, ${a[1]}px) translate(${l[0]}%, ${l[1]}%)`}const vr={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{}},xr={...vr,checkEquality:!0};function wr(e,t,n,o){const r={...xr,...o},i=new Map(t);t.clear(),n.clear();const s=o?.elevateNodesOnSelect?1e3:0;for(const a of e){let e=i.get(a.id);r.checkEquality&&a===e?.internals.userNode||(e={...r.defaults,...a,measured:{width:a.measured?.width,height:a.measured?.height},internals:{positionAbsolute:po(a,r.nodeOrigin),handleBounds:a.measured?e?.internals.handleBounds:void 0,z:Sr(a,s),userNode:a}}),t.set(a.id,e),a.parentId&&br(e,t,n,o)}}function br(e,t,n,o){const r={...vr,...o},i=e.parentId,s=t.get(i);if(!s)return void console.warn(`Parent node ${i} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);const a=n.get(i);a?a.set(e.id,e):n.set(i,new Map([[e.id,e]]));const l=o?.elevateNodesOnSelect?1e3:0,{x:c,y:u,z:d}=function(e,t,n,o){const r=po(e,n),i=Sr(e,o),s=t.internals.z??0;return{x:t.internals.positionAbsolute.x+r.x,y:t.internals.positionAbsolute.y+r.y,z:s>i?s:i}}(e,s,r.nodeOrigin,l),h=e.internals.positionAbsolute,f=c!==h.x||u!==h.y;(f||d!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:f?{x:c,y:u}:h,z:d})}function Sr(e,t){return(Ro(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Cr(e,t,n,o=[0,0]){const r=[],i=new Map;for(const n of e){const e=t.get(n.parentId);if(!e)continue;const o=i.get(n.parentId)?.expandedRect??Po(e),r=Oo(o,n.rect);i.set(n.parentId,{expandedRect:r,parent:e})}return i.size>0&&i.forEach((({expandedRect:t,parent:i},s)=>{const a=i.internals.positionAbsolute,l=Ho(i),c=i.origin??o,u=t.x<a.x?Math.round(Math.abs(a.x-t.x)):0,d=t.y<a.y?Math.round(Math.abs(a.y-t.y)):0,h=Math.max(l.width,Math.round(t.width)),f=Math.max(l.height,Math.round(t.height)),g=(h-l.width)*c[0],p=(f-l.height)*c[1];(u>0||d>0||g||p)&&(r.push({id:s,type:"position",position:{x:i.position.x-u+g,y:i.position.y-d+p}}),n.get(s)?.forEach((t=>{e.some((e=>e.id===t.id))||r.push({id:t.id,type:"position",position:{x:t.position.x+u,y:t.position.y+d}})}))),(l.width<t.width||l.height<t.height||u||d)&&r.push({id:s,type:"dimensions",setAttributes:!0,dimensions:{width:h+(u?c[0]*u-g:0),height:f+(d?c[1]*d-p:0)}})})),r}function Er(e,t,n){e.clear(),t.clear();for(const o of n){const{source:n,target:r,sourceHandle:i=null,targetHandle:s=null}=o,a=`${n}-source-${i}`,l=`${r}-target-${s}`,c=e.get(a)||new Map,u=e.get(l)||new Map,d={edgeId:o.id,source:n,target:r,sourceHandle:i,targetHandle:s};t.set(o.id,o),e.set(a,c.set(`${r}-${s}`,d)),e.set(l,u.set(`${n}-${i}`,d))}}function kr(e,t){if(null===e||null===t)return!1;const n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t];if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++)if(n[e].id!==o[e].id||n[e].type!==o[e].type||!Object.is(n[e].data,o[e].data))return!1;return!0}function _r(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return!!n&&(!!n.selected||_r(n,t))}function Mr(e,t,n){let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1}function Nr({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[e,i]of t){const t=n.get(e)?.internals.userNode;t&&r.push({...t,position:i.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e).internals.userNode;return[{...i,position:t.get(e)?.position||i.position,dragging:o},r]}function Pr({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},u=null,d=!1,h=null,f=!1;return{update:function({noDragClassName:g,handleSelector:p,domNode:m,isSelectable:y,nodeId:v,nodeClickDistance:x=0}){function w({x:e,y:n},r){const{nodeLookup:s,nodeExtent:l,snapGrid:c,snapToGrid:u,nodeOrigin:d,onNodeDrag:h,onSelectionDrag:f,onError:g,updateNodePositions:p}=t();i={x:e,y:n};let m=!1,y={x:0,y:0,x2:0,y2:0};if(a.size>1&&l){const e=mo(a);y=Mo(e)}for(const[t,o]of a){let r={x:e-o.distance.x,y:n-o.distance.y};u&&(r=$o(r,c));let i=[[l[0][0],l[0][1]],[l[1][0],l[1][1]]];if(a.size>1&&l&&!o.extent){const{positionAbsolute:e}=o.internals,t=e.x-y.x+l[0][0],n=e.x+o.measured.width-y.x2+l[1][0];i=[[t,e.y-y.y+l[0][1]],[n,e.y+o.measured.height-y.y2+l[1][1]]]}const{position:h,positionAbsolute:f}=bo({nodeId:t,nextPosition:r,nodeLookup:s,nodeExtent:i,nodeOrigin:d,onError:g});m=m||o.position.x!==h.x||o.position.y!==h.y,o.position=h,o.internals.positionAbsolute=f}if(m&&(p(a,!0),r&&(o||h||!v&&f))){const[e,t]=Nr({nodeId:v,dragItems:a,nodeLookup:s});o?.(r,a,e,t),h?.(r,e,t),v||f?.(r,t)}}async function b(){if(!u)return;const{transform:e,panBy:n,autoPanSpeed:o}=t(),[r,a]=ko(c,u,o);0===r&&0===a||(i.x=(i.x??0)-r/e[2],i.y=(i.y??0)-a/e[2],await n({x:r,y:a})&&w(i,null)),s=requestAnimationFrame(b)}function S(o){const{nodeLookup:r,multiSelectionActive:s,nodesDraggable:l,transform:c,snapGrid:u,snapToGrid:h,selectNodesOnDrag:f,onNodeDragStart:g,onSelectionDragStart:p,unselectNodesAndEdges:m}=t();d=!0,f&&y||s||!v||r.get(v)?.selected||m(),y&&f&&v&&e?.(v);const x=Yo(o.sourceEvent,{transform:c,snapGrid:u,snapToGrid:h});if(i=x,a=function(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!_r(s,e))&&(s.draggable||t&&void 0===s.draggable)){const t=e.get(i);t&&r.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return r}(r,l,x,v),a.size>0&&(n||g||!v&&p)){const[e,t]=Nr({nodeId:v,dragItems:a,nodeLookup:r});n?.(o.sourceEvent,a,e,t),g?.(o.sourceEvent,e,t),v||p?.(o.sourceEvent,t)}}h=Se(m);const C=$e().clickDistance(x).on("start",(e=>{const{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:s,snapToGrid:a}=t();f=!1,0===o&&S(e);const l=Yo(e.sourceEvent,{transform:r,snapGrid:s,snapToGrid:a});i=l,u=n?.getBoundingClientRect()||null,c=Uo(e.sourceEvent,u)})).on("drag",(e=>{const{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:s,nodeDragThreshold:h}=t(),g=Yo(e.sourceEvent,{transform:o,snapGrid:r,snapToGrid:s});if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(f=!0),!f){if(!l&&n&&d&&(l=!0,b()),!d){const t=g.xSnapped-(i.x??0),n=g.ySnapped-(i.y??0);Math.sqrt(t*t+n*n)>h&&S(e)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&a&&d&&(c=Uo(e.sourceEvent,u),w(g,e.sourceEvent))}})).on("end",(e=>{if(d&&!f&&(l=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:s}=t();if(o(a,!1),r||i||!v&&s){const[t,o]=Nr({nodeId:v,dragItems:a,nodeLookup:n,dragging:!1});r?.(e.sourceEvent,a,t,o),i?.(e.sourceEvent,t,o),v||s?.(e.sourceEvent,o)}}})).filter((e=>{const t=e.target;return!e.button&&(!g||!Mr(t,`.${g}`,m))&&(!p||Mr(t,p,m))}));h.call(C)},destroy:function(){h?.on(".drag",null)}}}function zr(e,t,n,o){let r=null;return[(t[n]||[]).reduce(((t,i)=>{if(e.id===o.nodeId&&n===o.handleType&&i.id===o.handleId)r=i;else{const n=gr(e,i,i.position,!0);t.push({...i,...n})}return t}),[]),r]}function Or(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}const Ir=()=>!0;function Ar(t,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:s,doc:a,lib:l,flowId:c,isValidConnection:u=Ir,handleLookup:d}){const h="target"===s,f=n?a.querySelector(`.${l}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:g,y:p}=Uo(t),m=a.elementFromPoint(g,p),y=m?.classList.contains(`${l}-flow__handle`)?m:f,v={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const t=Or(void 0,y),n=y.getAttribute("data-nodeid"),s=y.getAttribute("data-handleid"),a=y.classList.contains("connectable"),l=y.classList.contains("connectableend");if(!n)return v;const c={source:h?n:r,sourceHandle:h?s:i,target:h?r:n,targetHandle:h?i:s};v.connection=c;const f=a&&l&&(o===e.ConnectionMode.Strict?h&&"source"===t||!h&&"target"===t:n!==r||s!==i);v.isValid=f&&u(c);const g=d?.get(`${n}-${t}-${s}`);g&&(v.toHandle={...g})}return v}const Rr={onPointerDown:function(t,{connectionMode:n,connectionRadius:o,handleId:r,nodeId:i,edgeUpdaterType:s,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:h,panBy:f,cancelConnection:g,onConnectStart:p,onConnect:m,onConnectEnd:y,isValidConnection:v=Ir,onReconnectEnd:x,updateConnection:w,getTransform:b,getFromHandle:S,autoPanSpeed:C}){const E=Fo(t.target);let k,_=0;const{x:M,y:N}=Uo(t),P=E?.elementFromPoint(M,N),z=Or(s,P),O=l?.getBoundingClientRect();if(!O||!z)return;let I=Uo(t,O),A=!1,R=null,D=!1,$=null;const[L,T]=function({nodeLookup:e,nodeId:t,handleId:n,handleType:o}){const r=new Map,i={nodeId:t,handleId:n,handleType:o};let s=null;for(const t of e.values())if(t.internals.handleBounds){const[e,n]=zr(t,t.internals.handleBounds,"source",i),[o,a]=zr(t,t.internals.handleBounds,"target",i);s=s||(n??a),[...e,...o].forEach((e=>r.set(`${e.nodeId}-${e.type}-${e.id}`,e)))}if(!s){const n=e.get(t);if(n?.internals.handleBounds){i.handleType="source"===o?"target":"source";const[,e]=zr(n,n.internals.handleBounds,i.handleType,i);s=e}}return[r,s]}({nodeLookup:c,nodeId:i,handleId:r,handleType:z});function B(){if(!d||!O)return;const[e,t]=ko(I,O,C);f({x:e,y:t}),_=requestAnimationFrame(B)}const V={...T,nodeId:i,type:z,position:T.position},j=c.get(i),H={inProgress:!0,isValid:null,from:gr(j,V,e.Position.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:j,to:I,toHandle:null,toPosition:lo[V.position],toNode:null};w(H);let Z=H;function X(e){if(!S()||!V)return void Y(e);const t=b();I=Uo(e,O),k=function(e,t,n){let o=[],r=1/0;for(const i of n.values()){const n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));n<=t&&(n<r?o=[i]:n===r&&o.push(i),r=n)}return o.length?1===o.length?o[0]:o.find((e=>"target"===e.type))||o[0]:null}(Lo(I,t,!1,[1,1]),o,L),A||(B(),A=!0);const s=Ar(e,{handle:k,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:v,doc:E,lib:u,flowId:h,handleLookup:L});$=s.handleDomNode,R=s.connection,D=function(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}(!!k,s.isValid);const l={...Z,isValid:D,to:k&&D?To({x:k.x,y:k.y},t):I,toHandle:s.toHandle,toPosition:D&&s.toHandle?s.toHandle.position:lo[V.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null};D&&k&&Z.toHandle&&l.toHandle&&Z.toHandle.type===l.toHandle.type&&Z.toHandle.nodeId===l.toHandle.nodeId&&Z.toHandle.id===l.toHandle.id||(w(l),Z=l)}function Y(e){(k||$)&&R&&D&&m?.(R),y?.(e),s&&x?.(e),g(),cancelAnimationFrame(_),A=!1,D=!1,R=null,$=null,E.removeEventListener("mousemove",X),E.removeEventListener("mouseup",Y),E.removeEventListener("touchmove",X),E.removeEventListener("touchend",Y)}p?.(t,{nodeId:i,handleId:r,handleType:z}),E.addEventListener("mousemove",X),E.addEventListener("mouseup",Y),E.addEventListener("touchmove",X),E.addEventListener("touchend",Y)},isValid:Ar};const Dr=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,$r=e=>({x:e.x,y:e.y,zoom:e.k}),Lr=({x:e,y:t,zoom:n})=>jn.translate(e,t).scale(n),Tr=(e,t)=>e.target.closest(`.${t}`),Br=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Vr=(e,t=0,n=(()=>{}))=>{const o="number"==typeof t&&t>0;return o||n(),o?e.transition().duration(t).on("end",n):e},jr=e=>{const t=e.ctrlKey&&Vo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function Hr({domNode:t,minZoom:n,maxZoom:o,paneClickDistance:r,translateExtent:i,viewport:s,onPanZoom:a,onPanZoomStart:l,onPanZoomEnd:c,onTransformChange:u,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=t.getBoundingClientRect(),g=Un().clickDistance(!Ro(r)||r<0?0:r).scaleExtent([n,o]).translateExtent(i),p=Se(t).call(g);w({x:s.x,y:s.y,zoom:So(s.zoom,n,o)},[[0,0],[f.width,f.height]],i);const m=p.on("wheel.zoom"),y=p.on("dblclick.zoom");function v(e,t){return p?new Promise((n=>{g?.transform(Vr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)}function x(){g.on("zoom",null)}async function w(e,t,n){const o=Lr(e),r=g?.constrain()(o,t,n);return r&&await v(r),new Promise((e=>e(r)))}return g.wheelDelta(jr),{update:function({noWheelClassName:t,noPanClassName:n,onPaneContextMenu:o,userSelectionActive:r,panOnScroll:i,panOnDrag:s,panOnScrollMode:f,panOnScrollSpeed:v,preventScrolling:w,zoomOnPinch:b,zoomOnScroll:S,zoomOnDoubleClick:C,zoomActivationKeyPressed:E,lib:k}){r&&!h.isZoomingOrPanning&&x();const _=i&&!E&&!r?function({zoomPanValues:t,noWheelClassName:n,d3Selection:o,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Tr(d,n))return!1;d.preventDefault(),d.stopImmediatePropagation();const h=o.property("__zoom").k||1;if(d.ctrlKey&&a){const e=Ce(d),t=jr(d),n=h*Math.pow(2,t);return void r.scaleTo(o,n,e,d)}const f=1===d.deltaMode?20:1;let g=i===e.PanOnScrollMode.Vertical?0:d.deltaX*f,p=i===e.PanOnScrollMode.Horizontal?0:d.deltaY*f;!Vo()&&d.shiftKey&&i!==e.PanOnScrollMode.Vertical&&(g=d.deltaY*f,p=0),r.translateBy(o,-g/h*s,-p/h*s,{internal:!0});const m=$r(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling||(t.isPanScrolling=!0,l?.(d,m)),t.isPanScrolling&&(c?.(d,m),t.panScrollTimeout=setTimeout((()=>{u?.(d,m),t.isPanScrolling=!1}),150))}}({zoomPanValues:h,noWheelClassName:t,d3Selection:p,d3Zoom:g,panOnScrollMode:f,panOnScrollSpeed:v,zoomOnPinch:b,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:c}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){if(!t&&"wheel"===o.type&&!o.ctrlKey||Tr(o,e))return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:t,preventScrolling:w,d3ZoomHandler:m});if(p.on("wheel.zoom",_,{passive:!1}),!r){const e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=$r(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,"mousedown"===o.sourceEvent?.type&&t(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:l});g.on("start",e);const t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!(!n||!Br(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,$r(i.transform))}}({zoomPanValues:h,panOnDrag:s,onPaneContextMenu:!!o,onPanZoom:a,onTransformChange:u});g.on("zoom",t);const n=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Br(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r&&Dr(e.prevViewport,s.transform))){const t=$r(s.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{r?.(s.sourceEvent,t)}),n?150:0)}}}({zoomPanValues:h,panOnDrag:s,panOnScroll:i,onPaneContextMenu:o,onPanZoomEnd:c,onDraggingChange:d});g.on("end",n)}const M=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c}){return u=>{const d=e||t,h=n&&u.ctrlKey;if(1===u.button&&"mousedown"===u.type&&(Tr(u,`${c}-flow__node`)||Tr(u,`${c}-flow__edge`)))return!0;if(!(o||d||r||i||n))return!1;if(s)return!1;if(Tr(u,a)&&"wheel"===u.type)return!1;if(Tr(u,l)&&("wheel"!==u.type||r&&"wheel"===u.type&&!e))return!1;if(!n&&u.ctrlKey&&"wheel"===u.type)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!d&&!r&&!h&&"wheel"===u.type)return!1;if(!o&&("mousedown"===u.type||"touchstart"===u.type))return!1;if(Array.isArray(o)&&!o.includes(u.button)&&"mousedown"===u.type)return!1;const f=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||"wheel"===u.type)&&f}}({zoomActivationKeyPressed:E,panOnDrag:s,zoomOnScroll:S,panOnScroll:i,zoomOnDoubleClick:C,zoomOnPinch:b,userSelectionActive:r,noPanClassName:n,noWheelClassName:t,lib:k});g.filter(M),C?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)},destroy:x,setViewport:async function(e,t){const n=Lr(e);return await v(n,t),new Promise((e=>e(n)))},setViewportConstrained:w,getViewport:function(){const e=p?Hn(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){return p?new Promise((n=>{g?.scaleTo(Vr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)},scaleBy:function(e,t){return p?new Promise((n=>{g?.scaleBy(Vr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)},setScaleExtent:function(e){g?.scaleExtent(e)},setTranslateExtent:function(e){g?.translateExtent(e)},syncViewport:function(e){if(p){const t=Lr(e),n=p.property("__zoom");n.k===e.zoom&&n.x===e.x&&n.y===e.y||g?.transform(p,t,null,{sync:!0})}},setClickDistance:function(e){const t=!Ro(e)||e<0?0:e;g?.clickDistance(t)}}}var Zr;!function(e){e.Line="line",e.Handle="handle"}(Zr||(Zr={}));const Xr=["top-left","top-right","bottom-left","bottom-right"],Yr=["top","right","bottom","left"];function Wr(e,t){return Math.max(0,t-e)}function Fr(e,t){return Math.max(0,e-t)}function Kr(e,t,n){return Math.max(0,t-e,e-n)}function Gr(e,t){return e?!t:t}const qr={width:0,height:0,x:0,y:0},Ur={...qr,pointerX:0,pointerY:0,aspectRatio:1};function Qr(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function Jr({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Se(e);return{update:function({controlPosition:e,boundaries:s,keepAspectRatio:a,onResizeStart:l,onResize:c,onResizeEnd:u,shouldResize:d}){let h={...qr},f={...Ur};const g=function(e){return{isHorizontal:e.includes("right")||e.includes("left"),isVertical:e.includes("bottom")||e.includes("top"),affectsX:e.includes("left"),affectsY:e.includes("top")}}(e);let p,m,y,v,x=[];const w=$e().on("start",(e=>{const{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:s,nodeOrigin:a}=n();if(p=o.get(t),!p)return;const{xSnapped:c,ySnapped:u}=Yo(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:s});h={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},f={...h,pointerX:c,pointerY:u,aspectRatio:h.width/h.height},m=void 0,p.parentId&&("parent"===p.extent||p.expandParent)&&(m=o.get(p.parentId),y=m&&"parent"===p.extent?function(e){return[[0,0],[e.measured.width,e.measured.height]]}(m):void 0),x=[],v=void 0;for(const[e,n]of o)if(n.parentId===t&&(x.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){const e=Qr(n,p,n.origin??a);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}l?.(e,{...h})})).on("drag",(e=>{const{transform:t,snapGrid:r,snapToGrid:i,nodeOrigin:l}=n(),u=Yo(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:i}),w=[];if(!p)return;const{x:b,y:S,width:C,height:E}=h,k={},_=p.origin??l,{width:M,height:N,x:P,y:z}=function(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:d}=t,h=u&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:p,maxWidth:m,minHeight:y,maxHeight:v}=o,{x:x,y:w,width:b,height:S,aspectRatio:C}=e;let E=Math.floor(u?f-e.pointerX:0),k=Math.floor(d?g-e.pointerY:0);const _=b+(l?-E:E),M=S+(c?-k:k),N=-i[0]*b,P=-i[1]*S;let z=Kr(_,p,m),O=Kr(M,y,v);if(s){let e=0,t=0;l&&E<0?e=Wr(x+E+N,s[0][0]):!l&&E>0&&(e=Fr(x+_+N,s[1][0])),c&&k<0?t=Wr(w+k+P,s[0][1]):!c&&k>0&&(t=Fr(w+M+P,s[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(a){let e=0,t=0;l&&E>0?e=Fr(x+E,a[0][0]):!l&&E<0&&(e=Wr(x+_,a[1][0])),c&&k>0?t=Fr(w+k,a[0][1]):!c&&k<0&&(t=Wr(w+M,a[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(r){if(u){const e=Kr(_/C,y,v)*C;if(z=Math.max(z,e),s){let e=0;e=!l&&!c||l&&!c&&h?Fr(w+P+_/C,s[1][1])*C:Wr(w+P+(l?E:-E)/C,s[0][1])*C,z=Math.max(z,e)}if(a){let e=0;e=!l&&!c||l&&!c&&h?Wr(w+_/C,a[1][1])*C:Fr(w+(l?E:-E)/C,a[0][1])*C,z=Math.max(z,e)}}if(d){const e=Kr(M*C,p,m)/C;if(O=Math.max(O,e),s){let e=0;e=!l&&!c||c&&!l&&h?Fr(x+M*C+N,s[1][0])/C:Wr(x+(c?k:-k)*C+N,s[0][0])/C,O=Math.max(O,e)}if(a){let e=0;e=!l&&!c||c&&!l&&h?Wr(x+M*C,a[1][0])/C:Fr(x+(c?k:-k)*C,a[0][0])/C,O=Math.max(O,e)}}}k+=k<0?O:-O,E+=E<0?z:-z,r&&(h?_>M*C?k=(Gr(l,c)?-E:E)/C:E=(Gr(l,c)?-k:k)*C:u?(k=E/C,c=l):(E=k*C,l=c));const I=l?x+E:x,A=c?w+k:w;return{width:b+(l?-E:E),height:S+(c?-k:k),x:i[0]*E*(l?-1:1)+I,y:i[1]*k*(c?-1:1)+A}}(f,g,u,s,a,_,y,v),O=M!==C,I=N!==E,A=P!==b&&O,R=z!==S&&I;if(!(A||R||O||I))return;if((A||R||1===_[0]||1===_[1])&&(k.x=A?P:h.x,k.y=R?z:h.y,h.x=k.x,h.y=k.y,x.length>0)){const e=P-b,t=z-S;for(const n of x)n.position={x:n.position.x-e+_[0]*(M-C),y:n.position.y-t+_[1]*(N-E)},w.push(n)}if((O||I)&&(k.width=O?M:h.width,k.height=I?N:h.height,h.width=k.width,h.height=k.height),m&&p.expandParent){const e=_[0]*(k.width??0);k.x&&k.x<e&&(h.x=e,f.x=f.x-(k.x-e));const t=_[1]*(k.height??0);k.y&&k.y<t&&(h.y=t,f.y=f.y-(k.y-t))}const D=function({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=-1*l[0]),a&&i&&(l[1]=-1*l[1]),l}({width:h.width,prevWidth:C,height:h.height,prevHeight:E,affectsX:g.affectsX,affectsY:g.affectsY}),$={...h,direction:D},L=d?.(e,$);!1!==L&&(c?.(e,$),o(k,w))})).on("end",(e=>{u?.(e,{...h}),r?.()}));i.call(w)},destroy:function(){i.on(".drag",null)}}}function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ti,ni,oi,ri={exports:{}},ii={},si={exports:{}},ai={};function li(){return ni||(ni=1,si.exports=function(){if(ti)return ai;ti=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=o({inst:{value:n,getSnapshot:t}}),c=l[0].inst,u=l[1];return i((function(){c.value=n,c.getSnapshot=t,a(c)&&u({inst:c})}),[e,n,t]),r((function(){return a(c)&&u({inst:c}),e((function(){a(c)&&u({inst:c})}))}),[e]),s(n),n};return ai.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,ai}()),si.exports}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFlow={},e.jsxRuntime,e.React,e.ReactDOM)}(this,(function(e,t,n,o){"use strict";function r(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=r(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var i={value:()=>{}};function s(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new a(o)}function a(e){this._=e}function l(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function c(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=i,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}a.prototype=s.prototype={constructor:a,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),s=-1,a=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++s<a;)if(n=(e=i[s]).type)r[n]=c(r[n],e.name,t);else if(null==t)for(n in r)r[n]=c(r[n],e.name,null);return this}for(;++s<a;)if((n=(e=i[s]).type)&&(n=l(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new a(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},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)}};var u="http://www.w3.org/1999/xhtml",d={svg:"http://www.w3.org/2000/svg",xhtml:u,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function h(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),d.hasOwnProperty(t)?{space:d[t],local:e}:e}function f(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===u&&t.documentElement.namespaceURI===u?t.createElement(e):t.createElementNS(n,e)}}function g(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function p(e){var t=h(e);return(t.local?g:f)(t)}function m(){}function y(e){return null==e?m:function(){return this.querySelector(e)}}function v(){return[]}function x(e){return null==e?v:function(){return this.querySelectorAll(e)}}function w(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function b(e){return function(){return this.matches(e)}}function S(e){return function(t){return t.matches(e)}}var C=Array.prototype.find;function E(){return this.firstElementChild}var k=Array.prototype.filter;function _(){return Array.from(this.children)}function M(e){return new Array(e.length)}function N(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function P(e,t,n,o,r,i){for(var s,a=0,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],o[a]=s):n[a]=new N(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function z(e,t,n,o,r,i,s){var a,l,c,u=new Map,d=t.length,h=i.length,f=new Array(d);for(a=0;a<d;++a)(l=t[a])&&(f[a]=c=s.call(l,l.__data__,a,t)+"",u.has(c)?r[a]=l:u.set(c,l));for(a=0;a<h;++a)c=s.call(e,i[a],a,i)+"",(l=u.get(c))?(o[a]=l,l.__data__=i[a],u.delete(c)):n[a]=new N(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&u.get(f[a])===l&&(r[a]=l)}function O(e){return e.__data__}function A(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function I(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function R(e){return function(){this.removeAttribute(e)}}function D(e){return function(){this.removeAttributeNS(e.space,e.local)}}function L(e,t){return function(){this.setAttribute(e,t)}}function $(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function T(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function V(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function j(e){return function(){this.style.removeProperty(e)}}function H(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Z(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function X(e,t){return e.style.getPropertyValue(t)||V(e).getComputedStyle(e,null).getPropertyValue(t)}function Y(e){return function(){delete this[e]}}function W(e,t){return function(){this[e]=t}}function F(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function K(e){return e.trim().split(/^|\s+/)}function G(e){return e.classList||new q(e)}function q(e){this._node=e,this._names=K(e.getAttribute("class")||"")}function U(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Q(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function J(e){return function(){U(this,e)}}function ee(e){return function(){Q(this,e)}}function te(e,t){return function(){(t.apply(this,arguments)?U:Q)(this,e)}}function ne(){this.textContent=""}function oe(e){return function(){this.textContent=e}}function re(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function ie(){this.innerHTML=""}function se(e){return function(){this.innerHTML=e}}function ae(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function le(){this.nextSibling&&this.parentNode.appendChild(this)}function ce(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ue(){return null}function de(){var e=this.parentNode;e&&e.removeChild(this)}function he(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ge(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function pe(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function me(e,t,n){var o=V(e),r=o.CustomEvent;"function"==typeof r?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 ye(e,t){return function(){return me(this,e,t)}}function ve(e,t){return function(){return me(this,e,t.apply(this,arguments))}}N.prototype={constructor:N,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)}},q.prototype={add:function(e){this._names.indexOf(e)<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}};var xe=[null];function we(e,t){this._groups=e,this._parents=t}function be(){return new we([[document.documentElement]],xe)}function Se(e){return"string"==typeof e?new we([[document.querySelector(e)]],[document.documentElement]):new we([[e]],xe)}function Ce(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(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())).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]}we.prototype=be.prototype={constructor:we,select:function(e){"function"!=typeof e&&(e=y(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s,a=t[r],l=a.length,c=o[r]=new Array(l),u=0;u<l;++u)(i=a[u])&&(s=e.call(i,i.__data__,u,a))&&("__data__"in i&&(s.__data__=i.__data__),c[u]=s);return new we(o,this._parents)},selectAll:function(e){e="function"==typeof e?w(e):x(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s,a=t[i],l=a.length,c=0;c<l;++c)(s=a[c])&&(o.push(e.call(s,s.__data__,c,a)),r.push(s));return new we(o,r)},selectChild:function(e){return this.select(null==e?E:function(e){return function(){return C.call(this.children,e)}}("function"==typeof e?e:S(e)))},selectChildren:function(e){return this.selectAll(null==e?_:function(e){return function(){return k.call(this.children,e)}}("function"==typeof e?e:S(e)))},filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s=t[r],a=s.length,l=o[r]=[],c=0;c<a;++c)(i=s[c])&&e.call(i,i.__data__,c,s)&&l.push(i);return new we(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,O);var n,o=t?z:P,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var s=i.length,a=new Array(s),l=new Array(s),c=new Array(s),u=0;u<s;++u){var d=r[u],h=i[u],f=h.length,g=A(e.call(d,d&&d.__data__,u,r)),p=g.length,m=l[u]=new Array(p),y=a[u]=new Array(p);o(d,h,m,y,c[u]=new Array(f),g,t);for(var v,x,w=0,b=0;w<p;++w)if(v=m[w]){for(w>=b&&(b=w+1);!(x=y[b])&&++b<p;);v._next=x||null}}return(a=new we(a,r))._enter=l,a._exit=c,a},enter:function(){return new we(this._enter||this._groups.map(M),this._parents)},exit:function(){return new we(this._exit||this._groups.map(M),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c,u=n[l],d=o[l],h=u.length,f=a[l]=new Array(h),g=0;g<h;++g)(c=u[g]||d[g])&&(f[g]=c);for(;l<r;++l)a[l]=n[l];return new we(a,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,s=r[i];--i>=0;)(o=r[i])&&(s&&4^o.compareDocumentPosition(s)&&s.parentNode.insertBefore(o,s),s=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=I);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s,a=n[i],l=a.length,c=r[i]=new Array(l),u=0;u<l;++u)(s=a[u])&&(c[u]=s);c.sort(t)}return new we(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){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},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],s=0,a=i.length;s<a;++s)(r=i[s])&&e.call(r,r.__data__,s,i);return this},attr:function(e,t){var n=h(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?D:R:"function"==typeof t?n.local?B:T:n.local?$:L)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?j:"function"==typeof t?Z:H)(e,t,null==n?"":n)):X(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Y:"function"==typeof t?F:W)(e,t)):this.node()[e]},classed:function(e,t){var n=K(e+"");if(arguments.length<2){for(var o=G(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?te:t?J:ee)(n,t))},text:function(e){return arguments.length?this.each(null==e?ne:("function"==typeof e?re:oe)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?ie:("function"==typeof e?ae:se)(e)):this.node().innerHTML},raise:function(){return this.each(le)},lower:function(){return this.each(ce)},append:function(e){var t="function"==typeof e?e:p(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:p(e),o=null==t?ue:"function"==typeof t?t:y(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(de)},clone:function(e){return this.select(e?fe:he)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),s=i.length;if(!(arguments.length<2)){for(a=t?pe:ge,o=0;o<s;++o)this.each(a(i[o],t,n));return this}var a=this.node().__on;if(a)for(var l,c=0,u=a.length;c<u;++c)for(o=0,l=a[c];o<s;++o)if((r=i[o]).type===l.type&&r.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?ve:ye)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,s=r.length;i<s;++i)(o=r[i])&&(yield o)}};const Ee={passive:!1},ke={capture:!0,passive:!1};function _e(e){e.stopImmediatePropagation()}function Me(e){e.preventDefault(),e.stopImmediatePropagation()}function Ne(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",Me,ke);"onselectstart"in t?n.on("selectstart.drag",Me,ke):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pe(e,t){var n=e.document.documentElement,o=Se(e).on("dragstart.drag",null);t&&(o.on("click.drag",Me,ke),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ze=e=>()=>e;function Oe(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Ae(e){return!e.ctrlKey&&!e.button}function Ie(){return this.parentNode}function Re(e,t){return null==t?{x:e.x,y:e.y}:t}function De(){return navigator.maxTouchPoints||"ontouchstart"in this}function Le(){var e,t,n,o,r=Ae,i=Ie,a=Re,l=De,c={},u=s("start","drag","end"),d=0,h=0;function f(e){e.on("mousedown.drag",g).filter(l).on("touchstart.drag",y).on("touchmove.drag",v,Ee).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(s,a){if(!o&&r.call(this,s,a)){var l=w(this,i.call(this,s,a),s,a,"mouse");l&&(Se(s.view).on("mousemove.drag",p,ke).on("mouseup.drag",m,ke),Ne(s.view),_e(s),n=!1,e=s.clientX,t=s.clientY,l("start",s))}}function p(o){if(Me(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>h}c.mouse("drag",o)}function m(e){Se(e.view).on("mousemove.drag mouseup.drag",null),Pe(e.view,n),Me(e),c.mouse("end",e)}function y(e,t){if(r.call(this,e,t)){var n,o,s=e.changedTouches,a=i.call(this,e,t),l=s.length;for(n=0;n<l;++n)(o=w(this,a,e,t,s[n].identifier,s[n]))&&(_e(e),o("start",e,s[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=c[o[t].identifier])&&(Me(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=c[r[t].identifier])&&(_e(e),n("end",e,r[t]))}function w(e,t,n,o,r,i){var s,l,h,g=u.copy(),p=Ce(i||n,t);if(null!=(h=a.call(e,new Oe("beforestart",{sourceEvent:n,target:f,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return s=h.x-p[0]||0,l=h.y-p[1]||0,function n(i,a,u){var m,y=p;switch(i){case"start":c[r]=n,m=d++;break;case"end":delete c[r],--d;case"drag":p=Ce(u||a,t),m=d}g.call(i,e,new Oe(i,{sourceEvent:a,subject:h,target:f,identifier:r,active:m,x:p[0]+s,y:p[1]+l,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return f.filter=function(e){return arguments.length?(r="function"==typeof e?e:ze(!!e),f):r},f.container=function(e){return arguments.length?(i="function"==typeof e?e:ze(e),f):i},f.subject=function(e){return arguments.length?(a="function"==typeof e?e:ze(e),f):a},f.touchable=function(e){return arguments.length?(l="function"==typeof e?e:ze(!!e),f):l},f.on=function(){var e=u.on.apply(u,arguments);return e===u?f:e},f.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,f):Math.sqrt(h)},f}function $e(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Be(){}Oe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Ve=.7,je=1/Ve,He="\\s*([+-]?\\d+)\\s*",Ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ye=/^#([0-9a-f]{3,8})$/,We=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Fe=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),Ke=new RegExp(`^rgba\\(${He},${He},${He},${Ze}\\)$`),Ge=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Ze}\\)$`),qe=new RegExp(`^hsl\\(${Ze},${Xe},${Xe}\\)$`),Ue=new RegExp(`^hsla\\(${Ze},${Xe},${Xe},${Ze}\\)$`),Qe={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};function Je(){return this.rgb().formatHex()}function et(){return this.rgb().formatRgb()}function tt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ye.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?nt(t):3===n?new it(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?ot(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?ot(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=We.exec(e))?new it(t[1],t[2],t[3],1):(t=Fe.exec(e))?new it(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ke.exec(e))?ot(t[1],t[2],t[3],t[4]):(t=Ge.exec(e))?ot(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=qe.exec(e))?dt(t[1],t[2]/100,t[3]/100,1):(t=Ue.exec(e))?dt(t[1],t[2]/100,t[3]/100,t[4]):Qe.hasOwnProperty(e)?nt(Qe[e]):"transparent"===e?new it(NaN,NaN,NaN,0):null}function nt(e){return new it(e>>16&255,e>>8&255,255&e,1)}function ot(e,t,n,o){return o<=0&&(e=t=n=NaN),new it(e,t,n,o)}function rt(e,t,n,o){return 1===arguments.length?((r=e)instanceof Be||(r=tt(r)),r?new it((r=r.rgb()).r,r.g,r.b,r.opacity):new it):new it(e,t,n,null==o?1:o);var r}function it(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function st(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function at(){const e=lt(this.opacity);return`${1===e?"rgb(":"rgba("}${ct(this.r)}, ${ct(this.g)}, ${ct(this.b)}${1===e?")":`, ${e})`}`}function lt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return((e=ct(e))<16?"0":"")+e.toString(16)}function dt(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,n,o)}function ht(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof Be||(e=tt(e)),!e)return new ft;if(e instanceof ft)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,l=(i+r)/2;return a?(s=t===i?(n-o)/a+6*(n<o):n===i?(o-t)/a+2:(t-n)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new ft(s,a,l,e.opacity)}function ft(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function gt(e){return(e=(e||0)%360)<0?e+360:e}function pt(e){return Math.max(0,Math.min(1,e||0))}function mt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}$e(Be,tt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Je,formatHex:Je,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ht(this).formatHsl()},formatRgb:et,toString:et}),$e(it,rt,Te(Be,{brighter(e){return e=null==e?je:Math.pow(je,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?Ve:Math.pow(Ve,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it(ct(this.r),ct(this.g),ct(this.b),lt(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:st,formatHex:st,formatHex8:function(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:at,toString:at})),$e(ft,(function(e,t,n,o){return 1===arguments.length?ht(e):new ft(e,t,n,null==o?1:o)}),Te(Be,{brighter(e){return e=null==e?je:Math.pow(je,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?Ve:Math.pow(Ve,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),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 it(mt(e>=240?e-240:e+120,r,o),mt(e,r,o),mt(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ft(gt(this.h),pt(this.s),pt(this.l),lt(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=lt(this.opacity);return`${1===e?"hsl(":"hsla("}${gt(this.h)}, ${100*pt(this.s)}%, ${100*pt(this.l)}%${1===e?")":`, ${e})`}`}}));var yt=e=>()=>e;function vt(e){return 1==(e=+e)?xt:function(t,n){return n-t?function(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)}}(t,n,e):yt(isNaN(t)?n:t)}}function xt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):yt(isNaN(e)?t:e)}var wt=function e(t){var n=vt(t);function o(e,t){var o=n((e=rt(e)).r,(t=rt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),s=xt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=s(t),e+""}}return o.gamma=e,o}(1);function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var St=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ct=new RegExp(St.source,"g");function Et(e,t){var n,o,r,i=St.lastIndex=Ct.lastIndex=0,s=-1,a=[],l=[];for(e+="",t+="";(n=St.exec(e))&&(o=Ct.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),a[s]?a[s]+=r:a[++s]=r),(n=n[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,l.push({i:s,x:bt(n,o)})),i=Ct.lastIndex;return i<t.length&&(r=t.slice(i),a[s]?a[s]+=r:a[++s]=r),a.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,o=0;o<t;++o)a[(n=l[o]).i]=n.x(e);return a.join("")})}var kt,_t=180/Math.PI,Mt={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nt(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*_t,skewX:Math.atan(l)*_t,scaleX:s,scaleY:a}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,s){var a=[],l=[];return i=e(i),s=e(s),function(e,o,r,i,s,a){if(e!==r||o!==i){var l=s.push("translate(",null,t,null,n);a.push({i:l-4,x:bt(e,r)},{i:l-2,x:bt(o,i)})}else(r||i)&&s.push("translate("+r+t+i+n)}(i.translateX,i.translateY,s.translateX,s.translateY,a,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:bt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,s.rotate,a,l),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:bt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,s.skewX,a,l),function(e,t,n,o,i,s){if(e!==n||t!==o){var a=i.push(r(i)+"scale(",null,",",null,")");s.push({i:a-4,x:bt(e,n)},{i:a-2,x:bt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,s.scaleX,s.scaleY,a,l),i=s=null,function(e){for(var t,n=-1,o=l.length;++n<o;)a[(t=l[n]).i]=t.x(e);return a.join("")}}}var zt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mt:Nt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ot=Pt((function(e){return null==e?Mt:(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),(e=kt.transform.baseVal.consolidate())?Nt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):Mt)}),", ",")",")");function At(e){return((e=Math.exp(e))+1/e)/2}var It,Rt,Dt=function e(t,n,o){function r(e,r){var i,s,a=e[0],l=e[1],c=e[2],u=r[0],d=r[1],h=r[2],f=u-a,g=d-l,p=f*f+g*g;if(p<1e-12)s=Math.log(h/c)/t,i=function(e){return[a+e*f,l+e*g,c*Math.exp(t*e*s)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);s=(w-x)/t,i=function(e){var o,r=e*s,i=At(x),u=c/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[a+u*f,l+u*g,c*i/At(t*r+x)]}}return i.duration=1e3*s*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),Lt=0,$t=0,Tt=0,Bt=1e3,Vt=0,jt=0,Ht=0,Zt="object"==typeof performance&&performance.now?performance:Date,Xt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yt(){return jt||(Xt(Wt),jt=Zt.now()+Ht)}function Wt(){jt=0}function Ft(){this._call=this._time=this._next=null}function Kt(e,t,n){var o=new Ft;return o.restart(e,t,n),o}function Gt(){jt=(Vt=Zt.now())+Ht,Lt=$t=0;try{!function(){Yt(),++Lt;for(var e,t=It;t;)(e=jt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Lt}()}finally{Lt=0,function(){var e,t,n=It,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:It=t);Rt=e,Ut(o)}(),jt=0}}function qt(){var e=Zt.now(),t=e-Vt;t>Bt&&(Ht-=t,Vt=e)}function Ut(e){Lt||($t&&($t=clearTimeout($t)),e-jt>24?(e<1/0&&($t=setTimeout(Gt,e-Zt.now()-Ht)),Tt&&(Tt=clearInterval(Tt))):(Tt||(Vt=Zt.now(),Tt=setInterval(qt,Bt)),Lt=1,Xt(Gt)))}function Qt(e,t,n){var o=new Ft;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Ft.prototype=Kt.prototype={constructor:Ft,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Yt():+n)+(null==t?0:+t),this._next||Rt===this||(Rt?Rt._next=this:It=this,Rt=this),this._call=e,this._time=n,Ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ut())}};var Jt=s("start","end","cancel","interrupt"),en=[],tn=0,nn=1,on=2,rn=3,sn=4,an=5,ln=6;function cn(e,t,n,o,r,i){var s=e.__transition;if(s){if(n in s)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=nn,n.timer.restart(s,n.delay,n.time),n.delay<=e&&s(e-n.delay)}function s(i){var c,u,d,h;if(n.state!==nn)return l();for(c in r)if((h=r[c]).name===n.name){if(h.state===rn)return Qt(s);h.state===sn?(h.state=ln,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=ln,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(Qt((function(){n.state===rn&&(n.state=sn,n.timer.restart(a,n.delay,n.time),a(i))})),n.state=on,n.on.call("start",e,e.__data__,n.index,n.group),n.state===on){for(n.state=rn,o=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=an,1),i=-1,s=o.length;++i<s;)o[i].call(e,r);n.state===an&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var o in n.state=ln,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Kt(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Jt,tween:en,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:tn})}function un(e,t){var n=hn(e,t);if(n.state>tn)throw new Error("too late; already scheduled");return n}function dn(e,t){var n=hn(e,t);if(n.state>rn)throw new Error("too late; already running");return n}function hn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function fn(e,t){var n,o,r,i=e.__transition,s=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>on&&n.state<an,n.state=ln,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):s=!1;s&&delete e.__transition}}function gn(e,t){var n,o;return function(){var r=dn(this,e),i=r.tween;if(i!==n)for(var s=0,a=(o=n=i).length;s<a;++s)if(o[s].name===t){(o=o.slice()).splice(s,1);break}r.tween=o}}function pn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=dn(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function mn(e,t,n){var o=e._id;return e.each((function(){var e=dn(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return hn(e,o).value[t]}}function yn(e,t){var n;return("number"==typeof t?bt:t instanceof tt?wt:(n=tt(t))?(t=n,wt):Et)(e,t)}function vn(e){return function(){this.removeAttribute(e)}}function xn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wn(e,t,n){var o,r,i=n+"";return function(){var s=this.getAttribute(e);return s===i?null:s===o?r:r=t(o=s,n)}}function bn(e,t,n){var o,r,i=n+"";return function(){var s=this.getAttributeNS(e.space,e.local);return s===i?null:s===o?r:r=t(o=s,n)}}function Sn(e,t,n){var o,r,i;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttribute(e))===(a=l+"")?null:s===o&&a===r?i:(r=a,i=t(o=s,l));this.removeAttribute(e)}}function Cn(e,t,n){var o,r,i;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttributeNS(e.space,e.local))===(a=l+"")?null:s===o&&a===r?i:(r=a,i=t(o=s,l));this.removeAttributeNS(e.space,e.local)}}function En(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function kn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){return function(){un(this,e).delay=+t.apply(this,arguments)}}function Mn(e,t){return t=+t,function(){un(this,e).delay=t}}function Nn(e,t){return function(){dn(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){dn(this,e).duration=t}}var zn=be.prototype.constructor;function On(e){return function(){this.style.removeProperty(e)}}var An=0;function In(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Rn(){return++An}var Dn=be.prototype;In.prototype={constructor:In,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=y(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a,l,c=o[s],u=c.length,d=i[s]=new Array(u),h=0;h<u;++h)(a=c[h])&&(l=e.call(a,a.__data__,h,c))&&("__data__"in a&&(l.__data__=a.__data__),d[h]=l,cn(d[h],t,n,h,d,hn(a,n)));return new In(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=x(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l,c=o[a],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var h,f=e.call(l,l.__data__,d,c),g=hn(l,n),p=0,m=f.length;p<m;++p)(h=f[p])&&cn(h,t,n,p,f,g);i.push(f),s.push(l)}return new In(i,s,t,n)},selectChild:Dn.selectChild,selectChildren:Dn.selectChildren,filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,s=t[r],a=s.length,l=o[r]=[],c=0;c<a;++c)(i=s[c])&&e.call(i,i.__data__,c,s)&&l.push(i);return new In(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l,c=t[a],u=n[a],d=c.length,h=s[a]=new Array(d),f=0;f<d;++f)(l=c[f]||u[f])&&(h[f]=l);for(;a<o;++a)s[a]=t[a];return new In(s,this._parents,this._name,this._id)},selection:function(){return new zn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Rn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s,a=o[i],l=a.length,c=0;c<l;++c)if(s=a[c]){var u=hn(s,t);cn(s,e,n,c,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new In(o,this._parents,e,n)},call:Dn.call,nodes:Dn.nodes,node:Dn.node,size:Dn.size,empty:Dn.empty,each:Dn.each,on:function(e,t){var n=this._id;return arguments.length<2?hn(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?un:dn;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}(n,e,t))},attr:function(e,t){var n=h(e),o="transform"===n?Ot:yn;return this.attrTween(e,"function"==typeof t?(n.local?Cn:Sn)(n,o,mn(this,"attr."+e,t)):null==t?(n.local?xn:vn)(n):(n.local?bn:wn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=h(e);return this.tween(n,(o.local?En:kn)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?zt:yn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=X(this,e),s=(this.style.removeProperty(e),X(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}(e,o)).on("end.style."+e,On(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var s=X(this,e),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(e),l=a=X(this,e)),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}(e,o,mn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,s="style."+t,a="end."+s;return function(){var l=dn(this,e),c=l.on,u=null==l.value[s]?i||(i=On(t)):void 0;c===n&&r===u||(o=(n=c).copy()).on(a,r=u),l.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var s=X(this,e);return s===i?null:s===o?r:r=t(o=s,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(mn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=hn(this.node(),n).tween,i=0,s=r.length;i<s;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?gn:pn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?_n:Mn)(t,e)):hn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Nn:Pn)(t,e)):hn(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){dn(this,e).ease=t}}(t,e)):hn(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;dn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,s){var a={value:s},l={value:function(){0==--r&&i()}};n.each((function(){var n=dn(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:Dn[Symbol.iterator]};var Ln={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function $n(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}be.prototype.interrupt=function(e){return this.each((function(){fn(this,e)}))},be.prototype.transition=function(e){var t,n;e instanceof In?(t=e._id,e=e._name):(t=Rn(),(n=Ln).time=Yt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s,a=o[i],l=a.length,c=0;c<l;++c)(s=a[c])&&cn(s,e,t,c,a,n||$n(s,t));return new In(o,this._parents,e,t)};var Tn=e=>()=>e;function Bn(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 Vn(e,t,n){this.k=e,this.x=t,this.y=n}Vn.prototype={constructor:Vn,scale:function(e){return 1===e?this:new Vn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new Vn(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 jn=new Vn(1,0,0);function Hn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return jn;return e.__zoom}function Zn(e){e.stopImmediatePropagation()}function Xn(e){e.preventDefault(),e.stopImmediatePropagation()}function Yn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Wn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).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 Fn(){return this.__zoom||jn}function Kn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gn(){return navigator.maxTouchPoints||"ontouchstart"in this}function qn(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 Un(){var e,t,n,o=Yn,r=Wn,i=qn,a=Kn,l=Gn,c=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],d=250,h=Dt,f=s("start","zoom","end"),g=500,p=150,m=0,y=10;function v(e){e.property("__zoom",Fn).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",M).filter(l).on("touchstart.zoom",N).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(e,t){return(t=Math.max(c[0],Math.min(c[1],t)))===e.k?e:new Vn(t,e.x,e.y)}function w(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new Vn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function S(e,t,n,o){e.on("start.zoom",(function(){C(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){C(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,s=C(e,i).event(o),a=r.apply(e,i),l=null==n?b(a):"function"==typeof n?n.apply(e,i):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,i):t,f=h(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=f(e),n=c/t[2];e=new Vn(n,l[0]-t[0]*n,l[1]-t[1]*n)}s.zoom(null,e)}}))}function C(e,t,n){return!n&&e.__zooming||new E(e,t)}function E(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=C(this,t).event(e),r=this.__zoom,s=Math.max(c[0],Math.min(c[1],r.k*Math.pow(2,a.apply(this,arguments)))),l=Ce(e);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[l,r.invert(l)],fn(this),n.start()}Xn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),p),n.zoom("mouse",i(w(x(r,s),n.mouse[0],n.mouse[1]),n.extent,u))}}function _(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,s=C(this,t,!0).event(e),a=Se(e.view).on("mousemove.zoom",(function(e){if(Xn(e),!s.moved){var t=e.clientX-c,n=e.clientY-d;s.moved=t*t+n*n>m}s.event(e).zoom("mouse",i(w(s.that.__zoom,s.mouse[0]=Ce(e,r),s.mouse[1]),s.extent,u))}),!0).on("mouseup.zoom",(function(e){a.on("mousemove.zoom mouseup.zoom",null),Pe(e.view,s.moved),Xn(e),s.event(e).end()}),!0),l=Ce(e,r),c=e.clientX,d=e.clientY;Ne(e.view),Zn(e),s.mouse=[l,this.__zoom.invert(l)],fn(this),s.start()}}function M(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,s=Ce(e.changedTouches?e.changedTouches[0]:e,this),a=n.invert(s),l=n.k*(e.shiftKey?.5:2),c=i(w(x(n,l),s,a),r.apply(this,t),u);Xn(e),d>0?Se(this).transition().duration(d).call(S,c,s,e):Se(this).call(v.transform,c,s,e)}}function N(n,...r){if(o.apply(this,arguments)){var i,s,a,l,c=n.touches,u=c.length,d=C(this,r,n.changedTouches.length===u).event(n);for(Zn(n),s=0;s<u;++s)l=[l=Ce(a=c[s],this),this.__zoom.invert(l),a.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),g)),fn(this),d.start())}}function P(e,...t){if(this.__zooming){var n,o,r,s,a=C(this,t).event(e),l=e.changedTouches,c=l.length;for(Xn(e),n=0;n<c;++n)r=Ce(o=l[n],this),a.touch0&&a.touch0[2]===o.identifier?a.touch0[0]=r:a.touch1&&a.touch1[2]===o.identifier&&(a.touch1[0]=r);if(o=a.that.__zoom,a.touch1){var d=a.touch0[0],h=a.touch0[1],f=a.touch1[0],g=a.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=x(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],s=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!a.touch0)return;r=a.touch0[0],s=a.touch0[1]}a.zoom("touch",i(w(o,r,s),a.extent,u))}}function z(e,...o){if(this.__zooming){var r,i,s=C(this,o).event(e),a=e.changedTouches,l=a.length;for(Zn(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),g),r=0;r<l;++r)i=a[r],s.touch0&&s.touch0[2]===i.identifier?delete s.touch0:s.touch1&&s.touch1[2]===i.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(i=Ce(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<y)){var c=Se(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return v.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Fn),e!==r?S(e,t,n,o):r.interrupt().each((function(){C(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},v.scaleBy=function(e,t,n,o){v.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},v.scaleTo=function(e,t,n,o){v.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,s=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,a=o.invert(s),l="function"==typeof t?t.apply(this,arguments):t;return i(w(x(o,l),s,a),e,u)}),n,o)},v.translateBy=function(e,t,n,o){v.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),u)}),null,o)},v.translateTo=function(e,t,n,o,s){v.transform(e,(function(){var e=r.apply(this,arguments),s=this.__zoom,a=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(jn.translate(a[0],a[1]).scale(s.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,u)}),o,s)},E.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Se(this.that).datum();f.call(e,this.that,new Bn(e,{sourceEvent:this.sourceEvent,target:v,type:e,transform:this.that.__zoom,dispatch:f}),t)}},v.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:Tn(+e),v):a},v.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),v):o},v.touchable=function(e){return arguments.length?(l="function"==typeof e?e:Tn(!!e),v):l},v.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),v):r},v.scaleExtent=function(e){return arguments.length?(c[0]=+e[0],c[1]=+e[1],v):[c[0],c[1]]},v.translateExtent=function(e){return arguments.length?(u[0][0]=+e[0][0],u[1][0]=+e[1][0],u[0][1]=+e[0][1],u[1][1]=+e[1][1],v):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},v.constrain=function(e){return arguments.length?(i=e,v):i},v.duration=function(e){return arguments.length?(d=+e,v):d},v.interpolate=function(e){return arguments.length?(h=e,v):h},v.on=function(){var e=f.on.apply(f,arguments);return e===f?v:e},v.clickDistance=function(e){return arguments.length?(m=(e=+e)*e,v):Math.sqrt(m)},v.tapDistance=function(e){return arguments.length?(y=+e,v):y},v}Hn.prototype=Vn.prototype;const Qn={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: "${"source"===e?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.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"];var to,no,oo;e.ConnectionMode=void 0,(to=e.ConnectionMode||(e.ConnectionMode={})).Strict="strict",to.Loose="loose",e.PanOnScrollMode=void 0,(no=e.PanOnScrollMode||(e.PanOnScrollMode={})).Free="free",no.Vertical="vertical",no.Horizontal="horizontal",e.SelectionMode=void 0,(oo=e.SelectionMode||(e.SelectionMode={})).Partial="partial",oo.Full="full";const ro={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var io,so,ao;e.ConnectionLineType=void 0,(io=e.ConnectionLineType||(e.ConnectionLineType={})).Bezier="default",io.Straight="straight",io.Step="step",io.SmoothStep="smoothstep",io.SimpleBezier="simplebezier",e.MarkerType=void 0,(so=e.MarkerType||(e.MarkerType={})).Arrow="arrow",so.ArrowClosed="arrowclosed",e.Position=void 0,(ao=e.Position||(e.Position={})).Left="left",ao.Top="top",ao.Right="right",ao.Bottom="bottom";const lo={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top};function co(e,t){if(!e&&!t)return!0;if(!e||!t||e.size!==t.size)return!1;if(!e.size&&!t.size)return!0;for(const n of e.keys())if(!t.has(n))return!1;return!0}function uo(e,t,n){if(!n)return;const o=[];e.forEach(((e,n)=>{t?.has(n)||o.push(e)})),o.length&&n(o)}function ho(e){return null===e?null:e?"valid":"invalid"}const fo=e=>"id"in e&&"source"in e&&"target"in e,go=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),po=(e,t=[0,0])=>{const{width:n,height:o}=Ho(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},mo=(e,t={})=>{if(0===e.size)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach((e=>{if(void 0===t.filter||t.filter(e)){const t=zo(e);n=_o(n,t)}})),No(n)},yo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...$o(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const t of e.values()){const{measured:e,selectable:n=!0,hidden:o=!1}=t;if(s&&!n||o)continue;const r=e.width??t.width??t.initialWidth??null,c=e.height??t.height??t.initialHeight??null,u=Ao(a,Po(t)),d=(r??0)*(c??0),h=i&&u>0;(!t.internals.handleBounds||h||u>=d||t.dragging)&&l.push(t)}return l},vo=(e,t)=>{const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))};function xo(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map((e=>e.id))):null;return e.forEach((e=>{!(e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden))||o&&!o.has(e.id)||n.set(e.id,e)})),n}async function wo({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(0===e.size)return Promise.resolve(!1);const a=mo(e),l=Bo(a,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration}),Promise.resolve(!0)}function bo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let d=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.measured?.width??0),t[1][1]-(e.measured?.height??0)]]:t}(s,s.extent||r);if("parent"!==s.extent||s.expandParent)a&&jo(s.extent)&&(d=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);else if(a){const e=s.measured.width,t=s.measured.height,n=a.measured.width,o=a.measured.height;e&&t&&n&&o&&(d=[[l,c],[l+n-e,c+o-t]])}else i?.("005",Qn.error005());const h=jo(d)?Co(t,d):t;return{position:{x:h.x-l+s.measured.width*u[0],y:h.y-c+s.measured.height*u[1]},positionAbsolute:h}}const So=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Co=(e={x:0,y:0},t)=>({x:So(e.x,t[0][0],t[1][0]),y:So(e.y,t[0][1],t[1][1])}),Eo=(e,t,n)=>e<t?So(Math.abs(e-t),1,t)/t:e>n?-So(Math.abs(e-n),1,t)/t:0,ko=(e,t,n=15,o=40)=>[Eo(e.x,o,t.width-o)*n,Eo(e.y,o,t.height-o)*n],_o=(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)}),Mo=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),No=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Po=(e,t=[0,0])=>{const{x:n,y:o}=go(e)?e.internals.positionAbsolute:po(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},zo=(e,t=[0,0])=>{const{x:n,y:o}=go(e)?e.internals.positionAbsolute:po(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Oo=(e,t)=>No(_o(Mo(e),Mo(t))),Ao=(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)},Io=e=>Ro(e.width)&&Ro(e.height)&&Ro(e.x)&&Ro(e.y),Ro=e=>!isNaN(e)&&isFinite(e),Do=(e,t)=>{},Lo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),$o=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?Lo(a,s):a},To=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),Bo=(e,t,n,o,r,i)=>{const s=t/(e.width*(1+i)),a=n/(e.height*(1+i)),l=Math.min(s,a),c=So(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Vo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function jo(e){return void 0!==e&&"parent"!==e}function Ho(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Zo(e){return void 0!==(e.measured?.width??e.width??e.initialWidth)&&void 0!==(e.measured?.height??e.height??e.initialHeight)}function Xo(e,t={width:0,height:0},n,o,r){let i=n;const s={...e};for(;i;){const e=o.get(i);if(i=e?.parentId,e){const n=e.origin||r;s.x+=e.internals.positionAbsolute.x-(t.width??0)*n[0],s.y+=e.internals.positionAbsolute.y-(t.height??0)*n[1]}}return s}function Yo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o}){const{x:r,y:i}=Uo(e),s=$o({x:r,y:i},o),{x:a,y:l}=n?Lo(s,t):s;return{xSnapped:a,ySnapped:l,...s}}const Wo=e=>({width:e.offsetWidth,height:e.offsetHeight}),Fo=e=>e.getRootNode?.()||window?.document,Ko=["INPUT","SELECT","TEXTAREA"];function Go(e){const t=e.composedPath?.()?.[0]||e.target;return Ko.includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}const qo=e=>"clientX"in e,Uo=(e,t)=>{const n=qo(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return i&&i.length?Array.from(i).map((t=>{const i=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:r,position:t.getAttribute("data-handlepos"),x:(i.left-n.left)/o,y:(i.top-n.top)/o,...Wo(t)}})):null};function Jo({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=.125*e+.375*r+.375*s+.125*n,c=.125*t+.375*i+.375*a+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}function er(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function tr({pos:t,x1:n,y1:o,x2:r,y2:i,c:s}){switch(t){case e.Position.Left:return[n-er(n-r,s),o];case e.Position.Right:return[n+er(r-n,s),o];case e.Position.Top:return[n,o-er(o-i,s)];case e.Position.Bottom:return[n,o+er(i-o,s)]}}function nr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top,curvature:a=.25}){const[l,c]=tr({pos:o,x1:t,y1:n,x2:r,y2:i,c:a}),[u,d]=tr({pos:s,x1:r,y1:i,x2:t,y2:n,c:a}),[h,f,g,p]=Jo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${t},${n} C${l},${c} ${u},${d} ${r},${i}`,h,f,g,p]}function or({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;return[i,o<t?o+s:o-s,r,s]}function rr({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=_o(zo(e),zo(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 Ao(s,No(i))>0}const ir=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,sr=(e,t)=>{if(!e.source||!e.target)return t;let n;return n=fo(e)?{...e}:{...e,id:ir(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:(null===n.sourceHandle&&delete n.sourceHandle,null===n.targetHandle&&delete n.targetHandle,t.concat(n))};function ar({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=or({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const lr={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},cr=({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1},ur=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20}){const[d,h,f,g,p]=function({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:s}){const a=lr[n],l=lr[r],c={x:t.x+a.x*s,y:t.y+a.y*s},u={x:o.x+l.x*s,y:o.y+l.y*s},d=cr({source:c,sourcePosition:n,target:u}),h=0!==d.x?"x":"y",f=d[h];let g,p,m=[];const y={x:0,y:0},v={x:0,y:0},[x,w,b,S]=or({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(a[h]*l[h]==-1){g=i.x??x,p=i.y??w;const e=[{x:g,y:c.y},{x:g,y:u.y}],t=[{x:c.x,y:p},{x:u.x,y:p}];m=a[h]===f?"x"===h?e:t:"x"===h?t:e}else{const e=[{x:c.x,y:u.y}],i=[{x:u.x,y:c.y}];if(m="x"===h?a.x===f?i:e:a.y===f?e:i,n===r){const e=Math.abs(t[h]-o[h]);if(e<=s){const n=Math.min(s-1,s-e);a[h]===f?y[h]=(c[h]>t[h]?-1:1)*n:v[h]=(u[h]>o[h]?-1:1)*n}}if(n!==r){const t="x"===h?"y":"x",n=a[h]===l[t],o=c[t]>u[t],r=c[t]<u[t];(1===a[h]&&(!n&&o||n&&r)||1!==a[h]&&(!n&&r||n&&o))&&(m="x"===h?e:i)}const d={x:c.x+y.x,y:c.y+y.y},x={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(x.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(x.y-m[0].y))?(g=(d.x+x.x)/2,p=m[0].y):(g=m[0].x,p=(d.y+x.y)/2)}return[[t,{x:c.x+y.x,y:c.y+y.y},...m,{x:u.x+v.x,y:u.y+v.y},o],g,p,b,S]}({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:s,center:{x:l,y:c},offset:u});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(ur(e,t)/2,ur(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)return`L ${i+r*(e.x<n.x?-1:1)},${s}Q ${i},${s} ${i},${s+r*(e.y<n.y?1:-1)}`;const a=e.x<n.x?1:-1;return`L ${i},${s+r*(e.y<n.y?-1:1)}Q ${i},${s} ${i+r*a},${s}`}(d[n-1],t,d[n+1],a):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),h,f,g,p]}function hr(e){return e&&!(!e.internals.handleBounds&&!e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fr(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,"source"===o.type?t.push(o):"target"===o.type&&n.push(o);return{source:t,target:n}}function gr(t,n,o=e.Position.Left,r=!1){const i=(n?.x??0)+t.internals.positionAbsolute.x,s=(n?.y??0)+t.internals.positionAbsolute.y,{width:a,height:l}=n??Ho(t);if(r)return{x:i+a/2,y:s+l/2};switch(n?.position??o){case e.Position.Top:return{x:i+a/2,y:s};case e.Position.Right:return{x:i+a,y:s+l/2};case e.Position.Bottom:return{x:i+a/2,y:s+l};case e.Position.Left:return{x:i,y:s+l/2}}}function pr(e,t){return e&&(t?e.find((e=>e.id===t)):e[0])||null}function mr(e,t){if(!e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`}function yr(t,n,o,r,i){let s=.5;"start"===i?s=0:"end"===i&&(s=1);let a=[(t.x+t.width*s)*n.zoom+n.x,t.y*n.zoom+n.y-r],l=[-100*s,-100];switch(o){case e.Position.Right:a=[(t.x+t.width)*n.zoom+n.x+r,(t.y+t.height*s)*n.zoom+n.y],l=[0,-100*s];break;case e.Position.Bottom:a[1]=(t.y+t.height)*n.zoom+n.y+r,l[1]=0;break;case e.Position.Left:a=[t.x*n.zoom+n.x-r,(t.y+t.height*s)*n.zoom+n.y],l=[-100,-100*s]}return`translate(${a[0]}px, ${a[1]}px) translate(${l[0]}%, ${l[1]}%)`}const vr={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{}},xr={...vr,checkEquality:!0};function wr(e,t,n,o){const r={...xr,...o},i=new Map(t);t.clear(),n.clear();const s=o?.elevateNodesOnSelect?1e3:0;for(const a of e){let e=i.get(a.id);r.checkEquality&&a===e?.internals.userNode||(e={...r.defaults,...a,measured:{width:a.measured?.width,height:a.measured?.height},internals:{positionAbsolute:po(a,r.nodeOrigin),handleBounds:a.measured?e?.internals.handleBounds:void 0,z:Sr(a,s),userNode:a}}),t.set(a.id,e),a.parentId&&br(e,t,n,o)}}function br(e,t,n,o){const r={...vr,...o},i=e.parentId,s=t.get(i);if(!s)return void console.warn(`Parent node ${i} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);const a=n.get(i);a?a.set(e.id,e):n.set(i,new Map([[e.id,e]]));const l=o?.elevateNodesOnSelect?1e3:0,{x:c,y:u,z:d}=function(e,t,n,o){const r=po(e,n),i=Sr(e,o),s=t.internals.z??0;return{x:t.internals.positionAbsolute.x+r.x,y:t.internals.positionAbsolute.y+r.y,z:s>i?s:i}}(e,s,r.nodeOrigin,l),h=e.internals.positionAbsolute,f=c!==h.x||u!==h.y;(f||d!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:f?{x:c,y:u}:h,z:d})}function Sr(e,t){return(Ro(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Cr(e,t,n,o=[0,0]){const r=[],i=new Map;for(const n of e){const e=t.get(n.parentId);if(!e)continue;const o=i.get(n.parentId)?.expandedRect??Po(e),r=Oo(o,n.rect);i.set(n.parentId,{expandedRect:r,parent:e})}return i.size>0&&i.forEach((({expandedRect:t,parent:i},s)=>{const a=i.internals.positionAbsolute,l=Ho(i),c=i.origin??o,u=t.x<a.x?Math.round(Math.abs(a.x-t.x)):0,d=t.y<a.y?Math.round(Math.abs(a.y-t.y)):0,h=Math.max(l.width,Math.round(t.width)),f=Math.max(l.height,Math.round(t.height)),g=(h-l.width)*c[0],p=(f-l.height)*c[1];(u>0||d>0||g||p)&&(r.push({id:s,type:"position",position:{x:i.position.x-u+g,y:i.position.y-d+p}}),n.get(s)?.forEach((t=>{e.some((e=>e.id===t.id))||r.push({id:t.id,type:"position",position:{x:t.position.x+u,y:t.position.y+d}})}))),(l.width<t.width||l.height<t.height||u||d)&&r.push({id:s,type:"dimensions",setAttributes:!0,dimensions:{width:h+(u?c[0]*u-g:0),height:f+(d?c[1]*d-p:0)}})})),r}function Er(e,t,n){e.clear(),t.clear();for(const o of n){const{source:n,target:r,sourceHandle:i=null,targetHandle:s=null}=o,a=`${n}-source-${i}`,l=`${r}-target-${s}`,c=e.get(a)||new Map,u=e.get(l)||new Map,d={edgeId:o.id,source:n,target:r,sourceHandle:i,targetHandle:s};t.set(o.id,o),e.set(a,c.set(`${r}-${s}`,d)),e.set(l,u.set(`${n}-${i}`,d))}}function kr(e,t){if(null===e||null===t)return!1;const n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t];if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++)if(n[e].id!==o[e].id||n[e].type!==o[e].type||!Object.is(n[e].data,o[e].data))return!1;return!0}function _r(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return!!n&&(!!n.selected||_r(n,t))}function Mr(e,t,n){let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1}function Nr({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[e,i]of t){const t=n.get(e)?.internals.userNode;t&&r.push({...t,position:i.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e).internals.userNode;return[{...i,position:t.get(e)?.position||i.position,dragging:o},r]}function Pr({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},u=null,d=!1,h=null,f=!1;return{update:function({noDragClassName:g,handleSelector:p,domNode:m,isSelectable:y,nodeId:v,nodeClickDistance:x=0}){function w({x:e,y:n},r){const{nodeLookup:s,nodeExtent:l,snapGrid:c,snapToGrid:u,nodeOrigin:d,onNodeDrag:h,onSelectionDrag:f,onError:g,updateNodePositions:p}=t();i={x:e,y:n};let m=!1,y={x:0,y:0,x2:0,y2:0};if(a.size>1&&l){const e=mo(a);y=Mo(e)}for(const[t,o]of a){let r={x:e-o.distance.x,y:n-o.distance.y};u&&(r=Lo(r,c));let i=[[l[0][0],l[0][1]],[l[1][0],l[1][1]]];if(a.size>1&&l&&!o.extent){const{positionAbsolute:e}=o.internals,t=e.x-y.x+l[0][0],n=e.x+o.measured.width-y.x2+l[1][0];i=[[t,e.y-y.y+l[0][1]],[n,e.y+o.measured.height-y.y2+l[1][1]]]}const{position:h,positionAbsolute:f}=bo({nodeId:t,nextPosition:r,nodeLookup:s,nodeExtent:i,nodeOrigin:d,onError:g});m=m||o.position.x!==h.x||o.position.y!==h.y,o.position=h,o.internals.positionAbsolute=f}if(m&&(p(a,!0),r&&(o||h||!v&&f))){const[e,t]=Nr({nodeId:v,dragItems:a,nodeLookup:s});o?.(r,a,e,t),h?.(r,e,t),v||f?.(r,t)}}async function b(){if(!u)return;const{transform:e,panBy:n,autoPanSpeed:o}=t(),[r,a]=ko(c,u,o);0===r&&0===a||(i.x=(i.x??0)-r/e[2],i.y=(i.y??0)-a/e[2],await n({x:r,y:a})&&w(i,null)),s=requestAnimationFrame(b)}function S(o){const{nodeLookup:r,multiSelectionActive:s,nodesDraggable:l,transform:c,snapGrid:u,snapToGrid:h,selectNodesOnDrag:f,onNodeDragStart:g,onSelectionDragStart:p,unselectNodesAndEdges:m}=t();d=!0,f&&y||s||!v||r.get(v)?.selected||m(),y&&f&&v&&e?.(v);const x=Yo(o.sourceEvent,{transform:c,snapGrid:u,snapToGrid:h});if(i=x,a=function(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!_r(s,e))&&(s.draggable||t&&void 0===s.draggable)){const t=e.get(i);t&&r.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return r}(r,l,x,v),a.size>0&&(n||g||!v&&p)){const[e,t]=Nr({nodeId:v,dragItems:a,nodeLookup:r});n?.(o.sourceEvent,a,e,t),g?.(o.sourceEvent,e,t),v||p?.(o.sourceEvent,t)}}h=Se(m);const C=Le().clickDistance(x).on("start",(e=>{const{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:s,snapToGrid:a}=t();f=!1,0===o&&S(e);const l=Yo(e.sourceEvent,{transform:r,snapGrid:s,snapToGrid:a});i=l,u=n?.getBoundingClientRect()||null,c=Uo(e.sourceEvent,u)})).on("drag",(e=>{const{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:s,nodeDragThreshold:h}=t(),g=Yo(e.sourceEvent,{transform:o,snapGrid:r,snapToGrid:s});if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(f=!0),!f){if(!l&&n&&d&&(l=!0,b()),!d){const t=g.xSnapped-(i.x??0),n=g.ySnapped-(i.y??0);Math.sqrt(t*t+n*n)>h&&S(e)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&a&&d&&(c=Uo(e.sourceEvent,u),w(g,e.sourceEvent))}})).on("end",(e=>{if(d&&!f&&(l=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:s}=t();if(o(a,!1),r||i||!v&&s){const[t,o]=Nr({nodeId:v,dragItems:a,nodeLookup:n,dragging:!1});r?.(e.sourceEvent,a,t,o),i?.(e.sourceEvent,t,o),v||s?.(e.sourceEvent,o)}}})).filter((e=>{const t=e.target;return!e.button&&(!g||!Mr(t,`.${g}`,m))&&(!p||Mr(t,p,m))}));h.call(C)},destroy:function(){h?.on(".drag",null)}}}const zr=250;function Or(e,t,n,o){let r=[],i=1/0;const s=function(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:2*n,height:2*n};for(const e of t.values())Ao(r,Po(e))>0&&o.push(e);return o}(e,n,t+zr);for(const n of s){const s=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(const a of s){if(o.nodeId===a.nodeId&&o.type===a.type&&o.id===a.id)continue;const{x:s,y:l}=gr(n,a,a.position,!0),c=Math.sqrt(Math.pow(s-e.x,2)+Math.pow(l-e.y,2));c>t||(c<i?(r=[{...a,x:s,y:l}],i=c):c===i&&r.push({...a,x:s,y:l}))}}if(!r.length)return null;if(r.length>1){const e="source"===o.type?"target":"source";return r.find((t=>t.type===e))??r[0]}return r[0]}function Ar(e,t,n,o,r=!1){const i=o.get(e);if(!i)return null;const s=i.internals.handleBounds?.[t],a=(n?s?.find((e=>e.id===n)):s?.[0])??null;return a&&r?{...a,...gr(i,a,a.position,!0)}:a}function Ir(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}const Rr=()=>!0;function Dr(t,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:s,doc:a,lib:l,flowId:c,isValidConnection:u=Rr,nodeLookup:d}){const h="target"===s,f=n?a.querySelector(`.${l}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:g,y:p}=Uo(t),m=a.elementFromPoint(g,p),y=m?.classList.contains(`${l}-flow__handle`)?m:f,v={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const t=Ir(void 0,y),n=y.getAttribute("data-nodeid"),s=y.getAttribute("data-handleid"),a=y.classList.contains("connectable"),l=y.classList.contains("connectableend");if(!n||!t)return v;const c={source:h?n:r,sourceHandle:h?s:i,target:h?r:n,targetHandle:h?i:s};v.connection=c;const f=a&&l&&(o===e.ConnectionMode.Strict?h&&"source"===t||!h&&"target"===t:n!==r||s!==i);v.isValid=f&&u(c),v.toHandle=Ar(n,t,s,d,!1)}return v}const Lr={onPointerDown:function(t,{connectionMode:n,connectionRadius:o,handleId:r,nodeId:i,edgeUpdaterType:s,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:h,panBy:f,cancelConnection:g,onConnectStart:p,onConnect:m,onConnectEnd:y,isValidConnection:v=Rr,onReconnectEnd:x,updateConnection:w,getTransform:b,getFromHandle:S,autoPanSpeed:C}){const E=Fo(t.target);let k,_=0;const{x:M,y:N}=Uo(t),P=E?.elementFromPoint(M,N),z=Ir(s,P),O=l?.getBoundingClientRect();if(!O||!z)return;const A=Ar(i,z,r,c);if(!A)return;let I=Uo(t,O),R=!1,D=null,L=!1,$=null;function T(){if(!d||!O)return;const[e,t]=ko(I,O,C);f({x:e,y:t}),_=requestAnimationFrame(T)}const B={...A,nodeId:i,type:z,position:A.position},V=c.get(i),j={inProgress:!0,isValid:null,from:gr(V,B,e.Position.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:I,toHandle:null,toPosition:lo[B.position],toNode:null};w(j);let H=j;function Z(e){if(!S()||!B)return void X(e);const t=b();I=Uo(e,O),k=Or($o(I,t,!1,[1,1]),o,c,B),R||(T(),R=!0);const s=Dr(e,{handle:k,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:v,doc:E,lib:u,flowId:h,nodeLookup:c});$=s.handleDomNode,D=s.connection,L=function(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}(!!k,s.isValid);const l={...H,isValid:L,to:k&&L?To({x:k.x,y:k.y},t):I,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:lo[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null};L&&k&&H.toHandle&&l.toHandle&&H.toHandle.type===l.toHandle.type&&H.toHandle.nodeId===l.toHandle.nodeId&&H.toHandle.id===l.toHandle.id&&H.to.x===l.to.x&&H.to.y===l.to.y||(w(l),H=l)}function X(e){(k||$)&&D&&L&&m?.(D);const{inProgress:t,...n}=H,o={...n,toPosition:H.toHandle?H.toPosition:null};y?.(e,o),s&&x?.(e,o),g(),cancelAnimationFrame(_),R=!1,L=!1,D=null,$=null,E.removeEventListener("mousemove",Z),E.removeEventListener("mouseup",X),E.removeEventListener("touchmove",Z),E.removeEventListener("touchend",X)}p?.(t,{nodeId:i,handleId:r,handleType:z}),E.addEventListener("mousemove",Z),E.addEventListener("mouseup",X),E.addEventListener("touchmove",Z),E.addEventListener("touchend",X)},isValid:Dr};const $r=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Tr=e=>({x:e.x,y:e.y,zoom:e.k}),Br=({x:e,y:t,zoom:n})=>jn.translate(e,t).scale(n),Vr=(e,t)=>e.target.closest(`.${t}`),jr=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Hr=(e,t=0,n=(()=>{}))=>{const o="number"==typeof t&&t>0;return o||n(),o?e.transition().duration(t).on("end",n):e},Zr=e=>{const t=e.ctrlKey&&Vo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function Xr({domNode:t,minZoom:n,maxZoom:o,paneClickDistance:r,translateExtent:i,viewport:s,onPanZoom:a,onPanZoomStart:l,onPanZoomEnd:c,onTransformChange:u,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=t.getBoundingClientRect(),g=Un().clickDistance(!Ro(r)||r<0?0:r).scaleExtent([n,o]).translateExtent(i),p=Se(t).call(g);w({x:s.x,y:s.y,zoom:So(s.zoom,n,o)},[[0,0],[f.width,f.height]],i);const m=p.on("wheel.zoom"),y=p.on("dblclick.zoom");function v(e,t){return p?new Promise((n=>{g?.transform(Hr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)}function x(){g.on("zoom",null)}async function w(e,t,n){const o=Br(e),r=g?.constrain()(o,t,n);return r&&await v(r),new Promise((e=>e(r)))}return g.wheelDelta(Zr),{update:function({noWheelClassName:t,noPanClassName:n,onPaneContextMenu:o,userSelectionActive:r,panOnScroll:i,panOnDrag:s,panOnScrollMode:f,panOnScrollSpeed:v,preventScrolling:w,zoomOnPinch:b,zoomOnScroll:S,zoomOnDoubleClick:C,zoomActivationKeyPressed:E,lib:k}){r&&!h.isZoomingOrPanning&&x();const _=i&&!E&&!r?function({zoomPanValues:t,noWheelClassName:n,d3Selection:o,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Vr(d,n))return!1;d.preventDefault(),d.stopImmediatePropagation();const h=o.property("__zoom").k||1;if(d.ctrlKey&&a){const e=Ce(d),t=Zr(d),n=h*Math.pow(2,t);return void r.scaleTo(o,n,e,d)}const f=1===d.deltaMode?20:1;let g=i===e.PanOnScrollMode.Vertical?0:d.deltaX*f,p=i===e.PanOnScrollMode.Horizontal?0:d.deltaY*f;!Vo()&&d.shiftKey&&i!==e.PanOnScrollMode.Vertical&&(g=d.deltaY*f,p=0),r.translateBy(o,-g/h*s,-p/h*s,{internal:!0});const m=Tr(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling||(t.isPanScrolling=!0,l?.(d,m)),t.isPanScrolling&&(c?.(d,m),t.panScrollTimeout=setTimeout((()=>{u?.(d,m),t.isPanScrolling=!1}),150))}}({zoomPanValues:h,noWheelClassName:t,d3Selection:p,d3Zoom:g,panOnScrollMode:f,panOnScrollSpeed:v,zoomOnPinch:b,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:c}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){if(!t&&"wheel"===o.type&&!o.ctrlKey||Vr(o,e))return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:t,preventScrolling:w,d3ZoomHandler:m});if(p.on("wheel.zoom",_,{passive:!1}),!r){const e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=Tr(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,"mousedown"===o.sourceEvent?.type&&t(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:l});g.on("start",e);const t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!(!n||!jr(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Tr(i.transform))}}({zoomPanValues:h,panOnDrag:s,onPaneContextMenu:!!o,onPanZoom:a,onTransformChange:u});g.on("zoom",t);const n=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&jr(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r&&$r(e.prevViewport,s.transform))){const t=Tr(s.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{r?.(s.sourceEvent,t)}),n?150:0)}}}({zoomPanValues:h,panOnDrag:s,panOnScroll:i,onPaneContextMenu:o,onPanZoomEnd:c,onDraggingChange:d});g.on("end",n)}const M=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c}){return u=>{const d=e||t,h=n&&u.ctrlKey;if(1===u.button&&"mousedown"===u.type&&(Vr(u,`${c}-flow__node`)||Vr(u,`${c}-flow__edge`)))return!0;if(!(o||d||r||i||n))return!1;if(s)return!1;if(Vr(u,a)&&"wheel"===u.type)return!1;if(Vr(u,l)&&("wheel"!==u.type||r&&"wheel"===u.type&&!e))return!1;if(!n&&u.ctrlKey&&"wheel"===u.type)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!d&&!r&&!h&&"wheel"===u.type)return!1;if(!o&&("mousedown"===u.type||"touchstart"===u.type))return!1;if(Array.isArray(o)&&!o.includes(u.button)&&"mousedown"===u.type)return!1;const f=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||"wheel"===u.type)&&f}}({zoomActivationKeyPressed:E,panOnDrag:s,zoomOnScroll:S,panOnScroll:i,zoomOnDoubleClick:C,zoomOnPinch:b,userSelectionActive:r,noPanClassName:n,noWheelClassName:t,lib:k});g.filter(M),C?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)},destroy:x,setViewport:async function(e,t){const n=Br(e);return await v(n,t),new Promise((e=>e(n)))},setViewportConstrained:w,getViewport:function(){const e=p?Hn(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){return p?new Promise((n=>{g?.scaleTo(Hr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)},scaleBy:function(e,t){return p?new Promise((n=>{g?.scaleBy(Hr(p,t?.duration,(()=>n(!0))),e)})):Promise.resolve(!1)},setScaleExtent:function(e){g?.scaleExtent(e)},setTranslateExtent:function(e){g?.translateExtent(e)},syncViewport:function(e){if(p){const t=Br(e),n=p.property("__zoom");n.k===e.zoom&&n.x===e.x&&n.y===e.y||g?.transform(p,t,null,{sync:!0})}},setClickDistance:function(e){const t=!Ro(e)||e<0?0:e;g?.clickDistance(t)}}}var Yr;!function(e){e.Line="line",e.Handle="handle"}(Yr||(Yr={}));const Wr=["top-left","top-right","bottom-left","bottom-right"],Fr=["top","right","bottom","left"];function Kr(e,t){return Math.max(0,t-e)}function Gr(e,t){return Math.max(0,e-t)}function qr(e,t,n){return Math.max(0,t-e,e-n)}function Ur(e,t){return e?!t:t}const Qr={width:0,height:0,x:0,y:0},Jr={...Qr,pointerX:0,pointerY:0,aspectRatio:1};function ei(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function ti({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Se(e);return{update:function({controlPosition:e,boundaries:s,keepAspectRatio:a,onResizeStart:l,onResize:c,onResizeEnd:u,shouldResize:d}){let h={...Qr},f={...Jr};const g=function(e){return{isHorizontal:e.includes("right")||e.includes("left"),isVertical:e.includes("bottom")||e.includes("top"),affectsX:e.includes("left"),affectsY:e.includes("top")}}(e);let p,m,y,v,x=[];const w=Le().on("start",(e=>{const{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:s,nodeOrigin:a}=n();if(p=o.get(t),!p)return;const{xSnapped:c,ySnapped:u}=Yo(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:s});h={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},f={...h,pointerX:c,pointerY:u,aspectRatio:h.width/h.height},m=void 0,p.parentId&&("parent"===p.extent||p.expandParent)&&(m=o.get(p.parentId),y=m&&"parent"===p.extent?function(e){return[[0,0],[e.measured.width,e.measured.height]]}(m):void 0),x=[],v=void 0;for(const[e,n]of o)if(n.parentId===t&&(x.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){const e=ei(n,p,n.origin??a);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}l?.(e,{...h})})).on("drag",(e=>{const{transform:t,snapGrid:r,snapToGrid:i,nodeOrigin:l}=n(),u=Yo(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:i}),w=[];if(!p)return;const{x:b,y:S,width:C,height:E}=h,k={},_=p.origin??l,{width:M,height:N,x:P,y:z}=function(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:d}=t,h=u&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:p,maxWidth:m,minHeight:y,maxHeight:v}=o,{x:x,y:w,width:b,height:S,aspectRatio:C}=e;let E=Math.floor(u?f-e.pointerX:0),k=Math.floor(d?g-e.pointerY:0);const _=b+(l?-E:E),M=S+(c?-k:k),N=-i[0]*b,P=-i[1]*S;let z=qr(_,p,m),O=qr(M,y,v);if(s){let e=0,t=0;l&&E<0?e=Kr(x+E+N,s[0][0]):!l&&E>0&&(e=Gr(x+_+N,s[1][0])),c&&k<0?t=Kr(w+k+P,s[0][1]):!c&&k>0&&(t=Gr(w+M+P,s[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(a){let e=0,t=0;l&&E>0?e=Gr(x+E,a[0][0]):!l&&E<0&&(e=Kr(x+_,a[1][0])),c&&k>0?t=Gr(w+k,a[0][1]):!c&&k<0&&(t=Kr(w+M,a[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(r){if(u){const e=qr(_/C,y,v)*C;if(z=Math.max(z,e),s){let e=0;e=!l&&!c||l&&!c&&h?Gr(w+P+_/C,s[1][1])*C:Kr(w+P+(l?E:-E)/C,s[0][1])*C,z=Math.max(z,e)}if(a){let e=0;e=!l&&!c||l&&!c&&h?Kr(w+_/C,a[1][1])*C:Gr(w+(l?E:-E)/C,a[0][1])*C,z=Math.max(z,e)}}if(d){const e=qr(M*C,p,m)/C;if(O=Math.max(O,e),s){let e=0;e=!l&&!c||c&&!l&&h?Gr(x+M*C+N,s[1][0])/C:Kr(x+(c?k:-k)*C+N,s[0][0])/C,O=Math.max(O,e)}if(a){let e=0;e=!l&&!c||c&&!l&&h?Kr(x+M*C,a[1][0])/C:Gr(x+(c?k:-k)*C,a[0][0])/C,O=Math.max(O,e)}}}k+=k<0?O:-O,E+=E<0?z:-z,r&&(h?_>M*C?k=(Ur(l,c)?-E:E)/C:E=(Ur(l,c)?-k:k)*C:u?(k=E/C,c=l):(E=k*C,l=c));const A=l?x+E:x,I=c?w+k:w;return{width:b+(l?-E:E),height:S+(c?-k:k),x:i[0]*E*(l?-1:1)+A,y:i[1]*k*(c?-1:1)+I}}(f,g,u,s,a,_,y,v),O=M!==C,A=N!==E,I=P!==b&&O,R=z!==S&&A;if(!(I||R||O||A))return;if((I||R||1===_[0]||1===_[1])&&(k.x=I?P:h.x,k.y=R?z:h.y,h.x=k.x,h.y=k.y,x.length>0)){const e=P-b,t=z-S;for(const n of x)n.position={x:n.position.x-e+_[0]*(M-C),y:n.position.y-t+_[1]*(N-E)},w.push(n)}if((O||A)&&(k.width=O?M:h.width,k.height=A?N:h.height,h.width=k.width,h.height=k.height),m&&p.expandParent){const e=_[0]*(k.width??0);k.x&&k.x<e&&(h.x=e,f.x=f.x-(k.x-e));const t=_[1]*(k.height??0);k.y&&k.y<t&&(h.y=t,f.y=f.y-(k.y-t))}const D=function({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=-1*l[0]),a&&i&&(l[1]=-1*l[1]),l}({width:h.width,prevWidth:C,height:h.height,prevHeight:E,affectsX:g.affectsX,affectsY:g.affectsY}),L={...h,direction:D},$=d?.(e,L);!1!==$&&(c?.(e,L),o(k,w))})).on("end",(e=>{u?.(e,{...h}),r?.()}));i.call(w)},destroy:function(){i.on(".drag",null)}}}function ni(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oi,ri,ii,si={exports:{}},ai={},li={exports:{}},ci={};function ui(){return ri||(ri=1,li.exports=function(){if(oi)return ci;oi=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=o({inst:{value:n,getSnapshot:t}}),c=l[0].inst,u=l[1];return i((function(){c.value=n,c.getSnapshot=t,a(c)&&u({inst:c})}),[e,n,t]),r((function(){return a(c)&&u({inst:c}),e((function(){a(c)&&u({inst:c})}))}),[e]),s(n),n};return ci.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,ci}()),li.exports}
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/ri.exports=function(){if(oi)return ii;oi=1;var e=n,t=li(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return ii.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=a((function(){function e(e){if(!s){if(s=!0,r=e,e=c(e),void 0!==u&&h.hasValue){var t=h.value;if(u(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=c(e);return void 0!==u&&u(t,n)?t:(r=e,i=n)}var r,i,s=!1,a=void 0===n?null:n;return[function(){return e(t())},null===a?void 0:function(){return e(a())}]}),[t,n,c,u]);var f=r(e,d[0],d[1]);return s((function(){h.hasValue=!0,h.value=f}),[f]),l(f),f},ii}();var ci=ei(ri.exports);const ui=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(o,r,i),i},{useSyncExternalStoreWithSelector:di}=ci;function hi(e,t=e.getState,o){const r=di(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}const fi=(e,t)=>{const n=(e=>e?ui(e):ui)(e),o=(e,o=t)=>hi(n,e,o);return Object.assign(o,n),o},gi=n.createContext(null),pi=gi.Provider,mi=Qn.error001();function yi(e,t){const o=n.useContext(gi);if(null===o)throw new Error(mi);return hi(o,e,t)}function vi(){const e=n.useContext(gi);if(null===e)throw new Error(mi);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe})),[e])}const xi={display:"none"},wi={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},bi="react-flow__node-desc",Si="react-flow__edge-desc",Ci="react-flow__aria-live",Ei=e=>e.ariaLiveMessage;function ki({rfId:e}){const n=yi(Ei);return t.jsx("div",{id:`${Ci}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:wi,children:n})}function _i({rfId:e,disableKeyboardA11y:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{id:`${bi}-${e}`,style:xi,children:["Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),t.jsx("div",{id:`${Si}-${e}`,style:xi,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!n&&t.jsx(ki,{rfId:e})]})}const Mi=e=>e.userSelectionActive?"none":"all";function Ni({position:e="top-left",children:n,className:o,style:i,...s}){const a=yi(Mi),l=`${e}`.split("-");return t.jsx("div",{className:r(["react-flow__panel",o,...l]),style:{...i,pointerEvents:a},...s,children:n})}function Pi({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(Ni,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}function zi(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}const Oi=e=>{const t=[],n=[];for(const[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(const[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Ii=e=>e.id;function Ai(e,t){return zi(e.selectedNodes.map(Ii),t.selectedNodes.map(Ii))&&zi(e.selectedEdges.map(Ii),t.selectedEdges.map(Ii))}function Ri({onSelectionChange:e}){const t=vi(),{selectedNodes:o,selectedEdges:r}=yi(Oi,Ai);return n.useEffect((()=>{const n={nodes:o,edges:r};e?.(n),t.getState().onSelectionChangeHandlers.forEach((e=>e(n)))}),[o,r,e]),null}const Di=e=>!!e.onSelectionChangeHandlers;function $i({onSelectionChange:e}){const n=yi(Di);return e||n?t.jsx(Ri,{onSelectionChange:e}):null}const Li=[0,0],Ti={x:0,y:0,zoom:1},Bi=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","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","onBeforeDelete","debug","autoPanSpeed","paneClickDistance","rfId"],Vi=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,setPaneClickDistance:e.setPaneClickDistance}),ji={translateExtent:Jn,nodeOrigin:Li,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function Hi(e){const{setNodes:t,setEdges:o,setMinZoom:r,setMaxZoom:i,setTranslateExtent:s,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c,setPaneClickDistance:u}=yi(Vi,zi),d=vi();n.useEffect((()=>(c(e.defaultNodes,e.defaultEdges),()=>{h.current=ji,l()})),[]);const h=n.useRef(ji);return n.useEffect((()=>{for(const n of Bi){const l=e[n];l!==h.current[n]&&(void 0!==e[n]&&("nodes"===n?t(l):"edges"===n?o(l):"minZoom"===n?r(l):"maxZoom"===n?i(l):"translateExtent"===n?s(l):"nodeExtent"===n?a(l):"paneClickDistance"===n?u(l):"fitView"===n?d.setState({fitViewOnInit:l}):"fitViewOptions"===n?d.setState({fitViewOnInitOptions:l}):d.setState({[n]:l})))}h.current=e}),Bi.map((t=>e[t]))),null}function Zi(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null}const Xi="undefined"!=typeof document?document:null;function Yi(e=null,t={target:Xi,actInsideInputWithModifier:!0}){const[o,r]=n.useState(!1),i=n.useRef(!1),s=n.useRef(new Set([])),[a,l]=n.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return n.useEffect((()=>{const n=t?.target||Xi;if(null!==e){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Go(e))return!1;const n=Fi(e.code,l);s.current.add(e[n]),Wi(a,s.current,!1)&&(e.preventDefault(),r(!0))},o=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Go(e))return!1;const n=Fi(e.code,l);Wi(a,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(e[n]),"Meta"===e.key&&s.current.clear(),i.current=!1},c=()=>{s.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",o),window.addEventListener("blur",c),window.addEventListener("contextmenu",c),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",o),window.removeEventListener("blur",c),window.removeEventListener("contextmenu",c)}}}),[e,r]),o}function Wi(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function Fi(e,t){return t.includes(e)?"code":"key"}const Ki=()=>{const e=vi();return n.useMemo((()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration: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},{duration:n?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>{const{nodeLookup:n,width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=xo(n,t);return a?wo({nodes:l,width:o,height:r,minZoom:i,maxZoom:s,panZoom:a},t):Promise.resolve(!1)},setCenter:async(t,n,o)=>{const{width:r,height:i,maxZoom:s,panZoom:a}=e.getState(),l=void 0!==o?.zoom?o.zoom:s,c=r/2-t*l,u=i/2-n*l;return a?(await a.setViewport({x:c,y:u,zoom:l},{duration:o?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=Bo(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(l,{duration:n?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:o,snapGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:s,y:a}=i.getBoundingClientRect(),l={x:t.x-s,y:t.y-a};return Lo(l,o,n.snapToGrid,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=To(t,n);return{x:s.x+r,y:s.y+i}}})),[])};function Gi(e,t){const n=[],o=new Map;for(const t of e)if("add"!==t.type)if("remove"===t.type||"replace"===t.type)o.set(t.id,[t]);else{const e=o.get(t.id);e?e.push(t):o.set(t.id,[t])}else n.push(t.item);for(const e of t){const t=o.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}const r={...e};for(const e of t)qi(e,r);n.push(r)}return n}function qi(e,t){switch(e.type){case"select":t.selected=e.selected;break;case"position":void 0!==e.position&&(t.position=e.position),void 0!==e.dragging&&(t.dragging=e.dragging);break;case"dimensions":void 0!==e.dimensions&&(t.measured??={},t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),"boolean"==typeof e.resizing&&(t.resizing=e.resizing)}}function Ui(e,t){return Gi(e,t)}function Qi(e,t){return Gi(e,t)}function Ji(e,t){return{id:e,type:"select",selected:t}}function es(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const e=t.has(r);void 0===i.selected&&!e||i.selected===e||(n&&(i.selected=e),o.push(Ji(i.id,e)))}return o}function ts({items:e=[],lookup:t}){const n=[],o=new Map(e.map((e=>[e.id,e])));for(const o of e){const e=t.get(o.id),r=e?.internals?.userNode??e;void 0!==r&&r!==o&&n.push({id:o.id,item:o,type:"replace"}),void 0===r&&n.push({item:o,type:"add"})}for(const[e]of t){void 0===o.get(e)&&n.push({id:e,type:"remove"})}return n}function ns(e){return{id:e.id,type:"remove"}}const os=e=>(e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e))(e),rs=e=>fo(e);function is(e){return n.forwardRef(e)}const ss="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function as(e){const[t,o]=n.useState(!1),[r]=n.useState((()=>function(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}((()=>o(!0)))));return ss((()=>{if(!t)return void r.reset();const n=r.get();n.length&&(e(n),r.reset()),o(!1)}),[t]),r}const ls=n.createContext(null);function cs({children:e}){const o=vi(),r=as(n.useCallback((e=>{const{nodes:t=[],setNodes:n,hasDefaultNodes:r,onNodesChange:i,nodeLookup:s}=o.getState();let a=t;for(const t of e)a="function"==typeof t?t(a):t;r?n(a):i&&i(ts({items:a,lookup:s}))}),[])),i=as(n.useCallback((e=>{const{edges:t=[],setEdges:n,hasDefaultEdges:r,onEdgesChange:i,edgeLookup:s}=o.getState();let a=t;for(const t of e)a="function"==typeof t?t(a):t;r?n(a):i&&i(ts({items:a,lookup:s}))}),[])),s=n.useMemo((()=>({nodeQueue:r,edgeQueue:i})),[]);return t.jsx(ls.Provider,{value:s,children:e})}const us=e=>!!e.panZoom;function ds(){const e=Ki(),t=vi(),o=function(){const e=n.useContext(ls);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}(),r=yi(us),i=n.useMemo((()=>{const e=e=>t.getState().nodeLookup.get(e),n=e=>{o.nodeQueue.push(e)},r=e=>{o.edgeQueue.push(e)},i=e=>{const{nodeLookup:n,nodeOrigin:o}=t.getState(),r=os(e)?e:n.get(e.id),i=r.parentId?Xo(r.position,r.measured,r.parentId,n,o):r.position,s={id:r.id,position:i,width:r.measured?.width??r.width,height:r.measured?.height??r.height,data:r.data};return Po(s)},s=(e,t,o={replace:!1})=>{n((n=>n.map((n=>{if(n.id===e){const e="function"==typeof t?t(n):t;return o.replace&&os(e)?e:{...n,...e}}return n}))))},a=(e,t,n={replace:!1})=>{r((o=>o.map((o=>{if(o.id===e){const e="function"==typeof t?t(o):t;return n.replace&&rs(e)?e:{...o,...e}}return o}))))};return{getNodes:()=>t.getState().nodes.map((e=>({...e}))),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:n,setEdges:r,addNodes:e=>{const t=Array.isArray(e)?e:[e];o.nodeQueue.push((e=>[...e,...t]))},addEdges:e=>{const t=Array.isArray(e)?e:[e];o.edgeQueue.push((e=>[...e,...t]))},toObject:()=>{const{nodes:e=[],edges:n=[],transform:o}=t.getState(),[r,i,s]=o;return{nodes:e.map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:i,zoom:s}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{const{nodes:o,edges:r,onNodesDelete:i,onEdgesDelete:s,triggerNodeChanges:a,triggerEdgeChanges:l,onDelete:c,onBeforeDelete:u}=t.getState(),{nodes:d,edges:h}=await async function({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map((e=>e.id))),s=[];for(const e of n){if(!1===e.deletable)continue;const t=i.has(e.id),n=!t&&e.parentId&&s.find((t=>t.id===e.parentId));(t||n)&&s.push(e)}const a=new Set(t.map((e=>e.id))),l=o.filter((e=>!1!==e.deletable)),c=vo(s,l);for(const e of l)a.has(e.id)&&!c.find((t=>t.id===e.id))&&c.push(e);if(!r)return{edges:c,nodes:s};const u=await r({nodes:s,edges:c});return"boolean"==typeof u?u?{edges:c,nodes:s}:{edges:[],nodes:[]}:u}({nodesToRemove:e,edgesToRemove:n,nodes:o,edges:r,onBeforeDelete:u}),f=h.length>0,g=d.length>0;if(f){const e=h.map(ns);s?.(h),l(e)}if(g){const e=d.map(ns);i?.(d),a(e)}return(g||f)&&c?.({nodes:d,edges:h}),{deletedNodes:d,deletedEdges:h}},getIntersectingNodes:(e,n=!0,o)=>{const r=Ao(e),s=r?e:i(e),a=void 0!==o;return s?(o||t.getState().nodes).filter((o=>{const i=t.getState().nodeLookup.get(o.id);if(i&&!r&&(o.id===e.id||!i.internals.positionAbsolute))return!1;const l=Po(a?o:i),c=Io(l,s);return n&&c>0||c>=s.width*s.height})):[]},isNodeIntersecting:(e,t,n=!0)=>{const o=Ao(e)?e:i(e);if(!o)return!1;const r=Io(o,t);return n&&r>0||r>=o.width*o.height},updateNode:s,updateNodeData:(e,t,n={replace:!1})=>{s(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)},updateEdge:a,updateEdgeData:(e,t,n={replace:!1})=>{a(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)}}}),[]);return n.useMemo((()=>({...i,...e,viewportInitialized:r})),[r])}const hs=e=>e.selected,fs={actInsideInputWithModifier:!1},gs="undefined"!=typeof window?window:void 0;const ps={position:"absolute",width:"100%",height:"100%",top:0,left:0},ms=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function ys({onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=e.PanOnScrollMode.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:d,translateExtent:h,minZoom:f,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:x,onViewportChange:w,isControlledViewport:b,paneClickDistance:S}){const C=vi(),E=n.useRef(null),{userSelectionActive:k,lib:_}=yi(ms,zi),M=Yi(p),N=n.useRef();return function(e){const t=vi();n.useEffect((()=>{const n=()=>{if(!e.current)return!1;const n=Wo(e.current);0!==n.height&&0!==n.width||t.getState().onError?.("004",Qn.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener("resize",n);const t=new ResizeObserver((()=>n()));return t.observe(e.current),()=>{window.removeEventListener("resize",n),t&&e.current&&t.unobserve(e.current)}}}),[])}(E),n.useEffect((()=>{if(E.current){N.current=Hr({domNode:E.current,minZoom:f,maxZoom:g,translateExtent:h,viewport:d,paneClickDistance:S,onTransformChange:e=>{w?.({x:e[0],y:e[1],zoom:e[2]}),b||C.setState({transform:e})},onDraggingChange:e=>C.setState({paneDragging:e}),onPanZoomStart:(e,t)=>{const{onViewportChangeStart:n,onMoveStart:o}=C.getState();o?.(e,t),n?.(t)},onPanZoom:(e,t)=>{const{onViewportChange:n,onMove:o}=C.getState();o?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{const{onViewportChangeEnd:n,onMoveEnd:o}=C.getState();o?.(e,t),n?.(t)}});const{x:e,y:t,zoom:n}=N.current.getViewport();return C.setState({panZoom:N.current,transform:[e,t,n],domNode:E.current.closest(".react-flow")}),()=>{N.current?.destroy()}}}),[]),n.useEffect((()=>{N.current?.update({onPaneContextMenu:o,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:s,panOnScrollSpeed:a,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:M,preventScrolling:m,noPanClassName:x,userSelectionActive:k,noWheelClassName:v,lib:_})}),[o,r,i,s,a,l,c,u,M,m,x,k,v,_]),t.jsx("div",{className:"react-flow__renderer",ref:E,style:ps,children:y})}const vs=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function xs(){const{userSelectionActive:e,userSelectionRect:n}=yi(vs,zi);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const ws=(e,t)=>n=>{n.target===t.current&&e?.(n)},bs=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function Ss({isSelecting:o,selectionKeyPressed:i,selectionMode:s=e.SelectionMode.Full,panOnDrag:a,selectionOnDrag:l,onSelectionStart:c,onSelectionEnd:u,onPaneClick:d,onPaneContextMenu:h,onPaneScroll:f,onPaneMouseEnter:g,onPaneMouseMove:p,onPaneMouseLeave:m,children:y}){const v=n.useRef(null),x=vi(),w=n.useRef(0),b=n.useRef(0),S=n.useRef(),C=n.useRef(new Map),{userSelectionActive:E,elementsSelectable:k,dragging:_}=yi(bs,zi),M=k&&(o||E),N=n.useRef(!1),P=n.useRef(!1),z=e=>{N.current?N.current=!1:(d?.(e),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1}))},O=f?e=>f(e):void 0;return t.jsxs("div",{className:r(["react-flow__pane",{draggable:a,dragging:_,selection:o}]),onClick:M?void 0:ws(z,v),onContextMenu:ws((e=>{Array.isArray(a)&&a?.includes(2)?e.preventDefault():h?.(e)}),v),onWheel:ws(O,v),onPointerEnter:M?void 0:g,onPointerDown:M?e=>{const{resetSelectedElements:t,domNode:n,edgeLookup:r}=x.getState();if(S.current=n?.getBoundingClientRect(),e.target?.setPointerCapture?.(e.pointerId),!k||!o||0!==e.button||e.target!==v.current||!S.current)return;P.current=!0,N.current=!1,C.current=new Map;for(const[e,t]of r)C.current.set(t.source,C.current.get(t.source)?.add(e)||new Set([e])),C.current.set(t.target,C.current.get(t.target)?.add(e)||new Set([e]));const{x:i,y:s}=Uo(e.nativeEvent,S.current);t(),x.setState({userSelectionRect:{width:0,height:0,startX:i,startY:s,x:i,y:s}}),c?.(e)}:p,onPointerMove:M?t=>{const{userSelectionRect:n,edgeLookup:o,transform:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:l}=x.getState();if(!S.current||!n)return;N.current=!0;const{x:c,y:u}=Uo(t.nativeEvent,S.current),{startX:d,startY:h}=n,f={startX:d,startY:h,x:c<d?c:d,y:u<h?u:h,width:Math.abs(c-d),height:Math.abs(u-h)},g=yo(i,f,r,s===e.SelectionMode.Partial,!0),p=new Set,m=new Set;for(const e of g){m.add(e.id);const t=C.current.get(e.id);if(t)for(const e of t)p.add(e)}if(w.current!==m.size){w.current=m.size;a(es(i,m,!0))}if(b.current!==p.size){b.current=p.size;l(es(o,p))}x.setState({userSelectionRect:f,userSelectionActive:!0,nodesSelectionActive:!1})}:p,onPointerUp:M?e=>{if(0!==e.button||!P.current)return;e.target?.releasePointerCapture?.(e.pointerId);const{userSelectionRect:t}=x.getState();!E&&t&&e.target===v.current&&z?.(e),w.current>0&&x.setState({nodesSelectionActive:!0}),x.setState({userSelectionActive:!1,userSelectionRect:null}),w.current=0,b.current=0,u?.(e),(i||l)&&(N.current=!1),P.current=!1}:void 0,onPointerLeave:m,ref:v,style:ps,children:[y,t.jsx(xs,{})]})}function Cs({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=t.getState(),c=a.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>o?.current?.blur()))):r([e])):l?.("012",Qn.error012(e))}function Es({nodeRef:e,disabled:t=!1,noDragClassName:o,handleSelector:r,nodeId:i,isSelectable:s,nodeClickDistance:a}){const l=vi(),[c,u]=n.useState(!1),d=n.useRef();return n.useEffect((()=>{d.current=Pr({getStoreItems:()=>l.getState(),onNodeMouseDown:t=>{Cs({id:t,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})}),[]),n.useEffect((()=>{if(t)d.current?.destroy();else if(e.current)return d.current?.update({noDragClassName:o,handleSelector:r,domNode:e.current,isSelectable:s,nodeId:i,nodeClickDistance:a}),()=>{d.current?.destroy()}}),[o,r,t,s,e,i]),c}const ks=e=>t=>t.selected&&(t.draggable||e&&void 0===t.draggable);function _s(){const e=vi();return n.useCallback((t=>{const{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:s,updateNodePositions:a,nodeLookup:l,nodeOrigin:c}=e.getState(),u=new Map,d=ks(i),h=o?r[0]:5,f=o?r[1]:5,g=t.direction.x*h*t.factor,p=t.direction.y*f*t.factor;for(const[,e]of l){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+g,y:e.internals.positionAbsolute.y+p};o&&(t=$o(t,r));const{position:i,positionAbsolute:a}=bo({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:c,onError:s});e.position=i,e.internals.positionAbsolute=a,u.set(e.id,e)}a(u)}),[])}const Ms=n.createContext(null),Ns=Ms.Provider;Ms.Consumer;const Ps=()=>n.useContext(Ms),zs=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId});const Os=n.memo(is((function({type:n="source",position:o=e.Position.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:g,...p},m){const y=c||null,v="target"===n,x=vi(),w=Ps(),{connectOnClick:b,noPanClassName:S,rfId:C}=yi(zs,zi),{connectingFrom:E,connectingTo:k,clickConnecting:_,isPossibleEndHandle:M,connectionInProcess:N,valid:P}=yi(((t,n,o)=>r=>{const{connectionClickStartHandle:i,connectionMode:s,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=c?.nodeId===t&&c?.id===n&&c?.type===o;return{connectingFrom:l?.nodeId===t&&l?.id===n&&l?.type===o,connectingTo:d,clickConnecting:i?.nodeId===t&&i?.id===n&&i?.type===o,isPossibleEndHandle:s===e.ConnectionMode.Strict?l?.type!==o:t!==l?.nodeId||n!==l?.id,connectionInProcess:!!l,valid:d&&u}})(w,y,n),zi);w||x.getState().onError?.("010",Qn.error010());const z=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=x.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=x.getState();t(sr(r,e))}n?.(r),u?.(r)},O=e=>{if(!w)return;const t=qo(e.nativeEvent);if(a&&(t&&0===e.button||!t)){const t=x.getState();Rr.onPointerDown(e.nativeEvent,{autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:v,handleId:y,nodeId:w,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:t.onConnectEnd,updateConnection:t.updateConnection,onConnect:z,isValidConnection:i||t.isValidConnection,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed})}t?f?.(e):g?.(e)};return t.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":o,"data-id":`${C}-${w}-${y}-${n}`,className:r(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",S,h,{source:!v,target:v,connectable:s,connectablestart:a,connectableend:l,clickconnecting:_,connectingfrom:E,connectingto:k,valid:P,connectionindicator:s&&(!N||M)&&(N?l:a)}]),onMouseDown:O,onTouchStart:O,onClick:b?e=>{const{onClickConnectStart:t,onClickConnectEnd:o,connectionClickStartHandle:r,connectionMode:s,isValidConnection:l,lib:c,rfId:u}=x.getState();if(!w||!r&&!a)return;if(!r)return t?.(e.nativeEvent,{nodeId:w,handleId:y,handleType:n}),void x.setState({connectionClickStartHandle:{nodeId:w,type:n,id:y}});const d=Fo(e.target),h=i||l,{connection:f,isValid:g}=Rr.isValid(e.nativeEvent,{handle:{nodeId:w,id:y,type:n},connectionMode:s,fromNodeId:r.nodeId,fromHandleId:r.id||null,fromType:r.type,isValidConnection:h,flowId:u,doc:d,lib:c});g&&f&&z(f),o?.(e),x.setState({connectionClickStartHandle:null})}:void 0,ref:m,...p,children:d})})));const Is={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},As={input:function({data:n,isConnectable:o,sourcePosition:r=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[n?.label,t.jsx(Os,{type:"source",position:r,isConnectable:o})]})},default:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top,sourcePosition:i=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Os,{type:"target",position:r,isConnectable:o}),n?.label,t.jsx(Os,{type:"source",position:i,isConnectable:o})]})},output:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Os,{type:"target",position:r,isConnectable:o}),n?.label]})},group:function(){return null}};const Rs=e=>{const{width:t,height:n,x:o,y:r}=mo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Ro(t)?t:null,height:Ro(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 Ds({onSelectionContextMenu:e,noPanClassName:o,disableKeyboardA11y:i}){const s=vi(),{width:a,height:l,transformString:c,userSelectionActive:u}=yi(Rs,zi),d=_s(),h=n.useRef(null);if(n.useEffect((()=>{i||h.current?.focus({preventScroll:!0})}),[i]),Es({nodeRef:h}),u||!a||!l)return null;const f=e?t=>{const n=s.getState().nodes.filter((e=>e.selected));e(t,n)}:void 0;return t.jsx("div",{className:r(["react-flow__nodesselection","react-flow__container",o]),style:{transform:c},children:t.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:i?void 0:-1,onKeyDown:i?void 0:e=>{Object.prototype.hasOwnProperty.call(Is,e.key)&&d({direction:Is[e.key],factor:e.shiftKey?4:1})},style:{width:a,height:l}})})}const $s="undefined"!=typeof window?window:void 0,Ls=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ts({children:e,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:l,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:d,selectionOnDrag:h,selectionMode:f,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:y,zoomActivationKeyCode:v,elementsSelectable:x,zoomOnScroll:w,zoomOnPinch:b,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:k,panOnDrag:_,defaultViewport:M,translateExtent:N,minZoom:P,maxZoom:z,preventScrolling:O,onSelectionContextMenu:I,noWheelClassName:A,noPanClassName:R,disableKeyboardA11y:D,onViewportChange:$,isControlledViewport:L}){const{nodesSelectionActive:T,userSelectionActive:B}=yi(Ls),V=Yi(d,{target:$s}),j=Yi(y,{target:$s}),H=j||_,Z=j||S,X=h&&!0!==H,Y=V||B||X;return function({deleteKeyCode:e,multiSelectionKeyCode:t}){const o=vi(),{deleteElements:r}=ds(),i=Yi(e,fs),s=Yi(t,{target:gs});n.useEffect((()=>{if(i){const{edges:e,nodes:t}=o.getState();r({nodes:t.filter(hs),edges:e.filter(hs)}),o.setState({nodesSelectionActive:!1})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:s})}),[s])}({deleteKeyCode:u,multiSelectionKeyCode:m}),t.jsx(ys,{onPaneContextMenu:a,elementsSelectable:x,zoomOnScroll:w,zoomOnPinch:b,panOnScroll:Z,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:k,panOnDrag:!V&&H,defaultViewport:M,translateExtent:N,minZoom:P,maxZoom:z,zoomActivationKeyCode:v,preventScrolling:O,noWheelClassName:A,noPanClassName:R,onViewportChange:$,isControlledViewport:L,paneClickDistance:c,children:t.jsxs(Ss,{onSelectionStart:g,onSelectionEnd:p,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:l,panOnDrag:H,isSelecting:!!Y,selectionMode:f,selectionKeyPressed:V,selectionOnDrag:X,children:[e,T&&t.jsx(Ds,{onSelectionContextMenu:I,noPanClassName:R,disableKeyboardA11y:D})]})})}Ts.displayName="FlowRenderer";const Bs=n.memo(Ts),Vs=e=>t=>e?yo(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map((e=>e.id)):Array.from(t.nodeLookup.keys());const js=e=>e.updateNodeInternals;function Hs({id:e,onClick:o,onMouseEnter:i,onMouseMove:s,onMouseLeave:a,onContextMenu:l,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:g,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:x,nodeExtent:w,nodeClickDistance:b,onError:S}){const{node:C,internals:E,isParent:k}=yi((t=>{const n=t.nodeLookup.get(e),o=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:o}}),zi);let _=C.type||"default",M=x?.[_]||As[_];void 0===M&&(S?.("003",Qn.error003(_)),_="default",M=As.default);const N=!!(C.draggable||u&&void 0===C.draggable),P=!!(C.selectable||d&&void 0===C.selectable),z=!!(C.connectable||h&&void 0===C.connectable),O=!!(C.focusable||f&&void 0===C.focusable),I=vi(),A=Zo(C),R=function({node:e,nodeType:t,hasDimensions:o,resizeObserver:r}){const i=vi(),s=n.useRef(null),a=n.useRef(null),l=n.useRef(e.sourcePosition),c=n.useRef(e.targetPosition),u=n.useRef(t),d=o&&!!e.internals.handleBounds;return n.useEffect((()=>{!s.current||e.hidden||d&&a.current===s.current||(a.current&&r?.unobserve(a.current),r?.observe(s.current),a.current=s.current)}),[d,e.hidden]),n.useEffect((()=>()=>{a.current&&(r?.unobserve(a.current),a.current=null)}),[]),n.useEffect((()=>{if(s.current){const n=u.current!==t,o=l.current!==e.sourcePosition,r=c.current!==e.targetPosition;(n||o||r)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}}),[e.id,t,e.sourcePosition,e.targetPosition]),s}({node:C,nodeType:_,hasDimensions:A,resizeObserver:g}),D=Es({nodeRef:R,disabled:C.hidden||!N,noDragClassName:p,handleSelector:C.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:b}),$=_s();if(C.hidden)return null;const L=Ho(C),T=function(e){return void 0===e.internals.handleBounds?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}(C),B=w?Co(E.positionAbsolute,w):E.positionAbsolute,V=P||N||o||i||s||a,j=i?e=>i(e,{...E.userNode}):void 0,H=s?e=>s(e,{...E.userNode}):void 0,Z=a?e=>a(e,{...E.userNode}):void 0,X=l?e=>l(e,{...E.userNode}):void 0,Y=c?e=>c(e,{...E.userNode}):void 0;return t.jsx("div",{className:r(["react-flow__node",`react-flow__node-${_}`,{[m]:N},C.className,{selected:C.selected,selectable:P,parent:k,draggable:N,dragging:D}]),ref:R,style:{zIndex:E.z,transform:`translate(${B.x}px,${B.y}px)`,pointerEvents:V?"all":"none",visibility:A?"visible":"hidden",...C.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:Z,onContextMenu:X,onClick:t=>{const{selectNodesOnDrag:n,nodeDragThreshold:r}=I.getState();P&&(!n||!N||r>0)&&Cs({id:e,store:I,nodeRef:R}),o&&o(t,{...E.userNode})},onDoubleClick:Y,onKeyDown:O?t=>{if(!Go(t.nativeEvent)&&!y)if(eo.includes(t.key)&&P){const n="Escape"===t.key;Cs({id:e,store:I,unselect:n,nodeRef:R})}else N&&C.selected&&Object.prototype.hasOwnProperty.call(Is,t.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${t.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~B.x}, y: ${~~B.y}`}),$({direction:Is[t.key],factor:t.shiftKey?4:1}))}:void 0,tabIndex:O?0:void 0,role:O?"button":void 0,"aria-describedby":y?void 0:`${bi}-${v}`,"aria-label":C.ariaLabel,children:t.jsx(Ns,{value:e,children:t.jsx(M,{id:e,data:C.data,type:_,positionAbsoluteX:B.x,positionAbsoluteY:B.y,selected:C.selected,selectable:P,draggable:N,deletable:C.deletable??!0,isConnectable:z,sourcePosition:C.sourcePosition,targetPosition:C.targetPosition,dragging:D,dragHandle:C.dragHandle,zIndex:E.z,parentId:C.parentId,...L})})})}const Zs=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Xs(e){const{nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:s,onError:a}=yi(Zs,zi),l=(c=e.onlyRenderVisibleElements,yi(n.useCallback(Vs(c),[c]),zi));var c;const u=function(){const e=yi(js),[t]=n.useState((()=>"undefined"==typeof ResizeObserver?null:new ResizeObserver((t=>{const n=new Map;t.forEach((e=>{const t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})})),e(n)}))));return n.useEffect((()=>()=>{t?.disconnect()}),[t]),t}();return t.jsx("div",{className:"react-flow__nodes",style:ps,children:l.map((n=>t.jsx(Hs,{id:n,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:u,nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},n)))})}Xs.displayName="NodeRenderer";const Ys=n.memo(Xs);const Ws={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[e.MarkerType.ArrowClosed]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Fs=({id:e,type:o,color:r,width:i=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const u=function(e){const t=vi();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Ws,e)?Ws[e]:(t.getState().onError?.("009",Qn.error009(e)),null)),[e])}(o);return u?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:c,refX:"0",refY:"0",children:t.jsx(u,{color:r,strokeWidth:l})}):null},Ks=({defaultColor:e,rfId:o})=>{const r=yi((e=>e.edges)),i=yi((e=>e.defaultEdgeOptions)),s=n.useMemo((()=>{const t=function(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce(((e,s)=>([s.markerStart||o,s.markerEnd||r].forEach((o=>{if(o&&"object"==typeof o){const r=mr(o,t);i.has(r)||(e.push({id:r,color:o.color||n,...o}),i.add(r))}})),e)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))}(r,{id:o,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd});return t}),[r,i,o,e]);return s.length?t.jsx("svg",{className:"react-flow__marker",children:t.jsx("defs",{children:s.map((e=>t.jsx(Fs,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id)))})}):null};Ks.displayName="MarkerDefinitions";var Gs=n.memo(Ks);function qs({x:e,y:o,label:i,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[g,p]=n.useState({x:1,y:0,width:0,height:0}),m=r(["react-flow__edge-textwrapper",h]),y=n.useRef(null);return n.useEffect((()=>{if(y.current){const e=y.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[i]),void 0!==i&&i?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...f,children:[a&&t.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:y,style:s,children:i}),d]}):null}qs.displayName="EdgeText";const Us=n.memo(qs);function Qs({id:e,path:n,labelX:o,labelY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,className:p,interactionWidth:m=20}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{id:e,style:h,d:n,fill:"none",className:r(["react-flow__edge-path",p]),markerEnd:f,markerStart:g}),m&&t.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),s&&Ro(o)&&Ro(i)?t.jsx(Us,{x:o,y:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function Js({pos:t,x1:n,y1:o,x2:r,y2:i}){return t===e.Position.Left||t===e.Position.Right?[.5*(n+r),o]:[n,.5*(o+i)]}function ea({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top}){const[a,l]=Js({pos:o,x1:t,y1:n,x2:r,y2:i}),[c,u]=Js({pos:s,x1:r,y1:i,x2:t,y2:n}),[d,h,f,g]=Jo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${n} C${a},${l} ${c},${u} ${r},${i}`,d,h,f,g]}function ta(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})=>{const[w,b,S]=ea({sourceX:r,sourceY:i,sourcePosition:l,targetX:s,targetY:a,targetPosition:c}),C=o.isInternal?void 0:n;return t.jsx(Qs,{id:C,path:w,labelX:b,labelY:S,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})}))}const na=ta({isInternal:!1}),oa=ta({isInternal:!0});function ra(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,sourcePosition:p=e.Position.Bottom,targetPosition:m=e.Position.Top,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,C]=dr({sourceX:r,sourceY:i,sourcePosition:p,targetX:s,targetY:a,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset}),E=o.isInternal?void 0:n;return t.jsx(Qs,{id:E,path:b,labelX:S,labelY:C,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:v,interactionWidth:w})}))}na.displayName="SimpleBezierEdge",oa.displayName="SimpleBezierEdgeInternal";const ia=ra({isInternal:!1}),sa=ra({isInternal:!0});function aa(e){return n.memo((({id:o,...r})=>{const i=e.isInternal?void 0:o;return t.jsx(ia,{...r,id:i,pathOptions:n.useMemo((()=>({borderRadius:0,offset:r.pathOptions?.offset})),[r.pathOptions?.offset])})}))}ia.displayName="SmoothStepEdge",sa.displayName="SmoothStepEdgeInternal";const la=aa({isInternal:!1}),ca=aa({isInternal:!0});function ua(e){return n.memo((({id:n,sourceX:o,sourceY:r,targetX:i,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})=>{const[y,v,x]=ar({sourceX:o,sourceY:r,targetX:i,targetY:s}),w=e.isInternal?void 0:n;return t.jsx(Qs,{id:w,path:y,labelX:v,labelY:x,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})}))}la.displayName="StepEdge",ca.displayName="StepEdgeInternal";const da=ua({isInternal:!1}),ha=ua({isInternal:!0});function fa(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,C]=nr({sourceX:r,sourceY:i,sourcePosition:l,targetX:s,targetY:a,targetPosition:c,curvature:x?.curvature}),E=o.isInternal?void 0:n;return t.jsx(Qs,{id:E,path:b,labelX:S,labelY:C,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:w})}))}da.displayName="StraightEdge",ha.displayName="StraightEdgeInternal";const ga=fa({isInternal:!1}),pa=fa({isInternal:!0});ga.displayName="BezierEdge",pa.displayName="BezierEdgeInternal";const ma={default:pa,straight:ha,step:ca,smoothstep:sa,simplebezier:oa},ya={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},va=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,xa=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,wa="react-flow__edgeupdater";function ba({position:e,centerX:n,centerY:o,radius:i=10,onMouseDown:s,onMouseEnter:a,onMouseOut:l,type:c}){return t.jsx("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:l,className:r([wa,`${wa}-${c}`]),cx:va(n,i,e),cy:xa(o,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Sa({isReconnectable:e,reconnectRadius:n,edge:o,targetHandleId:r,sourceHandleId:i,sourceX:s,sourceY:a,targetX:l,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:g,setReconnecting:p,setUpdateHover:m}){const y=vi(),v=(e,t)=>{if(0!==e.button)return;const{autoPanOnConnect:n,domNode:s,isValidConnection:a,connectionMode:l,connectionRadius:c,lib:u,onConnectStart:d,onConnectEnd:m,cancelConnection:v,nodeLookup:x,rfId:w,panBy:b,updateConnection:S}=y.getState(),C=t?o.target:o.source,E=(t?r:i)||null,k=t?"target":"source",_=t;p(!0),f?.(e,o,k);Rr.onPointerDown(e.nativeEvent,{autoPanOnConnect:n,connectionMode:l,connectionRadius:c,domNode:s,handleId:E,nodeId:C,nodeLookup:x,isTarget:_,edgeUpdaterType:k,lib:u,flowId:w,cancelConnection:v,panBy:b,isValidConnection:a,onConnect:e=>h?.(o,e),onConnectStart:d,onConnectEnd:m,onReconnectEnd:e=>{p(!1),g?.(e,o,k)},updateConnection:S,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle})},x=()=>m(!0),w=()=>m(!1);return t.jsxs(t.Fragment,{children:[("source"===e||!0===e)&&t.jsx(ba,{position:u,centerX:s,centerY:a,radius:n,onMouseDown:e=>v(e,!0),onMouseEnter:x,onMouseOut:w,type:"source"}),("target"===e||!0===e)&&t.jsx(ba,{position:d,centerX:l,centerY:c,radius:n,onMouseDown:e=>v(e,!1),onMouseEnter:x,onMouseOut:w,type:"target"})]})}function Ca({id:o,edgesFocusable:i,edgesReconnectable:s,elementsSelectable:a,onClick:l,onDoubleClick:c,onContextMenu:u,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,rfId:v,edgeTypes:x,noPanClassName:w,onError:b,disableKeyboardA11y:S}){let C=yi((e=>e.edgeLookup.get(o)));const E=yi((e=>e.defaultEdgeOptions));C=E?{...E,...C}:C;let k=C.type||"default",_=x?.[k]||ma[k];void 0===_&&(b?.("011",Qn.error011(k)),k="default",_=ma.default);const M=!!(C.focusable||i&&void 0===C.focusable),N=void 0!==p&&(C.reconnectable||s&&void 0===C.reconnectable),P=!!(C.selectable||a&&void 0===C.selectable),z=n.useRef(null),[O,I]=n.useState(!1),[A,R]=n.useState(!1),D=vi(),{zIndex:$,sourceX:L,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H}=yi(n.useCallback((t=>{const n=t.nodeLookup.get(C.source),r=t.nodeLookup.get(C.target);if(!n||!r)return{zIndex:C.zIndex,...ya};const i=function(t){const{sourceNode:n,targetNode:o}=t;if(!hr(n)||!hr(o))return null;const r=n.internals.handleBounds||fr(n.handles),i=o.internals.handleBounds||fr(o.handles),s=pr(r?.source??[],t.sourceHandle),a=pr(t.connectionMode===e.ConnectionMode.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),t.targetHandle);if(!s||!a)return t.onError?.("008",Qn.error008(s?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const l=s?.position||e.Position.Bottom,c=a?.position||e.Position.Top,u=gr(n,s,l),d=gr(o,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}({id:o,sourceNode:n,targetNode:r,sourceHandle:C.sourceHandle||null,targetHandle:C.targetHandle||null,connectionMode:t.connectionMode,onError:b}),s=function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1}){if(!r)return o;const i=n||t.selected||e.selected,s=Math.max(e.internals.z||0,t.internals.z||0,1e3);return o+(i?s:0)}({selected:C.selected,zIndex:C.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect});return{zIndex:s,...i||ya}}),[C.source,C.target,C.sourceHandle,C.targetHandle,C.selected,C.zIndex]),zi),Z=n.useMemo((()=>C.markerStart?`url('#${mr(C.markerStart,v)}')`:void 0),[C.markerStart,v]),X=n.useMemo((()=>C.markerEnd?`url('#${mr(C.markerEnd,v)}')`:void 0),[C.markerEnd,v]);if(C.hidden||null===L||null===T||null===B||null===V)return null;const Y=c?e=>{c(e,{...C})}:void 0,W=u?e=>{u(e,{...C})}:void 0,F=d?e=>{d(e,{...C})}:void 0,K=h?e=>{h(e,{...C})}:void 0,G=f?e=>{f(e,{...C})}:void 0;return t.jsx("svg",{style:{zIndex:$},children:t.jsxs("g",{className:r(["react-flow__edge",`react-flow__edge-${k}`,C.className,w,{selected:C.selected,animated:C.animated,inactive:!P&&!l,updating:O,selectable:P}]),onClick:e=>{const{addSelectedEdges:t,unselectNodesAndEdges:n,multiSelectionActive:r}=D.getState();P&&(D.setState({nodesSelectionActive:!1}),C.selected&&r?(n({nodes:[],edges:[C]}),z.current?.blur()):t([o])),l&&l(e,C)},onDoubleClick:Y,onContextMenu:W,onMouseEnter:F,onMouseMove:K,onMouseLeave:G,onKeyDown:M?e=>{if(!S&&eo.includes(e.key)&&P){const{unselectNodesAndEdges:t,addSelectedEdges:n}=D.getState();"Escape"===e.key?(z.current?.blur(),t({edges:[C]})):n([o])}}:void 0,tabIndex:M?0:void 0,role:M?"button":"img","data-id":o,"data-testid":`rf__edge-${o}`,"aria-label":null===C.ariaLabel?void 0:C.ariaLabel||`Edge from ${C.source} to ${C.target}`,"aria-describedby":M?`${Si}-${v}`:void 0,ref:z,children:[!A&&t.jsx(_,{id:o,source:C.source,target:C.target,type:C.type,selected:C.selected,animated:C.animated,selectable:P,deletable:C.deletable??!0,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,sourceX:L,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H,data:C.data,style:C.style,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerStart:Z,markerEnd:X,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth}),N&&t.jsx(Sa,{edge:C,isReconnectable:N,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,sourceX:L,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H,setUpdateHover:I,setReconnecting:R,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle})]})})}const Ea=e=>({width:e.width,height:e.height,edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ka({defaultMarkerColor:e,onlyRenderVisibleElements:o,rfId:r,edgeTypes:i,noPanClassName:s,onReconnect:a,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:h,reconnectRadius:f,onEdgeDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:y}){const{edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,onError:b}=yi(Ea,zi),S=(C=o,yi(n.useCallback((e=>{if(!C)return e.edges.map((e=>e.id));const t=[];if(e.width&&e.height)for(const n of e.edges){const o=e.nodeLookup.get(n.source),r=e.nodeLookup.get(n.target);o&&r&&rr({sourceNode:o,targetNode:r,width:e.width,height:e.height,transform:e.transform})&&t.push(n.id)}return t}),[C]),zi));var C;return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(Gs,{defaultColor:e,rfId:r}),S.map((e=>t.jsx(Ca,{id:e,edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:l,onMouseEnter:c,onMouseMove:u,onMouseLeave:d,onClick:h,reconnectRadius:f,onDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,rfId:r,onError:b,edgeTypes:i,disableKeyboardA11y:y},e)))]})}ka.displayName="EdgeRenderer";const _a=n.memo(ka),Ma=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Na({children:e}){const n=yi(Ma);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}const Pa=e=>e.panZoom?.syncViewport;const za=e=>e.connection.inProgress?{...e.connection,to:Lo(e.connection.to,e.transform)}:{...e.connection};function Oa(){return yi(za,zi)}const Ia=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Aa({containerStyle:e,style:n,type:o,component:i}){const{nodesConnectable:s,width:a,height:l,isValid:c,inProgress:u}=yi(Ia,zi);return!!(a&&s&&u)?t.jsx("svg",{style:e,width:a,height:l,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:r(["react-flow__connection",ho(c)]),children:t.jsx(Ra,{style:n,type:o,CustomComponent:i,isValid:c})})}):null}const Ra=({style:n,type:o=e.ConnectionLineType.Bezier,CustomComponent:r,isValid:i})=>{const{inProgress:s,from:a,fromNode:l,fromHandle:c,fromPosition:u,to:d,toNode:h,toHandle:f,toPosition:g}=Oa();if(!s)return;if(r)return t.jsx(r,{connectionLineType:o,connectionLineStyle:n,fromNode:l,fromHandle:c,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:u,toPosition:g,connectionStatus:ho(i),toNode:h,toHandle:f});let p="";const m={sourceX:a.x,sourceY:a.y,sourcePosition:u,targetX:d.x,targetY:d.y,targetPosition:g};switch(o){case e.ConnectionLineType.Bezier:[p]=nr(m);break;case e.ConnectionLineType.SimpleBezier:[p]=ea(m);break;case e.ConnectionLineType.Step:[p]=dr({...m,borderRadius:0});break;case e.ConnectionLineType.SmoothStep:[p]=dr(m);break;default:[p]=ar(m)}return t.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:n})};Ra.displayName="ConnectionLine";const Da={};function $a(e=Da){n.useRef(e),vi(),n.useEffect((()=>{}),[e])}function La({nodeTypes:e,edgeTypes:o,onInit:r,onNodeClick:i,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:g,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:x,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,multiSelectionKeyCode:C,panActivationKeyCode:E,zoomActivationKeyCode:k,deleteKeyCode:_,onlyRenderVisibleElements:M,elementsSelectable:N,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,preventScrolling:A,defaultMarkerColor:R,zoomOnScroll:D,zoomOnPinch:$,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,zoomOnDoubleClick:V,panOnDrag:j,onPaneClick:H,onPaneMouseEnter:Z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneScroll:W,onPaneContextMenu:F,paneClickDistance:K,nodeClickDistance:G,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:Q,onEdgeMouseLeave:J,reconnectRadius:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:oe,noDragClassName:re,noWheelClassName:ie,noPanClassName:se,disableKeyboardA11y:ae,nodeExtent:le,rfId:ce,viewport:ue,onViewportChange:de}){return $a(e),$a(o),vi(),n.useRef(!1),n.useEffect((()=>{}),[]),function(e){const t=ds(),o=n.useRef(!1);n.useEffect((()=>{!o.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),o.current=!0)}),[e,t.viewportInitialized])}(r),function(e){const t=yi(Pa),o=vi();n.useEffect((()=>{e&&(t?.(e),o.setState({transform:[e.x,e.y,e.zoom]}))}),[e,t])}(ue),t.jsx(Bs,{onPaneClick:H,onPaneMouseEnter:Z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneContextMenu:F,onPaneScroll:W,paneClickDistance:K,deleteKeyCode:_,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:E,zoomActivationKeyCode:k,elementsSelectable:N,zoomOnScroll:D,zoomOnPinch:$,zoomOnDoubleClick:V,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,panOnDrag:j,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,onSelectionContextMenu:f,preventScrolling:A,noDragClassName:re,noWheelClassName:ie,noPanClassName:se,disableKeyboardA11y:ae,onViewportChange:de,isControlledViewport:!!ue,children:t.jsxs(Na,{children:[t.jsx(_a,{edgeTypes:o,onEdgeClick:s,onEdgeDoubleClick:l,onReconnect:te,onReconnectStart:ne,onReconnectEnd:oe,onlyRenderVisibleElements:M,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:Q,onEdgeMouseLeave:J,reconnectRadius:ee,defaultMarkerColor:R,noPanClassName:se,disableKeyboardA11y:ae,rfId:ce}),t.jsx(Aa,{style:y,type:m,component:v,containerStyle:x}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(Ys,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,nodeClickDistance:G,onlyRenderVisibleElements:M,noPanClassName:se,noDragClassName:re,disableKeyboardA11y:ae,nodeExtent:le,rfId:ce}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}La.displayName="GraphView";const Ta=n.memo(La),Ba=({nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,nodeOrigin:l}={})=>{const c=new Map,u=new Map,d=new Map,h=new Map,f=r??n??[],g=o??t??[],p=l??[0,0];Er(d,h,f),wr(g,c,u,{nodeOrigin:p,elevateNodesOnSelect:!1});let m=[0,0,1];if(a&&i&&s){const e=mo(c,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),{x:t,y:n,zoom:o}=Bo(e,i,s,.5,2,.1);m=[t,n,o]}return{rfId:"1",width:0,height:0,transform:m,nodes:g,nodeLookup:c,parentLookup:u,edges:f,edgeLookup:h,connectionLookup:d,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==o,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:Jn,nodeExtent:Jn,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:e.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connection:{...ro},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanSpeed:15,connectionRadius:20,onError:Do,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},Va=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,nodeOrigin:a})=>{return l=(l,c)=>({...Ba({nodes:e,edges:t,width:r,height:i,fitView:s,nodeOrigin:a,defaultNodes:n,defaultEdges:o}),setNodes:e=>{const{nodeLookup:t,parentLookup:n,nodeOrigin:o,elevateNodesOnSelect:r}=c();wr(e,t,n,{nodeOrigin:o,elevateNodesOnSelect:r,checkEquality:!0}),l({nodes:e})},setEdges:e=>{const{connectionLookup:t,edgeLookup:n}=c();Er(t,n,e),l({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){const{setNodes:t}=c();t(e),l({hasDefaultNodes:!0})}if(t){const{setEdges:e}=c();e(t),l({hasDefaultEdges:!0})}},updateNodeInternals:e=>{const{triggerNodeChanges:t,nodeLookup:n,parentLookup:o,fitViewOnInit:r,fitViewDone:i,fitViewOnInitOptions:s,domNode:a,nodeOrigin:u,debug:d,fitViewSync:h}=c(),{changes:f,updatedInternals:g}=function(e,t,n,o,r){const i=o?.querySelector(".xyflow__viewport");let s=!1;if(!i)return{changes:[],updatedInternals:s};const a=[],l=window.getComputedStyle(i),{m22:c}=new window.DOMMatrixReadOnly(l.transform),u=[];for(const o of e.values()){const e=t.get(o.id);if(e)if(e.hidden)e.internals={...e.internals,handleBounds:void 0},s=!0;else{const i=Wo(o.nodeElement),l=e.measured.width!==i.width||e.measured.height!==i.height;if(i.width&&i.height&&(l||!e.internals.handleBounds||o.force)){const d=o.nodeElement.getBoundingClientRect();e.measured=i,e.internals={...e.internals,positionAbsolute:po(e,r),handleBounds:{source:Qo("source",o.nodeElement,d,c,e.id),target:Qo("target",o.nodeElement,d,c,e.id)}},e.parentId&&br(e,t,n,{nodeOrigin:r}),s=!0,l&&(a.push({id:e.id,type:"dimensions",dimensions:i}),e.expandParent&&e.parentId&&u.push({id:e.id,parentId:e.parentId,rect:Po(e,r)}))}}}if(u.length>0){const e=Cr(u,t,n,r);a.push(...e)}return{changes:a,updatedInternals:s}}(e,n,o,a,u);if(!g)return;!function(e,t,n){const o={...vr,...n};for(const n of e.values())n.parentId&&br(n,e,t,o)}(n,o,{nodeOrigin:u});let p=i;!i&&r&&(p=h({...s,nodes:s?.nodes})),l({fitViewDone:p}),f?.length>0&&(d&&console.log("React Flow: trigger node changes",f),t?.(f))},updateNodePositions:(e,t=!1)=>{const n=[],o=[];for(const[r,i]of e){const e={id:r,type:"position",position:i.position,dragging:t};i?.expandParent&&i?.parentId&&e.position&&(n.push({id:r,parentId:i.parentId,rect:{...i.internals.positionAbsolute,width:i.measured.width,height:i.measured.height}}),e.position.x=Math.max(0,e.position.x),e.position.y=Math.max(0,e.position.y)),o.push(e)}if(n.length>0){const{nodeLookup:e,parentLookup:t,nodeOrigin:r}=c(),i=Cr(n,e,t,r);o.push(...i)}c().triggerNodeChanges(o)},triggerNodeChanges:e=>{const{onNodesChange:t,setNodes:n,nodes:o,hasDefaultNodes:r,debug:i}=c();e?.length&&(r&&n(Ui(e,o)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{const{onEdgesChange:t,setEdges:n,edges:o,hasDefaultEdges:r,debug:i}=c();e?.length&&(r&&n(Qi(e,o)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c();t?r(e.map((e=>Ji(e,!0)))):(r(es(o,new Set([...e]),!0)),i(es(n)))},addSelectedEdges:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c();t?i(e.map((e=>Ji(e,!0)))):(i(es(n,new Set([...e]))),r(es(o,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{const{edges:n,nodes:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c(),s=t||n,a=(e||o).map((e=>(e.selected=!1,Ji(e.id,!1)))),l=s.map((e=>Ji(e.id,!1)));r(a),i(l)},setMinZoom:e=>{const{panZoom:t,maxZoom:n}=c();t?.setScaleExtent([e,n]),l({minZoom:e})},setMaxZoom:e=>{const{panZoom:t,minZoom:n}=c();t?.setScaleExtent([n,e]),l({maxZoom:e})},setTranslateExtent:e=>{c().panZoom?.setTranslateExtent(e),l({translateExtent:e})},setPaneClickDistance:e=>{c().panZoom?.setClickDistance(e)},resetSelectedElements:()=>{const{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:o}=c(),r=t.reduce(((e,t)=>t.selected?[...e,Ji(t.id,!1)]:e),[]),i=e.reduce(((e,t)=>t.selected?[...e,Ji(t.id,!1)]:e),[]);n(r),o(i)},setNodeExtent:e=>{const{nodeLookup:t}=c();for(const[,n]of t){const o=Co(n.position,e);t.set(n.id,{...n,internals:{...n.internals,positionAbsolute:o}})}l({nodeExtent:e})},panBy:e=>{const{transform:t,width:n,height:o,panZoom:r,translateExtent:i}=c();return async function({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)}({delta:e,panZoom:r,transform:t,translateExtent:i,width:n,height:o})},fitView:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeLookup:s}=c();return t?wo({nodes:xo(s,e),width:n,height:o,panZoom:t,minZoom:r,maxZoom:i},e):Promise.resolve(!1)},fitViewSync:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeLookup:s}=c();if(!t)return!1;const a=xo(s,e);return wo({nodes:a,width:n,height:o,panZoom:t,minZoom:r,maxZoom:i},e),a.size>0},cancelConnection:()=>{l({connection:{...ro}})},updateConnection:e=>{l({connection:e})},reset:()=>l({...Ba()})}),c=Object.is,l?fi(l,c):fi;var l,c};function ja({initialNodes:e,initialEdges:o,defaultNodes:r,defaultEdges:i,initialWidth:s,initialHeight:a,fitView:l,nodeOrigin:c,children:u}){const[d]=n.useState((()=>Va({nodes:e,edges:o,defaultNodes:r,defaultEdges:i,width:s,height:a,fitView:l,nodeOrigin:c})));return t.jsx(pi,{value:d,children:t.jsx(cs,{children:u})})}function Ha({children:e,nodes:o,edges:r,defaultNodes:i,defaultEdges:s,width:a,height:l,fitView:c,nodeOrigin:u}){return n.useContext(gi)?t.jsx(t.Fragment,{children:e}):t.jsx(ja,{initialNodes:o,initialEdges:r,defaultNodes:i,defaultEdges:s,initialWidth:a,initialHeight:l,fitView:c,nodeOrigin:u,children:e})}const Za={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var Xa=is((function({nodes:o,edges:i,defaultNodes:s,defaultEdges:a,className:l,nodeTypes:c,edgeTypes:u,onNodeClick:d,onEdgeClick:h,onInit:f,onMove:g,onMoveStart:p,onMoveEnd:m,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:E,onNodeContextMenu:k,onNodeDoubleClick:_,onNodeDragStart:M,onNodeDrag:N,onNodeDragStop:P,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onSelectionChange:A,onSelectionDragStart:R,onSelectionDrag:D,onSelectionDragStop:$,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onBeforeDelete:V,connectionMode:j,connectionLineType:H=e.ConnectionLineType.Bezier,connectionLineStyle:Z,connectionLineComponent:X,connectionLineContainerStyle:Y,deleteKeyCode:W="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:K=!1,selectionMode:G=e.SelectionMode.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:U=(Vo()?"Meta":"Control"),zoomActivationKeyCode:Q=(Vo()?"Meta":"Control"),snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,nodeOrigin:se=Li,edgesFocusable:ae,edgesReconnectable:le,elementsSelectable:ce=!0,defaultViewport:ue=Ti,minZoom:de=.5,maxZoom:he=2,translateExtent:fe=Jn,preventScrolling:ge=!0,nodeExtent:pe,defaultMarkerColor:me="#b1b1b7",zoomOnScroll:ye=!0,zoomOnPinch:ve=!0,panOnScroll:xe=!1,panOnScrollSpeed:we=.5,panOnScrollMode:be=e.PanOnScrollMode.Free,zoomOnDoubleClick:Se=!0,panOnDrag:Ce=!0,onPaneClick:Ee,onPaneMouseEnter:ke,onPaneMouseMove:_e,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:ze=0,nodeClickDistance:Oe=0,children:Ie,onReconnect:Ae,onReconnectStart:Re,onReconnectEnd:De,onEdgeContextMenu:$e,onEdgeDoubleClick:Le,onEdgeMouseEnter:Te,onEdgeMouseMove:Be,onEdgeMouseLeave:Ve,reconnectRadius:je=10,onNodesChange:He,onEdgesChange:Ze,noDragClassName:Xe="nodrag",noWheelClassName:Ye="nowheel",noPanClassName:We="nopan",fitView:Fe,fitViewOptions:Ke,connectOnClick:Ge,attributionPosition:qe,proOptions:Ue,defaultEdgeOptions:Qe,elevateNodesOnSelect:Je,elevateEdgesOnSelect:et,disableKeyboardA11y:tt=!1,autoPanOnConnect:nt,autoPanOnNodeDrag:ot,autoPanSpeed:rt,connectionRadius:it,isValidConnection:st,onError:at,style:lt,id:ct,nodeDragThreshold:ut,viewport:dt,onViewportChange:ht,width:ft,height:gt,colorMode:pt="light",debug:mt,...yt},vt){const xt=ct||"1",wt=function(e){const[t,o]=n.useState("system"===e?null:e);return n.useEffect((()=>{if("system"!==e)return void o(e);const t=Zi(),n=()=>o(t?.matches?"dark":"light");return n(),t?.addEventListener("change",n),()=>{t?.removeEventListener("change",n)}}),[e]),null!==t?t:Zi()?.matches?"dark":"light"}(pt);return t.jsx("div",{...yt,style:{...lt,...Za},ref:vt,className:r(["react-flow",l,wt]),"data-testid":"rf__wrapper",id:ct,children:t.jsxs(Ha,{nodes:o,edges:i,width:ft,height:gt,fitView:Fe,nodeOrigin:se,children:[t.jsx(Ta,{onInit:f,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:E,onNodeContextMenu:k,onNodeDoubleClick:_,nodeTypes:c,edgeTypes:u,connectionLineType:H,connectionLineStyle:Z,connectionLineComponent:X,connectionLineContainerStyle:Y,selectionKeyCode:F,selectionOnDrag:K,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:U,panActivationKeyCode:q,zoomActivationKeyCode:Q,onlyRenderVisibleElements:te,defaultViewport:ue,translateExtent:fe,minZoom:de,maxZoom:he,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:ve,zoomOnDoubleClick:Se,panOnScroll:xe,panOnScrollSpeed:we,panOnScrollMode:be,panOnDrag:Ce,onPaneClick:Ee,onPaneMouseEnter:ke,onPaneMouseMove:_e,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:ze,nodeClickDistance:Oe,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onReconnect:Ae,onReconnectStart:Re,onReconnectEnd:De,onEdgeContextMenu:$e,onEdgeDoubleClick:Le,onEdgeMouseEnter:Te,onEdgeMouseMove:Be,onEdgeMouseLeave:Ve,reconnectRadius:je,defaultMarkerColor:me,noDragClassName:Xe,noWheelClassName:Ye,noPanClassName:We,rfId:xt,disableKeyboardA11y:tt,nodeExtent:pe,viewport:dt,onViewportChange:ht}),t.jsx(Hi,{nodes:o,edges:i,defaultNodes:s,defaultEdges:a,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,edgesFocusable:ae,edgesReconnectable:le,elementsSelectable:ce,elevateNodesOnSelect:Je,elevateEdgesOnSelect:et,minZoom:de,maxZoom:he,nodeExtent:pe,onNodesChange:He,onEdgesChange:Ze,snapToGrid:J,snapGrid:ee,connectionMode:j,translateExtent:fe,connectOnClick:Ge,defaultEdgeOptions:Qe,fitView:Fe,fitViewOptions:Ke,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onNodeDragStart:M,onNodeDrag:N,onNodeDragStop:P,onSelectionDrag:D,onSelectionDragStart:R,onSelectionDragStop:$,onMove:g,onMoveStart:p,onMoveEnd:m,noPanClassName:We,nodeOrigin:se,rfId:xt,autoPanOnConnect:nt,autoPanOnNodeDrag:ot,autoPanSpeed:rt,onError:at,connectionRadius:it,isValidConnection:st,selectNodesOnDrag:ne,nodeDragThreshold:ut,onBeforeDelete:V,paneClickDistance:ze,debug:mt}),t.jsx($i,{onSelectionChange:A}),Ie,t.jsx(Pi,{proOptions:Ue,position:qe}),t.jsx(_i,{rfId:xt,disableKeyboardA11y:tt})]})})}));const Ya=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");const Wa=e=>e.domNode?.querySelector(".react-flow__viewport-portal");const Fa=e=>e.nodes;const Ka=e=>e.edges;const Ga=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});const qa={includeHiddenNodes:!1};function Ua({dimensions:e,lineWidth:n,variant:o,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:r(["react-flow__background-pattern",o,i])})}function Qa({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:r(["react-flow__background-pattern","dots",n])})}var Ja;e.BackgroundVariant=void 0,(Ja=e.BackgroundVariant||(e.BackgroundVariant={})).Lines="lines",Ja.Dots="dots",Ja.Cross="cross";const el={[e.BackgroundVariant.Dots]:1,[e.BackgroundVariant.Lines]:1,[e.BackgroundVariant.Cross]:6},tl=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function nl({id:o,variant:i=e.BackgroundVariant.Dots,gap:s=20,size:a,lineWidth:l=1,offset:c=2,color:u,bgColor:d,style:h,className:f,patternClassName:g}){const p=n.useRef(null),{transform:m,patternId:y}=yi(tl,zi),v=a||el[i],x=i===e.BackgroundVariant.Dots,w=i===e.BackgroundVariant.Cross,b=Array.isArray(s)?s:[s,s],S=[b[0]*m[2]||1,b[1]*m[2]||1],C=v*m[2],E=w?[C,C]:S,k=x?[C/c,C/c]:[E[0]/c,E[1]/c],_=`${y}${o||""}`;return t.jsxs("svg",{className:r(["react-flow__background",f]),style:{...h,...ps,"--xy-background-color-props":d,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:_,x:m[0]%S[0],y:m[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:x?t.jsx(Qa,{radius:C/c,className:g}):t.jsx(Ua,{dimensions:E,lineWidth:l,variant:i,className:g})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${_})`})]})}nl.displayName="Background";const ol=n.memo(nl);function rl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function il(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function sl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.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 al(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 ll(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 cl({children:e,className:n,...o}){return t.jsx("button",{type:"button",className:r(["react-flow__controls-button",n]),...o,children:e})}const ul=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function dl({style:e,showZoom:n=!0,showFitView:o=!0,showInteractive:i=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:l,onFitView:c,onInteractiveChange:u,className:d,children:h,position:f="bottom-left",orientation:g="vertical","aria-label":p="React Flow controls"}){const m=vi(),{isInteractive:y,minZoomReached:v,maxZoomReached:x}=yi(ul,zi),{zoomIn:w,zoomOut:b,fitView:S}=ds(),C="horizontal"===g?"horizontal":"vertical";return t.jsxs(Ni,{className:r(["react-flow__controls",C,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(cl,{onClick:()=>{w(),a?.()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x,children:t.jsx(rl,{})}),t.jsx(cl,{onClick:()=>{b(),l?.()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:t.jsx(il,{})})]}),o&&t.jsx(cl,{className:"react-flow__controls-fitview",onClick:()=>{S(s),c?.()},title:"fit view","aria-label":"fit view",children:t.jsx(sl,{})}),i&&t.jsx(cl,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),u?.(!y)},title:"toggle interactivity","aria-label":"toggle interactivity",children:y?t.jsx(ll,{}):t.jsx(al,{})}),h]})}dl.displayName="Controls";const hl=n.memo(dl);const fl=n.memo((function({id:e,x:n,y:o,width:i,height:s,style:a,color:l,strokeColor:c,strokeWidth:u,className:d,borderRadius:h,shapeRendering:f,selected:g,onClick:p}){const{background:m,backgroundColor:y}=a||{},v=l||m||y;return t.jsx("rect",{className:r(["react-flow__minimap-node",{selected:g},d]),x:n,y:o,rx:h,ry:h,width:i,height:s,style:{fill:v,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?t=>p(t,e):void 0})})),gl=e=>e.nodes.map((e=>e.id)),pl=e=>e instanceof Function?e:()=>e;const ml=n.memo((function({id:e,nodeColorFunc:n,nodeStrokeColorFunc:o,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:h}=yi((t=>{const n=t.nodeLookup.get(e),{x:o,y:r}=n.internals.positionAbsolute;return{node:n,x:o,y:r}}),zi);if(!u||u.hidden||!Zo(u))return null;const{width:f,height:g}=Ho(u);return t.jsx(l,{x:d,y:h,width:f,height:g,style:u.style,selected:!!u.selected,className:r(u),color:n(u),borderRadius:i,strokeColor:o(u),strokeWidth:s,shapeRendering:a,onClick:c,id:u.id})}));var yl=n.memo((function({nodeStrokeColor:e,nodeColor:n,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:s=fl,onClick:a}){const l=yi(gl,zi),c=pl(n),u=pl(e),d=pl(o),h="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:l.map((e=>t.jsx(ml,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:s,onClick:a,shapeRendering:h},e)))})}));const vl=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?Oo(mo(e.nodeLookup),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}};function xl({style:e,className:o,nodeStrokeColor:i,nodeColor:s,nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:g,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:x=!1,ariaLabel:w="React Flow mini map",inversePan:b,zoomStep:S=10,offsetScale:C=5}){const E=vi(),k=n.useRef(null),{boundingRect:_,viewBB:M,rfId:N,panZoom:P,translateExtent:z,flowWidth:O,flowHeight:I}=yi(vl,zi),A=e?.width??200,R=e?.height??150,D=_.width/A,$=_.height/R,L=Math.max(D,$),T=L*A,B=L*R,V=C*L,j=_.x-(T-_.width)/2-V,H=_.y-(B-_.height)/2-V,Z=T+2*V,X=B+2*V,Y=`react-flow__minimap-desc-${N}`,W=n.useRef(0),F=n.useRef();W.current=L,n.useEffect((()=>{if(k.current&&P)return F.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Se(e);return{update:function({translateExtent:e,width:i,height:s,zoomStep:a=10,pannable:l=!0,zoomable:c=!0,inversePan:u=!1}){let d=[0,0];const h=Un().on("start",(e=>{"mousedown"!==e.sourceEvent.type&&"touchstart"!==e.sourceEvent.type||(d=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])})).on("zoom",l?r=>{const a=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!t)return;const l=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],c=[l[0]-d[0],l[1]-d[1]];d=l;const h=o()*Math.max(a[2],Math.log(a[2]))*(u?-1:1),f={x:a[0]-c[0]*h,y:a[1]-c[1]*h},g=[[0,0],[i,s]];t.setViewportConstrained({x:f.x,y:f.y,zoom:a[2]},g,e)}:null).on("zoom.wheel",c?e=>{const o=n();if("wheel"!==e.sourceEvent.type||!t)return;const r=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*a,i=o[2]*Math.pow(2,r);t.scaleTo(i)}:null);r.call(h,{})},destroy:function(){r.on("zoom",null)},pointer:Ce}}({domNode:k.current,panZoom:P,getTransform:()=>E.getState().transform,getViewScale:()=>W.current}),()=>{F.current?.destroy()}}),[P]),n.useEffect((()=>{F.current?.update({translateExtent:z,width:O,height:I,inversePan:b,pannable:v,zoomStep:S,zoomable:x})}),[v,x,b,S,z,O,I]);const K=m?e=>{const[t,n]=F.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,G=y?n.useCallback(((e,t)=>{const n=E.getState().nodeLookup.get(t);y(e,n)}),[]):void 0;return t.jsx(Ni,{position:p,style:{...e,"--xy-minimap-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof h?h:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof f?f:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof g?g*L:void 0,"--xy-minimap-node-background-color-props":"string"==typeof s?s:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof i?i:void 0,"--xy-minimap-node-stroke-width-props":"string"==typeof c?c:void 0},className:r(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:A,height:R,viewBox:`${j} ${H} ${Z} ${X}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:k,onClick:K,children:[w&&t.jsx("title",{id:Y,children:w}),t.jsx(yl,{onClick:G,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:u}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${j-V},${H-V}h${Z+2*V}v${X+2*V}h${-Z-2*V}z\n M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}xl.displayName="MiniMap";const wl=n.memo(xl);const bl=n.memo((function({nodeId:e,position:o,variant:i=Zr.Handle,className:s,style:a={},children:l,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:g=!1,shouldResize:p,onResizeStart:m,onResize:y,onResizeEnd:v}){const x=Ps(),w="string"==typeof e?e:x,b=vi(),S=n.useRef(null),C=i===Zr.Line?"right":"bottom-right",E=o??C,k=n.useRef(null);n.useEffect((()=>{if(S.current&&w)return k.current||(k.current=Jr({domNode:S.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}},onChange:(e,t)=>{const{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,nodeOrigin:i}=b.getState(),s=[],a={x:e.x,y:e.y},l=o.get(w);if(l&&l.expandParent&&l.parentId){const t=l.origin??i,n=e.width??l.measured.width,c=e.height??l.measured.height,u=Cr([{id:l.id,parentId:l.parentId,rect:{width:n,height:c,...Xo({x:e.x??l.position.x,y:e.y??l.position.y},{width:n,height:c},l.parentId,o,t)}}],o,r,i);s.push(...u),a.x=e.x?Math.max(t[0]*n,e.x):void 0,a.y=e.y?Math.max(t[1]*c,e.y):void 0}if(void 0!==a.x&&void 0!==a.y){const e={id:w,type:"position",position:{...a}};s.push(e)}if(void 0!==e.width&&void 0!==e.height){const t={id:w,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:e.width,height:e.height}};s.push(t)}for(const e of t){const t={...e,type:"position"};s.push(t)}n(s)},onEnd:()=>{const e={id:w,type:"dimensions",resizing:!1};b.getState().triggerNodeChanges([e])}})),k.current.update({controlPosition:E,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:g,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:p}),()=>{k.current?.destroy()}}),[E,u,d,h,f,g,m,y,v,p]);const _=E.split("-"),M=i===Zr.Line?"borderColor":"backgroundColor",N=c?{...a,[M]:c}:a;return t.jsx("div",{className:r(["react-flow__resize-control","nodrag",..._,i,s]),ref:S,style:N,children:l})}));const Sl=e=>e.domNode?.querySelector(".react-flow__renderer");function Cl({children:e}){const t=yi(Sl);return t?o.createPortal(e,t):null}const El=(e,t)=>e?.internals.positionAbsolute.x!==t?.internals.positionAbsolute.x||e?.internals.positionAbsolute.y!==t?.internals.positionAbsolute.y||e?.measured.width!==t?.measured.width||e?.measured.height!==t?.measured.height||e?.selected!==t?.selected||e?.internals.z!==t?.internals.z,kl=(e,t)=>{if(e.size!==t.size)return!1;for(const[n,o]of e)if(El(o,t.get(n)))return!1;return!0},_l=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2],selectedNodesCount:e.nodes.filter((e=>e.selected)).length});e.Background=ol,e.BaseEdge=Qs,e.BezierEdge=ga,e.ControlButton=cl,e.Controls=hl,e.EdgeLabelRenderer=function({children:e}){const t=yi(Ya);return t?o.createPortal(e,t):null},e.EdgeText=Us,e.Handle=Os,e.MiniMap=wl,e.NodeResizeControl=bl,e.NodeResizer=function({nodeId:e,isVisible:n=!0,handleClassName:o,handleStyle:r,lineClassName:i,lineStyle:s,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:h=!1,shouldResize:f,onResizeStart:g,onResize:p,onResizeEnd:m}){return n?t.jsxs(t.Fragment,{children:[Yr.map((n=>t.jsx(bl,{className:i,style:s,nodeId:e,position:n,variant:Zr.Line,color:a,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n))),Xr.map((n=>t.jsx(bl,{className:o,style:r,nodeId:e,position:n,color:a,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n)))]}):null},e.NodeToolbar=function({nodeId:o,children:i,className:s,style:a,isVisible:l,position:c=e.Position.Top,offset:u=10,align:d="center",...h}){const f=Ps(),g=n.useCallback((e=>{const t=(Array.isArray(o)?o:[o||f||""]).reduce(((t,n)=>{const o=e.nodeLookup.get(n);return o&&t.set(o.id,o),t}),new Map);return t}),[o,f]),p=yi(g,kl),{x:m,y:y,zoom:v,selectedNodesCount:x}=yi(_l,zi);if(!("boolean"==typeof l?l:1===p.size&&p.values().next().value.selected&&1===x)||!p.size)return null;const w=mo(p),b=Array.from(p.values()),S=Math.max(...b.map((e=>e.internals.z+1))),C={position:"absolute",transform:yr(w,{x:m,y:y,zoom:v},c,u,d),zIndex:S,...a};return t.jsx(Cl,{children:t.jsx("div",{style:C,className:r(["react-flow__node-toolbar",s]),...h,"data-id":b.reduce(((e,t)=>`${e}${t.id} `),"").trim(),children:i})})},e.Panel=Ni,e.ReactFlow=Xa,e.ReactFlowProvider=ja,e.SimpleBezierEdge=na,e.SmoothStepEdge=ia,e.StepEdge=la,e.StraightEdge=da,e.ViewportPortal=function({children:e}){const t=yi(Wa);return t?o.createPortal(e,t):null},e.addEdge=sr,e.applyEdgeChanges=Qi,e.applyNodeChanges=Ui,e.getBezierEdgeCenter=Jo,e.getBezierPath=nr,e.getConnectedEdges=vo,e.getEdgeCenter=or,e.getIncomers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.target===e.id&&o.add(t.source)})),t.filter((e=>o.has(e.id)))},e.getNodesBounds=(e,t={nodeOrigin:[0,0]})=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const o=zo(n,t.nodeOrigin);return _o(e,o)}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return No(n)},e.getOutgoers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.source===e.id&&o.add(t.target)})),t.filter((e=>o.has(e.id)))},e.getSimpleBezierPath=ea,e.getSmoothStepPath=dr,e.getStraightPath=ar,e.getViewportForBounds=Bo,e.isEdge=rs,e.isNode=os,e.reconnectEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return n;if(!n.find((t=>t.id===e.id)))return n;const s={...i,id:o.shouldReplaceId?ir(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter((e=>e.id!==r)).concat(s)},e.useConnection=Oa,e.useEdges=function(){return yi(Ka,zi)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Qi(e,t)))),[]);return[t,o,r]},e.useHandleConnections=function({type:e,id:t=null,nodeId:o,onConnect:r,onDisconnect:i}){const s=Ps(),a=o??s,l=n.useRef(null),c=yi((n=>n.connectionLookup.get(`${a}-${e}-${t}`)),co);return n.useEffect((()=>{if(l.current&&l.current!==c){const e=c??new Map;uo(l.current,e,i),uo(e,l.current,r)}l.current=c??new Map}),[c,r,i]),n.useMemo((()=>Array.from(c?.values()??[])),[c])},e.useInternalNode=function(e){return yi(n.useCallback((t=>t.nodeLookup.get(e)),[e]),zi)},e.useKeyPress=Yi,e.useNodeId=Ps,e.useNodes=function(){return yi(Fa,zi)},e.useNodesData=function(e){return yi(n.useCallback((t=>{const n=[],o=Array.isArray(e),r=o?e:[e];for(const e of r){const o=t.nodeLookup.get(e);o&&n.push({id:o.id,type:o.type,data:o.data})}return o?n:n[0]??null}),[e]),kr)},e.useNodesInitialized=function(e=qa){return yi((e=>t=>{if(0===t.nodeLookup.size)return!1;for(const[,{hidden:n,internals:o}]of t.nodeLookup)if((e.includeHiddenNodes||!n)&&(void 0===o.handleBounds||!Zo(o.userNode)))return!1;return!0})(e))},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Ui(e,t)))),[]);return[t,o,r]},e.useOnSelectionChange=function({onChange:e}){const t=vi();n.useEffect((()=>{const n=[...t.getState().onSelectionChangeHandlers,e];return t.setState({onSelectionChangeHandlers:n}),()=>{const n=t.getState().onSelectionChangeHandlers.filter((t=>t!==e));t.setState({onSelectionChangeHandlers:n})}}),[e])},e.useOnViewportChange=function({onStart:e,onChange:t,onEnd:o}){const r=vi();n.useEffect((()=>{r.setState({onViewportChangeStart:e})}),[e]),n.useEffect((()=>{r.setState({onViewportChange:t})}),[t]),n.useEffect((()=>{r.setState({onViewportChangeEnd:o})}),[o])},e.useReactFlow=ds,e.useStore=yi,e.useStoreApi=vi,e.useUpdateNodeInternals=function(){const e=vi();return n.useCallback((t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],i=new Map;r.forEach((e=>{const t=n?.querySelector(`.react-flow__node[data-id="${e}"]`);t&&i.set(e,{id:e,nodeElement:t,force:!0})})),requestAnimationFrame((()=>o(i)))}),[])},e.useViewport=function(){return yi(Ga,zi)}}));
|
|
10
|
+
*/si.exports=function(){if(ii)return ai;ii=1;var e=n,t=ui(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return ai.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=a((function(){function e(e){if(!s){if(s=!0,r=e,e=c(e),void 0!==u&&h.hasValue){var t=h.value;if(u(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=c(e);return void 0!==u&&u(t,n)?t:(r=e,i=n)}var r,i,s=!1,a=void 0===n?null:n;return[function(){return e(t())},null===a?void 0:function(){return e(a())}]}),[t,n,c,u]);var f=r(e,d[0],d[1]);return s((function(){h.hasValue=!0,h.value=f}),[f]),l(f),f},ai}();var di=ni(si.exports);const hi=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(o,r,i),i},{useSyncExternalStoreWithSelector:fi}=di;function gi(e,t=e.getState,o){const r=fi(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}const pi=(e,t)=>{const n=(e=>e?hi(e):hi)(e),o=(e,o=t)=>gi(n,e,o);return Object.assign(o,n),o},mi=n.createContext(null),yi=mi.Provider,vi=Qn.error001();function xi(e,t){const o=n.useContext(mi);if(null===o)throw new Error(vi);return gi(o,e,t)}function wi(){const e=n.useContext(mi);if(null===e)throw new Error(vi);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe})),[e])}const bi={display:"none"},Si={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ci="react-flow__node-desc",Ei="react-flow__edge-desc",ki="react-flow__aria-live",_i=e=>e.ariaLiveMessage;function Mi({rfId:e}){const n=xi(_i);return t.jsx("div",{id:`${ki}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Si,children:n})}function Ni({rfId:e,disableKeyboardA11y:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{id:`${Ci}-${e}`,style:bi,children:["Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),t.jsx("div",{id:`${Ei}-${e}`,style:bi,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!n&&t.jsx(Mi,{rfId:e})]})}const Pi=e=>e.userSelectionActive?"none":"all";function zi({position:e="top-left",children:n,className:o,style:i,...s}){const a=xi(Pi),l=`${e}`.split("-");return t.jsx("div",{className:r(["react-flow__panel",o,...l]),style:{...i,pointerEvents:a},...s,children:n})}function Oi({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(zi,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}function Ai(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}const Ii=e=>{const t=[],n=[];for(const[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(const[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Ri=e=>e.id;function Di(e,t){return Ai(e.selectedNodes.map(Ri),t.selectedNodes.map(Ri))&&Ai(e.selectedEdges.map(Ri),t.selectedEdges.map(Ri))}function Li({onSelectionChange:e}){const t=wi(),{selectedNodes:o,selectedEdges:r}=xi(Ii,Di);return n.useEffect((()=>{const n={nodes:o,edges:r};e?.(n),t.getState().onSelectionChangeHandlers.forEach((e=>e(n)))}),[o,r,e]),null}const $i=e=>!!e.onSelectionChangeHandlers;function Ti({onSelectionChange:e}){const n=xi($i);return e||n?t.jsx(Li,{onSelectionChange:e}):null}const Bi=[0,0],Vi={x:0,y:0,zoom:1},ji=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","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","onBeforeDelete","debug","autoPanSpeed","paneClickDistance","rfId"],Hi=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,setPaneClickDistance:e.setPaneClickDistance}),Zi={translateExtent:Jn,nodeOrigin:Bi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function Xi(e){const{setNodes:t,setEdges:o,setMinZoom:r,setMaxZoom:i,setTranslateExtent:s,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c,setPaneClickDistance:u}=xi(Hi,Ai),d=wi();n.useEffect((()=>(c(e.defaultNodes,e.defaultEdges),()=>{h.current=Zi,l()})),[]);const h=n.useRef(Zi);return n.useEffect((()=>{for(const n of ji){const l=e[n];l!==h.current[n]&&(void 0!==e[n]&&("nodes"===n?t(l):"edges"===n?o(l):"minZoom"===n?r(l):"maxZoom"===n?i(l):"translateExtent"===n?s(l):"nodeExtent"===n?a(l):"paneClickDistance"===n?u(l):"fitView"===n?d.setState({fitViewOnInit:l}):"fitViewOptions"===n?d.setState({fitViewOnInitOptions:l}):d.setState({[n]:l})))}h.current=e}),ji.map((t=>e[t]))),null}function Yi(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null}const Wi="undefined"!=typeof document?document:null;function Fi(e=null,t={target:Wi,actInsideInputWithModifier:!0}){const[o,r]=n.useState(!1),i=n.useRef(!1),s=n.useRef(new Set([])),[a,l]=n.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return n.useEffect((()=>{const n=t?.target||Wi;if(null!==e){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Go(e))return!1;const n=Gi(e.code,l);s.current.add(e[n]),Ki(a,s.current,!1)&&(e.preventDefault(),r(!0))},o=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Go(e))return!1;const n=Gi(e.code,l);Ki(a,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(e[n]),"Meta"===e.key&&s.current.clear(),i.current=!1},c=()=>{s.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",o),window.addEventListener("blur",c),window.addEventListener("contextmenu",c),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",o),window.removeEventListener("blur",c),window.removeEventListener("contextmenu",c)}}}),[e,r]),o}function Ki(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function Gi(e,t){return t.includes(e)?"code":"key"}const qi=()=>{const e=wi();return n.useMemo((()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration: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},{duration:n?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>{const{nodeLookup:n,width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=xo(n,t);return a?wo({nodes:l,width:o,height:r,minZoom:i,maxZoom:s,panZoom:a},t):Promise.resolve(!1)},setCenter:async(t,n,o)=>{const{width:r,height:i,maxZoom:s,panZoom:a}=e.getState(),l=void 0!==o?.zoom?o.zoom:s,c=r/2-t*l,u=i/2-n*l;return a?(await a.setViewport({x:c,y:u,zoom:l},{duration:o?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=Bo(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(l,{duration:n?.duration}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:o,snapGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:s,y:a}=i.getBoundingClientRect(),l={x:t.x-s,y:t.y-a};return $o(l,o,n.snapToGrid,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=To(t,n);return{x:s.x+r,y:s.y+i}}})),[])};function Ui(e,t){const n=[],o=new Map;for(const t of e)if("add"!==t.type)if("remove"===t.type||"replace"===t.type)o.set(t.id,[t]);else{const e=o.get(t.id);e?e.push(t):o.set(t.id,[t])}else n.push(t.item);for(const e of t){const t=o.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}const r={...e};for(const e of t)Qi(e,r);n.push(r)}return n}function Qi(e,t){switch(e.type){case"select":t.selected=e.selected;break;case"position":void 0!==e.position&&(t.position=e.position),void 0!==e.dragging&&(t.dragging=e.dragging);break;case"dimensions":void 0!==e.dimensions&&(t.measured??={},t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),"boolean"==typeof e.resizing&&(t.resizing=e.resizing)}}function Ji(e,t){return Ui(e,t)}function es(e,t){return Ui(e,t)}function ts(e,t){return{id:e,type:"select",selected:t}}function ns(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const e=t.has(r);void 0===i.selected&&!e||i.selected===e||(n&&(i.selected=e),o.push(ts(i.id,e)))}return o}function os({items:e=[],lookup:t}){const n=[],o=new Map(e.map((e=>[e.id,e])));for(const o of e){const e=t.get(o.id),r=e?.internals?.userNode??e;void 0!==r&&r!==o&&n.push({id:o.id,item:o,type:"replace"}),void 0===r&&n.push({item:o,type:"add"})}for(const[e]of t){void 0===o.get(e)&&n.push({id:e,type:"remove"})}return n}function rs(e){return{id:e.id,type:"remove"}}const is=e=>(e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e))(e),ss=e=>fo(e);function as(e){return n.forwardRef(e)}const ls="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function cs(e){const[t,o]=n.useState(!1),[r]=n.useState((()=>function(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}((()=>o(!0)))));return ls((()=>{if(!t)return void r.reset();const n=r.get();n.length&&(e(n),r.reset()),o(!1)}),[t]),r}const us=n.createContext(null);function ds({children:e}){const o=wi(),r=cs(n.useCallback((e=>{const{nodes:t=[],setNodes:n,hasDefaultNodes:r,onNodesChange:i,nodeLookup:s}=o.getState();let a=t;for(const t of e)a="function"==typeof t?t(a):t;r?n(a):i&&i(os({items:a,lookup:s}))}),[])),i=cs(n.useCallback((e=>{const{edges:t=[],setEdges:n,hasDefaultEdges:r,onEdgesChange:i,edgeLookup:s}=o.getState();let a=t;for(const t of e)a="function"==typeof t?t(a):t;r?n(a):i&&i(os({items:a,lookup:s}))}),[])),s=n.useMemo((()=>({nodeQueue:r,edgeQueue:i})),[]);return t.jsx(us.Provider,{value:s,children:e})}const hs=e=>!!e.panZoom;function fs(){const e=qi(),t=wi(),o=function(){const e=n.useContext(us);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}(),r=xi(hs),i=n.useMemo((()=>{const e=e=>t.getState().nodeLookup.get(e),n=e=>{o.nodeQueue.push(e)},r=e=>{o.edgeQueue.push(e)},i=e=>{const{nodeLookup:n,nodeOrigin:o}=t.getState(),r=is(e)?e:n.get(e.id),i=r.parentId?Xo(r.position,r.measured,r.parentId,n,o):r.position,s={id:r.id,position:i,width:r.measured?.width??r.width,height:r.measured?.height??r.height,data:r.data};return Po(s)},s=(e,t,o={replace:!1})=>{n((n=>n.map((n=>{if(n.id===e){const e="function"==typeof t?t(n):t;return o.replace&&is(e)?e:{...n,...e}}return n}))))},a=(e,t,n={replace:!1})=>{r((o=>o.map((o=>{if(o.id===e){const e="function"==typeof t?t(o):t;return n.replace&&ss(e)?e:{...o,...e}}return o}))))};return{getNodes:()=>t.getState().nodes.map((e=>({...e}))),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:n,setEdges:r,addNodes:e=>{const t=Array.isArray(e)?e:[e];o.nodeQueue.push((e=>[...e,...t]))},addEdges:e=>{const t=Array.isArray(e)?e:[e];o.edgeQueue.push((e=>[...e,...t]))},toObject:()=>{const{nodes:e=[],edges:n=[],transform:o}=t.getState(),[r,i,s]=o;return{nodes:e.map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:i,zoom:s}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{const{nodes:o,edges:r,onNodesDelete:i,onEdgesDelete:s,triggerNodeChanges:a,triggerEdgeChanges:l,onDelete:c,onBeforeDelete:u}=t.getState(),{nodes:d,edges:h}=await async function({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map((e=>e.id))),s=[];for(const e of n){if(!1===e.deletable)continue;const t=i.has(e.id),n=!t&&e.parentId&&s.find((t=>t.id===e.parentId));(t||n)&&s.push(e)}const a=new Set(t.map((e=>e.id))),l=o.filter((e=>!1!==e.deletable)),c=vo(s,l);for(const e of l)a.has(e.id)&&!c.find((t=>t.id===e.id))&&c.push(e);if(!r)return{edges:c,nodes:s};const u=await r({nodes:s,edges:c});return"boolean"==typeof u?u?{edges:c,nodes:s}:{edges:[],nodes:[]}:u}({nodesToRemove:e,edgesToRemove:n,nodes:o,edges:r,onBeforeDelete:u}),f=h.length>0,g=d.length>0;if(f){const e=h.map(rs);s?.(h),l(e)}if(g){const e=d.map(rs);i?.(d),a(e)}return(g||f)&&c?.({nodes:d,edges:h}),{deletedNodes:d,deletedEdges:h}},getIntersectingNodes:(e,n=!0,o)=>{const r=Io(e),s=r?e:i(e),a=void 0!==o;return s?(o||t.getState().nodes).filter((o=>{const i=t.getState().nodeLookup.get(o.id);if(i&&!r&&(o.id===e.id||!i.internals.positionAbsolute))return!1;const l=Po(a?o:i),c=Ao(l,s);return n&&c>0||c>=s.width*s.height})):[]},isNodeIntersecting:(e,t,n=!0)=>{const o=Io(e)?e:i(e);if(!o)return!1;const r=Ao(o,t);return n&&r>0||r>=o.width*o.height},updateNode:s,updateNodeData:(e,t,n={replace:!1})=>{s(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)},updateEdge:a,updateEdgeData:(e,t,n={replace:!1})=>{a(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)}}}),[]);return n.useMemo((()=>({...i,...e,viewportInitialized:r})),[r])}const gs=e=>e.selected,ps={actInsideInputWithModifier:!1},ms="undefined"!=typeof window?window:void 0;const ys={position:"absolute",width:"100%",height:"100%",top:0,left:0},vs=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function xs({onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=e.PanOnScrollMode.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:d,translateExtent:h,minZoom:f,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:x,onViewportChange:w,isControlledViewport:b,paneClickDistance:S}){const C=wi(),E=n.useRef(null),{userSelectionActive:k,lib:_}=xi(vs,Ai),M=Fi(p),N=n.useRef();return function(e){const t=wi();n.useEffect((()=>{const n=()=>{if(!e.current)return!1;const n=Wo(e.current);0!==n.height&&0!==n.width||t.getState().onError?.("004",Qn.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener("resize",n);const t=new ResizeObserver((()=>n()));return t.observe(e.current),()=>{window.removeEventListener("resize",n),t&&e.current&&t.unobserve(e.current)}}}),[])}(E),n.useEffect((()=>{if(E.current){N.current=Xr({domNode:E.current,minZoom:f,maxZoom:g,translateExtent:h,viewport:d,paneClickDistance:S,onTransformChange:e=>{w?.({x:e[0],y:e[1],zoom:e[2]}),b||C.setState({transform:e})},onDraggingChange:e=>C.setState({paneDragging:e}),onPanZoomStart:(e,t)=>{const{onViewportChangeStart:n,onMoveStart:o}=C.getState();o?.(e,t),n?.(t)},onPanZoom:(e,t)=>{const{onViewportChange:n,onMove:o}=C.getState();o?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{const{onViewportChangeEnd:n,onMoveEnd:o}=C.getState();o?.(e,t),n?.(t)}});const{x:e,y:t,zoom:n}=N.current.getViewport();return C.setState({panZoom:N.current,transform:[e,t,n],domNode:E.current.closest(".react-flow")}),()=>{N.current?.destroy()}}}),[]),n.useEffect((()=>{N.current?.update({onPaneContextMenu:o,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:s,panOnScrollSpeed:a,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:M,preventScrolling:m,noPanClassName:x,userSelectionActive:k,noWheelClassName:v,lib:_})}),[o,r,i,s,a,l,c,u,M,m,x,k,v,_]),t.jsx("div",{className:"react-flow__renderer",ref:E,style:ys,children:y})}const ws=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function bs(){const{userSelectionActive:e,userSelectionRect:n}=xi(ws,Ai);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const Ss=(e,t)=>n=>{n.target===t.current&&e?.(n)},Cs=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function Es({isSelecting:o,selectionKeyPressed:i,selectionMode:s=e.SelectionMode.Full,panOnDrag:a,selectionOnDrag:l,onSelectionStart:c,onSelectionEnd:u,onPaneClick:d,onPaneContextMenu:h,onPaneScroll:f,onPaneMouseEnter:g,onPaneMouseMove:p,onPaneMouseLeave:m,children:y}){const v=n.useRef(null),x=wi(),w=n.useRef(0),b=n.useRef(0),S=n.useRef(),C=n.useRef(new Map),{userSelectionActive:E,elementsSelectable:k,dragging:_}=xi(Cs,Ai),M=k&&(o||E),N=n.useRef(!1),P=n.useRef(!1),z=e=>{N.current?N.current=!1:(d?.(e),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1}))},O=f?e=>f(e):void 0;return t.jsxs("div",{className:r(["react-flow__pane",{draggable:a,dragging:_,selection:o}]),onClick:M?void 0:Ss(z,v),onContextMenu:Ss((e=>{Array.isArray(a)&&a?.includes(2)?e.preventDefault():h?.(e)}),v),onWheel:Ss(O,v),onPointerEnter:M?void 0:g,onPointerDown:M?e=>{const{resetSelectedElements:t,domNode:n,edgeLookup:r}=x.getState();if(S.current=n?.getBoundingClientRect(),!k||!o||0!==e.button||e.target!==v.current||!S.current)return;e.target?.setPointerCapture?.(e.pointerId),P.current=!0,N.current=!1,C.current=new Map;for(const[e,t]of r)C.current.set(t.source,C.current.get(t.source)?.add(e)||new Set([e])),C.current.set(t.target,C.current.get(t.target)?.add(e)||new Set([e]));const{x:i,y:s}=Uo(e.nativeEvent,S.current);t(),x.setState({userSelectionRect:{width:0,height:0,startX:i,startY:s,x:i,y:s}}),c?.(e)}:p,onPointerMove:M?t=>{const{userSelectionRect:n,edgeLookup:o,transform:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:l}=x.getState();if(!S.current||!n)return;N.current=!0;const{x:c,y:u}=Uo(t.nativeEvent,S.current),{startX:d,startY:h}=n,f={startX:d,startY:h,x:c<d?c:d,y:u<h?u:h,width:Math.abs(c-d),height:Math.abs(u-h)},g=yo(i,f,r,s===e.SelectionMode.Partial,!0),p=new Set,m=new Set;for(const e of g){m.add(e.id);const t=C.current.get(e.id);if(t)for(const e of t)p.add(e)}if(w.current!==m.size){w.current=m.size;a(ns(i,m,!0))}if(b.current!==p.size){b.current=p.size;l(ns(o,p))}x.setState({userSelectionRect:f,userSelectionActive:!0,nodesSelectionActive:!1})}:p,onPointerUp:M?e=>{if(0!==e.button||!P.current)return;e.target?.releasePointerCapture?.(e.pointerId);const{userSelectionRect:t}=x.getState();!E&&t&&e.target===v.current&&z?.(e),w.current>0&&x.setState({nodesSelectionActive:!0}),x.setState({userSelectionActive:!1,userSelectionRect:null}),w.current=0,b.current=0,u?.(e),(i||l)&&(N.current=!1),P.current=!1}:void 0,onPointerLeave:m,ref:v,style:ys,children:[y,t.jsx(bs,{})]})}function ks({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=t.getState(),c=a.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>o?.current?.blur()))):r([e])):l?.("012",Qn.error012(e))}function _s({nodeRef:e,disabled:t=!1,noDragClassName:o,handleSelector:r,nodeId:i,isSelectable:s,nodeClickDistance:a}){const l=wi(),[c,u]=n.useState(!1),d=n.useRef();return n.useEffect((()=>{d.current=Pr({getStoreItems:()=>l.getState(),onNodeMouseDown:t=>{ks({id:t,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})}),[]),n.useEffect((()=>{if(t)d.current?.destroy();else if(e.current)return d.current?.update({noDragClassName:o,handleSelector:r,domNode:e.current,isSelectable:s,nodeId:i,nodeClickDistance:a}),()=>{d.current?.destroy()}}),[o,r,t,s,e,i]),c}const Ms=e=>t=>t.selected&&(t.draggable||e&&void 0===t.draggable);function Ns(){const e=wi();return n.useCallback((t=>{const{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:s,updateNodePositions:a,nodeLookup:l,nodeOrigin:c}=e.getState(),u=new Map,d=Ms(i),h=o?r[0]:5,f=o?r[1]:5,g=t.direction.x*h*t.factor,p=t.direction.y*f*t.factor;for(const[,e]of l){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+g,y:e.internals.positionAbsolute.y+p};o&&(t=Lo(t,r));const{position:i,positionAbsolute:a}=bo({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:c,onError:s});e.position=i,e.internals.positionAbsolute=a,u.set(e.id,e)}a(u)}),[])}const Ps=n.createContext(null),zs=Ps.Provider;Ps.Consumer;const Os=()=>n.useContext(Ps),As=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId});const Is=n.memo(as((function({type:n="source",position:o=e.Position.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:g,...p},m){const y=c||null,v="target"===n,x=wi(),w=Os(),{connectOnClick:b,noPanClassName:S,rfId:C}=xi(As,Ai),{connectingFrom:E,connectingTo:k,clickConnecting:_,isPossibleEndHandle:M,connectionInProcess:N,valid:P}=xi(((t,n,o)=>r=>{const{connectionClickStartHandle:i,connectionMode:s,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=c?.nodeId===t&&c?.id===n&&c?.type===o;return{connectingFrom:l?.nodeId===t&&l?.id===n&&l?.type===o,connectingTo:d,clickConnecting:i?.nodeId===t&&i?.id===n&&i?.type===o,isPossibleEndHandle:s===e.ConnectionMode.Strict?l?.type!==o:t!==l?.nodeId||n!==l?.id,connectionInProcess:!!l,valid:d&&u}})(w,y,n),Ai);w||x.getState().onError?.("010",Qn.error010());const z=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=x.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=x.getState();t(sr(r,e))}n?.(r),u?.(r)},O=e=>{if(!w)return;const t=qo(e.nativeEvent);if(a&&(t&&0===e.button||!t)){const t=x.getState();Lr.onPointerDown(e.nativeEvent,{autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:v,handleId:y,nodeId:w,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:t.onConnectEnd,updateConnection:t.updateConnection,onConnect:z,isValidConnection:i||t.isValidConnection,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed})}t?f?.(e):g?.(e)};return t.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":o,"data-id":`${C}-${w}-${y}-${n}`,className:r(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",S,h,{source:!v,target:v,connectable:s,connectablestart:a,connectableend:l,clickconnecting:_,connectingfrom:E,connectingto:k,valid:P,connectionindicator:s&&(!N||M)&&(N?l:a)}]),onMouseDown:O,onTouchStart:O,onClick:b?e=>{const{onClickConnectStart:t,onClickConnectEnd:o,connectionClickStartHandle:r,connectionMode:s,isValidConnection:l,lib:c,rfId:u,nodeLookup:d,connection:h}=x.getState();if(!w||!r&&!a)return;if(!r)return t?.(e.nativeEvent,{nodeId:w,handleId:y,handleType:n}),void x.setState({connectionClickStartHandle:{nodeId:w,type:n,id:y}});const f=Fo(e.target),g=i||l,{connection:p,isValid:m}=Lr.isValid(e.nativeEvent,{handle:{nodeId:w,id:y,type:n},connectionMode:s,fromNodeId:r.nodeId,fromHandleId:r.id||null,fromType:r.type,isValidConnection:g,flowId:u,doc:f,lib:c,nodeLookup:d});m&&p&&z(p);const v=structuredClone(h);delete v.inProgress,v.toPosition=v.toHandle?v.toHandle.position:null,o?.(e,v),x.setState({connectionClickStartHandle:null})}:void 0,ref:m,...p,children:d})})));const Rs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ds={input:function({data:n,isConnectable:o,sourcePosition:r=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[n?.label,t.jsx(Is,{type:"source",position:r,isConnectable:o})]})},default:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top,sourcePosition:i=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Is,{type:"target",position:r,isConnectable:o}),n?.label,t.jsx(Is,{type:"source",position:i,isConnectable:o})]})},output:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Is,{type:"target",position:r,isConnectable:o}),n?.label]})},group:function(){return null}};const Ls=e=>{const{width:t,height:n,x:o,y:r}=mo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Ro(t)?t:null,height:Ro(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 $s({onSelectionContextMenu:e,noPanClassName:o,disableKeyboardA11y:i}){const s=wi(),{width:a,height:l,transformString:c,userSelectionActive:u}=xi(Ls,Ai),d=Ns(),h=n.useRef(null);if(n.useEffect((()=>{i||h.current?.focus({preventScroll:!0})}),[i]),_s({nodeRef:h}),u||!a||!l)return null;const f=e?t=>{const n=s.getState().nodes.filter((e=>e.selected));e(t,n)}:void 0;return t.jsx("div",{className:r(["react-flow__nodesselection","react-flow__container",o]),style:{transform:c},children:t.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:i?void 0:-1,onKeyDown:i?void 0:e=>{Object.prototype.hasOwnProperty.call(Rs,e.key)&&d({direction:Rs[e.key],factor:e.shiftKey?4:1})},style:{width:a,height:l}})})}const Ts="undefined"!=typeof window?window:void 0,Bs=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Vs({children:e,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:l,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:d,selectionOnDrag:h,selectionMode:f,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:y,zoomActivationKeyCode:v,elementsSelectable:x,zoomOnScroll:w,zoomOnPinch:b,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:k,panOnDrag:_,defaultViewport:M,translateExtent:N,minZoom:P,maxZoom:z,preventScrolling:O,onSelectionContextMenu:A,noWheelClassName:I,noPanClassName:R,disableKeyboardA11y:D,onViewportChange:L,isControlledViewport:$}){const{nodesSelectionActive:T,userSelectionActive:B}=xi(Bs),V=Fi(d,{target:Ts}),j=Fi(y,{target:Ts}),H=j||_,Z=j||S,X=h&&!0!==H,Y=V||B||X;return function({deleteKeyCode:e,multiSelectionKeyCode:t}){const o=wi(),{deleteElements:r}=fs(),i=Fi(e,ps),s=Fi(t,{target:ms});n.useEffect((()=>{if(i){const{edges:e,nodes:t}=o.getState();r({nodes:t.filter(gs),edges:e.filter(gs)}),o.setState({nodesSelectionActive:!1})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:s})}),[s])}({deleteKeyCode:u,multiSelectionKeyCode:m}),t.jsx(xs,{onPaneContextMenu:a,elementsSelectable:x,zoomOnScroll:w,zoomOnPinch:b,panOnScroll:Z,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:k,panOnDrag:!V&&H,defaultViewport:M,translateExtent:N,minZoom:P,maxZoom:z,zoomActivationKeyCode:v,preventScrolling:O,noWheelClassName:I,noPanClassName:R,onViewportChange:L,isControlledViewport:$,paneClickDistance:c,children:t.jsxs(Es,{onSelectionStart:g,onSelectionEnd:p,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:l,panOnDrag:H,isSelecting:!!Y,selectionMode:f,selectionKeyPressed:V,selectionOnDrag:X,children:[e,T&&t.jsx($s,{onSelectionContextMenu:A,noPanClassName:R,disableKeyboardA11y:D})]})})}Vs.displayName="FlowRenderer";const js=n.memo(Vs),Hs=e=>t=>e?yo(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map((e=>e.id)):Array.from(t.nodeLookup.keys());const Zs=e=>e.updateNodeInternals;function Xs({id:e,onClick:o,onMouseEnter:i,onMouseMove:s,onMouseLeave:a,onContextMenu:l,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:g,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:x,nodeExtent:w,nodeClickDistance:b,onError:S}){const{node:C,internals:E,isParent:k}=xi((t=>{const n=t.nodeLookup.get(e),o=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:o}}),Ai);let _=C.type||"default",M=x?.[_]||Ds[_];void 0===M&&(S?.("003",Qn.error003(_)),_="default",M=Ds.default);const N=!!(C.draggable||u&&void 0===C.draggable),P=!!(C.selectable||d&&void 0===C.selectable),z=!!(C.connectable||h&&void 0===C.connectable),O=!!(C.focusable||f&&void 0===C.focusable),A=wi(),I=Zo(C),R=function({node:e,nodeType:t,hasDimensions:o,resizeObserver:r}){const i=wi(),s=n.useRef(null),a=n.useRef(null),l=n.useRef(e.sourcePosition),c=n.useRef(e.targetPosition),u=n.useRef(t),d=o&&!!e.internals.handleBounds;return n.useEffect((()=>{!s.current||e.hidden||d&&a.current===s.current||(a.current&&r?.unobserve(a.current),r?.observe(s.current),a.current=s.current)}),[d,e.hidden]),n.useEffect((()=>()=>{a.current&&(r?.unobserve(a.current),a.current=null)}),[]),n.useEffect((()=>{if(s.current){const n=u.current!==t,o=l.current!==e.sourcePosition,r=c.current!==e.targetPosition;(n||o||r)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}}),[e.id,t,e.sourcePosition,e.targetPosition]),s}({node:C,nodeType:_,hasDimensions:I,resizeObserver:g}),D=_s({nodeRef:R,disabled:C.hidden||!N,noDragClassName:p,handleSelector:C.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:b}),L=Ns();if(C.hidden)return null;const $=Ho(C),T=function(e){return void 0===e.internals.handleBounds?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}(C),B=w?Co(E.positionAbsolute,w):E.positionAbsolute,V=P||N||o||i||s||a,j=i?e=>i(e,{...E.userNode}):void 0,H=s?e=>s(e,{...E.userNode}):void 0,Z=a?e=>a(e,{...E.userNode}):void 0,X=l?e=>l(e,{...E.userNode}):void 0,Y=c?e=>c(e,{...E.userNode}):void 0;return t.jsx("div",{className:r(["react-flow__node",`react-flow__node-${_}`,{[m]:N},C.className,{selected:C.selected,selectable:P,parent:k,draggable:N,dragging:D}]),ref:R,style:{zIndex:E.z,transform:`translate(${B.x}px,${B.y}px)`,pointerEvents:V?"all":"none",visibility:I?"visible":"hidden",...C.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:Z,onContextMenu:X,onClick:t=>{const{selectNodesOnDrag:n,nodeDragThreshold:r}=A.getState();P&&(!n||!N||r>0)&&ks({id:e,store:A,nodeRef:R}),o&&o(t,{...E.userNode})},onDoubleClick:Y,onKeyDown:O?t=>{if(!Go(t.nativeEvent)&&!y)if(eo.includes(t.key)&&P){const n="Escape"===t.key;ks({id:e,store:A,unselect:n,nodeRef:R})}else N&&C.selected&&Object.prototype.hasOwnProperty.call(Rs,t.key)&&(A.setState({ariaLiveMessage:`Moved selected node ${t.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~B.x}, y: ${~~B.y}`}),L({direction:Rs[t.key],factor:t.shiftKey?4:1}))}:void 0,tabIndex:O?0:void 0,role:O?"button":void 0,"aria-describedby":y?void 0:`${Ci}-${v}`,"aria-label":C.ariaLabel,children:t.jsx(zs,{value:e,children:t.jsx(M,{id:e,data:C.data,type:_,positionAbsoluteX:B.x,positionAbsoluteY:B.y,selected:C.selected,selectable:P,draggable:N,deletable:C.deletable??!0,isConnectable:z,sourcePosition:C.sourcePosition,targetPosition:C.targetPosition,dragging:D,dragHandle:C.dragHandle,zIndex:E.z,parentId:C.parentId,...$})})})}const Ys=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ws(e){const{nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:s,onError:a}=xi(Ys,Ai),l=(c=e.onlyRenderVisibleElements,xi(n.useCallback(Hs(c),[c]),Ai));var c;const u=function(){const e=xi(Zs),[t]=n.useState((()=>"undefined"==typeof ResizeObserver?null:new ResizeObserver((t=>{const n=new Map;t.forEach((e=>{const t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})})),e(n)}))));return n.useEffect((()=>()=>{t?.disconnect()}),[t]),t}();return t.jsx("div",{className:"react-flow__nodes",style:ys,children:l.map((n=>t.jsx(Xs,{id:n,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:u,nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},n)))})}Ws.displayName="NodeRenderer";const Fs=n.memo(Ws);const Ks={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[e.MarkerType.ArrowClosed]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Gs=({id:e,type:o,color:r,width:i=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const u=function(e){const t=wi();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Ks,e)?Ks[e]:(t.getState().onError?.("009",Qn.error009(e)),null)),[e])}(o);return u?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:c,refX:"0",refY:"0",children:t.jsx(u,{color:r,strokeWidth:l})}):null},qs=({defaultColor:e,rfId:o})=>{const r=xi((e=>e.edges)),i=xi((e=>e.defaultEdgeOptions)),s=n.useMemo((()=>{const t=function(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce(((e,s)=>([s.markerStart||o,s.markerEnd||r].forEach((o=>{if(o&&"object"==typeof o){const r=mr(o,t);i.has(r)||(e.push({id:r,color:o.color||n,...o}),i.add(r))}})),e)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))}(r,{id:o,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd});return t}),[r,i,o,e]);return s.length?t.jsx("svg",{className:"react-flow__marker",children:t.jsx("defs",{children:s.map((e=>t.jsx(Gs,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id)))})}):null};qs.displayName="MarkerDefinitions";var Us=n.memo(qs);function Qs({x:e,y:o,label:i,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[g,p]=n.useState({x:1,y:0,width:0,height:0}),m=r(["react-flow__edge-textwrapper",h]),y=n.useRef(null);return n.useEffect((()=>{if(y.current){const e=y.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[i]),void 0!==i&&i?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...f,children:[a&&t.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:y,style:s,children:i}),d]}):null}Qs.displayName="EdgeText";const Js=n.memo(Qs);function ea({id:e,path:n,labelX:o,labelY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,className:p,interactionWidth:m=20}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{id:e,style:h,d:n,fill:"none",className:r(["react-flow__edge-path",p]),markerEnd:f,markerStart:g}),m&&t.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),s&&Ro(o)&&Ro(i)?t.jsx(Js,{x:o,y:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function ta({pos:t,x1:n,y1:o,x2:r,y2:i}){return t===e.Position.Left||t===e.Position.Right?[.5*(n+r),o]:[n,.5*(o+i)]}function na({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:s=e.Position.Top}){const[a,l]=ta({pos:o,x1:t,y1:n,x2:r,y2:i}),[c,u]=ta({pos:s,x1:r,y1:i,x2:t,y2:n}),[d,h,f,g]=Jo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${n} C${a},${l} ${c},${u} ${r},${i}`,d,h,f,g]}function oa(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})=>{const[w,b,S]=na({sourceX:r,sourceY:i,sourcePosition:l,targetX:s,targetY:a,targetPosition:c}),C=o.isInternal?void 0:n;return t.jsx(ea,{id:C,path:w,labelX:b,labelY:S,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})}))}const ra=oa({isInternal:!1}),ia=oa({isInternal:!0});function sa(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,sourcePosition:p=e.Position.Bottom,targetPosition:m=e.Position.Top,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,C]=dr({sourceX:r,sourceY:i,sourcePosition:p,targetX:s,targetY:a,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset}),E=o.isInternal?void 0:n;return t.jsx(ea,{id:E,path:b,labelX:S,labelY:C,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:v,interactionWidth:w})}))}ra.displayName="SimpleBezierEdge",ia.displayName="SimpleBezierEdgeInternal";const aa=sa({isInternal:!1}),la=sa({isInternal:!0});function ca(e){return n.memo((({id:o,...r})=>{const i=e.isInternal?void 0:o;return t.jsx(aa,{...r,id:i,pathOptions:n.useMemo((()=>({borderRadius:0,offset:r.pathOptions?.offset})),[r.pathOptions?.offset])})}))}aa.displayName="SmoothStepEdge",la.displayName="SmoothStepEdgeInternal";const ua=ca({isInternal:!1}),da=ca({isInternal:!0});function ha(e){return n.memo((({id:n,sourceX:o,sourceY:r,targetX:i,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})=>{const[y,v,x]=ar({sourceX:o,sourceY:r,targetX:i,targetY:s}),w=e.isInternal?void 0:n;return t.jsx(ea,{id:w,path:y,labelX:v,labelY:x,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})}))}ua.displayName="StepEdge",da.displayName="StepEdgeInternal";const fa=ha({isInternal:!1}),ga=ha({isInternal:!0});function pa(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:s,targetY:a,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,C]=nr({sourceX:r,sourceY:i,sourcePosition:l,targetX:s,targetY:a,targetPosition:c,curvature:x?.curvature}),E=o.isInternal?void 0:n;return t.jsx(ea,{id:E,path:b,labelX:S,labelY:C,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:w})}))}fa.displayName="StraightEdge",ga.displayName="StraightEdgeInternal";const ma=pa({isInternal:!1}),ya=pa({isInternal:!0});ma.displayName="BezierEdge",ya.displayName="BezierEdgeInternal";const va={default:ya,straight:ga,step:da,smoothstep:la,simplebezier:ia},xa={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},wa=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,ba=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,Sa="react-flow__edgeupdater";function Ca({position:e,centerX:n,centerY:o,radius:i=10,onMouseDown:s,onMouseEnter:a,onMouseOut:l,type:c}){return t.jsx("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:l,className:r([Sa,`${Sa}-${c}`]),cx:wa(n,i,e),cy:ba(o,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Ea({isReconnectable:e,reconnectRadius:n,edge:o,targetHandleId:r,sourceHandleId:i,sourceX:s,sourceY:a,targetX:l,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:g,setReconnecting:p,setUpdateHover:m}){const y=wi(),v=(e,t)=>{if(0!==e.button)return;const{autoPanOnConnect:n,domNode:s,isValidConnection:a,connectionMode:l,connectionRadius:c,lib:u,onConnectStart:d,onConnectEnd:m,cancelConnection:v,nodeLookup:x,rfId:w,panBy:b,updateConnection:S}=y.getState(),C=t?o.target:o.source,E=(t?r:i)||null,k=t?"target":"source",_=t;p(!0),f?.(e,o,k);Lr.onPointerDown(e.nativeEvent,{autoPanOnConnect:n,connectionMode:l,connectionRadius:c,domNode:s,handleId:E,nodeId:C,nodeLookup:x,isTarget:_,edgeUpdaterType:k,lib:u,flowId:w,cancelConnection:v,panBy:b,isValidConnection:a,onConnect:e=>h?.(o,e),onConnectStart:d,onConnectEnd:m,onReconnectEnd:(e,t)=>{p(!1),g?.(e,o,k,t)},updateConnection:S,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle})},x=()=>m(!0),w=()=>m(!1);return t.jsxs(t.Fragment,{children:[("source"===e||!0===e)&&t.jsx(Ca,{position:u,centerX:s,centerY:a,radius:n,onMouseDown:e=>v(e,!0),onMouseEnter:x,onMouseOut:w,type:"source"}),("target"===e||!0===e)&&t.jsx(Ca,{position:d,centerX:l,centerY:c,radius:n,onMouseDown:e=>v(e,!1),onMouseEnter:x,onMouseOut:w,type:"target"})]})}function ka({id:o,edgesFocusable:i,edgesReconnectable:s,elementsSelectable:a,onClick:l,onDoubleClick:c,onContextMenu:u,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,rfId:v,edgeTypes:x,noPanClassName:w,onError:b,disableKeyboardA11y:S}){let C=xi((e=>e.edgeLookup.get(o)));const E=xi((e=>e.defaultEdgeOptions));C=E?{...E,...C}:C;let k=C.type||"default",_=x?.[k]||va[k];void 0===_&&(b?.("011",Qn.error011(k)),k="default",_=va.default);const M=!!(C.focusable||i&&void 0===C.focusable),N=void 0!==p&&(C.reconnectable||s&&void 0===C.reconnectable),P=!!(C.selectable||a&&void 0===C.selectable),z=n.useRef(null),[O,A]=n.useState(!1),[I,R]=n.useState(!1),D=wi(),{zIndex:L,sourceX:$,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H}=xi(n.useCallback((t=>{const n=t.nodeLookup.get(C.source),r=t.nodeLookup.get(C.target);if(!n||!r)return{zIndex:C.zIndex,...xa};const i=function(t){const{sourceNode:n,targetNode:o}=t;if(!hr(n)||!hr(o))return null;const r=n.internals.handleBounds||fr(n.handles),i=o.internals.handleBounds||fr(o.handles),s=pr(r?.source??[],t.sourceHandle),a=pr(t.connectionMode===e.ConnectionMode.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),t.targetHandle);if(!s||!a)return t.onError?.("008",Qn.error008(s?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const l=s?.position||e.Position.Bottom,c=a?.position||e.Position.Top,u=gr(n,s,l),d=gr(o,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}({id:o,sourceNode:n,targetNode:r,sourceHandle:C.sourceHandle||null,targetHandle:C.targetHandle||null,connectionMode:t.connectionMode,onError:b}),s=function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1}){if(!r)return o;const i=n||t.selected||e.selected,s=Math.max(e.internals.z||0,t.internals.z||0,1e3);return o+(i?s:0)}({selected:C.selected,zIndex:C.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect});return{zIndex:s,...i||xa}}),[C.source,C.target,C.sourceHandle,C.targetHandle,C.selected,C.zIndex]),Ai),Z=n.useMemo((()=>C.markerStart?`url('#${mr(C.markerStart,v)}')`:void 0),[C.markerStart,v]),X=n.useMemo((()=>C.markerEnd?`url('#${mr(C.markerEnd,v)}')`:void 0),[C.markerEnd,v]);if(C.hidden||null===$||null===T||null===B||null===V)return null;const Y=c?e=>{c(e,{...C})}:void 0,W=u?e=>{u(e,{...C})}:void 0,F=d?e=>{d(e,{...C})}:void 0,K=h?e=>{h(e,{...C})}:void 0,G=f?e=>{f(e,{...C})}:void 0;return t.jsx("svg",{style:{zIndex:L},children:t.jsxs("g",{className:r(["react-flow__edge",`react-flow__edge-${k}`,C.className,w,{selected:C.selected,animated:C.animated,inactive:!P&&!l,updating:O,selectable:P}]),onClick:e=>{const{addSelectedEdges:t,unselectNodesAndEdges:n,multiSelectionActive:r}=D.getState();P&&(D.setState({nodesSelectionActive:!1}),C.selected&&r?(n({nodes:[],edges:[C]}),z.current?.blur()):t([o])),l&&l(e,C)},onDoubleClick:Y,onContextMenu:W,onMouseEnter:F,onMouseMove:K,onMouseLeave:G,onKeyDown:M?e=>{if(!S&&eo.includes(e.key)&&P){const{unselectNodesAndEdges:t,addSelectedEdges:n}=D.getState();"Escape"===e.key?(z.current?.blur(),t({edges:[C]})):n([o])}}:void 0,tabIndex:M?0:void 0,role:M?"button":"img","data-id":o,"data-testid":`rf__edge-${o}`,"aria-label":null===C.ariaLabel?void 0:C.ariaLabel||`Edge from ${C.source} to ${C.target}`,"aria-describedby":M?`${Ei}-${v}`:void 0,ref:z,children:[!I&&t.jsx(_,{id:o,source:C.source,target:C.target,type:C.type,selected:C.selected,animated:C.animated,selectable:P,deletable:C.deletable??!0,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,sourceX:$,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H,data:C.data,style:C.style,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerStart:Z,markerEnd:X,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth}),N&&t.jsx(Ea,{edge:C,isReconnectable:N,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,sourceX:$,sourceY:T,targetX:B,targetY:V,sourcePosition:j,targetPosition:H,setUpdateHover:A,setReconnecting:R,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle})]})})}const _a=e=>({width:e.width,height:e.height,edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ma({defaultMarkerColor:e,onlyRenderVisibleElements:o,rfId:r,edgeTypes:i,noPanClassName:s,onReconnect:a,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:h,reconnectRadius:f,onEdgeDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:y}){const{edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,onError:b}=xi(_a,Ai),S=(C=o,xi(n.useCallback((e=>{if(!C)return e.edges.map((e=>e.id));const t=[];if(e.width&&e.height)for(const n of e.edges){const o=e.nodeLookup.get(n.source),r=e.nodeLookup.get(n.target);o&&r&&rr({sourceNode:o,targetNode:r,width:e.width,height:e.height,transform:e.transform})&&t.push(n.id)}return t}),[C]),Ai));var C;return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(Us,{defaultColor:e,rfId:r}),S.map((e=>t.jsx(ka,{id:e,edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:l,onMouseEnter:c,onMouseMove:u,onMouseLeave:d,onClick:h,reconnectRadius:f,onDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,rfId:r,onError:b,edgeTypes:i,disableKeyboardA11y:y},e)))]})}Ma.displayName="EdgeRenderer";const Na=n.memo(Ma),Pa=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function za({children:e}){const n=xi(Pa);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}const Oa=e=>e.panZoom?.syncViewport;function Aa(e){return e.connection.inProgress?{...e.connection,to:$o(e.connection.to,e.transform)}:{...e.connection}}function Ia(e){const t=function(e){if(e)return t=>{const n=Aa(t);return e(n)};return Aa}(e);return xi(t,Ai)}const Ra=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Da({containerStyle:e,style:n,type:o,component:i}){const{nodesConnectable:s,width:a,height:l,isValid:c,inProgress:u}=xi(Ra,Ai);return!!(a&&s&&u)?t.jsx("svg",{style:e,width:a,height:l,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:r(["react-flow__connection",ho(c)]),children:t.jsx(La,{style:n,type:o,CustomComponent:i,isValid:c})})}):null}const La=({style:n,type:o=e.ConnectionLineType.Bezier,CustomComponent:r,isValid:i})=>{const{inProgress:s,from:a,fromNode:l,fromHandle:c,fromPosition:u,to:d,toNode:h,toHandle:f,toPosition:g}=Ia();if(!s)return;if(r)return t.jsx(r,{connectionLineType:o,connectionLineStyle:n,fromNode:l,fromHandle:c,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:u,toPosition:g,connectionStatus:ho(i),toNode:h,toHandle:f});let p="";const m={sourceX:a.x,sourceY:a.y,sourcePosition:u,targetX:d.x,targetY:d.y,targetPosition:g};switch(o){case e.ConnectionLineType.Bezier:[p]=nr(m);break;case e.ConnectionLineType.SimpleBezier:[p]=na(m);break;case e.ConnectionLineType.Step:[p]=dr({...m,borderRadius:0});break;case e.ConnectionLineType.SmoothStep:[p]=dr(m);break;default:[p]=ar(m)}return t.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:n})};La.displayName="ConnectionLine";const $a={};function Ta(e=$a){n.useRef(e),wi(),n.useEffect((()=>{}),[e])}function Ba({nodeTypes:e,edgeTypes:o,onInit:r,onNodeClick:i,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:g,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:x,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,multiSelectionKeyCode:C,panActivationKeyCode:E,zoomActivationKeyCode:k,deleteKeyCode:_,onlyRenderVisibleElements:M,elementsSelectable:N,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:A,preventScrolling:I,defaultMarkerColor:R,zoomOnScroll:D,zoomOnPinch:L,panOnScroll:$,panOnScrollSpeed:T,panOnScrollMode:B,zoomOnDoubleClick:V,panOnDrag:j,onPaneClick:H,onPaneMouseEnter:Z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneScroll:W,onPaneContextMenu:F,paneClickDistance:K,nodeClickDistance:G,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:Q,onEdgeMouseLeave:J,reconnectRadius:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:oe,noDragClassName:re,noWheelClassName:ie,noPanClassName:se,disableKeyboardA11y:ae,nodeExtent:le,rfId:ce,viewport:ue,onViewportChange:de}){return Ta(e),Ta(o),wi(),n.useRef(!1),n.useEffect((()=>{}),[]),function(e){const t=fs(),o=n.useRef(!1);n.useEffect((()=>{!o.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),o.current=!0)}),[e,t.viewportInitialized])}(r),function(e){const t=xi(Oa),o=wi();n.useEffect((()=>{e&&(t?.(e),o.setState({transform:[e.x,e.y,e.zoom]}))}),[e,t])}(ue),t.jsx(js,{onPaneClick:H,onPaneMouseEnter:Z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneContextMenu:F,onPaneScroll:W,paneClickDistance:K,deleteKeyCode:_,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:E,zoomActivationKeyCode:k,elementsSelectable:N,zoomOnScroll:D,zoomOnPinch:L,zoomOnDoubleClick:V,panOnScroll:$,panOnScrollSpeed:T,panOnScrollMode:B,panOnDrag:j,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:A,onSelectionContextMenu:f,preventScrolling:I,noDragClassName:re,noWheelClassName:ie,noPanClassName:se,disableKeyboardA11y:ae,onViewportChange:de,isControlledViewport:!!ue,children:t.jsxs(za,{children:[t.jsx(Na,{edgeTypes:o,onEdgeClick:s,onEdgeDoubleClick:l,onReconnect:te,onReconnectStart:ne,onReconnectEnd:oe,onlyRenderVisibleElements:M,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:Q,onEdgeMouseLeave:J,reconnectRadius:ee,defaultMarkerColor:R,noPanClassName:se,disableKeyboardA11y:ae,rfId:ce}),t.jsx(Da,{style:y,type:m,component:v,containerStyle:x}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(Fs,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,nodeClickDistance:G,onlyRenderVisibleElements:M,noPanClassName:se,noDragClassName:re,disableKeyboardA11y:ae,nodeExtent:le,rfId:ce}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}Ba.displayName="GraphView";const Va=n.memo(Ba),ja=({nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,nodeOrigin:l}={})=>{const c=new Map,u=new Map,d=new Map,h=new Map,f=r??n??[],g=o??t??[],p=l??[0,0];Er(d,h,f),wr(g,c,u,{nodeOrigin:p,elevateNodesOnSelect:!1});let m=[0,0,1];if(a&&i&&s){const e=mo(c,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),{x:t,y:n,zoom:o}=Bo(e,i,s,.5,2,.1);m=[t,n,o]}return{rfId:"1",width:0,height:0,transform:m,nodes:g,nodeLookup:c,parentLookup:u,edges:f,edgeLookup:h,connectionLookup:d,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==o,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:Jn,nodeExtent:Jn,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:e.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connection:{...ro},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanSpeed:15,connectionRadius:20,onError:Do,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},Ha=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,nodeOrigin:a})=>{return l=(l,c)=>({...ja({nodes:e,edges:t,width:r,height:i,fitView:s,nodeOrigin:a,defaultNodes:n,defaultEdges:o}),setNodes:e=>{const{nodeLookup:t,parentLookup:n,nodeOrigin:o,elevateNodesOnSelect:r}=c();wr(e,t,n,{nodeOrigin:o,elevateNodesOnSelect:r,checkEquality:!0}),l({nodes:e})},setEdges:e=>{const{connectionLookup:t,edgeLookup:n}=c();Er(t,n,e),l({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){const{setNodes:t}=c();t(e),l({hasDefaultNodes:!0})}if(t){const{setEdges:e}=c();e(t),l({hasDefaultEdges:!0})}},updateNodeInternals:(e,t={triggerFitView:!0})=>{const{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,fitViewOnInit:i,fitViewDone:s,fitViewOnInitOptions:a,domNode:u,nodeOrigin:d,debug:h,fitViewSync:f}=c(),{changes:g,updatedInternals:p}=function(e,t,n,o,r){const i=o?.querySelector(".xyflow__viewport");let s=!1;if(!i)return{changes:[],updatedInternals:s};const a=[],l=window.getComputedStyle(i),{m22:c}=new window.DOMMatrixReadOnly(l.transform),u=[];for(const o of e.values()){const e=t.get(o.id);if(e)if(e.hidden)e.internals={...e.internals,handleBounds:void 0},s=!0;else{const i=Wo(o.nodeElement),l=e.measured.width!==i.width||e.measured.height!==i.height;if(i.width&&i.height&&(l||!e.internals.handleBounds||o.force)){const d=o.nodeElement.getBoundingClientRect();e.measured=i,e.internals={...e.internals,positionAbsolute:po(e,r),handleBounds:{source:Qo("source",o.nodeElement,d,c,e.id),target:Qo("target",o.nodeElement,d,c,e.id)}},e.parentId&&br(e,t,n,{nodeOrigin:r}),s=!0,l&&(a.push({id:e.id,type:"dimensions",dimensions:i}),e.expandParent&&e.parentId&&u.push({id:e.id,parentId:e.parentId,rect:Po(e,r)}))}}}if(u.length>0){const e=Cr(u,t,n,r);a.push(...e)}return{changes:a,updatedInternals:s}}(e,o,r,u,d);if(p){if(function(e,t,n){const o={...vr,...n};for(const n of e.values())n.parentId&&br(n,e,t,o)}(o,r,{nodeOrigin:d}),t.triggerFitView){let e=s;!s&&i&&(e=f({...a,nodes:a?.nodes})),l({fitViewDone:e})}else l({});g?.length>0&&(h&&console.log("React Flow: trigger node changes",g),n?.(g))}},updateNodePositions:(e,t=!1)=>{const n=[],o=[];for(const[r,i]of e){const e={id:r,type:"position",position:i.position,dragging:t};i?.expandParent&&i?.parentId&&e.position&&(n.push({id:r,parentId:i.parentId,rect:{...i.internals.positionAbsolute,width:i.measured.width,height:i.measured.height}}),e.position.x=Math.max(0,e.position.x),e.position.y=Math.max(0,e.position.y)),o.push(e)}if(n.length>0){const{nodeLookup:e,parentLookup:t,nodeOrigin:r}=c(),i=Cr(n,e,t,r);o.push(...i)}c().triggerNodeChanges(o)},triggerNodeChanges:e=>{const{onNodesChange:t,setNodes:n,nodes:o,hasDefaultNodes:r,debug:i}=c();e?.length&&(r&&n(Ji(e,o)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{const{onEdgesChange:t,setEdges:n,edges:o,hasDefaultEdges:r,debug:i}=c();e?.length&&(r&&n(es(e,o)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c();t?r(e.map((e=>ts(e,!0)))):(r(ns(o,new Set([...e]),!0)),i(ns(n)))},addSelectedEdges:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c();t?i(e.map((e=>ts(e,!0)))):(i(ns(n,new Set([...e]))),r(ns(o,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{const{edges:n,nodes:o,triggerNodeChanges:r,triggerEdgeChanges:i}=c(),s=t||n,a=(e||o).map((e=>(e.selected=!1,ts(e.id,!1)))),l=s.map((e=>ts(e.id,!1)));r(a),i(l)},setMinZoom:e=>{const{panZoom:t,maxZoom:n}=c();t?.setScaleExtent([e,n]),l({minZoom:e})},setMaxZoom:e=>{const{panZoom:t,minZoom:n}=c();t?.setScaleExtent([n,e]),l({maxZoom:e})},setTranslateExtent:e=>{c().panZoom?.setTranslateExtent(e),l({translateExtent:e})},setPaneClickDistance:e=>{c().panZoom?.setClickDistance(e)},resetSelectedElements:()=>{const{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:o}=c(),r=t.reduce(((e,t)=>t.selected?[...e,ts(t.id,!1)]:e),[]),i=e.reduce(((e,t)=>t.selected?[...e,ts(t.id,!1)]:e),[]);n(r),o(i)},setNodeExtent:e=>{const{nodeLookup:t}=c();for(const[,n]of t){const o=Co(n.internals.positionAbsolute,e);t.set(n.id,{...n,internals:{...n.internals,positionAbsolute:o}})}l({nodeExtent:e})},panBy:e=>{const{transform:t,width:n,height:o,panZoom:r,translateExtent:i}=c();return async function({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)}({delta:e,panZoom:r,transform:t,translateExtent:i,width:n,height:o})},fitView:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeLookup:s}=c();return t?wo({nodes:xo(s,e),width:n,height:o,panZoom:t,minZoom:r,maxZoom:i},e):Promise.resolve(!1)},fitViewSync:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeLookup:s}=c();if(!t)return!1;const a=xo(s,e);return wo({nodes:a,width:n,height:o,panZoom:t,minZoom:r,maxZoom:i},e),a.size>0},cancelConnection:()=>{l({connection:{...ro}})},updateConnection:e=>{l({connection:e})},reset:()=>l({...ja()})}),c=Object.is,l?pi(l,c):pi;var l,c};function Za({initialNodes:e,initialEdges:o,defaultNodes:r,defaultEdges:i,initialWidth:s,initialHeight:a,fitView:l,nodeOrigin:c,children:u}){const[d]=n.useState((()=>Ha({nodes:e,edges:o,defaultNodes:r,defaultEdges:i,width:s,height:a,fitView:l,nodeOrigin:c})));return t.jsx(yi,{value:d,children:t.jsx(ds,{children:u})})}function Xa({children:e,nodes:o,edges:r,defaultNodes:i,defaultEdges:s,width:a,height:l,fitView:c,nodeOrigin:u}){return n.useContext(mi)?t.jsx(t.Fragment,{children:e}):t.jsx(Za,{initialNodes:o,initialEdges:r,defaultNodes:i,defaultEdges:s,initialWidth:a,initialHeight:l,fitView:c,nodeOrigin:u,children:e})}const Ya={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var Wa=as((function({nodes:o,edges:i,defaultNodes:s,defaultEdges:a,className:l,nodeTypes:c,edgeTypes:u,onNodeClick:d,onEdgeClick:h,onInit:f,onMove:g,onMoveStart:p,onMoveEnd:m,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:E,onNodeContextMenu:k,onNodeDoubleClick:_,onNodeDragStart:M,onNodeDrag:N,onNodeDragStop:P,onNodesDelete:z,onEdgesDelete:O,onDelete:A,onSelectionChange:I,onSelectionDragStart:R,onSelectionDrag:D,onSelectionDragStop:L,onSelectionContextMenu:$,onSelectionStart:T,onSelectionEnd:B,onBeforeDelete:V,connectionMode:j,connectionLineType:H=e.ConnectionLineType.Bezier,connectionLineStyle:Z,connectionLineComponent:X,connectionLineContainerStyle:Y,deleteKeyCode:W="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:K=!1,selectionMode:G=e.SelectionMode.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:U=(Vo()?"Meta":"Control"),zoomActivationKeyCode:Q=(Vo()?"Meta":"Control"),snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,nodeOrigin:se=Bi,edgesFocusable:ae,edgesReconnectable:le,elementsSelectable:ce=!0,defaultViewport:ue=Vi,minZoom:de=.5,maxZoom:he=2,translateExtent:fe=Jn,preventScrolling:ge=!0,nodeExtent:pe,defaultMarkerColor:me="#b1b1b7",zoomOnScroll:ye=!0,zoomOnPinch:ve=!0,panOnScroll:xe=!1,panOnScrollSpeed:we=.5,panOnScrollMode:be=e.PanOnScrollMode.Free,zoomOnDoubleClick:Se=!0,panOnDrag:Ce=!0,onPaneClick:Ee,onPaneMouseEnter:ke,onPaneMouseMove:_e,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:ze=0,nodeClickDistance:Oe=0,children:Ae,onReconnect:Ie,onReconnectStart:Re,onReconnectEnd:De,onEdgeContextMenu:Le,onEdgeDoubleClick:$e,onEdgeMouseEnter:Te,onEdgeMouseMove:Be,onEdgeMouseLeave:Ve,reconnectRadius:je=10,onNodesChange:He,onEdgesChange:Ze,noDragClassName:Xe="nodrag",noWheelClassName:Ye="nowheel",noPanClassName:We="nopan",fitView:Fe,fitViewOptions:Ke,connectOnClick:Ge,attributionPosition:qe,proOptions:Ue,defaultEdgeOptions:Qe,elevateNodesOnSelect:Je,elevateEdgesOnSelect:et,disableKeyboardA11y:tt=!1,autoPanOnConnect:nt,autoPanOnNodeDrag:ot,autoPanSpeed:rt,connectionRadius:it,isValidConnection:st,onError:at,style:lt,id:ct,nodeDragThreshold:ut,viewport:dt,onViewportChange:ht,width:ft,height:gt,colorMode:pt="light",debug:mt,...yt},vt){const xt=ct||"1",wt=function(e){const[t,o]=n.useState("system"===e?null:e);return n.useEffect((()=>{if("system"!==e)return void o(e);const t=Yi(),n=()=>o(t?.matches?"dark":"light");return n(),t?.addEventListener("change",n),()=>{t?.removeEventListener("change",n)}}),[e]),null!==t?t:Yi()?.matches?"dark":"light"}(pt);return t.jsx("div",{...yt,style:{...lt,...Ya},ref:vt,className:r(["react-flow",l,wt]),"data-testid":"rf__wrapper",id:ct,children:t.jsxs(Xa,{nodes:o,edges:i,width:ft,height:gt,fitView:Fe,nodeOrigin:se,children:[t.jsx(Va,{onInit:f,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:E,onNodeContextMenu:k,onNodeDoubleClick:_,nodeTypes:c,edgeTypes:u,connectionLineType:H,connectionLineStyle:Z,connectionLineComponent:X,connectionLineContainerStyle:Y,selectionKeyCode:F,selectionOnDrag:K,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:U,panActivationKeyCode:q,zoomActivationKeyCode:Q,onlyRenderVisibleElements:te,defaultViewport:ue,translateExtent:fe,minZoom:de,maxZoom:he,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:ve,zoomOnDoubleClick:Se,panOnScroll:xe,panOnScrollSpeed:we,panOnScrollMode:be,panOnDrag:Ce,onPaneClick:Ee,onPaneMouseEnter:ke,onPaneMouseMove:_e,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:ze,nodeClickDistance:Oe,onSelectionContextMenu:$,onSelectionStart:T,onSelectionEnd:B,onReconnect:Ie,onReconnectStart:Re,onReconnectEnd:De,onEdgeContextMenu:Le,onEdgeDoubleClick:$e,onEdgeMouseEnter:Te,onEdgeMouseMove:Be,onEdgeMouseLeave:Ve,reconnectRadius:je,defaultMarkerColor:me,noDragClassName:Xe,noWheelClassName:Ye,noPanClassName:We,rfId:xt,disableKeyboardA11y:tt,nodeExtent:pe,viewport:dt,onViewportChange:ht}),t.jsx(Xi,{nodes:o,edges:i,defaultNodes:s,defaultEdges:a,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,edgesFocusable:ae,edgesReconnectable:le,elementsSelectable:ce,elevateNodesOnSelect:Je,elevateEdgesOnSelect:et,minZoom:de,maxZoom:he,nodeExtent:pe,onNodesChange:He,onEdgesChange:Ze,snapToGrid:J,snapGrid:ee,connectionMode:j,translateExtent:fe,connectOnClick:Ge,defaultEdgeOptions:Qe,fitView:Fe,fitViewOptions:Ke,onNodesDelete:z,onEdgesDelete:O,onDelete:A,onNodeDragStart:M,onNodeDrag:N,onNodeDragStop:P,onSelectionDrag:D,onSelectionDragStart:R,onSelectionDragStop:L,onMove:g,onMoveStart:p,onMoveEnd:m,noPanClassName:We,nodeOrigin:se,rfId:xt,autoPanOnConnect:nt,autoPanOnNodeDrag:ot,autoPanSpeed:rt,onError:at,connectionRadius:it,isValidConnection:st,selectNodesOnDrag:ne,nodeDragThreshold:ut,onBeforeDelete:V,paneClickDistance:ze,debug:mt}),t.jsx(Ti,{onSelectionChange:I}),Ae,t.jsx(Oi,{proOptions:Ue,position:qe}),t.jsx(Ni,{rfId:xt,disableKeyboardA11y:tt})]})})}));const Fa=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");const Ka=e=>e.domNode?.querySelector(".react-flow__viewport-portal");const Ga=e=>e.nodes;const qa=e=>e.edges;const Ua=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});const Qa={includeHiddenNodes:!1};function Ja({dimensions:e,lineWidth:n,variant:o,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:r(["react-flow__background-pattern",o,i])})}function el({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:r(["react-flow__background-pattern","dots",n])})}var tl;e.BackgroundVariant=void 0,(tl=e.BackgroundVariant||(e.BackgroundVariant={})).Lines="lines",tl.Dots="dots",tl.Cross="cross";const nl={[e.BackgroundVariant.Dots]:1,[e.BackgroundVariant.Lines]:1,[e.BackgroundVariant.Cross]:6},ol=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function rl({id:o,variant:i=e.BackgroundVariant.Dots,gap:s=20,size:a,lineWidth:l=1,offset:c=0,color:u,bgColor:d,style:h,className:f,patternClassName:g}){const p=n.useRef(null),{transform:m,patternId:y}=xi(ol,Ai),v=a||nl[i],x=i===e.BackgroundVariant.Dots,w=i===e.BackgroundVariant.Cross,b=Array.isArray(s)?s:[s,s],S=[b[0]*m[2]||1,b[1]*m[2]||1],C=v*m[2],E=Array.isArray(c)?c:[c,c],k=[E[0]*m[2]||1,E[1]*m[2]||1],_=w?[C,C]:S,M=`${y}${o||""}`;return t.jsxs("svg",{className:r(["react-flow__background",f]),style:{...h,...ys,"--xy-background-color-props":d,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:M,x:m[0]%S[0],y:m[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:x?t.jsx(el,{radius:C/2,className:g}):t.jsx(Ja,{dimensions:_,lineWidth:l,variant:i,className:g})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}rl.displayName="Background";const il=n.memo(rl);function sl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function al(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ll(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.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 cl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 ul(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.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 dl({children:e,className:n,...o}){return t.jsx("button",{type:"button",className:r(["react-flow__controls-button",n]),...o,children:e})}const hl=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function fl({style:e,showZoom:n=!0,showFitView:o=!0,showInteractive:i=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:l,onFitView:c,onInteractiveChange:u,className:d,children:h,position:f="bottom-left",orientation:g="vertical","aria-label":p="React Flow controls"}){const m=wi(),{isInteractive:y,minZoomReached:v,maxZoomReached:x}=xi(hl,Ai),{zoomIn:w,zoomOut:b,fitView:S}=fs(),C="horizontal"===g?"horizontal":"vertical";return t.jsxs(zi,{className:r(["react-flow__controls",C,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(dl,{onClick:()=>{w(),a?.()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x,children:t.jsx(sl,{})}),t.jsx(dl,{onClick:()=>{b(),l?.()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:t.jsx(al,{})})]}),o&&t.jsx(dl,{className:"react-flow__controls-fitview",onClick:()=>{S(s),c?.()},title:"fit view","aria-label":"fit view",children:t.jsx(ll,{})}),i&&t.jsx(dl,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),u?.(!y)},title:"toggle interactivity","aria-label":"toggle interactivity",children:y?t.jsx(ul,{}):t.jsx(cl,{})}),h]})}fl.displayName="Controls";const gl=n.memo(fl);const pl=n.memo((function({id:e,x:n,y:o,width:i,height:s,style:a,color:l,strokeColor:c,strokeWidth:u,className:d,borderRadius:h,shapeRendering:f,selected:g,onClick:p}){const{background:m,backgroundColor:y}=a||{},v=l||m||y;return t.jsx("rect",{className:r(["react-flow__minimap-node",{selected:g},d]),x:n,y:o,rx:h,ry:h,width:i,height:s,style:{fill:v,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?t=>p(t,e):void 0})})),ml=e=>e.nodes.map((e=>e.id)),yl=e=>e instanceof Function?e:()=>e;const vl=n.memo((function({id:e,nodeColorFunc:n,nodeStrokeColorFunc:o,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:h}=xi((t=>{const n=t.nodeLookup.get(e),{x:o,y:r}=n.internals.positionAbsolute;return{node:n,x:o,y:r}}),Ai);if(!u||u.hidden||!Zo(u))return null;const{width:f,height:g}=Ho(u);return t.jsx(l,{x:d,y:h,width:f,height:g,style:u.style,selected:!!u.selected,className:r(u),color:n(u),borderRadius:i,strokeColor:o(u),strokeWidth:s,shapeRendering:a,onClick:c,id:u.id})}));var xl=n.memo((function({nodeStrokeColor:e,nodeColor:n,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:s=pl,onClick:a}){const l=xi(ml,Ai),c=yl(n),u=yl(e),d=yl(o),h="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:l.map((e=>t.jsx(vl,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:s,onClick:a,shapeRendering:h},e)))})}));const wl=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?Oo(mo(e.nodeLookup),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}};function bl({style:e,className:o,nodeStrokeColor:i,nodeColor:s,nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:g,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:x=!1,ariaLabel:w="React Flow mini map",inversePan:b,zoomStep:S=10,offsetScale:C=5}){const E=wi(),k=n.useRef(null),{boundingRect:_,viewBB:M,rfId:N,panZoom:P,translateExtent:z,flowWidth:O,flowHeight:A}=xi(wl,Ai),I=e?.width??200,R=e?.height??150,D=_.width/I,L=_.height/R,$=Math.max(D,L),T=$*I,B=$*R,V=C*$,j=_.x-(T-_.width)/2-V,H=_.y-(B-_.height)/2-V,Z=T+2*V,X=B+2*V,Y=`react-flow__minimap-desc-${N}`,W=n.useRef(0),F=n.useRef();W.current=$,n.useEffect((()=>{if(k.current&&P)return F.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Se(e);return{update:function({translateExtent:e,width:i,height:s,zoomStep:a=10,pannable:l=!0,zoomable:c=!0,inversePan:u=!1}){let d=[0,0];const h=Un().on("start",(e=>{"mousedown"!==e.sourceEvent.type&&"touchstart"!==e.sourceEvent.type||(d=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])})).on("zoom",l?r=>{const a=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!t)return;const l=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],c=[l[0]-d[0],l[1]-d[1]];d=l;const h=o()*Math.max(a[2],Math.log(a[2]))*(u?-1:1),f={x:a[0]-c[0]*h,y:a[1]-c[1]*h},g=[[0,0],[i,s]];t.setViewportConstrained({x:f.x,y:f.y,zoom:a[2]},g,e)}:null).on("zoom.wheel",c?e=>{const o=n();if("wheel"!==e.sourceEvent.type||!t)return;const r=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*a,i=o[2]*Math.pow(2,r);t.scaleTo(i)}:null);r.call(h,{})},destroy:function(){r.on("zoom",null)},pointer:Ce}}({domNode:k.current,panZoom:P,getTransform:()=>E.getState().transform,getViewScale:()=>W.current}),()=>{F.current?.destroy()}}),[P]),n.useEffect((()=>{F.current?.update({translateExtent:z,width:O,height:A,inversePan:b,pannable:v,zoomStep:S,zoomable:x})}),[v,x,b,S,z,O,A]);const K=m?e=>{const[t,n]=F.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,G=y?n.useCallback(((e,t)=>{const n=E.getState().nodeLookup.get(t);y(e,n)}),[]):void 0;return t.jsx(zi,{position:p,style:{...e,"--xy-minimap-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof h?h:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof f?f:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof g?g*$:void 0,"--xy-minimap-node-background-color-props":"string"==typeof s?s:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof i?i:void 0,"--xy-minimap-node-stroke-width-props":"string"==typeof c?c:void 0},className:r(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:I,height:R,viewBox:`${j} ${H} ${Z} ${X}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:k,onClick:K,children:[w&&t.jsx("title",{id:Y,children:w}),t.jsx(xl,{onClick:G,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:u}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${j-V},${H-V}h${Z+2*V}v${X+2*V}h${-Z-2*V}z\n M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}bl.displayName="MiniMap";const Sl=n.memo(bl);const Cl=n.memo((function({nodeId:e,position:o,variant:i=Yr.Handle,className:s,style:a={},children:l,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:g=!1,shouldResize:p,onResizeStart:m,onResize:y,onResizeEnd:v}){const x=Os(),w="string"==typeof e?e:x,b=wi(),S=n.useRef(null),C=i===Yr.Line?"right":"bottom-right",E=o??C,k=n.useRef(null);n.useEffect((()=>{if(S.current&&w)return k.current||(k.current=ti({domNode:S.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}},onChange:(e,t)=>{const{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,nodeOrigin:i}=b.getState(),s=[],a={x:e.x,y:e.y},l=o.get(w);if(l&&l.expandParent&&l.parentId){const t=l.origin??i,n=e.width??l.measured.width,c=e.height??l.measured.height,u=Cr([{id:l.id,parentId:l.parentId,rect:{width:n,height:c,...Xo({x:e.x??l.position.x,y:e.y??l.position.y},{width:n,height:c},l.parentId,o,t)}}],o,r,i);s.push(...u),a.x=e.x?Math.max(t[0]*n,e.x):void 0,a.y=e.y?Math.max(t[1]*c,e.y):void 0}if(void 0!==a.x&&void 0!==a.y){const e={id:w,type:"position",position:{...a}};s.push(e)}if(void 0!==e.width&&void 0!==e.height){const t={id:w,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:e.width,height:e.height}};s.push(t)}for(const e of t){const t={...e,type:"position"};s.push(t)}n(s)},onEnd:()=>{const e={id:w,type:"dimensions",resizing:!1};b.getState().triggerNodeChanges([e])}})),k.current.update({controlPosition:E,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:g,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:p}),()=>{k.current?.destroy()}}),[E,u,d,h,f,g,m,y,v,p]);const _=E.split("-"),M=i===Yr.Line?"borderColor":"backgroundColor",N=c?{...a,[M]:c}:a;return t.jsx("div",{className:r(["react-flow__resize-control","nodrag",..._,i,s]),ref:S,style:N,children:l})}));const El=e=>e.domNode?.querySelector(".react-flow__renderer");function kl({children:e}){const t=xi(El);return t?o.createPortal(e,t):null}const _l=(e,t)=>e?.internals.positionAbsolute.x!==t?.internals.positionAbsolute.x||e?.internals.positionAbsolute.y!==t?.internals.positionAbsolute.y||e?.measured.width!==t?.measured.width||e?.measured.height!==t?.measured.height||e?.selected!==t?.selected||e?.internals.z!==t?.internals.z,Ml=(e,t)=>{if(e.size!==t.size)return!1;for(const[n,o]of e)if(_l(o,t.get(n)))return!1;return!0},Nl=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2],selectedNodesCount:e.nodes.filter((e=>e.selected)).length});e.Background=il,e.BaseEdge=ea,e.BezierEdge=ma,e.ControlButton=dl,e.Controls=gl,e.EdgeLabelRenderer=function({children:e}){const t=xi(Fa);return t?o.createPortal(e,t):null},e.EdgeText=Js,e.Handle=Is,e.MiniMap=Sl,e.NodeResizeControl=Cl,e.NodeResizer=function({nodeId:e,isVisible:n=!0,handleClassName:o,handleStyle:r,lineClassName:i,lineStyle:s,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:h=!1,shouldResize:f,onResizeStart:g,onResize:p,onResizeEnd:m}){return n?t.jsxs(t.Fragment,{children:[Fr.map((n=>t.jsx(Cl,{className:i,style:s,nodeId:e,position:n,variant:Yr.Line,color:a,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n))),Wr.map((n=>t.jsx(Cl,{className:o,style:r,nodeId:e,position:n,color:a,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n)))]}):null},e.NodeToolbar=function({nodeId:o,children:i,className:s,style:a,isVisible:l,position:c=e.Position.Top,offset:u=10,align:d="center",...h}){const f=Os(),g=n.useCallback((e=>{const t=(Array.isArray(o)?o:[o||f||""]).reduce(((t,n)=>{const o=e.nodeLookup.get(n);return o&&t.set(o.id,o),t}),new Map);return t}),[o,f]),p=xi(g,Ml),{x:m,y:y,zoom:v,selectedNodesCount:x}=xi(Nl,Ai);if(!("boolean"==typeof l?l:1===p.size&&p.values().next().value.selected&&1===x)||!p.size)return null;const w=mo(p),b=Array.from(p.values()),S=Math.max(...b.map((e=>e.internals.z+1))),C={position:"absolute",transform:yr(w,{x:m,y:y,zoom:v},c,u,d),zIndex:S,...a};return t.jsx(kl,{children:t.jsx("div",{style:C,className:r(["react-flow__node-toolbar",s]),...h,"data-id":b.reduce(((e,t)=>`${e}${t.id} `),"").trim(),children:i})})},e.Panel=zi,e.ReactFlow=Wa,e.ReactFlowProvider=Za,e.SimpleBezierEdge=ra,e.SmoothStepEdge=aa,e.StepEdge=ua,e.StraightEdge=fa,e.ViewportPortal=function({children:e}){const t=xi(Ka);return t?o.createPortal(e,t):null},e.addEdge=sr,e.applyEdgeChanges=es,e.applyNodeChanges=Ji,e.getBezierEdgeCenter=Jo,e.getBezierPath=nr,e.getConnectedEdges=vo,e.getEdgeCenter=or,e.getIncomers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.target===e.id&&o.add(t.source)})),t.filter((e=>o.has(e.id)))},e.getNodesBounds=(e,t={nodeOrigin:[0,0]})=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const o=zo(n,t.nodeOrigin);return _o(e,o)}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return No(n)},e.getOutgoers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.source===e.id&&o.add(t.target)})),t.filter((e=>o.has(e.id)))},e.getSimpleBezierPath=na,e.getSmoothStepPath=dr,e.getStraightPath=ar,e.getViewportForBounds=Bo,e.isEdge=ss,e.isNode=is,e.reconnectEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return n;if(!n.find((t=>t.id===e.id)))return n;const s={...i,id:o.shouldReplaceId?ir(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter((e=>e.id!==r)).concat(s)},e.useConnection=Ia,e.useEdges=function(){return xi(qa,Ai)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>es(e,t)))),[]);return[t,o,r]},e.useHandleConnections=function({type:e,id:t=null,nodeId:o,onConnect:r,onDisconnect:i}){const s=Os(),a=o??s,l=n.useRef(null),c=xi((n=>n.connectionLookup.get(`${a}-${e}-${t}`)),co);return n.useEffect((()=>{if(l.current&&l.current!==c){const e=c??new Map;uo(l.current,e,i),uo(e,l.current,r)}l.current=c??new Map}),[c,r,i]),n.useMemo((()=>Array.from(c?.values()??[])),[c])},e.useInternalNode=function(e){return xi(n.useCallback((t=>t.nodeLookup.get(e)),[e]),Ai)},e.useKeyPress=Fi,e.useNodeId=Os,e.useNodes=function(){return xi(Ga,Ai)},e.useNodesData=function(e){return xi(n.useCallback((t=>{const n=[],o=Array.isArray(e),r=o?e:[e];for(const e of r){const o=t.nodeLookup.get(e);o&&n.push({id:o.id,type:o.type,data:o.data})}return o?n:n[0]??null}),[e]),kr)},e.useNodesInitialized=function(e=Qa){return xi((e=>t=>{if(0===t.nodeLookup.size)return!1;for(const[,{hidden:n,internals:o}]of t.nodeLookup)if((e.includeHiddenNodes||!n)&&(void 0===o.handleBounds||!Zo(o.userNode)))return!1;return!0})(e))},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Ji(e,t)))),[]);return[t,o,r]},e.useOnSelectionChange=function({onChange:e}){const t=wi();n.useEffect((()=>{const n=[...t.getState().onSelectionChangeHandlers,e];return t.setState({onSelectionChangeHandlers:n}),()=>{const n=t.getState().onSelectionChangeHandlers.filter((t=>t!==e));t.setState({onSelectionChangeHandlers:n})}}),[e])},e.useOnViewportChange=function({onStart:e,onChange:t,onEnd:o}){const r=wi();n.useEffect((()=>{r.setState({onViewportChangeStart:e})}),[e]),n.useEffect((()=>{r.setState({onViewportChange:t})}),[t]),n.useEffect((()=>{r.setState({onViewportChangeEnd:o})}),[o])},e.useReactFlow=fs,e.useStore=xi,e.useStoreApi=wi,e.useUpdateNodeInternals=function(){const e=wi();return n.useCallback((t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],i=new Map;r.forEach((e=>{const t=n?.querySelector(`.react-flow__node[data-id="${e}"]`);t&&i.set(e,{id:e,nodeElement:t,force:!0})})),requestAnimationFrame((()=>o(i,{triggerFitView:!1})))}),[])},e.useViewport=function(){return xi(Ua,Ai)}}));
|