import{r as $,g as ia,b as R,c as oa}from"./@radix-DP6vWzyx.js";function ht(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=ht(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var Hi={exports:{}},Oi={},Li={exports:{}},Vi={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var pe=$;function sa(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var aa=typeof Object.is=="function"?Object.is:sa,ca=pe.useState,la=pe.useEffect,ua=pe.useLayoutEffect,fa=pe.useDebugValue;function ha(t,e){var n=e(),r=ca({inst:{value:n,getSnapshot:e}}),i=r[0].inst,o=r[1];return ua(function(){i.value=n,i.getSnapshot=e,zn(i)&&o({inst:i})},[t,n,e]),la(function(){return zn(i)&&o({inst:i}),t(function(){zn(i)&&o({inst:i})})},[t]),fa(n),n}function zn(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!aa(t,n)}catch{return!0}}function da(t,e){return e()}var pa=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?da:ha;Vi.useSyncExternalStore=pe.useSyncExternalStore!==void 0?pe.useSyncExternalStore:pa;Li.exports=Vi;var ga=Li.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var En=$,ma=ga;function ya(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var va=typeof Object.is=="function"?Object.is:ya,wa=ma.useSyncExternalStore,xa=En.useRef,ba=En.useEffect,_a=En.useMemo,Sa=En.useDebugValue;Oi.useSyncExternalStoreWithSelector=function(t,e,n,r,i){var o=xa(null);if(o.current===null){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=_a(function(){function c(p){if(!l){if(l=!0,u=p,p=r(p),i!==void 0&&s.hasValue){var x=s.value;if(i(x,p))return f=x}return f=p}if(x=f,va(u,p))return x;var m=r(p);return i!==void 0&&i(x,m)?x:(u=p,f=m)}var l=!1,u,f,d=n===void 0?null:n;return[function(){return c(e())},d===null?void 0:function(){return c(d())}]},[e,n,r,i]);var a=wa(t,o[0],o[1]);return ba(function(){s.hasValue=!0,s.value=a},[a]),Sa(a),a};Hi.exports=Oi;var Ea=Hi.exports;const Na=ia(Ea),Aa={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_BASE_URL:"/api/v1",VITE_FEATURE_OS_KEY:"4rE42v3X6L4k0UCiA-Ot7g",VITE_FRONTEND_VERSION:"v0.27.2"},Vr=t=>{let e;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(e):u;if(!Object.is(d,e)){const p=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(x=>x(e,p))}},i=()=>e,c={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Aa?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=e=t(r,i,c);return c},Ma=t=>t?Vr(t):Vr,{useDebugValue:ka}=R,{useSyncExternalStoreWithSelector:$a}=Na,Ca=t=>t;function Yi(t,e=Ca,n){const r=$a(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return ka(r),r}const Yr=(t,e)=>{const n=Ma(t),r=(i,o=e)=>Yi(n,i,o);return Object.assign(r,n),r},Ia=(t,e)=>t?Yr(t,e):Yr;function it(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,i]of t)if(!Object.is(i,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var Ta={value:()=>{}};function Nn(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new sn(n)}function sn(t){this._=t}function Da(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}sn.prototype=Nn.prototype={constructor:sn,on:function(t,e){var n=this._,r=Da(t+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(t=r[o]).type)&&(i=Pa(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<s;)if(i=(t=r[o]).type)n[i]=Xr(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Xr(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new sn(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function Pa(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Xr(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Ta,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Qn="http://www.w3.org/1999/xhtml";const Ur={svg:"http://www.w3.org/2000/svg",xhtml:Qn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function An(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ur.hasOwnProperty(e)?{space:Ur[e],local:t}:t}function Fa(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Qn&&e.documentElement.namespaceURI===Qn?e.createElement(t):e.createElementNS(n,t)}}function za(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Xi(t){var e=An(t);return(e.local?za:Fa)(e)}function Ra(){}function mr(t){return t==null?Ra:function(){return this.querySelector(t)}}function Wa(t){typeof t!="function"&&(t=mr(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=new Array(s),c,l,u=0;u<s;++u)(c=o[u])&&(l=t.call(c,c.__data__,u,o))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new at(r,this._parents)}function Ba(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Ha(){return[]}function Ui(t){return t==null?Ha:function(){return this.querySelectorAll(t)}}function Oa(t){return function(){return Ba(t.apply(this,arguments))}}function La(t){typeof t=="function"?t=Oa(t):t=Ui(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s=e[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(r.push(t.call(c,c.__data__,l,s)),i.push(c));return new at(r,i)}function Gi(t){return function(){return this.matches(t)}}function qi(t){return function(e){return e.matches(t)}}var Va=Array.prototype.find;function Ya(t){return function(){return Va.call(this.children,t)}}function Xa(){return this.firstElementChild}function Ua(t){return this.select(t==null?Xa:Ya(typeof t=="function"?t:qi(t)))}var Ga=Array.prototype.filter;function qa(){return Array.from(this.children)}function Za(t){return function(){return Ga.call(this.children,t)}}function Ka(t){return this.selectAll(t==null?qa:Za(typeof t=="function"?t:qi(t)))}function Ja(t){typeof t!="function"&&(t=Gi(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=[],c,l=0;l<s;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new at(r,this._parents)}function Zi(t){return new Array(t.length)}function Qa(){return new at(this._enter||this._groups.map(Zi),this._parents)}function un(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}un.prototype={constructor:un,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function ja(t){return function(){return t}}function tc(t,e,n,r,i,o){for(var s=0,a,c=e.length,l=o.length;s<l;++s)(a=e[s])?(a.__data__=o[s],r[s]=a):n[s]=new un(t,o[s]);for(;s<c;++s)(a=e[s])&&(i[s]=a)}function ec(t,e,n,r,i,o,s){var a,c,l=new Map,u=e.length,f=o.length,d=new Array(u),p;for(a=0;a<u;++a)(c=e[a])&&(d[a]=p=s.call(c,c.__data__,a,e)+"",l.has(p)?i[a]=c:l.set(p,c));for(a=0;a<f;++a)p=s.call(t,o[a],a,o)+"",(c=l.get(p))?(r[a]=c,c.__data__=o[a],l.delete(p)):n[a]=new un(t,o[a]);for(a=0;a<u;++a)(c=e[a])&&l.get(d[a])===c&&(i[a]=c)}function nc(t){return t.__data__}function rc(t,e){if(!arguments.length)return Array.from(this,nc);var n=e?ec:tc,r=this._parents,i=this._groups;typeof t!="function"&&(t=ja(t));for(var o=i.length,s=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var u=r[l],f=i[l],d=f.length,p=ic(t.call(u,u&&u.__data__,l,r)),x=p.length,m=a[l]=new Array(x),g=s[l]=new Array(x),h=c[l]=new Array(d);n(u,f,m,g,h,p,e);for(var v=0,b=0,w,_;v<x;++v)if(w=m[v]){for(v>=b&&(b=v+1);!(_=g[b])&&++b<x;);w._next=_||null}}return s=new at(s,r),s._enter=a,s._exit=c,s}function ic(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function oc(){return new at(this._exit||this._groups.map(Zi),this._parents)}function sc(t,e,n){var r=this.enter(),i=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function ac(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),c=0;c<s;++c)for(var l=n[c],u=r[c],f=l.length,d=a[c]=new Array(f),p,x=0;x<f;++x)(p=l[x]||u[x])&&(d[x]=p);for(;c<i;++c)a[c]=n[c];return new at(a,this._parents)}function cc(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,o=r[i],s;--i>=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function lc(t){t||(t=uc);function e(f,d){return f&&d?t(f.__data__,d.__data__):!f-!d}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s=n[o],a=s.length,c=i[o]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(e)}return new at(i,this._parents).order()}function uc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function fc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function hc(){return Array.from(this)}function dc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null}function pc(){let t=0;for(const e of this)++t;return t}function gc(){return!this.node()}function mc(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,s=i.length,a;o<s;++o)(a=i[o])&&t.call(a,a.__data__,o,i);return this}function yc(t){return function(){this.removeAttribute(t)}}function vc(t){return function(){this.removeAttributeNS(t.space,t.local)}}function wc(t,e){return function(){this.setAttribute(t,e)}}function xc(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function bc(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function _c(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Sc(t,e){var n=An(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?vc:yc:typeof e=="function"?n.local?_c:bc:n.local?xc:wc)(n,e))}function Ki(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Ec(t){return function(){this.style.removeProperty(t)}}function Nc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Ac(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Mc(t,e,n){return arguments.length>1?this.each((e==null?Ec:typeof e=="function"?Ac:Nc)(t,e,n??"")):ge(this.node(),t)}function ge(t,e){return t.style.getPropertyValue(e)||Ki(t).getComputedStyle(t,null).getPropertyValue(e)}function kc(t){return function(){delete this[t]}}function $c(t,e){return function(){this[t]=e}}function Cc(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Ic(t,e){return arguments.length>1?this.each((e==null?kc:typeof e=="function"?Cc:$c)(t,e)):this.node()[t]}function Ji(t){return t.trim().split(/^|\s+/)}function yr(t){return t.classList||new Qi(t)}function Qi(t){this._node=t,this._names=Ji(t.getAttribute("class")||"")}Qi.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function ji(t,e){for(var n=yr(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function to(t,e){for(var n=yr(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Tc(t){return function(){ji(this,t)}}function Dc(t){return function(){to(this,t)}}function Pc(t,e){return function(){(e.apply(this,arguments)?ji:to)(this,t)}}function Fc(t,e){var n=Ji(t+"");if(arguments.length<2){for(var r=yr(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?Pc:e?Tc:Dc)(n,e))}function zc(){this.textContent=""}function Rc(t){return function(){this.textContent=t}}function Wc(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Bc(t){return arguments.length?this.each(t==null?zc:(typeof t=="function"?Wc:Rc)(t)):this.node().textContent}function Hc(){this.innerHTML=""}function Oc(t){return function(){this.innerHTML=t}}function Lc(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Vc(t){return arguments.length?this.each(t==null?Hc:(typeof t=="function"?Lc:Oc)(t)):this.node().innerHTML}function Yc(){this.nextSibling&&this.parentNode.appendChild(this)}function Xc(){return this.each(Yc)}function Uc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Gc(){return this.each(Uc)}function qc(t){var e=typeof t=="function"?t:Xi(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Zc(){return null}function Kc(t,e){var n=typeof t=="function"?t:Xi(t),r=e==null?Zc:typeof e=="function"?e:mr(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Jc(){var t=this.parentNode;t&&t.removeChild(this)}function Qc(){return this.each(Jc)}function jc(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function tl(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function el(t){return this.select(t?tl:jc)}function nl(t){return arguments.length?this.property("__data__",t):this.node().__data__}function rl(t){return function(e){t.call(this,e,this.__data__)}}function il(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function ol(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,o;n<i;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function sl(t,e,n){return function(){var r=this.__on,i,o=rl(e);if(r){for(var s=0,a=r.length;s<a;++s)if((i=r[s]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=e;return}}this.addEventListener(t.type,o,n),i={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(i):this.__on=[i]}}function al(t,e,n){var r=il(t+""),i,o=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(i=0,u=a[c];i<o;++i)if((s=r[i]).type===u.type&&s.name===u.name)return u.value}return}for(a=e?sl:ol,i=0;i<o;++i)this.each(a(r[i],e,n));return this}function eo(t,e,n){var r=Ki(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function cl(t,e){return function(){return eo(this,t,e)}}function ll(t,e){return function(){return eo(this,t,e.apply(this,arguments))}}function ul(t,e){return this.each((typeof e=="function"?ll:cl)(t,e))}function*fl(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length,s;i<o;++i)(s=r[i])&&(yield s)}var no=[null];function at(t,e){this._groups=t,this._parents=e}function He(){return new at([[document.documentElement]],no)}function hl(){return this}at.prototype=He.prototype={constructor:at,select:Wa,selectAll:La,selectChild:Ua,selectChildren:Ka,filter:Ja,data:rc,enter:Qa,exit:oc,join:sc,merge:ac,selection:hl,order:cc,sort:lc,call:fc,nodes:hc,node:dc,size:pc,empty:gc,each:mc,attr:Sc,style:Mc,property:Ic,classed:Fc,text:Bc,html:Vc,raise:Xc,lower:Gc,append:qc,insert:Kc,remove:Qc,clone:el,datum:nl,on:al,dispatch:ul,[Symbol.iterator]:fl};function yt(t){return typeof t=="string"?new at([[document.querySelector(t)]],[document.documentElement]):new at([[t]],no)}function dl(t){let e;for(;e=t.sourceEvent;)t=e;return t}function _t(t,e){if(t=dl(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const pl={passive:!1},De={capture:!0,passive:!1};function Rn(t){t.stopImmediatePropagation()}function le(t){t.preventDefault(),t.stopImmediatePropagation()}function ro(t){var e=t.document.documentElement,n=yt(t).on("dragstart.drag",le,De);"onselectstart"in e?n.on("selectstart.drag",le,De):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function io(t,e){var n=t.document.documentElement,r=yt(t).on("dragstart.drag",null);e&&(r.on("click.drag",le,De),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ye=t=>()=>t;function jn(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}jn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function gl(t){return!t.ctrlKey&&!t.button}function ml(){return this.parentNode}function yl(t,e){return e??{x:t.x,y:t.y}}function vl(){return navigator.maxTouchPoints||"ontouchstart"in this}function wl(){var t=gl,e=ml,n=yl,r=vl,i={},o=Nn("start","drag","end"),s=0,a,c,l,u,f=0;function d(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",g).on("touchmove.drag",h,pl).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,_){if(!(u||!t.call(this,w,_))){var N=b(this,e.call(this,w,_),w,_,"mouse");N&&(yt(w.view).on("mousemove.drag",x,De).on("mouseup.drag",m,De),ro(w.view),Rn(w),l=!1,a=w.clientX,c=w.clientY,N("start",w))}}function x(w){if(le(w),!l){var _=w.clientX-a,N=w.clientY-c;l=_*_+N*N>f}i.mouse("drag",w)}function m(w){yt(w.view).on("mousemove.drag mouseup.drag",null),io(w.view,l),le(w),i.mouse("end",w)}function g(w,_){if(t.call(this,w,_)){var N=w.changedTouches,M=e.call(this,w,_),C=N.length,k,D;for(k=0;k<C;++k)(D=b(this,M,w,_,N[k].identifier,N[k]))&&(Rn(w),D("start",w,N[k]))}}function h(w){var _=w.changedTouches,N=_.length,M,C;for(M=0;M<N;++M)(C=i[_[M].identifier])&&(le(w),C("drag",w,_[M]))}function v(w){var _=w.changedTouches,N=_.length,M,C;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),M=0;M<N;++M)(C=i[_[M].identifier])&&(Rn(w),C("end",w,_[M]))}function b(w,_,N,M,C,k){var D=o.copy(),W=_t(k||N,_),H,B,y;if((y=n.call(w,new jn("beforestart",{sourceEvent:N,target:d,identifier:C,active:s,x:W[0],y:W[1],dx:0,dy:0,dispatch:D}),M))!=null)return H=y.x-W[0]||0,B=y.y-W[1]||0,function A(E,T,P){var S=W,I;switch(E){case"start":i[C]=A,I=s++;break;case"end":delete i[C],--s;case"drag":W=_t(P||T,_),I=s;break}D.call(E,w,new jn(E,{sourceEvent:T,subject:y,target:d,identifier:C,active:I,x:W[0]+H,y:W[1]+B,dx:W[0]-S[0],dy:W[1]-S[1],dispatch:D}),M)}}return d.filter=function(w){return arguments.length?(t=typeof w=="function"?w:Ye(!!w),d):t},d.container=function(w){return arguments.length?(e=typeof w=="function"?w:Ye(w),d):e},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Ye(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Ye(!!w),d):r},d.on=function(){var w=o.on.apply(o,arguments);return w===o?d:w},d.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,d):Math.sqrt(f)},d}function vr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function oo(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Oe(){}var Pe=.7,fn=1/Pe,ue="\\s*([+-]?\\d+)\\s*",Fe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",St="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xl=/^#([0-9a-f]{3,8})$/,bl=new RegExp(`^rgb\\(${ue},${ue},${ue}\\)$`),_l=new RegExp(`^rgb\\(${St},${St},${St}\\)$`),Sl=new RegExp(`^rgba\\(${ue},${ue},${ue},${Fe}\\)$`),El=new RegExp(`^rgba\\(${St},${St},${St},${Fe}\\)$`),Nl=new RegExp(`^hsl\\(${Fe},${St},${St}\\)$`),Al=new RegExp(`^hsla\\(${Fe},${St},${St},${Fe}\\)$`),Gr={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};vr(Oe,ze,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:qr,formatHex:qr,formatHex8:Ml,formatHsl:kl,formatRgb:Zr,toString:Zr});function qr(){return this.rgb().formatHex()}function Ml(){return this.rgb().formatHex8()}function kl(){return so(this).formatHsl()}function Zr(){return this.rgb().formatRgb()}function ze(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=xl.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Kr(e):n===3?new ot(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Xe(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Xe(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=bl.exec(t))?new ot(e[1],e[2],e[3],1):(e=_l.exec(t))?new ot(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Sl.exec(t))?Xe(e[1],e[2],e[3],e[4]):(e=El.exec(t))?Xe(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Nl.exec(t))?jr(e[1],e[2]/100,e[3]/100,1):(e=Al.exec(t))?jr(e[1],e[2]/100,e[3]/100,e[4]):Gr.hasOwnProperty(t)?Kr(Gr[t]):t==="transparent"?new ot(NaN,NaN,NaN,0):null}function Kr(t){return new ot(t>>16&255,t>>8&255,t&255,1)}function Xe(t,e,n,r){return r<=0&&(t=e=n=NaN),new ot(t,e,n,r)}function $l(t){return t instanceof Oe||(t=ze(t)),t?(t=t.rgb(),new ot(t.r,t.g,t.b,t.opacity)):new ot}function tr(t,e,n,r){return arguments.length===1?$l(t):new ot(t,e,n,r??1)}function ot(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}vr(ot,tr,oo(Oe,{brighter(t){return t=t==null?fn:Math.pow(fn,t),new ot(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Pe:Math.pow(Pe,t),new ot(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ot(Zt(this.r),Zt(this.g),Zt(this.b),hn(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:Jr,formatHex:Jr,formatHex8:Cl,formatRgb:Qr,toString:Qr}));function Jr(){return`#${Gt(this.r)}${Gt(this.g)}${Gt(this.b)}`}function Cl(){return`#${Gt(this.r)}${Gt(this.g)}${Gt(this.b)}${Gt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Qr(){const t=hn(this.opacity);return`${t===1?"rgb(":"rgba("}${Zt(this.r)}, ${Zt(this.g)}, ${Zt(this.b)}${t===1?")":`, ${t})`}`}function hn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Zt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Gt(t){return t=Zt(t),(t<16?"0":"")+t.toString(16)}function jr(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new vt(t,e,n,r)}function so(t){if(t instanceof vt)return new vt(t.h,t.s,t.l,t.opacity);if(t instanceof Oe||(t=ze(t)),!t)return new vt;if(t instanceof vt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,c=(o+i)/2;return a?(e===o?s=(n-r)/a+(n<r)*6:n===o?s=(r-e)/a+2:s=(e-n)/a+4,a/=c<.5?o+i:2-o-i,s*=60):a=c>0&&c<1?0:s,new vt(s,a,c,t.opacity)}function Il(t,e,n,r){return arguments.length===1?so(t):new vt(t,e,n,r??1)}function vt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}vr(vt,Il,oo(Oe,{brighter(t){return t=t==null?fn:Math.pow(fn,t),new vt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Pe:Math.pow(Pe,t),new vt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ot(Wn(t>=240?t-240:t+120,i,r),Wn(t,i,r),Wn(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new vt(ti(this.h),Ue(this.s),Ue(this.l),hn(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 t=hn(this.opacity);return`${t===1?"hsl(":"hsla("}${ti(this.h)}, ${Ue(this.s)*100}%, ${Ue(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ti(t){return t=(t||0)%360,t<0?t+360:t}function Ue(t){return Math.max(0,Math.min(1,t||0))}function Wn(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const ao=t=>()=>t;function Tl(t,e){return function(n){return t+n*e}}function Dl(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function Pl(t){return(t=+t)==1?co:function(e,n){return n-e?Dl(e,n,t):ao(isNaN(e)?n:e)}}function co(t,e){var n=e-t;return n?Tl(t,n):ao(isNaN(t)?e:t)}const ei=function t(e){var n=Pl(e);function r(i,o){var s=n((i=tr(i)).r,(o=tr(o)).r),a=n(i.g,o.g),c=n(i.b,o.b),l=co(i.opacity,o.opacity);return function(u){return i.r=s(u),i.g=a(u),i.b=c(u),i.opacity=l(u),i+""}}return r.gamma=t,r}(1);function Dt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var er=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Bn=new RegExp(er.source,"g");function Fl(t){return function(){return t}}function zl(t){return function(e){return t(e)+""}}function Rl(t,e){var n=er.lastIndex=Bn.lastIndex=0,r,i,o,s=-1,a=[],c=[];for(t=t+"",e=e+"";(r=er.exec(t))&&(i=Bn.exec(e));)(o=i.index)>n&&(o=e.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,c.push({i:s,x:Dt(r,i)})),n=Bn.lastIndex;return n<e.length&&(o=e.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?c[0]?zl(c[0].x):Fl(e):(e=c.length,function(l){for(var u=0,f;u<e;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}var ni=180/Math.PI,nr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lo(t,e,n,r,i,o){var s,a,c;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),t*r<e*n&&(t=-t,e=-e,c=-c,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*ni,skewX:Math.atan(c)*ni,scaleX:s,scaleY:a}}var Ge;function Wl(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?nr:lo(e.a,e.b,e.c,e.d,e.e,e.f)}function Bl(t){return t==null||(Ge||(Ge=document.createElementNS("http://www.w3.org/2000/svg","g")),Ge.setAttribute("transform",t),!(t=Ge.transform.baseVal.consolidate()))?nr:(t=t.matrix,lo(t.a,t.b,t.c,t.d,t.e,t.f))}function uo(t,e,n,r){function i(l){return l.length?l.pop()+" ":""}function o(l,u,f,d,p,x){if(l!==f||u!==d){var m=p.push("translate(",null,e,null,n);x.push({i:m-4,x:Dt(l,f)},{i:m-2,x:Dt(u,d)})}else(f||d)&&p.push("translate("+f+e+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(i(f)+"rotate(",null,r)-2,x:Dt(l,u)})):u&&f.push(i(f)+"rotate("+u+r)}function a(l,u,f,d){l!==u?d.push({i:f.push(i(f)+"skewX(",null,r)-2,x:Dt(l,u)}):u&&f.push(i(f)+"skewX("+u+r)}function c(l,u,f,d,p,x){if(l!==f||u!==d){var m=p.push(i(p)+"scale(",null,",",null,")");x.push({i:m-4,x:Dt(l,f)},{i:m-2,x:Dt(u,d)})}else(f!==1||d!==1)&&p.push(i(p)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=t(l),u=t(u),o(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(p){for(var x=-1,m=d.length,g;++x<m;)f[(g=d[x]).i]=g.x(p);return f.join("")}}}var Hl=uo(Wl,"px, ","px)","deg)"),Ol=uo(Bl,", ",")",")"),Ll=1e-12;function ri(t){return((t=Math.exp(t))+1/t)/2}function Vl(t){return((t=Math.exp(t))-1/t)/2}function Yl(t){return((t=Math.exp(2*t))-1)/(t+1)}const Xl=function t(e,n,r){function i(o,s){var a=o[0],c=o[1],l=o[2],u=s[0],f=s[1],d=s[2],p=u-a,x=f-c,m=p*p+x*x,g,h;if(m<Ll)h=Math.log(d/l)/e,g=function(M){return[a+M*p,c+M*x,l*Math.exp(e*M*h)]};else{var v=Math.sqrt(m),b=(d*d-l*l+r*m)/(2*l*n*v),w=(d*d-l*l-r*m)/(2*d*n*v),_=Math.log(Math.sqrt(b*b+1)-b),N=Math.log(Math.sqrt(w*w+1)-w);h=(N-_)/e,g=function(M){var C=M*h,k=ri(_),D=l/(n*v)*(k*Yl(e*C+_)-Vl(_));return[a+D*p,c+D*x,l*k/ri(e*C+_)]}}return g.duration=h*1e3*e/Math.SQRT2,g}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,c=a*a;return t(s,a,c)},i}(Math.SQRT2,2,4);var me=0,Ie=0,Ae=0,fo=1e3,dn,Te,pn=0,Kt=0,Mn=0,Re=typeof performance=="object"&&performance.now?performance:Date,ho=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function wr(){return Kt||(ho(Ul),Kt=Re.now()+Mn)}function Ul(){Kt=0}function gn(){this._call=this._time=this._next=null}gn.prototype=po.prototype={constructor:gn,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?wr():+n)+(e==null?0:+e),!this._next&&Te!==this&&(Te?Te._next=this:dn=this,Te=this),this._call=t,this._time=n,rr()},stop:function(){this._call&&(this._call=null,this._time=1/0,rr())}};function po(t,e,n){var r=new gn;return r.restart(t,e,n),r}function Gl(){wr(),++me;for(var t=dn,e;t;)(e=Kt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--me}function ii(){Kt=(pn=Re.now())+Mn,me=Ie=0;try{Gl()}finally{me=0,Zl(),Kt=0}}function ql(){var t=Re.now(),e=t-pn;e>fo&&(Mn-=e,pn=t)}function Zl(){for(var t,e=dn,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:dn=n);Te=t,rr(r)}function rr(t){if(!me){Ie&&(Ie=clearTimeout(Ie));var e=t-Kt;e>24?(t<1/0&&(Ie=setTimeout(ii,t-Re.now()-Mn)),Ae&&(Ae=clearInterval(Ae))):(Ae||(pn=Re.now(),Ae=setInterval(ql,fo)),me=1,ho(ii))}}function oi(t,e,n){var r=new gn;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var Kl=Nn("start","end","cancel","interrupt"),Jl=[],go=0,si=1,ir=2,an=3,ai=4,or=5,cn=6;function kn(t,e,n,r,i,o){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;Ql(t,n,{name:e,index:r,group:i,on:Kl,tween:Jl,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:go})}function xr(t,e){var n=wt(t,e);if(n.state>go)throw new Error("too late; already scheduled");return n}function Et(t,e){var n=wt(t,e);if(n.state>an)throw new Error("too late; already running");return n}function wt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Ql(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=po(o,0,n.time);function o(l){n.state=si,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,p;if(n.state!==si)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===an)return oi(s);p.state===ai?(p.state=cn,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=cn,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(oi(function(){n.state===an&&(n.state=ai,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=ir,n.on.call("start",t,t.__data__,n.index,n.group),n.state===ir){for(n.state=an,i=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(i[++f]=p);i.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=or,1),f=-1,d=i.length;++f<d;)i[f].call(t,u);n.state===or&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=cn,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function ln(t,e){var n=t.__transition,r,i,o=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){o=!1;continue}i=r.state>ir&&r.state<or,r.state=cn,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}o&&delete t.__transition}}function jl(t){return this.each(function(){ln(this,t)})}function tu(t,e){var n,r;return function(){var i=Et(this,t),o=i.tween;if(o!==n){r=n=o;for(var s=0,a=r.length;s<a;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}i.tween=r}}function eu(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Et(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===e){i[c]=a;break}c===l&&i.push(a)}o.tween=i}}function nu(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=wt(this.node(),n).tween,i=0,o=r.length,s;i<o;++i)if((s=r[i]).name===t)return s.value;return null}return this.each((e==null?tu:eu)(n,t,e))}function br(t,e,n){var r=t._id;return t.each(function(){var i=Et(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return wt(i,r).value[e]}}function mo(t,e){var n;return(typeof e=="number"?Dt:e instanceof ze?ei:(n=ze(e))?(e=n,ei):Rl)(t,e)}function ru(t){return function(){this.removeAttribute(t)}}function iu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ou(t,e,n){var r,i=n+"",o;return function(){var s=this.getAttribute(t);return s===i?null:s===r?o:o=e(r=s,n)}}function su(t,e,n){var r,i=n+"",o;return function(){var s=this.getAttributeNS(t.space,t.local);return s===i?null:s===r?o:o=e(r=s,n)}}function au(t,e,n){var r,i,o;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),c=a+"",s===c?null:s===r&&c===i?o:(i=c,o=e(r=s,a)))}}function cu(t,e,n){var r,i,o;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),c=a+"",s===c?null:s===r&&c===i?o:(i=c,o=e(r=s,a)))}}function lu(t,e){var n=An(t),r=n==="transform"?Ol:mo;return this.attrTween(t,typeof e=="function"?(n.local?cu:au)(n,r,br(this,"attr."+t,e)):e==null?(n.local?iu:ru)(n):(n.local?su:ou)(n,r,e))}function uu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function fu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function hu(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&fu(t,o)),n}return i._value=e,i}function du(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&uu(t,o)),n}return i._value=e,i}function pu(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=An(t);return this.tween(n,(r.local?hu:du)(r,e))}function gu(t,e){return function(){xr(this,t).delay=+e.apply(this,arguments)}}function mu(t,e){return e=+e,function(){xr(this,t).delay=e}}function yu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?gu:mu)(e,t)):wt(this.node(),e).delay}function vu(t,e){return function(){Et(this,t).duration=+e.apply(this,arguments)}}function wu(t,e){return e=+e,function(){Et(this,t).duration=e}}function xu(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?vu:wu)(e,t)):wt(this.node(),e).duration}function bu(t,e){if(typeof e!="function")throw new Error;return function(){Et(this,t).ease=e}}function _u(t){var e=this._id;return arguments.length?this.each(bu(e,t)):wt(this.node(),e).ease}function Su(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Et(this,t).ease=n}}function Eu(t){if(typeof t!="function")throw new Error;return this.each(Su(this._id,t))}function Nu(t){typeof t!="function"&&(t=Gi(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=[],c,l=0;l<s;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new $t(r,this._parents,this._name,this._id)}function Au(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var c=e[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(f[p]=d);for(;a<r;++a)s[a]=e[a];return new $t(s,this._parents,this._name,this._id)}function Mu(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function ku(t,e,n){var r,i,o=Mu(e)?xr:Et;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}function $u(t,e){var n=this._id;return arguments.length<2?wt(this.node(),n).on.on(t):this.each(ku(n,t,e))}function Cu(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function Iu(){return this.on("end.remove",Cu(this._id))}function Tu(t){var e=this._name,n=this._id;typeof t!="function"&&(t=mr(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a=r[s],c=a.length,l=o[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=t.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,kn(l[d],e,n,d,l,wt(u,n)));return new $t(o,this._parents,e,n)}function Du(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Ui(t));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var c=r[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=t.call(u,u.__data__,f,c),p,x=wt(u,n),m=0,g=d.length;m<g;++m)(p=d[m])&&kn(p,e,n,m,d,x);o.push(d),s.push(u)}return new $t(o,s,e,n)}var Pu=He.prototype.constructor;function Fu(){return new Pu(this._groups,this._parents)}function zu(t,e){var n,r,i;return function(){var o=ge(this,t),s=(this.style.removeProperty(t),ge(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}function yo(t){return function(){this.style.removeProperty(t)}}function Ru(t,e,n){var r,i=n+"",o;return function(){var s=ge(this,t);return s===i?null:s===r?o:o=e(r=s,n)}}function Wu(t,e,n){var r,i,o;return function(){var s=ge(this,t),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(t),ge(this,t))),s===c?null:s===r&&c===i?o:(i=c,o=e(r=s,a))}}function Bu(t,e){var n,r,i,o="style."+e,s="end."+o,a;return function(){var c=Et(this,t),l=c.on,u=c.value[o]==null?a||(a=yo(e)):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(s,i=u),c.on=r}}function Hu(t,e,n){var r=(t+="")=="transform"?Hl:mo;return e==null?this.styleTween(t,zu(t,r)).on("end.style."+t,yo(t)):typeof e=="function"?this.styleTween(t,Wu(t,r,br(this,"style."+t,e))).each(Bu(this._id,t)):this.styleTween(t,Ru(t,r,e),n).on("end.style."+t,null)}function Ou(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Lu(t,e,n){var r,i;function o(){var s=e.apply(this,arguments);return s!==i&&(r=(i=s)&&Ou(t,s,n)),r}return o._value=e,o}function Vu(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Lu(t,e,n??""))}function Yu(t){return function(){this.textContent=t}}function Xu(t){return function(){var e=t(this);this.textContent=e??""}}function Uu(t){return this.tween("text",typeof t=="function"?Xu(br(this,"text",t)):Yu(t==null?"":t+""))}function Gu(t){return function(e){this.textContent=t.call(this,e)}}function qu(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&Gu(i)),e}return r._value=t,r}function Zu(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,qu(t))}function Ku(){for(var t=this._name,e=this._id,n=vo(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=wt(c,e);kn(c,t,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new $t(r,this._parents,t,n)}function Ju(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},c={value:function(){--i===0&&o()}};n.each(function(){var l=Et(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(c)),l.on=e}),i===0&&o()})}var Qu=0;function $t(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function vo(){return++Qu}var Mt=He.prototype;$t.prototype={constructor:$t,select:Tu,selectAll:Du,selectChild:Mt.selectChild,selectChildren:Mt.selectChildren,filter:Nu,merge:Au,selection:Fu,transition:Ku,call:Mt.call,nodes:Mt.nodes,node:Mt.node,size:Mt.size,empty:Mt.empty,each:Mt.each,on:$u,attr:lu,attrTween:pu,style:Hu,styleTween:Vu,text:Uu,textTween:Zu,remove:Iu,tween:nu,delay:yu,duration:xu,ease:_u,easeVarying:Eu,end:Ju,[Symbol.iterator]:Mt[Symbol.iterator]};function ju(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var tf={time:null,delay:0,duration:250,ease:ju};function ef(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function nf(t){var e,n;t instanceof $t?(e=t._id,t=t._name):(e=vo(),(n=tf).time=wr(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&kn(c,t,e,l,s,n||ef(c,e));return new $t(r,this._parents,t,e)}He.prototype.interrupt=jl;He.prototype.transition=nf;const qe=t=>()=>t;function rf(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function kt(t,e,n){this.k=t,this.x=e,this.y=n}kt.prototype={constructor:kt,scale:function(t){return t===1?this:new kt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new kt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Rt=new kt(1,0,0);kt.prototype;function Hn(t){t.stopImmediatePropagation()}function Me(t){t.preventDefault(),t.stopImmediatePropagation()}function of(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function sf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function ci(){return this.__zoom||Rt}function af(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function cf(){return navigator.maxTouchPoints||"ontouchstart"in this}function lf(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function uf(){var t=of,e=sf,n=lf,r=af,i=cf,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xl,l=Nn("start","zoom","end"),u,f,d,p=500,x=150,m=0,g=10;function h(y){y.property("__zoom",ci).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",D).filter(i).on("touchstart.zoom",W).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}h.transform=function(y,A,E,T){var P=y.selection?y.selection():y;P.property("__zoom",ci),y!==P?_(y,A,E,T):P.interrupt().each(function(){N(this,arguments).event(T).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},h.scaleBy=function(y,A,E,T){h.scaleTo(y,function(){var P=this.__zoom.k,S=typeof A=="function"?A.apply(this,arguments):A;return P*S},E,T)},h.scaleTo=function(y,A,E,T){h.transform(y,function(){var P=e.apply(this,arguments),S=this.__zoom,I=E==null?w(P):typeof E=="function"?E.apply(this,arguments):E,F=S.invert(I),z=typeof A=="function"?A.apply(this,arguments):A;return n(b(v(S,z),I,F),P,s)},E,T)},h.translateBy=function(y,A,E,T){h.transform(y,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof E=="function"?E.apply(this,arguments):E),e.apply(this,arguments),s)},null,T)},h.translateTo=function(y,A,E,T,P){h.transform(y,function(){var S=e.apply(this,arguments),I=this.__zoom,F=T==null?w(S):typeof T=="function"?T.apply(this,arguments):T;return n(Rt.translate(F[0],F[1]).scale(I.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof E=="function"?-E.apply(this,arguments):-E),S,s)},T,P)};function v(y,A){return A=Math.max(o[0],Math.min(o[1],A)),A===y.k?y:new kt(A,y.x,y.y)}function b(y,A,E){var T=A[0]-E[0]*y.k,P=A[1]-E[1]*y.k;return T===y.x&&P===y.y?y:new kt(y.k,T,P)}function w(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function _(y,A,E,T){y.on("start.zoom",function(){N(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(T).end()}).tween("zoom",function(){var P=this,S=arguments,I=N(P,S).event(T),F=e.apply(P,S),z=E==null?w(F):typeof E=="function"?E.apply(P,S):E,L=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),O=P.__zoom,X=typeof A=="function"?A.apply(P,S):A,G=c(O.invert(z).concat(L/O.k),X.invert(z).concat(L/X.k));return function(q){if(q===1)q=X;else{var Z=G(q),Q=L/Z[2];q=new kt(Q,z[0]-Z[0]*Q,z[1]-Z[1]*Q)}I.zoom(null,q)}})}function N(y,A,E){return!E&&y.__zooming||new M(y,A)}function M(y,A){this.that=y,this.args=A,this.active=0,this.sourceEvent=null,this.extent=e.apply(y,A),this.taps=0}M.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,A){return this.mouse&&y!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var A=yt(this.that).datum();l.call(y,this.that,new rf(y,{sourceEvent:this.sourceEvent,target:h,type:y,transform:this.that.__zoom,dispatch:l}),A)}};function C(y,...A){if(!t.apply(this,arguments))return;var E=N(this,A).event(y),T=this.__zoom,P=Math.max(o[0],Math.min(o[1],T.k*Math.pow(2,r.apply(this,arguments)))),S=_t(y);if(E.wheel)(E.mouse[0][0]!==S[0]||E.mouse[0][1]!==S[1])&&(E.mouse[1]=T.invert(E.mouse[0]=S)),clearTimeout(E.wheel);else{if(T.k===P)return;E.mouse=[S,T.invert(S)],ln(this),E.start()}Me(y),E.wheel=setTimeout(I,x),E.zoom("mouse",n(b(v(T,P),E.mouse[0],E.mouse[1]),E.extent,s));function I(){E.wheel=null,E.end()}}function k(y,...A){if(d||!t.apply(this,arguments))return;var E=y.currentTarget,T=N(this,A,!0).event(y),P=yt(y.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",L,!0),S=_t(y,E),I=y.clientX,F=y.clientY;ro(y.view),Hn(y),T.mouse=[S,this.__zoom.invert(S)],ln(this),T.start();function z(O){if(Me(O),!T.moved){var X=O.clientX-I,G=O.clientY-F;T.moved=X*X+G*G>m}T.event(O).zoom("mouse",n(b(T.that.__zoom,T.mouse[0]=_t(O,E),T.mouse[1]),T.extent,s))}function L(O){P.on("mousemove.zoom mouseup.zoom",null),io(O.view,T.moved),Me(O),T.event(O).end()}}function D(y,...A){if(t.apply(this,arguments)){var E=this.__zoom,T=_t(y.changedTouches?y.changedTouches[0]:y,this),P=E.invert(T),S=E.k*(y.shiftKey?.5:2),I=n(b(v(E,S),T,P),e.apply(this,A),s);Me(y),a>0?yt(this).transition().duration(a).call(_,I,T,y):yt(this).call(h.transform,I,T,y)}}function W(y,...A){if(t.apply(this,arguments)){var E=y.touches,T=E.length,P=N(this,A,y.changedTouches.length===T).event(y),S,I,F,z;for(Hn(y),I=0;I<T;++I)F=E[I],z=_t(F,this),z=[z,this.__zoom.invert(z),F.identifier],P.touch0?!P.touch1&&P.touch0[2]!==z[2]&&(P.touch1=z,P.taps=0):(P.touch0=z,S=!0,P.taps=1+!!u);u&&(u=clearTimeout(u)),S&&(P.taps<2&&(f=z[0],u=setTimeout(function(){u=null},p)),ln(this),P.start())}}function H(y,...A){if(this.__zooming){var E=N(this,A).event(y),T=y.changedTouches,P=T.length,S,I,F,z;for(Me(y),S=0;S<P;++S)I=T[S],F=_t(I,this),E.touch0&&E.touch0[2]===I.identifier?E.touch0[0]=F:E.touch1&&E.touch1[2]===I.identifier&&(E.touch1[0]=F);if(I=E.that.__zoom,E.touch1){var L=E.touch0[0],O=E.touch0[1],X=E.touch1[0],G=E.touch1[1],q=(q=X[0]-L[0])*q+(q=X[1]-L[1])*q,Z=(Z=G[0]-O[0])*Z+(Z=G[1]-O[1])*Z;I=v(I,Math.sqrt(q/Z)),F=[(L[0]+X[0])/2,(L[1]+X[1])/2],z=[(O[0]+G[0])/2,(O[1]+G[1])/2]}else if(E.touch0)F=E.touch0[0],z=E.touch0[1];else return;E.zoom("touch",n(b(I,F,z),E.extent,s))}}function B(y,...A){if(this.__zooming){var E=N(this,A).event(y),T=y.changedTouches,P=T.length,S,I;for(Hn(y),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),S=0;S<P;++S)I=T[S],E.touch0&&E.touch0[2]===I.identifier?delete E.touch0:E.touch1&&E.touch1[2]===I.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(I=_t(I,this),Math.hypot(f[0]-I[0],f[1]-I[1])<g)){var F=yt(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return h.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:qe(+y),h):r},h.filter=function(y){return arguments.length?(t=typeof y=="function"?y:qe(!!y),h):t},h.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:qe(!!y),h):i},h.extent=function(y){return arguments.length?(e=typeof y=="function"?y:qe([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),h):e},h.scaleExtent=function(y){return arguments.length?(o[0]=+y[0],o[1]=+y[1],h):[o[0],o[1]]},h.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],h):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},h.constrain=function(y){return arguments.length?(n=y,h):n},h.duration=function(y){return arguments.length?(a=+y,h):a},h.interpolate=function(y){return arguments.length?(c=y,h):c},h.on=function(){var y=l.on.apply(l,arguments);return y===l?h:y},h.clickDistance=function(y){return arguments.length?(m=(y=+y)*y,h):Math.sqrt(m)},h.tapDistance=function(y){return arguments.length?(g=+y,h):g},h}const $n=$.createContext(null),ff=$n.Provider,Ct={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:t=>`Node type "${t}" 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},wo=Ct.error001();function tt(t,e){const n=$.useContext($n);if(n===null)throw new Error(wo);return Yi(n,t,e)}const nt=()=>{const t=$.useContext($n);if(t===null)throw new Error(wo);return $.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},hf=t=>t.userSelectionActive?"none":"all";function df({position:t,children:e,className:n,style:r,...i}){const o=tt(hf),s=`${t}`.split("-");return R.createElement("div",{className:ht(["react-flow__panel",n,...s]),style:{...r,pointerEvents:o},...i},e)}function pf({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:R.createElement(df,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},R.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const gf=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:o={},labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u})=>{const f=$.useRef(null),[d,p]=$.useState({x:0,y:0,width:0,height:0}),x=ht(["react-flow__edge-textwrapper",l]);return $.useEffect(()=>{if(f.current){const m=f.current.getBBox();p({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:R.createElement("g",{transform:`translate(${t-d.width/2} ${e-d.height/2})`,className:x,visibility:d.width?"visible":"hidden",...u},i&&R.createElement("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),R.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:f,style:r},n),c)};var mf=$.memo(gf);const _r=t=>({width:t.offsetWidth,height:t.offsetHeight}),ye=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),Sr=(t={x:0,y:0},e)=>({x:ye(t.x,e[0][0],e[1][0]),y:ye(t.y,e[0][1],e[1][1])}),li=(t,e,n)=>t<e?ye(Math.abs(t-e),1,50)/50:t>n?-ye(Math.abs(t-n),1,50)/50:0,xo=(t,e)=>{const n=li(t.x,35,e.width-35)*20,r=li(t.y,35,e.height-35)*20;return[n,r]},bo=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},yf=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),Er=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),vf=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),ui=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),sr=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},wf=t=>ft(t.width)&&ft(t.height)&&ft(t.x)&&ft(t.y),ft=t=>!isNaN(t)&&isFinite(t),j=Symbol.for("internals"),_o=["Enter"," ","Escape"],xf=(t,e)=>{},bf=t=>"nativeEvent"in t;function ar(t){var i,o;const e=bf(t)?t.nativeEvent:t,n=((o=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:o[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const So=t=>"clientX"in t,Wt=(t,e)=>{var o,s;const n=So(t),r=n?t.clientX:(o=t.touches)==null?void 0:o[0].clientX,i=n?t.clientY:(s=t.touches)==null?void 0:s[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:i-((e==null?void 0:e.top)??0)}},mn=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Le=({id:t,path:e,labelX:n,labelY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:p=20})=>R.createElement(R.Fragment,null,R.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:d}),p&&R.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),i&&ft(n)&&ft(r)?R.createElement(mf,{x:n,y:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null);Le.displayName="BaseEdge";function ke(t,e,n){return n===void 0?n:r=>{const i=e().edges.find(o=>o.id===t);i&&n(r,{...i})}}function Eo({sourceX:t,sourceY:e,targetX:n,targetY:r}){const i=Math.abs(n-t)/2,o=n<t?n+i:n-i,s=Math.abs(r-e)/2,a=r<e?r+s:r-s;return[o,a,i,s]}function No({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:s,targetControlY:a}){const c=t*.125+i*.375+s*.375+n*.125,l=e*.125+o*.375+a*.375+r*.125,u=Math.abs(c-t),f=Math.abs(l-e);return[c,l,u,f]}var Jt;(function(t){t.Strict="strict",t.Loose="loose"})(Jt||(Jt={}));var qt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(qt||(qt={}));var We;(function(t){t.Partial="partial",t.Full="full"})(We||(We={}));var zt;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(zt||(zt={}));var yn;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(yn||(yn={}));var V;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(V||(V={}));function fi({pos:t,x1:e,y1:n,x2:r,y2:i}){return t===V.Left||t===V.Right?[.5*(e+r),n]:[e,.5*(n+i)]}function Ao({sourceX:t,sourceY:e,sourcePosition:n=V.Bottom,targetX:r,targetY:i,targetPosition:o=V.Top}){const[s,a]=fi({pos:n,x1:t,y1:e,x2:r,y2:i}),[c,l]=fi({pos:o,x1:r,y1:i,x2:t,y2:e}),[u,f,d,p]=No({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${t},${e} C${s},${a} ${c},${l} ${r},${i}`,u,f,d,p]}const Nr=$.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:i=V.Bottom,targetPosition:o=V.Top,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:x,interactionWidth:m})=>{const[g,h,v]=Ao({sourceX:t,sourceY:e,sourcePosition:i,targetX:n,targetY:r,targetPosition:o});return R.createElement(Le,{path:g,labelX:h,labelY:v,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:x,interactionWidth:m})});Nr.displayName="SimpleBezierEdge";const hi={[V.Left]:{x:-1,y:0},[V.Right]:{x:1,y:0},[V.Top]:{x:0,y:-1},[V.Bottom]:{x:0,y:1}},_f=({source:t,sourcePosition:e=V.Bottom,target:n})=>e===V.Left||e===V.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},di=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function Sf({source:t,sourcePosition:e=V.Bottom,target:n,targetPosition:r=V.Top,center:i,offset:o}){const s=hi[e],a=hi[r],c={x:t.x+s.x*o,y:t.y+s.y*o},l={x:n.x+a.x*o,y:n.y+a.y*o},u=_f({source:c,sourcePosition:e,target:l}),f=u.x!==0?"x":"y",d=u[f];let p=[],x,m;const g={x:0,y:0},h={x:0,y:0},[v,b,w,_]=Eo({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(s[f]*a[f]===-1){x=i.x??v,m=i.y??b;const M=[{x,y:c.y},{x,y:l.y}],C=[{x:c.x,y:m},{x:l.x,y:m}];s[f]===d?p=f==="x"?M:C:p=f==="x"?C:M}else{const M=[{x:c.x,y:l.y}],C=[{x:l.x,y:c.y}];if(f==="x"?p=s.x===d?C:M:p=s.y===d?M:C,e===r){const B=Math.abs(t[f]-n[f]);if(B<=o){const y=Math.min(o-1,o-B);s[f]===d?g[f]=(c[f]>t[f]?-1:1)*y:h[f]=(l[f]>n[f]?-1:1)*y}}if(e!==r){const B=f==="x"?"y":"x",y=s[f]===a[B],A=c[B]>l[B],E=c[B]<l[B];(s[f]===1&&(!y&&A||y&&E)||s[f]!==1&&(!y&&E||y&&A))&&(p=f==="x"?M:C)}const k={x:c.x+g.x,y:c.y+g.y},D={x:l.x+h.x,y:l.y+h.y},W=Math.max(Math.abs(k.x-p[0].x),Math.abs(D.x-p[0].x)),H=Math.max(Math.abs(k.y-p[0].y),Math.abs(D.y-p[0].y));W>=H?(x=(k.x+D.x)/2,m=p[0].y):(x=p[0].x,m=(k.y+D.y)/2)}return[[t,{x:c.x+g.x,y:c.y+g.y},...p,{x:l.x+h.x,y:l.y+h.y},n],x,m,w,_]}function Ef(t,e,n,r){const i=Math.min(di(t,e)/2,di(e,n)/2,r),{x:o,y:s}=e;if(t.x===o&&o===n.x||t.y===s&&s===n.y)return`L${o} ${s}`;if(t.y===s){const l=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${o+i*l},${s}Q ${o},${s} ${o},${s+i*u}`}const a=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${o},${s+i*c}Q ${o},${s} ${o+i*a},${s}`}function cr({sourceX:t,sourceY:e,sourcePosition:n=V.Bottom,targetX:r,targetY:i,targetPosition:o=V.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20}){const[u,f,d,p,x]=Sf({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:a,y:c},offset:l});return[u.reduce((g,h,v)=>{let b="";return v>0&&v<u.length-1?b=Ef(u[v-1],h,u[v+1],s):b=`${v===0?"M":"L"}${h.x} ${h.y}`,g+=b,g},""),f,d,p,x]}const Cn=$.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:f=V.Bottom,targetPosition:d=V.Top,markerEnd:p,markerStart:x,pathOptions:m,interactionWidth:g})=>{const[h,v,b]=cr({sourceX:t,sourceY:e,sourcePosition:f,targetX:n,targetY:r,targetPosition:d,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset});return R.createElement(Le,{path:h,labelX:v,labelY:b,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:x,interactionWidth:g})});Cn.displayName="SmoothStepEdge";const Ar=$.memo(t=>{var e;return R.createElement(Cn,{...t,pathOptions:$.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});Ar.displayName="StepEdge";function Nf({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[i,o,s,a]=Eo({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,i,o,s,a]}const Mr=$.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:p})=>{const[x,m,g]=Nf({sourceX:t,sourceY:e,targetX:n,targetY:r});return R.createElement(Le,{path:x,labelX:m,labelY:g,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:d,interactionWidth:p})});Mr.displayName="StraightEdge";function Ze(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function pi({pos:t,x1:e,y1:n,x2:r,y2:i,c:o}){switch(t){case V.Left:return[e-Ze(e-r,o),n];case V.Right:return[e+Ze(r-e,o),n];case V.Top:return[e,n-Ze(n-i,o)];case V.Bottom:return[e,n+Ze(i-n,o)]}}function Mo({sourceX:t,sourceY:e,sourcePosition:n=V.Bottom,targetX:r,targetY:i,targetPosition:o=V.Top,curvature:s=.25}){const[a,c]=pi({pos:n,x1:t,y1:e,x2:r,y2:i,c:s}),[l,u]=pi({pos:o,x1:r,y1:i,x2:t,y2:e,c:s}),[f,d,p,x]=No({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${t},${e} C${a},${c} ${l},${u} ${r},${i}`,f,d,p,x]}const vn=$.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:i=V.Bottom,targetPosition:o=V.Top,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:x,pathOptions:m,interactionWidth:g})=>{const[h,v,b]=Mo({sourceX:t,sourceY:e,sourcePosition:i,targetX:n,targetY:r,targetPosition:o,curvature:m==null?void 0:m.curvature});return R.createElement(Le,{path:h,labelX:v,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:x,interactionWidth:g})});vn.displayName="BezierEdge";const kr=$.createContext(null),Af=kr.Provider;kr.Consumer;const Mf=()=>$.useContext(kr),kf=t=>"id"in t&&"source"in t&&"target"in t,$f=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,lr=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,Cf=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),If=(t,e)=>{if(!t.source||!t.target)return e;let n;return kf(t)?n={...t}:n={...t,id:$f(t)},Cf(n,e)?e:e.concat(n)},ur=({x:t,y:e},[n,r,i],o,[s,a])=>{const c={x:(t-n)/i,y:(e-r)/i};return o?{x:s*Math.round(c.x/s),y:a*Math.round(c.y/a)}:c},ko=({x:t,y:e},[n,r,i])=>({x:t*i+n,y:e*i+r}),fe=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],r=(t.height??0)*e[1],i={x:t.position.x-n,y:t.position.y-r};return{...i,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-r}:i}},$r=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,i)=>{const{x:o,y:s}=fe(i,e).positionAbsolute;return yf(r,Er({x:o,y:s,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return vf(n)},$o=(t,e,[n,r,i]=[0,0,1],o=!1,s=!1,a=[0,0])=>{const c={x:(e.x-n)/i,y:(e.y-r)/i,width:e.width/i,height:e.height/i},l=[];return t.forEach(u=>{const{width:f,height:d,selectable:p=!0,hidden:x=!1}=u;if(s&&!p||x)return!1;const{positionAbsolute:m}=fe(u,a),g={x:m.x,y:m.y,width:f||0,height:d||0},h=sr(c,g),v=typeof f>"u"||typeof d>"u"||f===null||d===null,b=o&&h>0,w=(f||0)*(d||0);(v||b||h>=w||u.dragging)&&l.push(u)}),l},Co=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},Io=(t,e,n,r,i,o=.1)=>{const s=e/(t.width*(1+o)),a=n/(t.height*(1+o)),c=Math.min(s,a),l=ye(c,r,i),u=t.x+t.width/2,f=t.y+t.height/2,d=e/2-u*l,p=n/2-f*l;return{x:d,y:p,zoom:l}},Ut=(t,e=0)=>t.transition().duration(e);function gi(t,e,n,r){return(e[n]||[]).reduce((i,o)=>{var s,a;return`${t.id}-${o.id}-${n}`!==r&&i.push({id:o.id||null,type:n,nodeId:t.id,x:(((s=t.positionAbsolute)==null?void 0:s.x)??0)+o.x+o.width/2,y:(((a=t.positionAbsolute)==null?void 0:a.y)??0)+o.y+o.height/2}),i},[])}function Tf(t,e,n,r,i,o){const{x:s,y:a}=Wt(t),l=e.elementsFromPoint(s,a).find(x=>x.classList.contains("react-flow__handle"));if(l){const x=l.getAttribute("data-nodeid");if(x){const m=Cr(void 0,l),g=l.getAttribute("data-handleid"),h=o({nodeId:x,id:g,type:m});if(h){const v=i.find(b=>b.nodeId===x&&b.type===m&&b.id===g);return{handle:{id:g,type:m,nodeId:x,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:h}}}}let u=[],f=1/0;if(i.forEach(x=>{const m=Math.sqrt((x.x-n.x)**2+(x.y-n.y)**2);if(m<=r){const g=o(x);m<=f&&(m<f?u=[{handle:x,validHandleResult:g}]:m===f&&u.push({handle:x,validHandleResult:g}),f=m)}}),!u.length)return{handle:null,validHandleResult:To()};if(u.length===1)return u[0];const d=u.some(({validHandleResult:x})=>x.isValid),p=u.some(({handle:x})=>x.type==="target");return u.find(({handle:x,validHandleResult:m})=>p?x.type==="target":d?m.isValid:!0)||u[0]}const Df={source:null,target:null,sourceHandle:null,targetHandle:null},To=()=>({handleDomNode:null,isValid:!1,connection:Df,endHandle:null});function Do(t,e,n,r,i,o,s){const a=i==="target",c=s.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),l={...To(),handleDomNode:c};if(c){const u=Cr(void 0,c),f=c.getAttribute("data-nodeid"),d=c.getAttribute("data-handleid"),p=c.classList.contains("connectable"),x=c.classList.contains("connectableend"),m={source:a?f:n,sourceHandle:a?d:r,target:a?n:f,targetHandle:a?r:d};l.connection=m,p&&x&&(e===Jt.Strict?a&&u==="source"||!a&&u==="target":f!==n||d!==r)&&(l.endHandle={nodeId:f,handleId:d,type:u},l.isValid=o(m))}return l}function Pf({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((i,o)=>{if(o[j]){const{handleBounds:s}=o[j];let a=[],c=[];s&&(a=gi(o,s,"source",`${e}-${n}-${r}`),c=gi(o,s,"target",`${e}-${n}-${r}`)),i.push(...a,...c)}return i},[])}function Cr(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function On(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Ff(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function Po({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:i,getState:o,setState:s,isValidConnection:a,edgeUpdaterType:c,onReconnectEnd:l}){const u=bo(t.target),{connectionMode:f,domNode:d,autoPanOnConnect:p,connectionRadius:x,onConnectStart:m,panBy:g,getNodes:h,cancelConnection:v}=o();let b=0,w;const{x:_,y:N}=Wt(t),M=u==null?void 0:u.elementFromPoint(_,N),C=Cr(c,M),k=d==null?void 0:d.getBoundingClientRect();if(!k||!C)return;let D,W=Wt(t,k),H=!1,B=null,y=!1,A=null;const E=Pf({nodes:h(),nodeId:n,handleId:e,handleType:C}),T=()=>{if(!p)return;const[I,F]=xo(W,k);g({x:I,y:F}),b=requestAnimationFrame(T)};s({connectionPosition:W,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:C,connectionStartHandle:{nodeId:n,handleId:e,type:C},connectionEndHandle:null}),m==null||m(t,{nodeId:n,handleId:e,handleType:C});function P(I){const{transform:F}=o();W=Wt(I,k);const{handle:z,validHandleResult:L}=Tf(I,u,ur(W,F,!1,[1,1]),x,E,O=>Do(O,f,n,e,i?"target":"source",a,u));if(w=z,H||(T(),H=!0),A=L.handleDomNode,B=L.connection,y=L.isValid,s({connectionPosition:w&&y?ko({x:w.x,y:w.y},F):W,connectionStatus:Ff(!!w,y),connectionEndHandle:L.endHandle}),!w&&!y&&!A)return On(D);B.source!==B.target&&A&&(On(D),D=A,A.classList.add("connecting","react-flow__handle-connecting"),A.classList.toggle("valid",y),A.classList.toggle("react-flow__handle-valid",y))}function S(I){var F,z;(w||A)&&B&&y&&(r==null||r(B)),(z=(F=o()).onConnectEnd)==null||z.call(F,I),c&&(l==null||l(I)),On(D),v(),cancelAnimationFrame(b),H=!1,y=!1,B=null,A=null,u.removeEventListener("mousemove",P),u.removeEventListener("mouseup",S),u.removeEventListener("touchmove",P),u.removeEventListener("touchend",S)}u.addEventListener("mousemove",P),u.addEventListener("mouseup",S),u.addEventListener("touchmove",P),u.addEventListener("touchend",S)}const mi=()=>!0,zf=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Rf=(t,e,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:o,connectionClickStartHandle:s}=r;return{connecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===n||(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n,clickConnecting:(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n}},Fo=$.forwardRef(({type:t="source",position:e=V.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:f,...d},p)=>{var k,D;const x=s||null,m=t==="target",g=nt(),h=Mf(),{connectOnClick:v,noPanClassName:b}=tt(zf,it),{connecting:w,clickConnecting:_}=tt(Rf(h,x,t),it);h||(D=(k=g.getState()).onError)==null||D.call(k,"010",Ct.error010());const N=W=>{const{defaultEdgeOptions:H,onConnect:B,hasDefaultEdges:y}=g.getState(),A={...H,...W};if(y){const{edges:E,setEdges:T}=g.getState();T(If(A,E))}B==null||B(A),a==null||a(A)},M=W=>{if(!h)return;const H=So(W);i&&(H&&W.button===0||!H)&&Po({event:W,handleId:x,nodeId:h,onConnect:N,isTarget:m,getState:g.getState,setState:g.setState,isValidConnection:n||g.getState().isValidConnection||mi}),H?u==null||u(W):f==null||f(W)},C=W=>{const{onClickConnectStart:H,onClickConnectEnd:B,connectionClickStartHandle:y,connectionMode:A,isValidConnection:E}=g.getState();if(!h||!y&&!i)return;if(!y){H==null||H(W,{nodeId:h,handleId:x,handleType:t}),g.setState({connectionClickStartHandle:{nodeId:h,type:t,handleId:x}});return}const T=bo(W.target),P=n||E||mi,{connection:S,isValid:I}=Do({nodeId:h,id:x,type:t},A,y.nodeId,y.handleId||null,y.type,P,T);I&&N(S),B==null||B(W),g.setState({connectionClickStartHandle:null})};return R.createElement("div",{"data-handleid":x,"data-nodeid":h,"data-handlepos":e,"data-id":`${h}-${x}-${t}`,className:ht(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",b,l,{source:!m,target:m,connectable:r,connectablestart:i,connectableend:o,connecting:_,connectionindicator:r&&(i&&!w||o&&w)}]),onMouseDown:M,onTouchStart:M,onClick:v?C:void 0,ref:p,...d},c)});Fo.displayName="Handle";var wn=$.memo(Fo);const zo=({data:t,isConnectable:e,targetPosition:n=V.Top,sourcePosition:r=V.Bottom})=>R.createElement(R.Fragment,null,R.createElement(wn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,R.createElement(wn,{type:"source",position:r,isConnectable:e}));zo.displayName="DefaultNode";var fr=$.memo(zo);const Ro=({data:t,isConnectable:e,sourcePosition:n=V.Bottom})=>R.createElement(R.Fragment,null,t==null?void 0:t.label,R.createElement(wn,{type:"source",position:n,isConnectable:e}));Ro.displayName="InputNode";var Wo=$.memo(Ro);const Bo=({data:t,isConnectable:e,targetPosition:n=V.Top})=>R.createElement(R.Fragment,null,R.createElement(wn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Bo.displayName="OutputNode";var Ho=$.memo(Bo);const Ir=()=>null;Ir.displayName="GroupNode";const Wf=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Ke=t=>t.id;function Bf(t,e){return it(t.selectedNodes.map(Ke),e.selectedNodes.map(Ke))&&it(t.selectedEdges.map(Ke),e.selectedEdges.map(Ke))}const Oo=$.memo(({onSelectionChange:t})=>{const e=nt(),{selectedNodes:n,selectedEdges:r}=tt(Wf,Bf);return $.useEffect(()=>{const i={nodes:n,edges:r};t==null||t(i),e.getState().onSelectionChange.forEach(o=>o(i))},[n,r,t]),null});Oo.displayName="SelectionListener";const Hf=t=>!!t.onSelectionChange;function Of({onSelectionChange:t}){const e=tt(Hf);return t||e?R.createElement(Oo,{onSelectionChange:t}):null}const Lf=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function re(t,e){$.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function U(t,e,n){$.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const Vf=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:o,onConnectEnd:s,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:f,edgesFocusable:d,edgesUpdatable:p,elevateNodesOnSelect:x,minZoom:m,maxZoom:g,nodeExtent:h,onNodesChange:v,onEdgesChange:b,elementsSelectable:w,connectionMode:_,snapGrid:N,snapToGrid:M,translateExtent:C,connectOnClick:k,defaultEdgeOptions:D,fitView:W,fitViewOptions:H,onNodesDelete:B,onEdgesDelete:y,onNodeDrag:A,onNodeDragStart:E,onNodeDragStop:T,onSelectionDrag:P,onSelectionDragStart:S,onSelectionDragStop:I,noPanClassName:F,nodeOrigin:z,rfId:L,autoPanOnConnect:O,autoPanOnNodeDrag:X,onError:G,connectionRadius:q,isValidConnection:Z,nodeDragThreshold:Q})=>{const{setNodes:K,setEdges:pt,setDefaultNodesAndEdges:lt,setMinZoom:gt,setMaxZoom:ut,setTranslateExtent:et,setNodeExtent:xt,reset:J}=tt(Lf,it),Y=nt();return $.useEffect(()=>{const st=r==null?void 0:r.map(Bt=>({...Bt,...D}));return lt(n,st),()=>{J()}},[]),U("defaultEdgeOptions",D,Y.setState),U("connectionMode",_,Y.setState),U("onConnect",i,Y.setState),U("onConnectStart",o,Y.setState),U("onConnectEnd",s,Y.setState),U("onClickConnectStart",a,Y.setState),U("onClickConnectEnd",c,Y.setState),U("nodesDraggable",l,Y.setState),U("nodesConnectable",u,Y.setState),U("nodesFocusable",f,Y.setState),U("edgesFocusable",d,Y.setState),U("edgesUpdatable",p,Y.setState),U("elementsSelectable",w,Y.setState),U("elevateNodesOnSelect",x,Y.setState),U("snapToGrid",M,Y.setState),U("snapGrid",N,Y.setState),U("onNodesChange",v,Y.setState),U("onEdgesChange",b,Y.setState),U("connectOnClick",k,Y.setState),U("fitViewOnInit",W,Y.setState),U("fitViewOnInitOptions",H,Y.setState),U("onNodesDelete",B,Y.setState),U("onEdgesDelete",y,Y.setState),U("onNodeDrag",A,Y.setState),U("onNodeDragStart",E,Y.setState),U("onNodeDragStop",T,Y.setState),U("onSelectionDrag",P,Y.setState),U("onSelectionDragStart",S,Y.setState),U("onSelectionDragStop",I,Y.setState),U("noPanClassName",F,Y.setState),U("nodeOrigin",z,Y.setState),U("rfId",L,Y.setState),U("autoPanOnConnect",O,Y.setState),U("autoPanOnNodeDrag",X,Y.setState),U("onError",G,Y.setState),U("connectionRadius",q,Y.setState),U("isValidConnection",Z,Y.setState),U("nodeDragThreshold",Q,Y.setState),re(t,K),re(e,pt),re(m,gt),re(g,ut),re(C,et),re(h,xt),null},yi={display:"none"},Yf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lo="react-flow__node-desc",Vo="react-flow__edge-desc",Xf="react-flow__aria-live",Uf=t=>t.ariaLiveMessage;function Gf({rfId:t}){const e=tt(Uf);return R.createElement("div",{id:`${Xf}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Yf},e)}function qf({rfId:t,disableKeyboardA11y:e}){return R.createElement(R.Fragment,null,R.createElement("div",{id:`${Lo}-${t}`,style:yi},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),R.createElement("div",{id:`${Vo}-${t}`,style:yi},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&R.createElement(Gf,{rfId:t}))}var Be=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,r]=$.useState(!1),i=$.useRef(!1),o=$.useRef(new Set([])),[s,a]=$.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(f=>typeof f=="string").map(f=>f.split("+")),u=l.reduce((f,d)=>f.concat(...d),[]);return[l,u]}return[[],[]]},[t]);return $.useEffect(()=>{const c=typeof document<"u"?document:null,l=(e==null?void 0:e.target)||c;if(t!==null){const u=p=>{if(i.current=p.ctrlKey||p.metaKey||p.shiftKey,(!i.current||i.current&&!e.actInsideInputWithModifier)&&ar(p))return!1;const m=wi(p.code,a);o.current.add(p[m]),vi(s,o.current,!1)&&(p.preventDefault(),r(!0))},f=p=>{if((!i.current||i.current&&!e.actInsideInputWithModifier)&&ar(p))return!1;const m=wi(p.code,a);vi(s,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(p[m]),p.key==="Meta"&&o.current.clear(),i.current=!1},d=()=>{o.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",d),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",d)}}},[t,r]),n};function vi(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(i=>e.has(i)))}function wi(t,e){return e.includes(t)?"code":"key"}function Yo(t,e,n,r){var a,c;const i=t.parentNode||t.parentId;if(!i)return n;const o=e.get(i),s=fe(o,r);return Yo(o,e,{x:(n.x??0)+s.x,y:(n.y??0)+s.y,z:(((a=o[j])==null?void 0:a.z)??0)>(n.z??0)?((c=o[j])==null?void 0:c.z)??0:n.z??0},r)}function Xo(t,e,n){t.forEach(r=>{var o;const i=r.parentNode||r.parentId;if(i&&!t.has(i))throw new Error(`Parent node ${i} not found`);if(i||n!=null&&n[r.id]){const{x:s,y:a,z:c}=Yo(r,t,{...r.position,z:((o=r[j])==null?void 0:o.z)??0},e);r.positionAbsolute={x:s,y:a},r[j].z=c,n!=null&&n[r.id]&&(r[j].isParent=!0)}})}function Ln(t,e,n,r){const i=new Map,o={},s=r?1e3:0;return t.forEach(a=>{var p;const c=(ft(a.zIndex)?a.zIndex:0)+(a.selected?s:0),l=e.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},f=a.parentNode||a.parentId;f&&(o[f]=!0);const d=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==a.type;Object.defineProperty(u,j,{enumerable:!1,value:{handleBounds:d||(p=l==null?void 0:l[j])==null?void 0:p.handleBounds,z:c}}),i.set(a.id,u)}),Xo(i,n,o),i}function Uo(t,e={}){const{getNodes:n,width:r,height:i,minZoom:o,maxZoom:s,d3Zoom:a,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:f}=t(),d=e.initial&&!l&&u;if(a&&c&&(d||!e.initial)){const x=n().filter(g=>{var v;const h=e.includeHiddenNodes?g.width&&g.height:!g.hidden;return(v=e.nodes)!=null&&v.length?h&&e.nodes.some(b=>b.id===g.id):h}),m=x.every(g=>g.width&&g.height);if(x.length>0&&m){const g=$r(x,f),{x:h,y:v,zoom:b}=Io(g,r,i,e.minZoom??o,e.maxZoom??s,e.padding??.1),w=Rt.translate(h,v).scale(b);return typeof e.duration=="number"&&e.duration>0?a.transform(Ut(c,e.duration),w):a.transform(c,w),!0}}return!1}function Zf(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[j]:r[j],selected:n.selected})}),new Map(e)}function Kf(t,e){return e.map(n=>{const r=t.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function Je({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:i,edges:o,onNodesChange:s,onEdgesChange:a,hasDefaultNodes:c,hasDefaultEdges:l}=n();t!=null&&t.length&&(c&&r({nodeInternals:Zf(t,i)}),s==null||s(t)),e!=null&&e.length&&(l&&r({edges:Kf(e,o)}),a==null||a(e))}const ie=()=>{},Jf={zoomIn:ie,zoomOut:ie,zoomTo:ie,getZoom:()=>1,setViewport:ie,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ie,fitBounds:ie,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},Qf=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),jf=()=>{const t=nt(),{d3Zoom:e,d3Selection:n}=tt(Qf,it);return $.useMemo(()=>n&&e?{zoomIn:i=>e.scaleBy(Ut(n,i==null?void 0:i.duration),1.2),zoomOut:i=>e.scaleBy(Ut(n,i==null?void 0:i.duration),1/1.2),zoomTo:(i,o)=>e.scaleTo(Ut(n,o==null?void 0:o.duration),i),getZoom:()=>t.getState().transform[2],setViewport:(i,o)=>{const[s,a,c]=t.getState().transform,l=Rt.translate(i.x??s,i.y??a).scale(i.zoom??c);e.transform(Ut(n,o==null?void 0:o.duration),l)},getViewport:()=>{const[i,o,s]=t.getState().transform;return{x:i,y:o,zoom:s}},fitView:i=>Uo(t.getState,i),setCenter:(i,o,s)=>{const{width:a,height:c,maxZoom:l}=t.getState(),u=typeof(s==null?void 0:s.zoom)<"u"?s.zoom:l,f=a/2-i*u,d=c/2-o*u,p=Rt.translate(f,d).scale(u);e.transform(Ut(n,s==null?void 0:s.duration),p)},fitBounds:(i,o)=>{const{width:s,height:a,minZoom:c,maxZoom:l}=t.getState(),{x:u,y:f,zoom:d}=Io(i,s,a,c,l,(o==null?void 0:o.padding)??.1),p=Rt.translate(u,f).scale(d);e.transform(Ut(n,o==null?void 0:o.duration),p)},project:i=>{const{transform:o,snapToGrid:s,snapGrid:a}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),ur(i,o,s,a)},screenToFlowPosition:i=>{const{transform:o,snapToGrid:s,snapGrid:a,domNode:c}=t.getState();if(!c)return i;const{x:l,y:u}=c.getBoundingClientRect(),f={x:i.x-l,y:i.y-u};return ur(f,o,s,a)},flowToScreenPosition:i=>{const{transform:o,domNode:s}=t.getState();if(!s)return i;const{x:a,y:c}=s.getBoundingClientRect(),l=ko(i,o);return{x:l.x+a,y:l.y+c}},viewportInitialized:!0}:Jf,[e,n])};function Go(){const t=jf(),e=nt(),n=$.useCallback(()=>e.getState().getNodes().map(m=>({...m})),[]),r=$.useCallback(m=>e.getState().nodeInternals.get(m),[]),i=$.useCallback(()=>{const{edges:m=[]}=e.getState();return m.map(g=>({...g}))},[]),o=$.useCallback(m=>{const{edges:g=[]}=e.getState();return g.find(h=>h.id===m)},[]),s=$.useCallback(m=>{const{getNodes:g,setNodes:h,hasDefaultNodes:v,onNodesChange:b}=e.getState(),w=g(),_=typeof m=="function"?m(w):m;if(v)h(_);else if(b){const N=_.length===0?w.map(M=>({type:"remove",id:M.id})):_.map(M=>({item:M,type:"reset"}));b(N)}},[]),a=$.useCallback(m=>{const{edges:g=[],setEdges:h,hasDefaultEdges:v,onEdgesChange:b}=e.getState(),w=typeof m=="function"?m(g):m;if(v)h(w);else if(b){const _=w.length===0?g.map(N=>({type:"remove",id:N.id})):w.map(N=>({item:N,type:"reset"}));b(_)}},[]),c=$.useCallback(m=>{const g=Array.isArray(m)?m:[m],{getNodes:h,setNodes:v,hasDefaultNodes:b,onNodesChange:w}=e.getState();if(b){const N=[...h(),...g];v(N)}else if(w){const _=g.map(N=>({item:N,type:"add"}));w(_)}},[]),l=$.useCallback(m=>{const g=Array.isArray(m)?m:[m],{edges:h=[],setEdges:v,hasDefaultEdges:b,onEdgesChange:w}=e.getState();if(b)v([...h,...g]);else if(w){const _=g.map(N=>({item:N,type:"add"}));w(_)}},[]),u=$.useCallback(()=>{const{getNodes:m,edges:g=[],transform:h}=e.getState(),[v,b,w]=h;return{nodes:m().map(_=>({..._})),edges:g.map(_=>({..._})),viewport:{x:v,y:b,zoom:w}}},[]),f=$.useCallback(({nodes:m,edges:g})=>{const{nodeInternals:h,getNodes:v,edges:b,hasDefaultNodes:w,hasDefaultEdges:_,onNodesDelete:N,onEdgesDelete:M,onNodesChange:C,onEdgesChange:k}=e.getState(),D=(m||[]).map(A=>A.id),W=(g||[]).map(A=>A.id),H=v().reduce((A,E)=>{const T=E.parentNode||E.parentId,P=!D.includes(E.id)&&T&&A.find(I=>I.id===T);return(typeof E.deletable=="boolean"?E.deletable:!0)&&(D.includes(E.id)||P)&&A.push(E),A},[]),B=b.filter(A=>typeof A.deletable=="boolean"?A.deletable:!0),y=B.filter(A=>W.includes(A.id));if(H||y){const A=Co(H,B),E=[...y,...A],T=E.reduce((P,S)=>(P.includes(S.id)||P.push(S.id),P),[]);if((_||w)&&(_&&e.setState({edges:b.filter(P=>!T.includes(P.id))}),w&&(H.forEach(P=>{h.delete(P.id)}),e.setState({nodeInternals:new Map(h)}))),T.length>0&&(M==null||M(E),k&&k(T.map(P=>({id:P,type:"remove"})))),H.length>0&&(N==null||N(H),C)){const P=H.map(S=>({id:S.id,type:"remove"}));C(P)}}},[]),d=$.useCallback(m=>{const g=wf(m),h=g?null:e.getState().nodeInternals.get(m.id);return!g&&!h?[null,null,g]:[g?m:ui(h),h,g]},[]),p=$.useCallback((m,g=!0,h)=>{const[v,b,w]=d(m);return v?(h||e.getState().getNodes()).filter(_=>{if(!w&&(_.id===b.id||!_.positionAbsolute))return!1;const N=ui(_),M=sr(N,v);return g&&M>0||M>=v.width*v.height}):[]},[]),x=$.useCallback((m,g,h=!0)=>{const[v]=d(m);if(!v)return!1;const b=sr(v,g);return h&&b>0||b>=v.width*v.height},[]);return $.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:i,getEdge:o,setNodes:s,setEdges:a,addNodes:c,addEdges:l,toObject:u,deleteElements:f,getIntersectingNodes:p,isNodeIntersecting:x}),[t,n,r,i,o,s,a,c,l,u,f,p,x])}const th={actInsideInputWithModifier:!1};var eh=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=nt(),{deleteElements:r}=Go(),i=Be(t,th),o=Be(e);$.useEffect(()=>{if(i){const{edges:s,getNodes:a}=n.getState(),c=a().filter(u=>u.selected),l=s.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[i]),$.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function nh(t){const e=nt();$.useEffect(()=>{let n;const r=()=>{var o,s;if(!t.current)return;const i=_r(t.current);(i.height===0||i.width===0)&&((s=(o=e.getState()).onError)==null||s.call(o,"004",Ct.error004())),e.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),t.current&&(n=new ResizeObserver(()=>r()),n.observe(t.current)),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}},[])}const Tr={position:"absolute",width:"100%",height:"100%",top:0,left:0},rh=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,Qe=t=>({x:t.x,y:t.y,zoom:t.k}),oe=(t,e)=>t.target.closest(`.${e}`),xi=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),bi=t=>{const e=t.ctrlKey&&mn()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},ih=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),oh=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=qt.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:f=!0,defaultViewport:d,translateExtent:p,minZoom:x,maxZoom:m,zoomActivationKeyCode:g,preventScrolling:h=!0,children:v,noWheelClassName:b,noPanClassName:w})=>{const _=$.useRef(),N=nt(),M=$.useRef(!1),C=$.useRef(!1),k=$.useRef(null),D=$.useRef({x:0,y:0,zoom:0}),{d3Zoom:W,d3Selection:H,d3ZoomHandler:B,userSelectionActive:y}=tt(ih,it),A=Be(g),E=$.useRef(0),T=$.useRef(!1),P=$.useRef();return nh(k),$.useEffect(()=>{if(k.current){const S=k.current.getBoundingClientRect(),I=uf().scaleExtent([x,m]).translateExtent(p),F=yt(k.current).call(I),z=Rt.translate(d.x,d.y).scale(ye(d.zoom,x,m)),L=[[0,0],[S.width,S.height]],O=I.constrain()(z,L,p);I.transform(F,O),I.wheelDelta(bi),N.setState({d3Zoom:I,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[O.x,O.y,O.k],domNode:k.current.closest(".react-flow")})}},[]),$.useEffect(()=>{H&&W&&(s&&!A&&!y?H.on("wheel.zoom",S=>{if(oe(S,b))return!1;S.preventDefault(),S.stopImmediatePropagation();const I=H.property("__zoom").k||1;if(S.ctrlKey&&o){const Z=_t(S),Q=bi(S),K=I*Math.pow(2,Q);W.scaleTo(H,K,Z,S);return}const F=S.deltaMode===1?20:1;let z=c===qt.Vertical?0:S.deltaX*F,L=c===qt.Horizontal?0:S.deltaY*F;!mn()&&S.shiftKey&&c!==qt.Vertical&&(z=S.deltaY*F,L=0),W.translateBy(H,-(z/I)*a,-(L/I)*a,{internal:!0});const O=Qe(H.property("__zoom")),{onViewportChangeStart:X,onViewportChange:G,onViewportChangeEnd:q}=N.getState();clearTimeout(P.current),T.current||(T.current=!0,e==null||e(S,O),X==null||X(O)),T.current&&(t==null||t(S,O),G==null||G(O),P.current=setTimeout(()=>{n==null||n(S,O),q==null||q(O),T.current=!1},150))},{passive:!1}):typeof B<"u"&&H.on("wheel.zoom",function(S,I){if(!h&&S.type==="wheel"&&!S.ctrlKey||oe(S,b))return null;S.preventDefault(),B.call(this,S,I)},{passive:!1}))},[y,s,c,H,W,B,A,o,h,b,e,t,n]),$.useEffect(()=>{W&&W.on("start",S=>{var z,L;if(!S.sourceEvent||S.sourceEvent.internal)return null;E.current=(z=S.sourceEvent)==null?void 0:z.button;const{onViewportChangeStart:I}=N.getState(),F=Qe(S.transform);M.current=!0,D.current=F,((L=S.sourceEvent)==null?void 0:L.type)==="mousedown"&&N.setState({paneDragging:!0}),I==null||I(F),e==null||e(S.sourceEvent,F)})},[W,e]),$.useEffect(()=>{W&&(y&&!M.current?W.on("zoom",null):y||W.on("zoom",S=>{var F;const{onViewportChange:I}=N.getState();if(N.setState({transform:[S.transform.x,S.transform.y,S.transform.k]}),C.current=!!(r&&xi(f,E.current??0)),(t||I)&&!((F=S.sourceEvent)!=null&&F.internal)){const z=Qe(S.transform);I==null||I(z),t==null||t(S.sourceEvent,z)}}))},[y,W,t,f,r]),$.useEffect(()=>{W&&W.on("end",S=>{if(!S.sourceEvent||S.sourceEvent.internal)return null;const{onViewportChangeEnd:I}=N.getState();if(M.current=!1,N.setState({paneDragging:!1}),r&&xi(f,E.current??0)&&!C.current&&r(S.sourceEvent),C.current=!1,(n||I)&&rh(D.current,S.transform)){const F=Qe(S.transform);D.current=F,clearTimeout(_.current),_.current=setTimeout(()=>{I==null||I(F),n==null||n(S.sourceEvent,F)},s?150:0)}})},[W,s,f,n,r]),$.useEffect(()=>{W&&W.filter(S=>{const I=A||i,F=o&&S.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&S.button===1&&S.type==="mousedown"&&(oe(S,"react-flow__node")||oe(S,"react-flow__edge")))return!0;if(!f&&!I&&!s&&!l&&!o||y||!l&&S.type==="dblclick"||oe(S,b)&&S.type==="wheel"||oe(S,w)&&(S.type!=="wheel"||s&&S.type==="wheel"&&!A)||!o&&S.ctrlKey&&S.type==="wheel"||!I&&!s&&!F&&S.type==="wheel"||!f&&(S.type==="mousedown"||S.type==="touchstart")||Array.isArray(f)&&!f.includes(S.button)&&S.type==="mousedown")return!1;const z=Array.isArray(f)&&f.includes(S.button)||!S.button||S.button<=1;return(!S.ctrlKey||S.type==="wheel")&&z})},[y,W,i,o,s,l,f,u,A]),R.createElement("div",{className:"react-flow__renderer",ref:k,style:Tr},v)},sh=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function ah(){const{userSelectionActive:t,userSelectionRect:e}=tt(sh,it);return t&&e?R.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function _i(t,e){const n=e.parentNode||e.parentId,r=t.find(i=>i.id===n);if(r){const i=e.position.x+e.width-r.width,o=e.position.y+e.height-r.height;if(i>0||o>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),o>0&&(r.style.height+=o),e.position.x<0){const s=Math.abs(e.position.x);r.position.x=r.position.x-s,r.style.width+=s,e.position.x=0}if(e.position.y<0){const s=Math.abs(e.position.y);r.position.y=r.position.y-s,r.style.height+=s,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function qo(t,e){if(t.some(r=>r.type==="reset"))return t.filter(r=>r.type==="reset").map(r=>r.item);const n=t.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,i)=>{const o=t.filter(a=>a.id===i.id);if(o.length===0)return r.push(i),r;const s={...i};for(const a of o)if(a)switch(a.type){case"select":{s.selected=a.selected;break}case"position":{typeof a.position<"u"&&(s.position=a.position),typeof a.positionAbsolute<"u"&&(s.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(s.dragging=a.dragging),s.expandParent&&_i(r,s);break}case"dimensions":{typeof a.dimensions<"u"&&(s.width=a.dimensions.width,s.height=a.dimensions.height),typeof a.updateStyle<"u"&&(s.style={...s.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(s.resizing=a.resizing),s.expandParent&&_i(r,s);break}case"remove":return r}return r.push(s),r},n)}function Zo(t,e){return qo(t,e)}function ch(t,e){return qo(t,e)}const Pt=(t,e)=>({id:t,type:"select",selected:e});function ce(t,e){return t.reduce((n,r)=>{const i=e.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(Pt(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(Pt(r.id,!1))),n},[])}const Vn=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},lh=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Ko=$.memo(({isSelecting:t,selectionMode:e=We.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:o,onPaneContextMenu:s,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:f})=>{const d=$.useRef(null),p=nt(),x=$.useRef(0),m=$.useRef(0),g=$.useRef(),{userSelectionActive:h,elementsSelectable:v,dragging:b}=tt(lh,it),w=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,m.current=0},_=B=>{o==null||o(B),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},N=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}s==null||s(B)},M=a?B=>a(B):void 0,C=B=>{const{resetSelectedElements:y,domNode:A}=p.getState();if(g.current=A==null?void 0:A.getBoundingClientRect(),!v||!t||B.button!==0||B.target!==d.current||!g.current)return;const{x:E,y:T}=Wt(B,g.current);y(),p.setState({userSelectionRect:{width:0,height:0,startX:E,startY:T,x:E,y:T}}),r==null||r(B)},k=B=>{const{userSelectionRect:y,nodeInternals:A,edges:E,transform:T,onNodesChange:P,onEdgesChange:S,nodeOrigin:I,getNodes:F}=p.getState();if(!t||!g.current||!y)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const z=Wt(B,g.current),L=y.startX??0,O=y.startY??0,X={...y,x:z.x<L?z.x:L,y:z.y<O?z.y:O,width:Math.abs(z.x-L),height:Math.abs(z.y-O)},G=F(),q=$o(A,X,T,e===We.Partial,!0,I),Z=Co(q,E).map(K=>K.id),Q=q.map(K=>K.id);if(x.current!==Q.length){x.current=Q.length;const K=ce(G,Q);K.length&&(P==null||P(K))}if(m.current!==Z.length){m.current=Z.length;const K=ce(E,Z);K.length&&(S==null||S(K))}p.setState({userSelectionRect:X})},D=B=>{if(B.button!==0)return;const{userSelectionRect:y}=p.getState();!h&&y&&B.target===d.current&&(_==null||_(B)),p.setState({nodesSelectionActive:x.current>0}),w(),i==null||i(B)},W=B=>{h&&(p.setState({nodesSelectionActive:x.current>0}),i==null||i(B)),w()},H=v&&(t||h);return R.createElement("div",{className:ht(["react-flow__pane",{dragging:b,selection:t}]),onClick:H?void 0:Vn(_,d),onContextMenu:Vn(N,d),onWheel:Vn(M,d),onMouseEnter:H?void 0:c,onMouseDown:H?C:void 0,onMouseMove:H?k:l,onMouseUp:H?D:void 0,onMouseLeave:H?W:u,ref:d,style:Tr},f,R.createElement(ah,null))});Ko.displayName="Pane";function Jo(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:Jo(r,e):!1}function Si(t,e,n){let r=t;do{if(r!=null&&r.matches(e))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function uh(t,e,n,r){return Array.from(t.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!Jo(i,t))&&(i.draggable||e&&typeof i.draggable>"u")).map(i=>{var o,s;return{id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=i.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((s=i.positionAbsolute)==null?void 0:s.y)??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}})}function fh(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function Qo(t,e,n,r,i=[0,0],o){const s=fh(t,t.extent||r);let a=s;const c=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(c&&t.width&&t.height){const f=n.get(c),{x:d,y:p}=fe(f,i).positionAbsolute;a=f&&ft(d)&&ft(p)&&ft(f.width)&&ft(f.height)?[[d+t.width*i[0],p+t.height*i[1]],[d+f.width-t.width+t.width*i[0],p+f.height-t.height+t.height*i[1]]]:a}else o==null||o("005",Ct.error005()),a=s;else if(t.extent&&c&&t.extent!=="parent"){const f=n.get(c),{x:d,y:p}=fe(f,i).positionAbsolute;a=[[t.extent[0][0]+d,t.extent[0][1]+p],[t.extent[1][0]+d,t.extent[1][1]+p]]}let l={x:0,y:0};if(c){const f=n.get(c);l=fe(f,i).positionAbsolute}const u=a&&a!=="parent"?Sr(e,a):e;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function Yn({nodeId:t,dragItems:e,nodeInternals:n}){const r=e.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[t?r.find(i=>i.id===t):r[0],r]}const Ei=(t,e,n,r)=>{const i=e.querySelectorAll(t);if(!i||!i.length)return null;const o=Array.from(i),s=e.getBoundingClientRect(),a={x:s.width*r[0],y:s.height*r[1]};return o.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-s.left-a.x)/n,y:(l.top-s.top-a.y)/n,..._r(c)}})};function $e(t,e,n){return n===void 0?n:r=>{const i=e().nodeInternals.get(t);i&&n(r,{...i})}}function hr({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:s,nodeInternals:a,onError:c}=e.getState(),l=a.get(t);if(!l){c==null||c("012",Ct.error012(t));return}e.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):i([t])}function hh(){const t=nt();return $.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:o}=t.getState(),s=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,c={x:(s-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:o?i[0]*Math.round(c.x/i[0]):c.x,ySnapped:o?i[1]*Math.round(c.y/i[1]):c.y,...c}},[])}function Xn(t){return(e,n,r)=>t==null?void 0:t(e,r)}function jo({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,selectNodesOnDrag:s}){const a=nt(),[c,l]=$.useState(!1),u=$.useRef([]),f=$.useRef({x:null,y:null}),d=$.useRef(0),p=$.useRef(null),x=$.useRef({x:0,y:0}),m=$.useRef(null),g=$.useRef(!1),h=$.useRef(!1),v=$.useRef(!1),b=hh();return $.useEffect(()=>{if(t!=null&&t.current){const w=yt(t.current),_=({x:C,y:k})=>{const{nodeInternals:D,onNodeDrag:W,onSelectionDrag:H,updateNodePositions:B,nodeExtent:y,snapGrid:A,snapToGrid:E,nodeOrigin:T,onError:P}=a.getState();f.current={x:C,y:k};let S=!1,I={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&y){const z=$r(u.current,T);I=Er(z)}if(u.current=u.current.map(z=>{const L={x:C-z.distance.x,y:k-z.distance.y};E&&(L.x=A[0]*Math.round(L.x/A[0]),L.y=A[1]*Math.round(L.y/A[1]));const O=[[y[0][0],y[0][1]],[y[1][0],y[1][1]]];u.current.length>1&&y&&!z.extent&&(O[0][0]=z.positionAbsolute.x-I.x+y[0][0],O[1][0]=z.positionAbsolute.x+(z.width??0)-I.x2+y[1][0],O[0][1]=z.positionAbsolute.y-I.y+y[0][1],O[1][1]=z.positionAbsolute.y+(z.height??0)-I.y2+y[1][1]);const X=Qo(z,L,D,O,T,P);return S=S||z.position.x!==X.position.x||z.position.y!==X.position.y,z.position=X.position,z.positionAbsolute=X.positionAbsolute,z}),!S)return;B(u.current,!0,!0),l(!0);const F=i?W:Xn(H);if(F&&m.current){const[z,L]=Yn({nodeId:i,dragItems:u.current,nodeInternals:D});F(m.current,z,L)}},N=()=>{if(!p.current)return;const[C,k]=xo(x.current,p.current);if(C!==0||k!==0){const{transform:D,panBy:W}=a.getState();f.current.x=(f.current.x??0)-C/D[2],f.current.y=(f.current.y??0)-k/D[2],W({x:C,y:k})&&_(f.current)}d.current=requestAnimationFrame(N)},M=C=>{var T;const{nodeInternals:k,multiSelectionActive:D,nodesDraggable:W,unselectNodesAndEdges:H,onNodeDragStart:B,onSelectionDragStart:y}=a.getState();h.current=!0;const A=i?B:Xn(y);(!s||!o)&&!D&&i&&((T=k.get(i))!=null&&T.selected||H()),i&&o&&s&&hr({id:i,store:a,nodeRef:t});const E=b(C);if(f.current=E,u.current=uh(k,W,E,i),A&&u.current){const[P,S]=Yn({nodeId:i,dragItems:u.current,nodeInternals:k});A(C.sourceEvent,P,S)}};if(e)w.on(".drag",null);else{const C=wl().on("start",k=>{const{domNode:D,nodeDragThreshold:W}=a.getState();W===0&&M(k),v.current=!1;const H=b(k);f.current=H,p.current=(D==null?void 0:D.getBoundingClientRect())||null,x.current=Wt(k.sourceEvent,p.current)}).on("drag",k=>{var B,y;const D=b(k),{autoPanOnNodeDrag:W,nodeDragThreshold:H}=a.getState();if(k.sourceEvent.type==="touchmove"&&k.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!g.current&&h.current&&W&&(g.current=!0,N()),!h.current){const A=D.xSnapped-(((B=f==null?void 0:f.current)==null?void 0:B.x)??0),E=D.ySnapped-(((y=f==null?void 0:f.current)==null?void 0:y.y)??0);Math.sqrt(A*A+E*E)>H&&M(k)}(f.current.x!==D.xSnapped||f.current.y!==D.ySnapped)&&u.current&&h.current&&(m.current=k.sourceEvent,x.current=Wt(k.sourceEvent,p.current),_(D))}}).on("end",k=>{if(!(!h.current||v.current)&&(l(!1),g.current=!1,h.current=!1,cancelAnimationFrame(d.current),u.current)){const{updateNodePositions:D,nodeInternals:W,onNodeDragStop:H,onSelectionDragStop:B}=a.getState(),y=i?H:Xn(B);if(D(u.current,!1,!1),y){const[A,E]=Yn({nodeId:i,dragItems:u.current,nodeInternals:W});y(k.sourceEvent,A,E)}}}).filter(k=>{const D=k.target;return!k.button&&(!n||!Si(D,`.${n}`,t))&&(!r||Si(D,r,t))});return w.call(C),()=>{w.on(".drag",null)}}}},[t,e,n,r,o,a,i,s,b]),c}function ts(){const t=nt();return $.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:o,getNodes:s,snapToGrid:a,snapGrid:c,onError:l,nodesDraggable:u}=t.getState(),f=s().filter(v=>v.selected&&(v.draggable||u&&typeof v.draggable>"u")),d=a?c[0]:5,p=a?c[1]:5,x=n.isShiftPressed?4:1,m=n.x*d*x,g=n.y*p*x,h=f.map(v=>{if(v.positionAbsolute){const b={x:v.positionAbsolute.x+m,y:v.positionAbsolute.y+g};a&&(b.x=c[0]*Math.round(b.x/c[0]),b.y=c[1]*Math.round(b.y/c[1]));const{positionAbsolute:w,position:_}=Qo(v,b,r,i,void 0,l);v.position=_,v.positionAbsolute=w}return v});o(h,!0,!1)},[])}const he={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Ce=t=>{const e=({id:n,type:r,data:i,xPos:o,yPos:s,xPosOrigin:a,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:f,onMouseMove:d,onMouseLeave:p,onContextMenu:x,onDoubleClick:m,style:g,className:h,isDraggable:v,isSelectable:b,isConnectable:w,isFocusable:_,selectNodesOnDrag:N,sourcePosition:M,targetPosition:C,hidden:k,resizeObserver:D,dragHandle:W,zIndex:H,isParent:B,noDragClassName:y,noPanClassName:A,initialized:E,disableKeyboardA11y:T,ariaLabel:P,rfId:S,hasHandleBounds:I})=>{const F=nt(),z=$.useRef(null),L=$.useRef(null),O=$.useRef(M),X=$.useRef(C),G=$.useRef(r),q=b||v||u||f||d||p,Z=ts(),Q=$e(n,F.getState,f),K=$e(n,F.getState,d),pt=$e(n,F.getState,p),lt=$e(n,F.getState,x),gt=$e(n,F.getState,m),ut=J=>{const{nodeDragThreshold:Y}=F.getState();if(b&&(!N||!v||Y>0)&&hr({id:n,store:F,nodeRef:z}),u){const st=F.getState().nodeInternals.get(n);st&&u(J,{...st})}},et=J=>{if(!ar(J)&&!T)if(_o.includes(J.key)&&b){const Y=J.key==="Escape";hr({id:n,store:F,unselect:Y,nodeRef:z})}else v&&l&&Object.prototype.hasOwnProperty.call(he,J.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${J.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~s}`}),Z({x:he[J.key].x,y:he[J.key].y,isShiftPressed:J.shiftKey}))};$.useEffect(()=>()=>{L.current&&(D==null||D.unobserve(L.current),L.current=null)},[]),$.useEffect(()=>{if(z.current&&!k){const J=z.current;(!E||!I||L.current!==J)&&(L.current&&(D==null||D.unobserve(L.current)),D==null||D.observe(J),L.current=J)}},[k,E,I]),$.useEffect(()=>{const J=G.current!==r,Y=O.current!==M,st=X.current!==C;z.current&&(J||Y||st)&&(J&&(G.current=r),Y&&(O.current=M),st&&(X.current=C),F.getState().updateNodeDimensions([{id:n,nodeElement:z.current,forceUpdate:!0}]))},[n,r,M,C]);const xt=jo({nodeRef:z,disabled:k||!v,noDragClassName:y,handleSelector:W,nodeId:n,isSelectable:b,selectNodesOnDrag:N});return k?null:R.createElement("div",{className:ht(["react-flow__node",`react-flow__node-${r}`,{[A]:v},h,{selected:l,selectable:b,parent:B,dragging:xt}]),ref:z,style:{zIndex:H,transform:`translate(${a}px,${c}px)`,pointerEvents:q?"all":"none",visibility:E?"visible":"hidden",...g},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Q,onMouseMove:K,onMouseLeave:pt,onContextMenu:lt,onClick:ut,onDoubleClick:gt,onKeyDown:_?et:void 0,tabIndex:_?0:void 0,role:_?"button":void 0,"aria-describedby":T?void 0:`${Lo}-${S}`,"aria-label":P},R.createElement(Af,{value:n},R.createElement(t,{id:n,data:i,type:r,xPos:o,yPos:s,selected:l,isConnectable:w,sourcePosition:M,targetPosition:C,dragging:xt,dragHandle:W,zIndex:H})))};return e.displayName="NodeWrapper",$.memo(e)};const dh=t=>{const e=t.getNodes().filter(n=>n.selected);return{...$r(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function ph({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=nt(),{width:i,height:o,x:s,y:a,transformString:c,userSelectionActive:l}=tt(dh,it),u=ts(),f=$.useRef(null);if($.useEffect(()=>{var x;n||(x=f.current)==null||x.focus({preventScroll:!0})},[n]),jo({nodeRef:f}),l||!i||!o)return null;const d=t?x=>{const m=r.getState().getNodes().filter(g=>g.selected);t(x,m)}:void 0,p=x=>{Object.prototype.hasOwnProperty.call(he,x.key)&&u({x:he[x.key].x,y:he[x.key].y,isShiftPressed:x.shiftKey})};return R.createElement("div",{className:ht(["react-flow__nodesselection","react-flow__container",e]),style:{transform:c}},R.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:i,height:o,top:a,left:s}}))}var gh=$.memo(ph);const mh=t=>t.nodesSelectionActive,es=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:s,deleteKeyCode:a,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:f,selectionOnDrag:d,selectionMode:p,onSelectionStart:x,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:h,zoomActivationKeyCode:v,elementsSelectable:b,zoomOnScroll:w,zoomOnPinch:_,panOnScroll:N,panOnScrollSpeed:M,panOnScrollMode:C,zoomOnDoubleClick:k,panOnDrag:D,defaultViewport:W,translateExtent:H,minZoom:B,maxZoom:y,preventScrolling:A,onSelectionContextMenu:E,noWheelClassName:T,noPanClassName:P,disableKeyboardA11y:S})=>{const I=tt(mh),F=Be(f),z=Be(h),L=z||D,O=z||N,X=F||d&&L!==!0;return eh({deleteKeyCode:a,multiSelectionKeyCode:g}),R.createElement(oh,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:o,elementsSelectable:b,zoomOnScroll:w,zoomOnPinch:_,panOnScroll:O,panOnScrollSpeed:M,panOnScrollMode:C,zoomOnDoubleClick:k,panOnDrag:!F&&L,defaultViewport:W,translateExtent:H,minZoom:B,maxZoom:y,zoomActivationKeyCode:v,preventScrolling:A,noWheelClassName:T,noPanClassName:P},R.createElement(Ko,{onSelectionStart:x,onSelectionEnd:m,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:L,isSelecting:!!X,selectionMode:p},t,I&&R.createElement(gh,{onSelectionContextMenu:E,noPanClassName:P,disableKeyboardA11y:S})))};es.displayName="FlowRenderer";var yh=$.memo(es);function vh(t){return tt($.useCallback(n=>t?$o(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function wh(t){const e={input:Ce(t.input||Wo),default:Ce(t.default||fr),output:Ce(t.output||Ho),group:Ce(t.group||Ir)},n={},r=Object.keys(t).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,o)=>(i[o]=Ce(t[o]||fr),i),n);return{...e,...r}}const xh=({x:t,y:e,width:n,height:r,origin:i})=>!n||!r?{x:t,y:e}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:t,y:e}:{x:t-n*i[0],y:e-r*i[1]},bh=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),ns=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:o,onError:s}=tt(bh,it),a=vh(t.onlyRenderVisibleElements),c=$.useRef(),l=$.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(f=>{const d=f.map(p=>({id:p.target.getAttribute("data-id"),nodeElement:p.target,forceUpdate:!0}));o(d)});return c.current=u,u},[]);return $.useEffect(()=>()=>{var u;(u=c==null?void 0:c.current)==null||u.disconnect()},[]),R.createElement("div",{className:"react-flow__nodes",style:Tr},a.map(u=>{var _,N,M;let f=u.type||"default";t.nodeTypes[f]||(s==null||s("003",Ct.error003(f)),f="default");const d=t.nodeTypes[f]||t.nodeTypes.default,p=!!(u.draggable||e&&typeof u.draggable>"u"),x=!!(u.selectable||i&&typeof u.selectable>"u"),m=!!(u.connectable||n&&typeof u.connectable>"u"),g=!!(u.focusable||r&&typeof u.focusable>"u"),h=t.nodeExtent?Sr(u.positionAbsolute,t.nodeExtent):u.positionAbsolute,v=(h==null?void 0:h.x)??0,b=(h==null?void 0:h.y)??0,w=xh({x:v,y:b,width:u.width??0,height:u.height??0,origin:t.nodeOrigin});return R.createElement(d,{key:u.id,id:u.id,className:u.className,style:u.style,type:f,data:u.data,sourcePosition:u.sourcePosition||V.Bottom,targetPosition:u.targetPosition||V.Top,hidden:u.hidden,xPos:v,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!u.selected,isDraggable:p,isSelectable:x,isConnectable:m,isFocusable:g,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((_=u[j])==null?void 0:_.z)??0,isParent:!!((N=u[j])!=null&&N.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!u.width&&!!u.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((M=u[j])!=null&&M.handleBounds)})}))};ns.displayName="NodeRenderer";var _h=$.memo(ns);const Sh=(t,e,n)=>n===V.Left?t-e:n===V.Right?t+e:t,Eh=(t,e,n)=>n===V.Top?t-e:n===V.Bottom?t+e:t,Ni="react-flow__edgeupdater",Ai=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:s,type:a})=>R.createElement("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:s,className:ht([Ni,`${Ni}-${a}`]),cx:Sh(e,r,t),cy:Eh(n,r,t),r,stroke:"transparent",fill:"transparent"}),Nh=()=>!0;var se=t=>{const e=({id:n,className:r,type:i,data:o,onClick:s,onEdgeDoubleClick:a,selected:c,animated:l,label:u,labelStyle:f,labelShowBg:d,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:m,style:g,source:h,target:v,sourceX:b,sourceY:w,targetX:_,targetY:N,sourcePosition:M,targetPosition:C,elementsSelectable:k,hidden:D,sourceHandleId:W,targetHandleId:H,onContextMenu:B,onMouseEnter:y,onMouseMove:A,onMouseLeave:E,reconnectRadius:T,onReconnect:P,onReconnectStart:S,onReconnectEnd:I,markerEnd:F,markerStart:z,rfId:L,ariaLabel:O,isFocusable:X,isReconnectable:G,pathOptions:q,interactionWidth:Z,disableKeyboardA11y:Q})=>{const K=$.useRef(null),[pt,lt]=$.useState(!1),[gt,ut]=$.useState(!1),et=nt(),xt=$.useMemo(()=>`url('#${lr(z,L)}')`,[z,L]),J=$.useMemo(()=>`url('#${lr(F,L)}')`,[F,L]);if(D)return null;const Y=rt=>{var bt;const{edges:mt,addSelectedEdges:Lt,unselectNodesAndEdges:Vt,multiSelectionActive:Yt}=et.getState(),At=mt.find(Ee=>Ee.id===n);At&&(k&&(et.setState({nodesSelectionActive:!1}),At.selected&&Yt?(Vt({nodes:[],edges:[At]}),(bt=K.current)==null||bt.blur()):Lt([n])),s&&s(rt,At))},st=ke(n,et.getState,a),Bt=ke(n,et.getState,B),_e=ke(n,et.getState,y),Qt=ke(n,et.getState,A),jt=ke(n,et.getState,E),Nt=(rt,mt)=>{if(rt.button!==0)return;const{edges:Lt,isValidConnection:Vt}=et.getState(),Yt=mt?v:h,At=(mt?H:W)||null,bt=mt?"target":"source",Ee=Vt||Nh,Dn=mt,Ne=Lt.find(Xt=>Xt.id===n);ut(!0),S==null||S(rt,Ne,bt);const Pn=Xt=>{ut(!1),I==null||I(Xt,Ne,bt)};Po({event:rt,handleId:At,nodeId:Yt,onConnect:Xt=>P==null?void 0:P(Ne,Xt),isTarget:Dn,getState:et.getState,setState:et.setState,isValidConnection:Ee,edgeUpdaterType:bt,onReconnectEnd:Pn})},te=rt=>Nt(rt,!0),Ht=rt=>Nt(rt,!1),Ot=()=>lt(!0),ee=()=>lt(!1),ne=!k&&!s,Se=rt=>{var mt;if(!Q&&_o.includes(rt.key)&&k){const{unselectNodesAndEdges:Lt,addSelectedEdges:Vt,edges:Yt}=et.getState();rt.key==="Escape"?((mt=K.current)==null||mt.blur(),Lt({edges:[Yt.find(bt=>bt.id===n)]})):Vt([n])}};return R.createElement("g",{className:ht(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:c,animated:l,inactive:ne,updating:pt}]),onClick:Y,onDoubleClick:st,onContextMenu:Bt,onMouseEnter:_e,onMouseMove:Qt,onMouseLeave:jt,onKeyDown:X?Se:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":O===null?void 0:O||`Edge from ${h} to ${v}`,"aria-describedby":X?`${Vo}-${L}`:void 0,ref:K},!gt&&R.createElement(t,{id:n,source:h,target:v,selected:c,animated:l,label:u,labelStyle:f,labelShowBg:d,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:m,data:o,style:g,sourceX:b,sourceY:w,targetX:_,targetY:N,sourcePosition:M,targetPosition:C,sourceHandleId:W,targetHandleId:H,markerStart:xt,markerEnd:J,pathOptions:q,interactionWidth:Z}),G&&R.createElement(R.Fragment,null,(G==="source"||G===!0)&&R.createElement(Ai,{position:M,centerX:b,centerY:w,radius:T,onMouseDown:te,onMouseEnter:Ot,onMouseOut:ee,type:"source"}),(G==="target"||G===!0)&&R.createElement(Ai,{position:C,centerX:_,centerY:N,radius:T,onMouseDown:Ht,onMouseEnter:Ot,onMouseOut:ee,type:"target"})))};return e.displayName="EdgeWrapper",$.memo(e)};function Ah(t){const e={default:se(t.default||vn),straight:se(t.bezier||Mr),step:se(t.step||Ar),smoothstep:se(t.step||Cn),simplebezier:se(t.simplebezier||Nr)},n={},r=Object.keys(t).filter(i=>!["default","bezier"].includes(i)).reduce((i,o)=>(i[o]=se(t[o]||vn),i),n);return{...e,...r}}function Mi(t,e,n=null){const r=((n==null?void 0:n.x)||0)+e.x,i=((n==null?void 0:n.y)||0)+e.y,o=(n==null?void 0:n.width)||e.width,s=(n==null?void 0:n.height)||e.height;switch(t){case V.Top:return{x:r+o/2,y:i};case V.Right:return{x:r+o,y:i+s/2};case V.Bottom:return{x:r+o/2,y:i+s};case V.Left:return{x:r,y:i+s/2}}}function ki(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const Mh=(t,e,n,r,i,o)=>{const s=Mi(n,t,e),a=Mi(o,r,i);return{sourceX:s.x,sourceY:s.y,targetX:a.x,targetY:a.y}};function kh({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:o,width:s,height:a,transform:c}){const l={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+i),y2:Math.max(t.y+r,e.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=Er({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:s/c[2],height:a/c[2]}),f=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),d=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(f*d)>0}function $i(t){var r,i,o,s,a;const e=((r=t==null?void 0:t[j])==null?void 0:r.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)<"u"&&typeof((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.x)||0,y:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const $h=[{level:0,isMaxLevel:!0,edges:[]}];function Ch(t,e,n=!1){let r=-1;const i=t.reduce((s,a)=>{var u,f;const c=ft(a.zIndex);let l=c?a.zIndex:0;if(n){const d=e.get(a.target),p=e.get(a.source),x=a.selected||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),m=Math.max(((u=p==null?void 0:p[j])==null?void 0:u.z)||0,((f=d==null?void 0:d[j])==null?void 0:f.z)||0,1e3);l=(c?a.zIndex:0)+(x?m:0)}return s[l]?s[l].push(a):s[l]=[a],r=l>r?l:r,s},{}),o=Object.entries(i).map(([s,a])=>{const c=+s;return{edges:a,level:c,isMaxLevel:c===r}});return o.length===0?$h:o}function Ih(t,e,n){const r=tt($.useCallback(i=>t?i.edges.filter(o=>{const s=e.get(o.source),a=e.get(o.target);return(s==null?void 0:s.width)&&(s==null?void 0:s.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&kh({sourcePos:s.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:s.width,sourceHeight:s.height,targetWidth:a.width,targetHeight:a.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[t,e]));return Ch(r,e,n)}const Th=({color:t="none",strokeWidth:e=1})=>R.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Dh=({color:t="none",strokeWidth:e=1})=>R.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ci={[yn.Arrow]:Th,[yn.ArrowClosed]:Dh};function Ph(t){const e=nt();return $.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(Ci,t)?Ci[t]:((o=(i=e.getState()).onError)==null||o.call(i,"009",Ct.error009(t)),null)},[t])}const Fh=({id:t,type:e,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Ph(e);return c?R.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0"},R.createElement(c,{color:n,strokeWidth:s})):null},zh=({defaultColor:t,rfId:e})=>n=>{const r=[];return n.edges.reduce((i,o)=>([o.markerStart,o.markerEnd].forEach(s=>{if(s&&typeof s=="object"){const a=lr(s,e);r.includes(a)||(i.push({id:a,color:s.color||t,...s}),r.push(a))}}),i),[]).sort((i,o)=>i.id.localeCompare(o.id))},rs=({defaultColor:t,rfId:e})=>{const n=tt($.useCallback(zh({defaultColor:t,rfId:e}),[t,e]),(r,i)=>!(r.length!==i.length||r.some((o,s)=>o.id!==i[s].id)));return R.createElement("defs",null,n.map(r=>R.createElement(Fh,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};rs.displayName="MarkerDefinitions";var Rh=$.memo(rs);const Wh=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),is=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:o,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:p,onReconnectEnd:x,reconnectRadius:m,children:g,disableKeyboardA11y:h})=>{const{edgesFocusable:v,edgesUpdatable:b,elementsSelectable:w,width:_,height:N,connectionMode:M,nodeInternals:C,onError:k}=tt(Wh,it),D=Ih(e,C,n);return _?R.createElement(R.Fragment,null,D.map(({level:W,edges:H,isMaxLevel:B})=>R.createElement("svg",{key:W,style:{zIndex:W},width:_,height:N,className:"react-flow__edges react-flow__container"},B&&R.createElement(Rh,{defaultColor:t,rfId:r}),R.createElement("g",null,H.map(y=>{const[A,E,T]=$i(C.get(y.source)),[P,S,I]=$i(C.get(y.target));if(!T||!I)return null;let F=y.type||"default";i[F]||(k==null||k("011",Ct.error011(F)),F="default");const z=i[F]||i.default,L=M===Jt.Strict?S.target:(S.target??[]).concat(S.source??[]),O=ki(E.source,y.sourceHandle),X=ki(L,y.targetHandle),G=(O==null?void 0:O.position)||V.Bottom,q=(X==null?void 0:X.position)||V.Top,Z=!!(y.focusable||v&&typeof y.focusable>"u"),Q=y.reconnectable||y.updatable,K=typeof d<"u"&&(Q||b&&typeof Q>"u");if(!O||!X)return k==null||k("008",Ct.error008(O,y)),null;const{sourceX:pt,sourceY:lt,targetX:gt,targetY:ut}=Mh(A,O,G,P,X,q);return R.createElement(z,{key:y.id,id:y.id,className:ht([y.className,o]),type:F,data:y.data,selected:!!y.selected,animated:!!y.animated,hidden:!!y.hidden,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,style:y.style,source:y.source,target:y.target,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerEnd:y.markerEnd,markerStart:y.markerStart,sourceX:pt,sourceY:lt,targetX:gt,targetY:ut,sourcePosition:G,targetPosition:q,elementsSelectable:w,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:p,onReconnectEnd:x,reconnectRadius:m,rfId:r,ariaLabel:y.ariaLabel,isFocusable:Z,isReconnectable:K,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth,disableKeyboardA11y:h})})))),g):null};is.displayName="EdgeRenderer";var Bh=$.memo(is);const Hh=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function Oh({children:t}){const e=tt(Hh);return R.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function Lh(t){const e=Go(),n=$.useRef(!1);$.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const Vh={[V.Left]:V.Right,[V.Right]:V.Left,[V.Top]:V.Bottom,[V.Bottom]:V.Top},os=({nodeId:t,handleType:e,style:n,type:r=zt.Bezier,CustomComponent:i,connectionStatus:o})=>{var N,M,C;const{fromNode:s,handleId:a,toX:c,toY:l,connectionMode:u}=tt($.useCallback(k=>({fromNode:k.nodeInternals.get(t),handleId:k.connectionHandleId,toX:(k.connectionPosition.x-k.transform[0])/k.transform[2],toY:(k.connectionPosition.y-k.transform[1])/k.transform[2],connectionMode:k.connectionMode}),[t]),it),f=(N=s==null?void 0:s[j])==null?void 0:N.handleBounds;let d=f==null?void 0:f[e];if(u===Jt.Loose&&(d=d||(f==null?void 0:f[e==="source"?"target":"source"])),!s||!d)return null;const p=a?d.find(k=>k.id===a):d[0],x=p?p.x+p.width/2:(s.width??0)/2,m=p?p.y+p.height/2:s.height??0,g=(((M=s.positionAbsolute)==null?void 0:M.x)??0)+x,h=(((C=s.positionAbsolute)==null?void 0:C.y)??0)+m,v=p==null?void 0:p.position,b=v?Vh[v]:null;if(!v||!b)return null;if(i)return R.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:s,fromHandle:p,fromX:g,fromY:h,toX:c,toY:l,fromPosition:v,toPosition:b,connectionStatus:o});let w="";const _={sourceX:g,sourceY:h,sourcePosition:v,targetX:c,targetY:l,targetPosition:b};return r===zt.Bezier?[w]=Mo(_):r===zt.Step?[w]=cr({..._,borderRadius:0}):r===zt.SmoothStep?[w]=cr(_):r===zt.SimpleBezier?[w]=Ao(_):w=`M${g},${h} ${c},${l}`,R.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};os.displayName="ConnectionLine";const Yh=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function Xh({containerStyle:t,style:e,type:n,component:r}){const{nodeId:i,handleType:o,nodesConnectable:s,width:a,height:c,connectionStatus:l}=tt(Yh,it);return!(i&&o&&a&&s)?null:R.createElement("svg",{style:t,width:a,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},R.createElement("g",{className:ht(["react-flow__connection",l])},R.createElement(os,{nodeId:i,handleType:o,style:e,type:n,CustomComponent:r,connectionStatus:l})))}function Ii(t,e){return $.useRef(null),nt(),$.useMemo(()=>e(t),[t])}const ss=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:x,onSelectionStart:m,onSelectionEnd:g,connectionLineType:h,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:w,selectionKeyCode:_,selectionOnDrag:N,selectionMode:M,multiSelectionKeyCode:C,panActivationKeyCode:k,zoomActivationKeyCode:D,deleteKeyCode:W,onlyRenderVisibleElements:H,elementsSelectable:B,selectNodesOnDrag:y,defaultViewport:A,translateExtent:E,minZoom:T,maxZoom:P,preventScrolling:S,defaultMarkerColor:I,zoomOnScroll:F,zoomOnPinch:z,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:X,zoomOnDoubleClick:G,panOnDrag:q,onPaneClick:Z,onPaneMouseEnter:Q,onPaneMouseMove:K,onPaneMouseLeave:pt,onPaneScroll:lt,onPaneContextMenu:gt,onEdgeContextMenu:ut,onEdgeMouseEnter:et,onEdgeMouseMove:xt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:st,onReconnectEnd:Bt,reconnectRadius:_e,noDragClassName:Qt,noWheelClassName:jt,noPanClassName:Nt,elevateEdgesOnSelect:te,disableKeyboardA11y:Ht,nodeOrigin:Ot,nodeExtent:ee,rfId:ne})=>{const Se=Ii(t,wh),rt=Ii(e,Ah);return Lh(o),R.createElement(yh,{onPaneClick:Z,onPaneMouseEnter:Q,onPaneMouseMove:K,onPaneMouseLeave:pt,onPaneContextMenu:gt,onPaneScroll:lt,deleteKeyCode:W,selectionKeyCode:_,selectionOnDrag:N,selectionMode:M,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:C,panActivationKeyCode:k,zoomActivationKeyCode:D,elementsSelectable:B,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:F,zoomOnPinch:z,zoomOnDoubleClick:G,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:X,panOnDrag:q,defaultViewport:A,translateExtent:E,minZoom:T,maxZoom:P,onSelectionContextMenu:x,preventScrolling:S,noDragClassName:Qt,noWheelClassName:jt,noPanClassName:Nt,disableKeyboardA11y:Ht},R.createElement(Oh,null,R.createElement(Bh,{edgeTypes:rt,onEdgeClick:a,onEdgeDoubleClick:l,onlyRenderVisibleElements:H,onEdgeContextMenu:ut,onEdgeMouseEnter:et,onEdgeMouseMove:xt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:st,onReconnectEnd:Bt,reconnectRadius:_e,defaultMarkerColor:I,noPanClassName:Nt,elevateEdgesOnSelect:!!te,disableKeyboardA11y:Ht,rfId:ne},R.createElement(Xh,{style:v,type:h,component:b,containerStyle:w})),R.createElement("div",{className:"react-flow__edgelabel-renderer"}),R.createElement(_h,{nodeTypes:Se,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:p,selectNodesOnDrag:y,onlyRenderVisibleElements:H,noPanClassName:Nt,noDragClassName:Qt,disableKeyboardA11y:Ht,nodeOrigin:Ot,nodeExtent:ee,rfId:ne})))};ss.displayName="GraphView";var Uh=$.memo(ss);const dr=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Tt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:dr,nodeExtent:dr,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Jt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:xf,isValidConnection:void 0},Gh=()=>Ia((t,e)=>({...Tt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:o}=e();t({nodeInternals:Ln(n,r,i,o)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=e();t({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",o=typeof r<"u",s=i?Ln(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:s,edges:o?r:[],hasDefaultNodes:i,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:o,fitViewOnInitDone:s,fitViewOnInitOptions:a,domNode:c,nodeOrigin:l}=e(),u=c==null?void 0:c.querySelector(".react-flow__viewport");if(!u)return;const f=window.getComputedStyle(u),{m22:d}=new window.DOMMatrixReadOnly(f.transform),p=n.reduce((m,g)=>{const h=i.get(g.id);if(h!=null&&h.hidden)i.set(h.id,{...h,[j]:{...h[j],handleBounds:void 0}});else if(h){const v=_r(g.nodeElement);!!(v.width&&v.height&&(h.width!==v.width||h.height!==v.height||g.forceUpdate))&&(i.set(h.id,{...h,[j]:{...h[j],handleBounds:{source:Ei(".source",g.nodeElement,d,l),target:Ei(".target",g.nodeElement,d,l)}},...v}),m.push({id:h.id,type:"dimensions",dimensions:v}))}return m},[]);Xo(i,l);const x=s||o&&!s&&Uo(e,{initial:!0,...a});t({nodeInternals:new Map(i),fitViewOnInitDone:x}),(p==null?void 0:p.length)>0&&(r==null||r(p))},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:o}=e(),s=n.map(a=>{const c={id:a.id,type:"position",dragging:i};return r&&(c.positionAbsolute=a.positionAbsolute,c.position=a.position),c});o(s)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:o,nodeOrigin:s,getNodes:a,elevateNodesOnSelect:c}=e();if(n!=null&&n.length){if(o){const l=Zo(n,a()),u=Ln(l,i,s,c);t({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=e();let s,a=null;r?s=n.map(c=>Pt(c,!0)):(s=ce(o(),n),a=ce(i,[])),Je({changedNodes:s,changedEdges:a,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=e();let s,a=null;r?s=n.map(c=>Pt(c,!0)):(s=ce(i,n),a=ce(o(),[])),Je({changedNodes:a,changedEdges:s,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:o}=e(),s=n||o(),a=r||i,c=s.map(u=>(u.selected=!1,Pt(u.id,!1))),l=a.map(u=>Pt(u.id,!1));Je({changedNodes:c,changedEdges:l,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=e();r==null||r.scaleExtent([n,i]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=e();r==null||r.scaleExtent([i,n]),t({maxZoom:n})},setTranslateExtent:n=>{var r;(r=e().d3Zoom)==null||r.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=e(),o=r().filter(a=>a.selected).map(a=>Pt(a.id,!1)),s=n.filter(a=>a.selected).map(a=>Pt(a.id,!1));Je({changedNodes:o,changedEdges:s,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(i=>{i.positionAbsolute=Sr(i.position,n)}),t({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:o,d3Zoom:s,d3Selection:a,translateExtent:c}=e();if(!s||!a||!n.x&&!n.y)return!1;const l=Rt.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[i,o]],f=s==null?void 0:s.constrain()(l,u,c);return s.transform(a,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>t({connectionNodeId:Tt.connectionNodeId,connectionHandleId:Tt.connectionHandleId,connectionHandleType:Tt.connectionHandleType,connectionStatus:Tt.connectionStatus,connectionStartHandle:Tt.connectionStartHandle,connectionEndHandle:Tt.connectionEndHandle}),reset:()=>t({...Tt})}),Object.is),as=({children:t})=>{const e=$.useRef(null);return e.current||(e.current=Gh()),R.createElement(ff,{value:e.current},t)};as.displayName="ReactFlowProvider";const cs=({children:t})=>$.useContext($n)?R.createElement(R.Fragment,null,t):R.createElement(as,null,t);cs.displayName="ReactFlowWrapper";const qh={input:Wo,default:fr,output:Ho,group:Ir},Zh={default:vn,straight:Mr,step:Ar,smoothstep:Cn,simplebezier:Nr},Kh=[0,0],Jh=[15,15],Qh={x:0,y:0,zoom:1},jh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},td=$.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o=qh,edgeTypes:s=Zh,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onConnect:p,onConnectStart:x,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:h,onNodeMouseEnter:v,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:_,onNodeDoubleClick:N,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:k,onNodesDelete:D,onEdgesDelete:W,onSelectionChange:H,onSelectionDragStart:B,onSelectionDrag:y,onSelectionDragStop:A,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:P,connectionMode:S=Jt.Strict,connectionLineType:I=zt.Bezier,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:L,deleteKeyCode:O="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:G=!1,selectionMode:q=We.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:Q=mn()?"Meta":"Control",zoomActivationKeyCode:K=mn()?"Meta":"Control",snapToGrid:pt=!1,snapGrid:lt=Jh,onlyRenderVisibleElements:gt=!1,selectNodesOnDrag:ut=!0,nodesDraggable:et,nodesConnectable:xt,nodesFocusable:J,nodeOrigin:Y=Kh,edgesFocusable:st,edgesUpdatable:Bt,elementsSelectable:_e,defaultViewport:Qt=Qh,minZoom:jt=.5,maxZoom:Nt=2,translateExtent:te=dr,preventScrolling:Ht=!0,nodeExtent:Ot,defaultMarkerColor:ee="#b1b1b7",zoomOnScroll:ne=!0,zoomOnPinch:Se=!0,panOnScroll:rt=!1,panOnScrollSpeed:mt=.5,panOnScrollMode:Lt=qt.Free,zoomOnDoubleClick:Vt=!0,panOnDrag:Yt=!0,onPaneClick:At,onPaneMouseEnter:bt,onPaneMouseMove:Ee,onPaneMouseLeave:Dn,onPaneScroll:Ne,onPaneContextMenu:Pn,children:Br,onEdgeContextMenu:Xt,onEdgeDoubleClick:Ns,onEdgeMouseEnter:As,onEdgeMouseMove:Ms,onEdgeMouseLeave:ks,onEdgeUpdate:$s,onEdgeUpdateStart:Cs,onEdgeUpdateEnd:Is,onReconnect:Ts,onReconnectStart:Ds,onReconnectEnd:Ps,reconnectRadius:Fs=10,edgeUpdaterRadius:zs=10,onNodesChange:Rs,onEdgesChange:Ws,noDragClassName:Bs="nodrag",noWheelClassName:Hs="nowheel",noPanClassName:Hr="nopan",fitView:Os=!1,fitViewOptions:Ls,connectOnClick:Vs=!0,attributionPosition:Ys,proOptions:Xs,defaultEdgeOptions:Us,elevateNodesOnSelect:Gs=!0,elevateEdgesOnSelect:qs=!1,disableKeyboardA11y:Or=!1,autoPanOnConnect:Zs=!0,autoPanOnNodeDrag:Ks=!0,connectionRadius:Js=20,isValidConnection:Qs,onError:js,style:ta,id:Lr,nodeDragThreshold:ea,...na},ra)=>{const Fn=Lr||"1";return R.createElement("div",{...na,style:{...ta,...jh},ref:ra,className:ht(["react-flow",i]),"data-testid":"rf__wrapper",id:Lr},R.createElement(cs,null,R.createElement(Uh,{onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:_,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:s,connectionLineType:I,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:L,selectionKeyCode:X,selectionOnDrag:G,selectionMode:q,deleteKeyCode:O,multiSelectionKeyCode:Q,panActivationKeyCode:Z,zoomActivationKeyCode:K,onlyRenderVisibleElements:gt,selectNodesOnDrag:ut,defaultViewport:Qt,translateExtent:te,minZoom:jt,maxZoom:Nt,preventScrolling:Ht,zoomOnScroll:ne,zoomOnPinch:Se,zoomOnDoubleClick:Vt,panOnScroll:rt,panOnScrollSpeed:mt,panOnScrollMode:Lt,panOnDrag:Yt,onPaneClick:At,onPaneMouseEnter:bt,onPaneMouseMove:Ee,onPaneMouseLeave:Dn,onPaneScroll:Ne,onPaneContextMenu:Pn,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:P,onEdgeContextMenu:Xt,onEdgeDoubleClick:Ns,onEdgeMouseEnter:As,onEdgeMouseMove:Ms,onEdgeMouseLeave:ks,onReconnect:Ts??$s,onReconnectStart:Ds??Cs,onReconnectEnd:Ps??Is,reconnectRadius:Fs??zs,defaultMarkerColor:ee,noDragClassName:Bs,noWheelClassName:Hs,noPanClassName:Hr,elevateEdgesOnSelect:qs,rfId:Fn,disableKeyboardA11y:Or,nodeOrigin:Y,nodeExtent:Ot}),R.createElement(Vf,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:x,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:h,nodesDraggable:et,nodesConnectable:xt,nodesFocusable:J,edgesFocusable:st,edgesUpdatable:Bt,elementsSelectable:_e,elevateNodesOnSelect:Gs,minZoom:jt,maxZoom:Nt,nodeExtent:Ot,onNodesChange:Rs,onEdgesChange:Ws,snapToGrid:pt,snapGrid:lt,connectionMode:S,translateExtent:te,connectOnClick:Vs,defaultEdgeOptions:Us,fitView:Os,fitViewOptions:Ls,onNodesDelete:D,onEdgesDelete:W,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:k,onSelectionDrag:y,onSelectionDragStart:B,onSelectionDragStop:A,noPanClassName:Hr,nodeOrigin:Y,rfId:Fn,autoPanOnConnect:Zs,autoPanOnNodeDrag:Ks,onError:js,connectionRadius:Js,isValidConnection:Qs,nodeDragThreshold:ea}),R.createElement(Of,{onSelectionChange:H}),Br,R.createElement(pf,{proOptions:Xs,position:Ys}),R.createElement(qf,{rfId:Fn,disableKeyboardA11y:Or})))});td.displayName="ReactFlow";const ed=t=>t.getNodes();function Yd(){return tt(ed,it)}function ls(t){return e=>{const[n,r]=$.useState(e),i=$.useCallback(o=>r(s=>t(o,s)),[]);return[n,r,i]}}const Xd=ls(Zo),Ud=ls(ch);var Dr={exports:{}};Dr.exports;(function(t){(function(){var e,n,r,i,o,s,a,c,l,u,f,d,p,x,m;r=Math.floor,u=Math.min,n=function(g,h){return g<h?-1:g>h?1:0},l=function(g,h,v,b,w){var _;if(v==null&&(v=0),w==null&&(w=n),v<0)throw new Error("lo must be non-negative");for(b==null&&(b=g.length);v<b;)_=r((v+b)/2),w(h,g[_])<0?b=_:v=_+1;return[].splice.apply(g,[v,v-v].concat(h)),h},s=function(g,h,v){return v==null&&(v=n),g.push(h),x(g,0,g.length-1,v)},o=function(g,h){var v,b;return h==null&&(h=n),v=g.pop(),g.length?(b=g[0],g[0]=v,m(g,0,h)):b=v,b},c=function(g,h,v){var b;return v==null&&(v=n),b=g[0],g[0]=h,m(g,0,v),b},a=function(g,h,v){var b;return v==null&&(v=n),g.length&&v(g[0],h)<0&&(b=[g[0],h],h=b[0],g[0]=b[1],m(g,0,v)),h},i=function(g,h){var v,b,w,_,N,M;for(h==null&&(h=n),_=(function(){M=[];for(var C=0,k=r(g.length/2);0<=k?C<k:C>k;0<=k?C++:C--)M.push(C);return M}).apply(this).reverse(),N=[],b=0,w=_.length;b<w;b++)v=_[b],N.push(m(g,v,h));return N},p=function(g,h,v){var b;if(v==null&&(v=n),b=g.indexOf(h),b!==-1)return x(g,0,b,v),m(g,b,v)},f=function(g,h,v){var b,w,_,N,M;if(v==null&&(v=n),w=g.slice(0,h),!w.length)return w;for(i(w,v),M=g.slice(h),_=0,N=M.length;_<N;_++)b=M[_],a(w,b,v);return w.sort(v).reverse()},d=function(g,h,v){var b,w,_,N,M,C,k,D,W;if(v==null&&(v=n),h*10<=g.length){if(_=g.slice(0,h).sort(v),!_.length)return _;for(w=_[_.length-1],k=g.slice(h),N=0,C=k.length;N<C;N++)b=k[N],v(b,w)<0&&(l(_,b,0,null,v),_.pop(),w=_[_.length-1]);return _}for(i(g,v),W=[],M=0,D=u(h,g.length);0<=D?M<D:M>D;0<=D?++M:--M)W.push(o(g,v));return W},x=function(g,h,v,b){var w,_,N;for(b==null&&(b=n),w=g[v];v>h;){if(N=v-1>>1,_=g[N],b(w,_)<0){g[v]=_,v=N;continue}break}return g[v]=w},m=function(g,h,v){var b,w,_,N,M;for(v==null&&(v=n),w=g.length,M=h,_=g[h],b=2*h+1;b<w;)N=b+1,N<w&&!(v(g[b],g[N])<0)&&(b=N),g[h]=g[b],h=b,b=2*h+1;return g[h]=_,x(g,M,h,v)},e=function(){g.push=s,g.pop=o,g.replace=c,g.pushpop=a,g.heapify=i,g.updateItem=p,g.nlargest=f,g.nsmallest=d;function g(h){this.cmp=h??n,this.nodes=[]}return g.prototype.push=function(h){return s(this.nodes,h,this.cmp)},g.prototype.pop=function(){return o(this.nodes,this.cmp)},g.prototype.peek=function(){return this.nodes[0]},g.prototype.contains=function(h){return this.nodes.indexOf(h)!==-1},g.prototype.replace=function(h){return c(this.nodes,h,this.cmp)},g.prototype.pushpop=function(h){return a(this.nodes,h,this.cmp)},g.prototype.heapify=function(){return i(this.nodes,this.cmp)},g.prototype.updateItem=function(h){return p(this.nodes,h,this.cmp)},g.prototype.clear=function(){return this.nodes=[]},g.prototype.empty=function(){return this.nodes.length===0},g.prototype.size=function(){return this.nodes.length},g.prototype.clone=function(){var h;return h=new g,h.nodes=this.nodes.slice(0),h},g.prototype.toArray=function(){return this.nodes.slice(0)},g.prototype.insert=g.prototype.push,g.prototype.top=g.prototype.peek,g.prototype.front=g.prototype.peek,g.prototype.has=g.prototype.contains,g.prototype.copy=g.prototype.clone,g}(),t!==null&&t.exports?t.exports=e:window.Heap=e}).call(oa)})(Dr);var nd=Dr.exports,In=nd;function rd(t,e,n){this.x=t,this.y=e,this.walkable=n===void 0?!0:n}var Pr=rd,id={Always:1,Never:2,IfAtMostOneObstacle:3,OnlyWhenNoObstacles:4},dt=id,us=Pr,je=dt;function It(t,e,n){var r;typeof t!="object"?r=t:(e=t.length,r=t[0].length,n=t),this.width=r,this.height=e,this.nodes=this._buildNodes(r,e,n)}It.prototype._buildNodes=function(t,e,n){var r,i,o=new Array(e);for(r=0;r<e;++r)for(o[r]=new Array(t),i=0;i<t;++i)o[r][i]=new us(i,r);if(n===void 0)return o;if(n.length!==e||n[0].length!==t)throw new Error("Matrix size does not fit");for(r=0;r<e;++r)for(i=0;i<t;++i)n[r][i]&&(o[r][i].walkable=!1);return o};It.prototype.getNodeAt=function(t,e){return this.nodes[e][t]};It.prototype.isWalkableAt=function(t,e){return this.isInside(t,e)&&this.nodes[e][t].walkable};It.prototype.isInside=function(t,e){return t>=0&&t<this.width&&e>=0&&e<this.height};It.prototype.setWalkableAt=function(t,e,n){this.nodes[e][t].walkable=n};It.prototype.getNeighbors=function(t,e){var n=t.x,r=t.y,i=[],o=!1,s=!1,a=!1,c=!1,l=!1,u=!1,f=!1,d=!1,p=this.nodes;if(this.isWalkableAt(n,r-1)&&(i.push(p[r-1][n]),o=!0),this.isWalkableAt(n+1,r)&&(i.push(p[r][n+1]),a=!0),this.isWalkableAt(n,r+1)&&(i.push(p[r+1][n]),l=!0),this.isWalkableAt(n-1,r)&&(i.push(p[r][n-1]),f=!0),e===je.Never)return i;if(e===je.OnlyWhenNoObstacles)s=f&&o,c=o&&a,u=a&&l,d=l&&f;else if(e===je.IfAtMostOneObstacle)s=f||o,c=o||a,u=a||l,d=l||f;else if(e===je.Always)s=!0,c=!0,u=!0,d=!0;else throw new Error("Incorrect value of diagonalMovement");return s&&this.isWalkableAt(n-1,r-1)&&i.push(p[r-1][n-1]),c&&this.isWalkableAt(n+1,r-1)&&i.push(p[r-1][n+1]),u&&this.isWalkableAt(n+1,r+1)&&i.push(p[r+1][n+1]),d&&this.isWalkableAt(n-1,r+1)&&i.push(p[r+1][n-1]),i};It.prototype.clone=function(){var t,e,n=this.width,r=this.height,i=this.nodes,o=new It(n,r),s=new Array(r);for(t=0;t<r;++t)for(s[t]=new Array(n),e=0;e<n;++e)s[t][e]=new us(e,t,i[t][e].walkable);return o.nodes=s,o};var od=It,ct={};function pr(t){for(var e=[[t.x,t.y]];t.parent;)t=t.parent,e.push([t.x,t.y]);return e.reverse()}ct.backtrace=pr;function sd(t,e){var n=pr(t),r=pr(e);return n.concat(r.reverse())}ct.biBacktrace=sd;function ad(t){var e,n=0,r,i,o,s;for(e=1;e<t.length;++e)r=t[e-1],i=t[e],o=r[0]-i[0],s=r[1]-i[1],n+=Math.sqrt(o*o+s*s);return n}ct.pathLength=ad;function Fr(t,e,n,r){var i=Math.abs,o=[],s,a,c,l,u,f;for(c=i(n-t),l=i(r-e),s=t<n?1:-1,a=e<r?1:-1,u=c-l;o.push([t,e]),!(t===n&&e===r);)f=2*u,f>-l&&(u=u-l,t=t+s),f<c&&(u=u+c,e=e+a);return o}ct.interpolate=Fr;function cd(t){var e=[],n=t.length,r,i,o,s,a,c;if(n<2)return e;for(a=0;a<n-1;++a)for(r=t[a],i=t[a+1],o=Fr(r[0],r[1],i[0],i[1]),s=o.length,c=0;c<s-1;++c)e.push(o[c]);return e.push(t[n-1]),e}ct.expandPath=cd;function ld(t,e){var n=e.length,r=e[0][0],i=e[0][1],o=e[n-1][0],s=e[n-1][1],a,c,l,u,f,d,p,x,m,g,h;for(a=r,c=i,f=[[a,c]],d=2;d<n;++d){for(x=e[d],l=x[0],u=x[1],m=Fr(a,c,l,u),h=!1,p=1;p<m.length;++p)if(g=m[p],!t.isWalkableAt(g[0],g[1])){h=!0;break}h&&(lastValidCoord=e[d-1],f.push(lastValidCoord),a=lastValidCoord[0],c=lastValidCoord[1])}return f.push([o,s]),f}ct.smoothenPath=ld;function ud(t){if(t.length<3)return t;var e=[],n=t[0][0],r=t[0][1],i=t[1][0],o=t[1][1],s=i-n,a=o-r,c,l,u,f,d,p;for(d=Math.sqrt(s*s+a*a),s/=d,a/=d,e.push([n,r]),p=2;p<t.length;p++)c=i,l=o,u=s,f=a,i=t[p][0],o=t[p][1],s=i-c,a=o-l,d=Math.sqrt(s*s+a*a),s/=d,a/=d,(s!==u||a!==f)&&e.push([c,l]);return e.push([i,o]),e}ct.compressPath=ud;var Ve={manhattan:function(t,e){return t+e},euclidean:function(t,e){return Math.sqrt(t*t+e*e)},octile:function(t,e){var n=Math.SQRT2-1;return t<e?n*t+e:n*e+t},chebyshev:function(t,e){return Math.max(t,e)}},fd=In,hd=ct,Un=Ve,tn=dt;function fs(t){t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.heuristic=t.heuristic||Un.manhattan,this.weight=t.weight||1,this.diagonalMovement=t.diagonalMovement,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=tn.OnlyWhenNoObstacles:this.diagonalMovement=tn.IfAtMostOneObstacle:this.diagonalMovement=tn.Never),this.diagonalMovement===tn.Never?this.heuristic=t.heuristic||Un.manhattan:this.heuristic=t.heuristic||Un.octile}fs.prototype.findPath=function(t,e,n,r,i){var o=new fd(function(_,N){return _.f-N.f}),s=i.getNodeAt(t,e),a=i.getNodeAt(n,r),c=this.heuristic,l=this.diagonalMovement,u=this.weight,f=Math.abs,d=Math.SQRT2,p,x,m,g,h,v,b,w;for(s.g=0,s.f=0,o.push(s),s.opened=!0;!o.empty();){if(p=o.pop(),p.closed=!0,p===a)return hd.backtrace(a);for(x=i.getNeighbors(p,l),g=0,h=x.length;g<h;++g)m=x[g],!m.closed&&(v=m.x,b=m.y,w=p.g+(v-p.x===0||b-p.y===0?1:d),(!m.opened||w<m.g)&&(m.g=w,m.h=m.h||u*c(f(v-n),f(b-r)),m.f=m.g+m.h,m.parent=p,m.opened?o.updateItem(m):(o.push(m),m.opened=!0)))}return[]};var zr=fs,hs=zr;function xn(t){hs.call(this,t);var e=this.heuristic;this.heuristic=function(n,r){return e(n,r)*1e6}}xn.prototype=new hs;xn.prototype.constructor=xn;var dd=xn,pd=ct,Gn=dt;function ds(t){t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=Gn.OnlyWhenNoObstacles:this.diagonalMovement=Gn.IfAtMostOneObstacle:this.diagonalMovement=Gn.Never)}ds.prototype.findPath=function(t,e,n,r,i){var o=[],s=this.diagonalMovement,a=i.getNodeAt(t,e),c=i.getNodeAt(n,r),l,u,f,d,p;for(o.push(a),a.opened=!0;o.length;){if(f=o.shift(),f.closed=!0,f===c)return pd.backtrace(c);for(l=i.getNeighbors(f,s),d=0,p=l.length;d<p;++d)u=l[d],!(u.closed||u.opened)&&(o.push(u),u.opened=!0,u.parent=f)}return[]};var gd=ds,ps=zr;function bn(t){ps.call(this,t),this.heuristic=function(e,n){return 0}}bn.prototype=new ps;bn.prototype.constructor=bn;var md=bn,Ti=In,Di=ct,qn=Ve,en=dt;function gs(t){t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.heuristic=t.heuristic||qn.manhattan,this.weight=t.weight||1,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=en.OnlyWhenNoObstacles:this.diagonalMovement=en.IfAtMostOneObstacle:this.diagonalMovement=en.Never),this.diagonalMovement===en.Never?this.heuristic=t.heuristic||qn.manhattan:this.heuristic=t.heuristic||qn.octile}gs.prototype.findPath=function(t,e,n,r,i){var o=function(k,D){return k.f-D.f},s=new Ti(o),a=new Ti(o),c=i.getNodeAt(t,e),l=i.getNodeAt(n,r),u=this.heuristic,f=this.diagonalMovement,d=this.weight,p=Math.abs,x=Math.SQRT2,m,g,h,v,b,w,_,N,M=1,C=2;for(c.g=0,c.f=0,s.push(c),c.opened=M,l.g=0,l.f=0,a.push(l),l.opened=C;!s.empty()&&!a.empty();){for(m=s.pop(),m.closed=!0,g=i.getNeighbors(m,f),v=0,b=g.length;v<b;++v)if(h=g[v],!h.closed){if(h.opened===C)return Di.biBacktrace(m,h);w=h.x,_=h.y,N=m.g+(w-m.x===0||_-m.y===0?1:x),(!h.opened||N<h.g)&&(h.g=N,h.h=h.h||d*u(p(w-n),p(_-r)),h.f=h.g+h.h,h.parent=m,h.opened?s.updateItem(h):(s.push(h),h.opened=M))}for(m=a.pop(),m.closed=!0,g=i.getNeighbors(m,f),v=0,b=g.length;v<b;++v)if(h=g[v],!h.closed){if(h.opened===M)return Di.biBacktrace(h,m);w=h.x,_=h.y,N=m.g+(w-m.x===0||_-m.y===0?1:x),(!h.opened||N<h.g)&&(h.g=N,h.h=h.h||d*u(p(w-t),p(_-e)),h.f=h.g+h.h,h.parent=m,h.opened?a.updateItem(h):(a.push(h),h.opened=C))}}return[]};var Rr=gs,ms=Rr;function _n(t){ms.call(this,t);var e=this.heuristic;this.heuristic=function(n,r){return e(n,r)*1e6}}_n.prototype=new ms;_n.prototype.constructor=_n;var yd=_n,Pi=ct,Zn=dt;function ys(t){t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=Zn.OnlyWhenNoObstacles:this.diagonalMovement=Zn.IfAtMostOneObstacle:this.diagonalMovement=Zn.Never)}ys.prototype.findPath=function(t,e,n,r,i){var o=i.getNodeAt(t,e),s=i.getNodeAt(n,r),a=[],c=[],l,u,f,d=this.diagonalMovement,p=0,x=1,m,g;for(a.push(o),o.opened=!0,o.by=p,c.push(s),s.opened=!0,s.by=x;a.length&&c.length;){for(f=a.shift(),f.closed=!0,l=i.getNeighbors(f,d),m=0,g=l.length;m<g;++m)if(u=l[m],!u.closed){if(u.opened){if(u.by===x)return Pi.biBacktrace(f,u);continue}a.push(u),u.parent=f,u.opened=!0,u.by=p}for(f=c.shift(),f.closed=!0,l=i.getNeighbors(f,d),m=0,g=l.length;m<g;++m)if(u=l[m],!u.closed){if(u.opened){if(u.by===p)return Pi.biBacktrace(u,f);continue}c.push(u),u.parent=f,u.opened=!0,u.by=x}}return[]};var vd=ys,vs=Rr;function Sn(t){vs.call(this,t),this.heuristic=function(e,n){return 0}}Sn.prototype=new vs;Sn.prototype.constructor=Sn;var wd=Sn,Kn=Ve,Fi=Pr,nn=dt;function ws(t){t=t||{},this.allowDiagonal=t.allowDiagonal,this.dontCrossCorners=t.dontCrossCorners,this.diagonalMovement=t.diagonalMovement,this.heuristic=t.heuristic||Kn.manhattan,this.weight=t.weight||1,this.trackRecursion=t.trackRecursion||!1,this.timeLimit=t.timeLimit||1/0,this.diagonalMovement||(this.allowDiagonal?this.dontCrossCorners?this.diagonalMovement=nn.OnlyWhenNoObstacles:this.diagonalMovement=nn.IfAtMostOneObstacle:this.diagonalMovement=nn.Never),this.diagonalMovement===nn.Never?this.heuristic=t.heuristic||Kn.manhattan:this.heuristic=t.heuristic||Kn.octile}ws.prototype.findPath=function(t,e,n,r,i){var o=new Date().getTime(),s=(function(m,g){return this.heuristic(Math.abs(g.x-m.x),Math.abs(g.y-m.y))}).bind(this),a=function(m,g){return m.x===g.x||m.y===g.y?1:Math.SQRT2},c=(function(m,g,h,v,b){if(this.timeLimit>0&&new Date().getTime()-o>this.timeLimit*1e3)return 1/0;var w=g+s(m,u)*this.weight;if(w>h)return w;if(m==u)return v[b]=[m.x,m.y],m;var _,N,M,C,k=i.getNeighbors(m,this.diagonalMovement);for(M=0,_=1/0;C=k[M];++M){if(this.trackRecursion&&(C.retainCount=C.retainCount+1||1,C.tested!==!0&&(C.tested=!0)),N=c(C,g+a(m,C),h,v,b+1),N instanceof Fi)return v[b]=[m.x,m.y],N;this.trackRecursion&&--C.retainCount===0&&(C.tested=!1),N<_&&(_=N)}return _}).bind(this),l=i.getNodeAt(t,e),u=i.getNodeAt(n,r),f=s(l,u),d,p,x;for(d=0;;++d){if(p=[],x=c(l,0,f,p,0),x===1/0)return[];if(x instanceof Fi)return p;f=x}return[]};var xd=ws,bd=In,zi=ct,xs=Ve;function Wr(t){t=t||{},this.heuristic=t.heuristic||xs.manhattan,this.trackJumpRecursion=t.trackJumpRecursion||!1}Wr.prototype.findPath=function(t,e,n,r,i){var o=this.openList=new bd(function(l,u){return l.f-u.f}),s=this.startNode=i.getNodeAt(t,e),a=this.endNode=i.getNodeAt(n,r),c;for(this.grid=i,s.g=0,s.f=0,o.push(s),s.opened=!0;!o.empty();){if(c=o.pop(),c.closed=!0,c===a)return zi.expandPath(zi.backtrace(a));this._identifySuccessors(c)}return[]};Wr.prototype._identifySuccessors=function(t){var e=this.grid,n=this.heuristic,r=this.openList,i=this.endNode.x,o=this.endNode.y,s,a,c,l,u,f=t.x,d=t.y,p,x,m,g,h,v=Math.abs;for(s=this._findNeighbors(t),l=0,u=s.length;l<u;++l)if(a=s[l],c=this._jump(a[0],a[1],f,d),c){if(p=c[0],x=c[1],h=e.getNodeAt(p,x),h.closed)continue;m=xs.octile(v(p-f),v(x-d)),g=t.g+m,(!h.opened||g<h.g)&&(h.g=g,h.h=h.h||n(v(p-i),v(x-o)),h.f=h.g+h.h,h.parent=t,h.opened?r.updateItem(h):(r.push(h),h.opened=!0))}};var Tn=Wr,bs=Tn,_d=dt;function ve(t){bs.call(this,t)}ve.prototype=new bs;ve.prototype.constructor=ve;ve.prototype._jump=function(t,e,n,r){var i=this.grid,o=t-n,s=e-r;if(!i.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(i.getNodeAt(t,e).tested=!0),i.getNodeAt(t,e)===this.endNode)return[t,e];if(o!==0){if(i.isWalkableAt(t,e-1)&&!i.isWalkableAt(t-o,e-1)||i.isWalkableAt(t,e+1)&&!i.isWalkableAt(t-o,e+1))return[t,e]}else if(s!==0){if(i.isWalkableAt(t-1,e)&&!i.isWalkableAt(t-1,e-s)||i.isWalkableAt(t+1,e)&&!i.isWalkableAt(t+1,e-s))return[t,e];if(this._jump(t+1,e,t,e)||this._jump(t-1,e,t,e))return[t,e]}else throw new Error("Only horizontal and vertical movements are allowed");return this._jump(t+o,e+s,t,e)};ve.prototype._findNeighbors=function(t){var e=t.parent,n=t.x,r=t.y,i=this.grid,o,s,a,c,l=[],u,f,d,p;if(e)o=e.x,s=e.y,a=(n-o)/Math.max(Math.abs(n-o),1),c=(r-s)/Math.max(Math.abs(r-s),1),a!==0?(i.isWalkableAt(n,r-1)&&l.push([n,r-1]),i.isWalkableAt(n,r+1)&&l.push([n,r+1]),i.isWalkableAt(n+a,r)&&l.push([n+a,r])):c!==0&&(i.isWalkableAt(n-1,r)&&l.push([n-1,r]),i.isWalkableAt(n+1,r)&&l.push([n+1,r]),i.isWalkableAt(n,r+c)&&l.push([n,r+c]));else for(u=i.getNeighbors(t,_d.Never),d=0,p=u.length;d<p;++d)f=u[d],l.push([f.x,f.y]);return l};var Sd=ve,_s=Tn,Ed=dt;function we(t){_s.call(this,t)}we.prototype=new _s;we.prototype.constructor=we;we.prototype._jump=function(t,e,n,r){var i=this.grid,o=t-n,s=e-r;if(!i.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(i.getNodeAt(t,e).tested=!0),i.getNodeAt(t,e)===this.endNode)return[t,e];if(o!==0&&s!==0){if(i.isWalkableAt(t-o,e+s)&&!i.isWalkableAt(t-o,e)||i.isWalkableAt(t+o,e-s)&&!i.isWalkableAt(t,e-s))return[t,e];if(this._jump(t+o,e,t,e)||this._jump(t,e+s,t,e))return[t,e]}else if(o!==0){if(i.isWalkableAt(t+o,e+1)&&!i.isWalkableAt(t,e+1)||i.isWalkableAt(t+o,e-1)&&!i.isWalkableAt(t,e-1))return[t,e]}else if(i.isWalkableAt(t+1,e+s)&&!i.isWalkableAt(t+1,e)||i.isWalkableAt(t-1,e+s)&&!i.isWalkableAt(t-1,e))return[t,e];return this._jump(t+o,e+s,t,e)};we.prototype._findNeighbors=function(t){var e=t.parent,n=t.x,r=t.y,i=this.grid,o,s,a,c,l=[],u,f,d,p;if(e)o=e.x,s=e.y,a=(n-o)/Math.max(Math.abs(n-o),1),c=(r-s)/Math.max(Math.abs(r-s),1),a!==0&&c!==0?(i.isWalkableAt(n,r+c)&&l.push([n,r+c]),i.isWalkableAt(n+a,r)&&l.push([n+a,r]),i.isWalkableAt(n+a,r+c)&&l.push([n+a,r+c]),i.isWalkableAt(n-a,r)||l.push([n-a,r+c]),i.isWalkableAt(n,r-c)||l.push([n+a,r-c])):a===0?(i.isWalkableAt(n,r+c)&&l.push([n,r+c]),i.isWalkableAt(n+1,r)||l.push([n+1,r+c]),i.isWalkableAt(n-1,r)||l.push([n-1,r+c])):(i.isWalkableAt(n+a,r)&&l.push([n+a,r]),i.isWalkableAt(n,r+1)||l.push([n+a,r+1]),i.isWalkableAt(n,r-1)||l.push([n+a,r-1]));else for(u=i.getNeighbors(t,Ed.Always),d=0,p=u.length;d<p;++d)f=u[d],l.push([f.x,f.y]);return l};var Nd=we,Ss=Tn,Ad=dt;function xe(t){Ss.call(this,t)}xe.prototype=new Ss;xe.prototype.constructor=xe;xe.prototype._jump=function(t,e,n,r){var i=this.grid,o=t-n,s=e-r;if(!i.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(i.getNodeAt(t,e).tested=!0),i.getNodeAt(t,e)===this.endNode)return[t,e];if(o!==0&&s!==0){if(this._jump(t+o,e,t,e)||this._jump(t,e+s,t,e))return[t,e]}else if(o!==0){if(i.isWalkableAt(t,e-1)&&!i.isWalkableAt(t-o,e-1)||i.isWalkableAt(t,e+1)&&!i.isWalkableAt(t-o,e+1))return[t,e]}else if(s!==0&&(i.isWalkableAt(t-1,e)&&!i.isWalkableAt(t-1,e-s)||i.isWalkableAt(t+1,e)&&!i.isWalkableAt(t+1,e-s)))return[t,e];return i.isWalkableAt(t+o,e)&&i.isWalkableAt(t,e+s)?this._jump(t+o,e+s,t,e):null};xe.prototype._findNeighbors=function(t){var e=t.parent,n=t.x,r=t.y,i=this.grid,o,s,a,c,l=[],u,f,d,p;if(e)if(o=e.x,s=e.y,a=(n-o)/Math.max(Math.abs(n-o),1),c=(r-s)/Math.max(Math.abs(r-s),1),a!==0&&c!==0)i.isWalkableAt(n,r+c)&&l.push([n,r+c]),i.isWalkableAt(n+a,r)&&l.push([n+a,r]),i.isWalkableAt(n,r+c)&&i.isWalkableAt(n+a,r)&&l.push([n+a,r+c]);else{var x;if(a!==0){x=i.isWalkableAt(n+a,r);var m=i.isWalkableAt(n,r+1),g=i.isWalkableAt(n,r-1);x&&(l.push([n+a,r]),m&&l.push([n+a,r+1]),g&&l.push([n+a,r-1])),m&&l.push([n,r+1]),g&&l.push([n,r-1])}else if(c!==0){x=i.isWalkableAt(n,r+c);var h=i.isWalkableAt(n+1,r),v=i.isWalkableAt(n-1,r);x&&(l.push([n,r+c]),h&&l.push([n+1,r+c]),v&&l.push([n-1,r+c])),h&&l.push([n+1,r]),v&&l.push([n-1,r])}}else for(u=i.getNeighbors(t,Ad.OnlyWhenNoObstacles),d=0,p=u.length;d<p;++d)f=u[d],l.push([f.x,f.y]);return l};var Md=xe,Es=Tn,kd=dt;function be(t){Es.call(this,t)}be.prototype=new Es;be.prototype.constructor=be;be.prototype._jump=function(t,e,n,r){var i=this.grid,o=t-n,s=e-r;if(!i.isWalkableAt(t,e))return null;if(this.trackJumpRecursion===!0&&(i.getNodeAt(t,e).tested=!0),i.getNodeAt(t,e)===this.endNode)return[t,e];if(o!==0&&s!==0){if(i.isWalkableAt(t-o,e+s)&&!i.isWalkableAt(t-o,e)||i.isWalkableAt(t+o,e-s)&&!i.isWalkableAt(t,e-s))return[t,e];if(this._jump(t+o,e,t,e)||this._jump(t,e+s,t,e))return[t,e]}else if(o!==0){if(i.isWalkableAt(t+o,e+1)&&!i.isWalkableAt(t,e+1)||i.isWalkableAt(t+o,e-1)&&!i.isWalkableAt(t,e-1))return[t,e]}else if(i.isWalkableAt(t+1,e+s)&&!i.isWalkableAt(t+1,e)||i.isWalkableAt(t-1,e+s)&&!i.isWalkableAt(t-1,e))return[t,e];return i.isWalkableAt(t+o,e)||i.isWalkableAt(t,e+s)?this._jump(t+o,e+s,t,e):null};be.prototype._findNeighbors=function(t){var e=t.parent,n=t.x,r=t.y,i=this.grid,o,s,a,c,l=[],u,f,d,p;if(e)o=e.x,s=e.y,a=(n-o)/Math.max(Math.abs(n-o),1),c=(r-s)/Math.max(Math.abs(r-s),1),a!==0&&c!==0?(i.isWalkableAt(n,r+c)&&l.push([n,r+c]),i.isWalkableAt(n+a,r)&&l.push([n+a,r]),(i.isWalkableAt(n,r+c)||i.isWalkableAt(n+a,r))&&l.push([n+a,r+c]),!i.isWalkableAt(n-a,r)&&i.isWalkableAt(n,r+c)&&l.push([n-a,r+c]),!i.isWalkableAt(n,r-c)&&i.isWalkableAt(n+a,r)&&l.push([n+a,r-c])):a===0?i.isWalkableAt(n,r+c)&&(l.push([n,r+c]),i.isWalkableAt(n+1,r)||l.push([n+1,r+c]),i.isWalkableAt(n-1,r)||l.push([n-1,r+c])):i.isWalkableAt(n+a,r)&&(l.push([n+a,r]),i.isWalkableAt(n,r+1)||l.push([n+a,r+1]),i.isWalkableAt(n,r-1)||l.push([n+a,r-1]));else for(u=i.getNeighbors(t,kd.IfAtMostOneObstacle),d=0,p=u.length;d<p;++d)f=u[d],l.push([f.x,f.y]);return l};var $d=be,Jn=dt,Cd=Sd,Id=Nd,Td=Md,Dd=$d;function Pd(t){return t=t||{},t.diagonalMovement===Jn.Never?new Cd(t):t.diagonalMovement===Jn.Always?new Id(t):t.diagonalMovement===Jn.OnlyWhenNoObstacles?new Td(t):new Dd(t)}var Fd=Pd,zd={Heap:In,Node:Pr,Grid:od,Util:ct,DiagonalMovement:dt,Heuristic:Ve,AStarFinder:zr,BestFirstFinder:dd,BreadthFirstFinder:gd,DijkstraFinder:md,BiAStarFinder:Rr,BiBestFirstFinder:yd,BiBreadthFirstFinder:vd,BiDijkstraFinder:wd,IDAStarFinder:xd,JumpPointFinder:Fd},de=zd,gr=function(e,n){switch(n){case"top":return{x:e.x,y:e.y-1};case"bottom":return{x:e.x,y:e.y+1};case"left":return{x:e.x-1,y:e.y};case"right":return{x:e.x+1,y:e.y}}},Ri=function(e,n,r){for(var i=e.getNodeAt(n.x,n.y);!i.walkable;){e.setWalkableAt(i.x,i.y,!0);var o=gr(i,r);i=e.getNodeAt(o.x,o.y)}},rn=function(e,n,r,i){var o=e.x/i,s=e.y/i,a=n/i,c=r/i;if(a<1)for(;a!==1;)a++,o++;else if(a>1)for(;a!==1;)a--,o--;if(c<1)for(;c!==1;)c++,s++;else if(c>1)for(;c!==1;)c--,s--;return{x:o,y:s}},Wi=function(e,n,r,i){var o=e.x*i,s=e.y*i,a=n,c=r;if(a<i)for(;a!==i;)a=a+i,o=o-i;else if(a>i)for(;a!==i;)a=a-i,o=o+i;if(c<i)for(;c!==i;)c=c+i,s=s-i;else if(c>i)for(;c!==i;)c=c-i,s=s+i;return{x:o,y:s}},on=function(e,n){return n===void 0&&(n=10),Math.round(e/n)*n},ae=function(e,n){return n===void 0&&(n=10),Math.floor(e/n)*n},Ft=function(e,n){return n===void 0&&(n=10),Math.ceil(e/n)*n},Bi=function(e,n){n===void 0&&(n=0);var r=Math.max(Math.round(e),n);return r=Number.isInteger(r)?r:n,r=r>=n?r:n,r},Rd=function(e,n,r,i,o){o===void 0&&(o=2);var s=e.xMin,a=e.yMin,c=e.width,l=e.height,u=Ft(c,o)/o+1,f=Ft(l,o)/o+1,d=new de.Grid(u,f);n.forEach(function(b){for(var w=rn(b.topLeft,s,a,o),_=rn(b.bottomRight,s,a,o),N=w.x;N<_.x;N++)for(var M=w.y;M<_.y;M++)d.setWalkableAt(N,M,!1)});var p=rn({x:on(r.x,o),y:on(r.y,o)},s,a,o),x=rn({x:on(i.x,o),y:on(i.y,o)},s,a,o),m=d.getNodeAt(p.x,p.y);Ri(d,m,r.position);var g=d.getNodeAt(x.x,x.y);Ri(d,g,i.position);var h=gr(m,r.position),v=gr(g,i.position);return{grid:d,start:h,end:v}},Wd=function(e,n,r){var i=[[e.x,e.y]].concat(r,[[n.x,n.y]]);return Bd(i)},Bd=function(e){for(var n=0,r=1,i=e[0],o=e[0],s="M"+o[n]+","+o[r]+"M",a=0;a<e.length;a++){var c=e[a],l=Hd(i[n],i[r],c[n],c[r]);s+=" "+l[n]+","+l[r],s+="Q"+c[n]+","+c[r],i=c}var u=e[e.length-1];return s+=" "+u[0]+","+u[1],s},Hd=function(e,n,r,i){var o=(e-r)/2+r,s=(n-i)/2+i;return[o,s]},Od=function(e,n,r){try{var i=new de.AStarFinder({diagonalMovement:de.DiagonalMovement.Always}),o=i.findPath(n.x,n.y,r.x,r.y,e),s=de.Util.smoothenPath(e,o);return o.length===0||s.length===0?null:{fullPath:o,smoothedPath:s}}catch{return null}},Gd=function(e,n,r){try{var i=new de.JumpPointFinder({diagonalMovement:de.DiagonalMovement.Never}),o=i.findPath(n.x,n.y,r.x,r.y,e),s=o;return o.length===0||s.length===0?null:{fullPath:o,smoothedPath:s}}catch{return null}},Ld=function(e,n,r){n===void 0&&(n=2),r===void 0&&(r=2);var i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER,c=e.map(function(h){var v,b,w=Math.max(h.width||0,1),_=Math.max(h.height||0,1),N={x:((v=h.positionAbsolute)==null?void 0:v.x)||0,y:((b=h.positionAbsolute)==null?void 0:b.y)||0},M={x:N.x-n,y:N.y-n},C={x:N.x-n,y:N.y+_+n},k={x:N.x+w+n,y:N.y-n},D={x:N.x+w+n,y:N.y+_+n};return r>0&&(M.x=ae(M.x,r),M.y=ae(M.y,r),C.x=ae(C.x,r),C.y=Ft(C.y,r),k.x=Ft(k.x,r),k.y=ae(k.y,r),D.x=Ft(D.x,r),D.y=Ft(D.y,r)),M.y<a&&(a=M.y),M.x<s&&(s=M.x),D.y>o&&(o=D.y),D.x>i&&(i=D.x),{id:h.id,width:w,height:_,topLeft:M,bottomLeft:C,topRight:k,bottomRight:D}}),l=n*2;i=Ft(i+l,r),o=Ft(o+l,r),s=ae(s-l,r),a=ae(a-l,r);var u={x:s,y:a},f={x:s,y:o},d={x:i,y:a},p={x:i,y:o},x=Math.abs(u.x-d.x),m=Math.abs(u.y-f.y),g={topLeft:u,bottomLeft:f,topRight:d,bottomRight:p,width:x,height:m,xMax:i,yMax:o,xMin:s,yMin:a};return{nodeBoxes:c,graphBox:g}},qd=function(e){var n=e.options,r=n===void 0?{}:n,i=e.nodes,o=i===void 0?[]:i,s=e.sourceX,a=e.sourceY,c=e.targetX,l=e.targetY,u=e.sourcePosition,f=e.targetPosition;try{var d=r.drawEdge,p=d===void 0?Wd:d,x=r.generatePath,m=x===void 0?Od:x,g=r.gridRatio,h=g===void 0?10:g,v=r.nodePadding,b=v===void 0?10:v;h=Bi(h),b=Bi(b);var w=Ld(o,b,h),_=w.graphBox,N=w.nodeBoxes,M={x:s,y:a,position:u},C={x:c,y:l,position:f},k=Rd(_,N,M,C,h),D=k.grid,W=k.start,H=k.end,B=m(D,W,H);if(B===null)return null;var y=B.fullPath,A=B.smoothedPath,E=A.map(function(X){var G=X[0],q=X[1],Z=Wi({x:G,y:q},_.xMin,_.yMin,h);return[Z.x,Z.y]}),T=p(M,C,E),P=Math.floor(y.length/2),S=y[P],I=S[0],F=S[1],z=Wi({x:I,y:F},_.xMin,_.yMin,h),L=z.x,O=z.y;return{svgPathString:T,edgeCenterX:L,edgeCenterY:O}}catch{return null}};export{Le as B,wn as H,V as P,as as R,Cn as S,Go as a,Yd as b,Xd as c,Ud as d,td as e,qd as g,Gd as p,tt as u};
