@linkdlab/funcnodes_react_flow 0.3.21 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=
25
25
  *
26
26
  * This source code is licensed under the MIT license found in the
27
27
  * LICENSE file in the root directory of this source tree.
28
- */var C=(w||(w=1,"production"===process.env.NODE_ENV?u.exports=function(){if(g)return d;g=1;var t=e,n=b(),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;return d.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=s((function(){function e(e){if(!a){if(a=!0,o=e,e=c(e),void 0!==u&&f.hasValue){var t=f.value;if(u(t,e))return i=t}return i=e}if(t=i,r(o,e))return t;var n=c(e);return void 0!==u&&u(t,n)?(o=e,t):(o=e,i=n)}var o,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var p=o(e,d[0],d[1]);return a((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p},d}():u.exports=(v||(v=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=e,n=b(),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;x.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=s((function(){function e(e){if(!a){if(a=!0,o=e,e=c(e),void 0!==u&&f.hasValue){var t=f.value;if(u(t,e))return i=t}return i=e}if(t=i,r(o,e))return t;var n=c(e);return void 0!==u&&u(t,n)?(o=e,t):(o=e,i=n)}var o,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var p=o(e,d[0],d[1]);return a((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),x)),u.exports),k=l(C);const{useDebugValue:E}=e,{useSyncExternalStoreWithSelector:S}=k;let I=!1;const _=e=>e;const A=e=>{"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t="function"==typeof e?s(e):e,n=(e,n)=>function(e,t=_,n){n&&!I&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),I=!0);const r=S(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return E(r),r}(t,e,n);return Object.assign(n,t),n},N=e=>e?A(e):A;function O(e){return"[object Object]"===Object.prototype.toString.call(e)}function R(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e.constructor!==t.constructor)return!1;if(e.constructor===Object||e.constructor===Array){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!r.includes(o))return!1;if(!R(e[o],t[o]))return!1}}return!(e instanceof Date&&t instanceof Date)||e.getTime()===t.getTime()}const M=(e,t)=>{let n=!1;if(!O(e))throw new Error("Target must be a plain object");if(!O(t))throw new Error("Source must be a plain object");const r={...e};return Object.keys(t).forEach((o=>{const i=t[o],a=e[o];if(O(i)&&O(a)){const{new_obj:e,change:t}=M(a,i);t&&(n=!0,r[o]=e)}else R(a,i)||(n=!0,r[o]=i)})),{new_obj:r,change:n}},T=(e,t)=>{let n=!1;if(!O(e))throw new Error("Target must be a plain object");if(!O(t))throw new Error("Source must be a plain object");const r={...e};return Object.keys(t).forEach((o=>{const i=t[o],a=e[o];if(void 0!==a||void 0!==i){if(void 0===a)return n=!0,void(r[o]=i);if(O(i)&&O(a)){const{new_obj:e,change:t}=T(a,i);t&&(n=!0,r[o]=e)}}})),{new_obj:r,change:n}},P={id:"dummy",name:"dummy",node:"dummy",full_id:"dummy",type:"any",value:void 0,is_input:!1,connected:!1,does_trigger:!0,fullvalue:void 0,try_get_full_value:void 0,render_options:{set_default:!0,type:"any"},set_hidden:void 0,hidden:!1},D=e=>{if(!e.id)throw new Error("IO must have an id but is missing for "+JSON.stringify(e));void 0===e.name&&(e.name=e.id);const{new_obj:t}=T(e,P);return"any"!==t.render_options.type&&void 0!==t.render_options.type||(t.render_options.type=t.type),t},j={id:"dummy",node_name:"dummy",properties:{"frontend:size":[200,100],"frontend:pos":[NaN,NaN],"frontend:collapsed":!1},io:{},name:"dummy",in_trigger:!1,io_order:[],progress:{ascii:!1,elapsed:0,initial:0,n:0,prefix:"idle",unit:"it",unit_divisor:1e3,unit_scale:!1}},F=(e,t)=>{e.properties=e.properties||{},t.pos&&(e.properties["frontend:pos"]=t.pos),t.size&&(e.properties["frontend:size"]=t.size),void 0!==t.collapsed&&(e.properties["frontend:collapsed"]=!!t.collapsed)},L=JSON.stringify(j),z=e=>{if(!e.id)throw new Error("Node must have an id");const t=JSON.parse(L),{new_obj:n}=T(e,t);for(const e in n.io){if(void 0===n.io[e])continue;void 0===n.io[e].id&&(n.io[e].id=e);const t=D(n.io[e]);n.io[e]=t}return n},B=e=>{if(void 0===e.io&&(e.io={}),void 0===e.io_order)if(Array.isArray(e.io)){e.io_order=e.io.map((e=>e.id));const t={};for(const n of e.io)t[n.id]=n;e.io=t}else e.io_order=Object.keys(e.io);else if(Array.isArray(e.io)){const t={};for(const n of e.io)t[n.id]=n,e.io_order.includes(n.id)||e.io_order.push(n.id);e.io=t}else for(const t in e.io)e.io_order.includes(t)||e.io_order.push(t);return e};function V(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,r=0;r<e.length;r++)""!==(n=V(e[r]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:G}=e,{useSyncExternalStoreWithSelector:W}=k,H=e=>e;function X(e,t=H,n){const r=W(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return G(r),r}const $=(e,t)=>{const n=s(e),r=(e,r=t)=>X(n,e,r);return Object.assign(r,n),r};function Z(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Y={value:()=>{}};function U(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw new Error("illegal type: "+e);r[e]=[]}return new J(r)}function J(e){this._=e}function K(e,t){for(var n,r=0,o=e.length;r<o;++r)if((n=e[r]).name===t)return n.value}function q(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Y,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}J.prototype=U.prototype={constructor:J,on:function(e,t){var n,r=this._,o=function(e,t){return e.trim().split(/^|\s+/).map((function(e){var n="",r=e.indexOf(".");if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}(e+"",r),i=-1,a=o.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++i<a;)if(n=(e=o[i]).type)r[n]=q(r[n],e.name,t);else if(null==t)for(n in r)r[n]=q(r[n],e.name,null);return this}for(;++i<a;)if((n=(e=o[i]).type)&&(n=K(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new J(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,o=new Array(n),i=0;i<n;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(r=this._[e]).length;i<n;++i)r[i].value.apply(t,o)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};var Q="http://www.w3.org/1999/xhtml",ee={svg:"http://www.w3.org/2000/svg",xhtml:Q,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function te(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),ee.hasOwnProperty(t)?{space:ee[t],local:e}:e}function ne(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Q&&t.documentElement.namespaceURI===Q?t.createElement(e):t.createElementNS(n,e)}}function re(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function oe(e){var t=te(e);return(t.local?re:ne)(t)}function ie(){}function ae(e){return null==e?ie:function(){return this.querySelector(e)}}function se(){return[]}function le(e){return null==e?se:function(){return this.querySelectorAll(e)}}function ce(e){return function(){return function(e){return null==e?[]:Array.isArray(e)?e:Array.from(e)}(e.apply(this,arguments))}}function ue(e){return function(){return this.matches(e)}}function de(e){return function(t){return t.matches(e)}}var fe=Array.prototype.find;function pe(){return this.firstElementChild}var he=Array.prototype.filter;function me(){return Array.from(this.children)}function ge(e){return new Array(e.length)}function ye(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function be(e,t,n,r,o,i){for(var a,s=0,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new ye(e,i[s]);for(;s<l;++s)(a=t[s])&&(o[s]=a)}function ve(e,t,n,r,o,i,a){var s,l,c,u=new Map,d=t.length,f=i.length,p=new Array(d);for(s=0;s<d;++s)(l=t[s])&&(p[s]=c=a.call(l,l.__data__,s,t)+"",u.has(c)?o[s]=l:u.set(c,l));for(s=0;s<f;++s)c=a.call(e,i[s],s,i)+"",(l=u.get(c))?(r[s]=l,l.__data__=i[s],u.delete(c)):n[s]=new ye(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&u.get(p[s])===l&&(o[s]=l)}function we(e){return e.__data__}function xe(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function Ce(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ke(e){return function(){this.removeAttribute(e)}}function Ee(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Se(e,t){return function(){this.setAttribute(e,t)}}function Ie(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function _e(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function Ae(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ne(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Oe(e){return function(){this.style.removeProperty(e)}}function Re(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Me(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Te(e,t){return e.style.getPropertyValue(t)||Ne(e).getComputedStyle(e,null).getPropertyValue(t)}function Pe(e){return function(){delete this[e]}}function De(e,t){return function(){this[e]=t}}function je(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Fe(e){return e.trim().split(/^|\s+/)}function Le(e){return e.classList||new ze(e)}function ze(e){this._node=e,this._names=Fe(e.getAttribute("class")||"")}function Be(e,t){for(var n=Le(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ve(e,t){for(var n=Le(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function Ge(e){return function(){Be(this,e)}}function We(e){return function(){Ve(this,e)}}function He(e,t){return function(){(t.apply(this,arguments)?Be:Ve)(this,e)}}function Xe(){this.textContent=""}function $e(e){return function(){this.textContent=e}}function Ze(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function Ye(){this.innerHTML=""}function Ue(e){return function(){this.innerHTML=e}}function Je(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function Ke(){this.nextSibling&&this.parentNode.appendChild(this)}function qe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Qe(){return null}function et(){var e=this.parentNode;e&&e.removeChild(this)}function tt(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nt(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rt(e){return function(){var t=this.__on;if(t){for(var n,r=0,o=-1,i=t.length;r<i;++r)n=t[r],e.type&&n.type!==e.type||n.name!==e.name?t[++o]=n:this.removeEventListener(n.type,n.listener,n.options);++o?t.length=o:delete this.__on}}}function ot(e,t,n){return function(){var r,o=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(o)for(var a=0,s=o.length;a<s;++a)if((r=o[a]).type===e.type&&r.name===e.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),void(r.value=t);this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function it(e,t,n){var r=Ne(e),o=r.CustomEvent;"function"==typeof o?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function at(e,t){return function(){return it(this,e,t)}}function st(e,t){return function(){return it(this,e,t.apply(this,arguments))}}ye.prototype={constructor:ye,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},ze.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var lt=[null];function ct(e,t){this._groups=e,this._parents=t}function ut(){return new ct([[document.documentElement]],lt)}function dt(e){return"string"==typeof e?new ct([[document.querySelector(e)]],[document.documentElement]):new ct([[e]],lt)}function ft(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}ct.prototype=ut.prototype={constructor:ct,select:function(e){"function"!=typeof e&&(e=ae(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a,s=t[o],l=s.length,c=r[o]=new Array(l),u=0;u<l;++u)(i=s[u])&&(a=e.call(i,i.__data__,u,s))&&("__data__"in i&&(a.__data__=i.__data__),c[u]=a);return new ct(r,this._parents)},selectAll:function(e){e="function"==typeof e?ce(e):le(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var a,s=t[i],l=s.length,c=0;c<l;++c)(a=s[c])&&(r.push(e.call(a,a.__data__,c,s)),o.push(a));return new ct(r,o)},selectChild:function(e){return this.select(null==e?pe:function(e){return function(){return fe.call(this.children,e)}}("function"==typeof e?e:de(e)))},selectChildren:function(e){return this.selectAll(null==e?me:function(e){return function(){return he.call(this.children,e)}}("function"==typeof e?e:de(e)))},filter:function(e){"function"!=typeof e&&(e=ue(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a=t[o],s=a.length,l=r[o]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new ct(r,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,we);var n=t?ve:be,r=this._parents,o=this._groups;"function"!=typeof e&&(e=function(e){return function(){return e}}(e));for(var i=o.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var u=r[c],d=o[c],f=d.length,p=xe(e.call(u,u&&u.__data__,c,r)),h=p.length,m=s[c]=new Array(h),g=a[c]=new Array(h);n(u,d,m,g,l[c]=new Array(f),p,t);for(var y,b,v=0,w=0;v<h;++v)if(y=m[v]){for(v>=w&&(w=v+1);!(b=g[w])&&++w<h;);y._next=b||null}}return(a=new ct(a,r))._enter=s,a._exit=l,a},enter:function(){return new ct(this._enter||this._groups.map(ge),this._parents)},exit:function(){return new ct(this._exit||this._groups.map(ge),this._parents)},join:function(e,t,n){var r=this.enter(),o=this,i=this.exit();return"function"==typeof e?(r=e(r))&&(r=r.selection()):r=r.append(e+""),null!=t&&(o=t(o))&&(o=o.selection()),null==n?i.remove():n(i),r&&o?r.merge(o).order():o},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,a=Math.min(o,i),s=new Array(o),l=0;l<a;++l)for(var c,u=n[l],d=r[l],f=u.length,p=s[l]=new Array(f),h=0;h<f;++h)(c=u[h]||d[h])&&(p[h]=c);for(;l<o;++l)s[l]=n[l];return new ct(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r,o=e[t],i=o.length-1,a=o[i];--i>=0;)(r=o[i])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=Ce);for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var a,s=n[i],l=s.length,c=o[i]=new Array(l),u=0;u<l;++u)(a=s[u])&&(c[u]=a);c.sort(t)}return new ct(o,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var a=r[o];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o,i=t[n],a=0,s=i.length;a<s;++a)(o=i[a])&&e.call(o,o.__data__,a,i);return this},attr:function(e,t){var n=te(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==t?n.local?Ee:ke:"function"==typeof t?n.local?Ae:_e:n.local?Ie:Se)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?Oe:"function"==typeof t?Me:Re)(e,t,null==n?"":n)):Te(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Pe:"function"==typeof t?je:De)(e,t)):this.node()[e]},classed:function(e,t){var n=Fe(e+"");if(arguments.length<2){for(var r=Le(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each(("function"==typeof t?He:t?Ge:We)(n,t))},text:function(e){return arguments.length?this.each(null==e?Xe:("function"==typeof e?Ze:$e)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?Ye:("function"==typeof e?Je:Ue)(e)):this.node().innerHTML},raise:function(){return this.each(Ke)},lower:function(){return this.each(qe)},append:function(e){var t="function"==typeof e?e:oe(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:oe(e),r=null==t?Qe:"function"==typeof t?t:ae(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(et)},clone:function(e){return this.select(e?nt:tt)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var r,o,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?ot:rt,r=0;r<a;++r)this.each(s(i[r],t,n));return this}var s=this.node().__on;if(s)for(var l,c=0,u=s.length;c<u;++c)for(r=0,l=s[c];r<a;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?st:at)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r,o=e[t],i=0,a=o.length;i<a;++i)(r=o[i])&&(yield r)}};const pt={passive:!1},ht={capture:!0,passive:!1};function mt(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function yt(e){var t=e.document.documentElement,n=dt(e).on("dragstart.drag",gt,ht);"onselectstart"in t?n.on("selectstart.drag",gt,ht):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function bt(e,t){var n=e.document.documentElement,r=dt(e).on("dragstart.drag",null);t&&(r.on("click.drag",gt,ht),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var vt=e=>()=>e;function wt(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function xt(e){return!e.ctrlKey&&!e.button}function Ct(){return this.parentNode}function kt(e,t){return null==t?{x:e.x,y:e.y}:t}function Et(){return navigator.maxTouchPoints||"ontouchstart"in this}function St(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function It(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _t(){}wt.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var At=.7,Nt=1/At,Ot="\\s*([+-]?\\d+)\\s*",Rt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tt=/^#([0-9a-f]{3,8})$/,Pt=new RegExp(`^rgb\\(${Ot},${Ot},${Ot}\\)$`),Dt=new RegExp(`^rgb\\(${Mt},${Mt},${Mt}\\)$`),jt=new RegExp(`^rgba\\(${Ot},${Ot},${Ot},${Rt}\\)$`),Ft=new RegExp(`^rgba\\(${Mt},${Mt},${Mt},${Rt}\\)$`),Lt=new RegExp(`^hsl\\(${Rt},${Mt},${Mt}\\)$`),zt=new RegExp(`^hsla\\(${Rt},${Mt},${Mt},${Rt}\\)$`),Bt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Vt(){return this.rgb().formatHex()}function Gt(){return this.rgb().formatRgb()}function Wt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Tt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?Ht(t):3===n?new Zt(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?Xt(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?Xt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Pt.exec(e))?new Zt(t[1],t[2],t[3],1):(t=Dt.exec(e))?new Zt(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=jt.exec(e))?Xt(t[1],t[2],t[3],t[4]):(t=Ft.exec(e))?Xt(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Lt.exec(e))?Qt(t[1],t[2]/100,t[3]/100,1):(t=zt.exec(e))?Qt(t[1],t[2]/100,t[3]/100,t[4]):Bt.hasOwnProperty(e)?Ht(Bt[e]):"transparent"===e?new Zt(NaN,NaN,NaN,0):null}function Ht(e){return new Zt(e>>16&255,e>>8&255,255&e,1)}function Xt(e,t,n,r){return r<=0&&(e=t=n=NaN),new Zt(e,t,n,r)}function $t(e,t,n,r){return 1===arguments.length?function(e){return e instanceof _t||(e=Wt(e)),e?new Zt((e=e.rgb()).r,e.g,e.b,e.opacity):new Zt}(e):new Zt(e,t,n,null==r?1:r)}function Zt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function Yt(){return`#${qt(this.r)}${qt(this.g)}${qt(this.b)}`}function Ut(){const e=Jt(this.opacity);return`${1===e?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${1===e?")":`, ${e})`}`}function Jt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qt(e){return((e=Kt(e))<16?"0":"")+e.toString(16)}function Qt(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new tn(e,t,n,r)}function en(e){if(e instanceof tn)return new tn(e.h,e.s,e.l,e.opacity);if(e instanceof _t||(e=Wt(e)),!e)return new tn;if(e instanceof tn)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,s=i-o,l=(i+o)/2;return s?(a=t===i?(n-r)/s+6*(n<r):n===i?(r-t)/s+2:(t-n)/s+4,s/=l<.5?i+o:2-i-o,a*=60):s=l>0&&l<1?0:a,new tn(a,s,l,e.opacity)}function tn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function nn(e){return(e=(e||0)%360)<0?e+360:e}function rn(e){return Math.max(0,Math.min(1,e||0))}function on(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}St(_t,Wt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Vt,formatHex:Vt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return en(this).formatHsl()},formatRgb:Gt,toString:Gt}),St(Zt,$t,It(_t,{brighter(e){return e=null==e?Nt:Math.pow(Nt,e),new Zt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?At:Math.pow(At,e),new Zt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Zt(Kt(this.r),Kt(this.g),Kt(this.b),Jt(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:Yt,formatHex:Yt,formatHex8:function(){return`#${qt(this.r)}${qt(this.g)}${qt(this.b)}${qt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ut,toString:Ut})),St(tn,(function(e,t,n,r){return 1===arguments.length?en(e):new tn(e,t,n,null==r?1:r)}),It(_t,{brighter(e){return e=null==e?Nt:Math.pow(Nt,e),new tn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?At:Math.pow(At,e),new tn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Zt(on(e>=240?e-240:e+120,o,r),on(e,o,r),on(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new tn(nn(this.h),rn(this.s),rn(this.l),Jt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Jt(this.opacity);return`${1===e?"hsl(":"hsla("}${nn(this.h)}, ${100*rn(this.s)}%, ${100*rn(this.l)}%${1===e?")":`, ${e})`}`}}));var an=e=>()=>e;function sn(e){return 1==(e=+e)?ln:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):an(isNaN(t)?n:t)}}function ln(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):an(isNaN(e)?t:e)}var cn=function e(t){var n=sn(t);function r(e,t){var r=n((e=$t(e)).r,(t=$t(t)).r),o=n(e.g,t.g),i=n(e.b,t.b),a=ln(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=o(t),e.b=i(t),e.opacity=a(t),e+""}}return r.gamma=e,r}(1);function un(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var dn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fn=new RegExp(dn.source,"g");function pn(e,t){var n,r,o,i=dn.lastIndex=fn.lastIndex=0,a=-1,s=[],l=[];for(e+="",t+="";(n=dn.exec(e))&&(r=fn.exec(t));)(o=r.index)>i&&(o=t.slice(i,o),s[a]?s[a]+=o:s[++a]=o),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:un(n,r)})),i=fn.lastIndex;return i<t.length&&(o=t.slice(i),s[a]?s[a]+=o:s[++a]=o),s.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,r=0;r<t;++r)s[(n=l[r]).i]=n.x(e);return s.join("")})}var hn,mn=180/Math.PI,gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function yn(e,t,n,r,o,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*mn,skewX:Math.atan(l)*mn,scaleX:a,scaleY:s}}function bn(e,t,n,r){function o(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],l=[];return i=e(i),a=e(a),function(e,r,o,i,a,s){if(e!==o||r!==i){var l=a.push("translate(",null,t,null,n);s.push({i:l-4,x:un(e,o)},{i:l-2,x:un(r,i)})}else(o||i)&&a.push("translate("+o+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(o(n)+"rotate(",null,r)-2,x:un(e,t)})):t&&n.push(o(n)+"rotate("+t+r)}(i.rotate,a.rotate,s,l),function(e,t,n,i){e!==t?i.push({i:n.push(o(n)+"skewX(",null,r)-2,x:un(e,t)}):t&&n.push(o(n)+"skewX("+t+r)}(i.skewX,a.skewX,s,l),function(e,t,n,r,i,a){if(e!==n||t!==r){var s=i.push(o(i)+"scale(",null,",",null,")");a.push({i:s-4,x:un(e,n)},{i:s-2,x:un(t,r)})}else 1===n&&1===r||i.push(o(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,l),i=a=null,function(e){for(var t,n=-1,r=l.length;++n<r;)s[(t=l[n]).i]=t.x(e);return s.join("")}}}var vn=bn((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?gn:yn(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),wn=bn((function(e){return null==e?gn:(hn||(hn=document.createElementNS("http://www.w3.org/2000/svg","g")),hn.setAttribute("transform",e),(e=hn.transform.baseVal.consolidate())?yn((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):gn)}),", ",")",")");function xn(e){return((e=Math.exp(e))+1/e)/2}var Cn,kn,En=function e(t,n,r){function o(e,o){var i,a,s=e[0],l=e[1],c=e[2],u=o[0],d=o[1],f=o[2],p=u-s,h=d-l,m=p*p+h*h;if(m<1e-12)a=Math.log(f/c)/t,i=function(e){return[s+e*p,l+e*h,c*Math.exp(t*e*a)]};else{var g=Math.sqrt(m),y=(f*f-c*c+r*m)/(2*c*n*g),b=(f*f-c*c-r*m)/(2*f*n*g),v=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(b*b+1)-b);a=(w-v)/t,i=function(e){var r=e*a,o=xn(v),i=c/(n*g)*(o*function(e){return((e=Math.exp(2*e))-1)/(e+1)}(t*r+v)-function(e){return((e=Math.exp(e))-1/e)/2}(v));return[s+i*p,l+i*h,c*o/xn(t*r+v)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return o.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},o}(Math.SQRT2,2,4),Sn=0,In=0,_n=0,An=0,Nn=0,On=0,Rn="object"==typeof performance&&performance.now?performance:Date,Mn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tn(){return Nn||(Mn(Pn),Nn=Rn.now()+On)}function Pn(){Nn=0}function Dn(){this._call=this._time=this._next=null}function jn(e,t,n){var r=new Dn;return r.restart(e,t,n),r}function Fn(){Nn=(An=Rn.now())+On,Sn=In=0;try{!function(){Tn(),++Sn;for(var e,t=Cn;t;)(e=Nn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Sn}()}finally{Sn=0,function(){var e,t,n=Cn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Cn=t);kn=e,zn(r)}(),Nn=0}}function Ln(){var e=Rn.now(),t=e-An;t>1e3&&(On-=t,An=e)}function zn(e){Sn||(In&&(In=clearTimeout(In)),e-Nn>24?(e<1/0&&(In=setTimeout(Fn,e-Rn.now()-On)),_n&&(_n=clearInterval(_n))):(_n||(An=Rn.now(),_n=setInterval(Ln,1e3)),Sn=1,Mn(Fn)))}function Bn(e,t,n){var r=new Dn;return t=null==t?0:+t,r.restart((n=>{r.stop(),e(n+t)}),t,n),r}Dn.prototype=jn.prototype={constructor:Dn,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Tn():+n)+(null==t?0:+t),this._next||kn===this||(kn?kn._next=this:Cn=this,kn=this),this._call=e,this._time=n,zn()},stop:function(){this._call&&(this._call=null,this._time=1/0,zn())}};var Vn=U("start","end","cancel","interrupt"),Gn=[];function Wn(e,t,n,r,o,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var r,o=e.__transition;function i(e){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var c,u,d,f;if(1!==n.state)return l();for(c in o)if((f=o[c]).name===n.name){if(3===f.state)return Bn(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete o[c]):+c<t&&(f.state=6,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete o[c])}if(Bn((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(f=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=f);r.length=u+1}}function s(t){for(var o=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=5,1),i=-1,a=r.length;++i<a;)r[i].call(e,o);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete o[t],o)return;delete e.__transition}o[t]=n,n.timer=jn(i,0,n.time)}(e,n,{name:t,index:r,group:o,on:Vn,tween:Gn,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:0})}function Hn(e,t){var n=$n(e,t);if(n.state>0)throw new Error("too late; already scheduled");return n}function Xn(e,t){var n=$n(e,t);if(n.state>3)throw new Error("too late; already running");return n}function $n(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Zn(e,t){var n,r,o,i=e.__transition,a=!0;if(i){for(o in t=null==t?null:t+"",i)(n=i[o]).name===t?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[o]):a=!1;a&&delete e.__transition}}function Yn(e,t){var n,r;return function(){var o=Xn(this,e),i=o.tween;if(i!==n)for(var a=0,s=(r=n=i).length;a<s;++a)if(r[a].name===t){(r=r.slice()).splice(a,1);break}o.tween=r}}function Un(e,t,n){var r,o;if("function"!=typeof n)throw new Error;return function(){var i=Xn(this,e),a=i.tween;if(a!==r){o=(r=a).slice();for(var s={name:t,value:n},l=0,c=o.length;l<c;++l)if(o[l].name===t){o[l]=s;break}l===c&&o.push(s)}i.tween=o}}function Jn(e,t,n){var r=e._id;return e.each((function(){var e=Xn(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return $n(e,r).value[t]}}function Kn(e,t){var n;return("number"==typeof t?un:t instanceof Wt?cn:(n=Wt(t))?(t=n,cn):pn)(e,t)}function qn(e){return function(){this.removeAttribute(e)}}function Qn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function er(e,t,n){var r,o,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===r?o:o=t(r=a,n)}}function tr(e,t,n){var r,o,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?o:o=t(r=a,n)}}function nr(e,t,n){var r,o,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttribute(e))===(s=l+"")?null:a===r&&s===o?i:(o=s,i=t(r=a,l));this.removeAttribute(e)}}function rr(e,t,n){var r,o,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttributeNS(e.space,e.local))===(s=l+"")?null:a===r&&s===o?i:(o=s,i=t(r=a,l));this.removeAttributeNS(e.space,e.local)}}function or(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,o)),n}return o._value=t,o}function ir(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,o)),n}return o._value=t,o}function ar(e,t){return function(){Hn(this,e).delay=+t.apply(this,arguments)}}function sr(e,t){return t=+t,function(){Hn(this,e).delay=t}}function lr(e,t){return function(){Xn(this,e).duration=+t.apply(this,arguments)}}function cr(e,t){return t=+t,function(){Xn(this,e).duration=t}}var ur=ut.prototype.constructor;function dr(e){return function(){this.style.removeProperty(e)}}var fr=0;function pr(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function hr(){return++fr}var mr=ut.prototype;pr.prototype={constructor:pr,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=ae(e));for(var r=this._groups,o=r.length,i=new Array(o),a=0;a<o;++a)for(var s,l,c=r[a],u=c.length,d=i[a]=new Array(u),f=0;f<u;++f)(s=c[f])&&(l=e.call(s,s.__data__,f,c))&&("__data__"in s&&(l.__data__=s.__data__),d[f]=l,Wn(d[f],t,n,f,d,$n(s,n)));return new pr(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=le(e));for(var r=this._groups,o=r.length,i=[],a=[],s=0;s<o;++s)for(var l,c=r[s],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var f,p=e.call(l,l.__data__,d,c),h=$n(l,n),m=0,g=p.length;m<g;++m)(f=p[m])&&Wn(f,t,n,m,p,h);i.push(p),a.push(l)}return new pr(i,a,t,n)},selectChild:mr.selectChild,selectChildren:mr.selectChildren,filter:function(e){"function"!=typeof e&&(e=ue(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a=t[o],s=a.length,l=r[o]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new pr(r,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),a=new Array(r),s=0;s<i;++s)for(var l,c=t[s],u=n[s],d=c.length,f=a[s]=new Array(d),p=0;p<d;++p)(l=c[p]||u[p])&&(f[p]=l);for(;s<r;++s)a[s]=t[s];return new pr(a,this._parents,this._name,this._id)},selection:function(){return new ur(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=hr(),r=this._groups,o=r.length,i=0;i<o;++i)for(var a,s=r[i],l=s.length,c=0;c<l;++c)if(a=s[c]){var u=$n(a,t);Wn(a,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new pr(r,this._parents,e,n)},call:mr.call,nodes:mr.nodes,node:mr.node,size:mr.size,empty:mr.empty,each:mr.each,on:function(e,t){var n=this._id;return arguments.length<2?$n(this.node(),n).on.on(e):this.each(function(e,t,n){var r,o,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?Hn:Xn;return function(){var a=i(this,e),s=a.on;s!==r&&(o=(r=s).copy()).on(t,n),a.on=o}}(n,e,t))},attr:function(e,t){var n=te(e),r="transform"===n?wn:Kn;return this.attrTween(e,"function"==typeof t?(n.local?rr:nr)(n,r,Jn(this,"attr."+e,t)):null==t?(n.local?Qn:qn)(n):(n.local?tr:er)(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=te(e);return this.tween(n,(r.local?or:ir)(r,t))},style:function(e,t,n){var r="transform"==(e+="")?vn:Kn;return null==t?this.styleTween(e,function(e,t){var n,r,o;return function(){var i=Te(this,e),a=(this.style.removeProperty(e),Te(this,e));return i===a?null:i===n&&a===r?o:o=t(n=i,r=a)}}(e,r)).on("end.style."+e,dr(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var r,o,i;return function(){var a=Te(this,e),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(e),l=s=Te(this,e)),a===l?null:a===r&&l===o?i:(o=l,i=t(r=a,s))}}(e,r,Jn(this,"style."+e,t))).each(function(e,t){var n,r,o,i,a="style."+t,s="end."+a;return function(){var l=Xn(this,e),c=l.on,u=null==l.value[a]?i||(i=dr(t)):void 0;c===n&&o===u||(r=(n=c).copy()).on(s,o=u),l.on=r}}(this._id,e)):this.styleTween(e,function(e,t,n){var r,o,i=n+"";return function(){var a=Te(this,e);return a===i?null:a===r?o:o=t(r=a,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function(e,t,n){var r,o;function i(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&function(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,i,n)),r}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(Jn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&function(e){return function(t){this.textContent=e.call(this,t)}}(r)),t}return r._value=e,r}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,o=$n(this.node(),n).tween,i=0,a=o.length;i<a;++i)if((r=o[i]).name===e)return r.value;return null}return this.each((null==t?Yn:Un)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?ar:sr)(t,e)):$n(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?lr:cr)(t,e)):$n(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){Xn(this,e).ease=t}}(t,e)):$n(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;Xn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,r=n._id,o=n.size();return new Promise((function(i,a){var s={value:a},l={value:function(){0==--o&&i()}};n.each((function(){var n=Xn(this,r),o=n.on;o!==e&&((t=(e=o).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),n.on=t})),0===o&&i()}))},[Symbol.iterator]:mr[Symbol.iterator]};var gr={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function yr(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}ut.prototype.interrupt=function(e){return this.each((function(){Zn(this,e)}))},ut.prototype.transition=function(e){var t,n;e instanceof pr?(t=e._id,e=e._name):(t=hr(),(n=gr).time=Tn(),e=null==e?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var a,s=r[i],l=s.length,c=0;c<l;++c)(a=s[c])&&Wn(a,e,t,c,s,n||yr(a,t));return new pr(r,this._parents,e,t)};var br=e=>()=>e;function vr(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function wr(e,t,n){this.k=e,this.x=t,this.y=n}wr.prototype={constructor:wr,scale:function(e){return 1===e?this:new wr(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new wr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xr=new wr(1,0,0);function Cr(e){e.stopImmediatePropagation()}function kr(e){e.preventDefault(),e.stopImmediatePropagation()}function Er(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Sr(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Ir(){return this.__zoom||xr}function _r(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ar(){return navigator.maxTouchPoints||"ontouchstart"in this}function Nr(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function Or(){var e,t,n,r=Er,o=Sr,i=Nr,a=_r,s=Ar,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=En,f=U("start","zoom","end"),p=0,h=10;function m(e){e.property("__zoom",Ir).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",S).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new wr(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,o=t[1]-n[1]*e.k;return r===e.x&&o===e.y?e:new wr(e.k,r,o)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function v(e,t,n,r){e.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,i=arguments,a=w(e,i).event(r),s=o.apply(e,i),l=null==n?b(s):"function"==typeof n?n.apply(e,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,f="function"==typeof t?t.apply(e,i):t,p=d(u.invert(l).concat(c/u.k),f.invert(l).concat(c/f.k));return function(e){if(1===e)e=f;else{var t=p(e),n=c/t[2];e=new wr(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function w(e,t,n){return!n&&e.__zooming||new x(e,t)}function x(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=o.apply(e,t),this.taps=0}function C(e,...t){if(r.apply(this,arguments)){var n=w(this,t).event(e),o=this.__zoom,s=Math.max(l[0],Math.min(l[1],o.k*Math.pow(2,a.apply(this,arguments)))),u=ft(e);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=o.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(o.k===s)return;n.mouse=[u,o.invert(u)],Zn(this),n.start()}kr(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",i(y(g(o,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function k(e,...t){if(!n&&r.apply(this,arguments)){var o=e.currentTarget,a=w(this,t,!0).event(e),s=dt(e.view).on("mousemove.zoom",(function(e){if(kr(e),!a.moved){var t=e.clientX-u,n=e.clientY-d;a.moved=t*t+n*n>p}a.event(e).zoom("mouse",i(y(a.that.__zoom,a.mouse[0]=ft(e,o),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),bt(e.view,a.moved),kr(e),a.event(e).end()}),!0),l=ft(e,o),u=e.clientX,d=e.clientY;yt(e.view),Cr(e),a.mouse=[l,this.__zoom.invert(l)],Zn(this),a.start()}}function E(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,a=ft(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),d=i(y(g(n,l),a,s),o.apply(this,t),c);kr(e),u>0?dt(this).transition().duration(u).call(v,d,a,e):dt(this).call(m.transform,d,a,e)}}function S(n,...o){if(r.apply(this,arguments)){var i,a,s,l,c=n.touches,u=c.length,d=w(this,o,n.changedTouches.length===u).event(n);for(Cr(n),a=0;a<u;++a)l=[l=ft(s=c[a],this),this.__zoom.invert(l),s.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),Zn(this),d.start())}}function I(e,...t){if(this.__zooming){var n,r,o,a,s=w(this,t).event(e),l=e.changedTouches,u=l.length;for(kr(e),n=0;n<u;++n)o=ft(r=l[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=o:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=o);if(r=s.that.__zoom,s.touch1){var d=s.touch0[0],f=s.touch0[1],p=s.touch1[0],h=s.touch1[1],m=(m=p[0]-d[0])*m+(m=p[1]-d[1])*m,b=(b=h[0]-f[0])*b+(b=h[1]-f[1])*b;r=g(r,Math.sqrt(m/b)),o=[(d[0]+p[0])/2,(d[1]+p[1])/2],a=[(f[0]+h[0])/2,(f[1]+h[1])/2]}else{if(!s.touch0)return;o=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(y(r,o,a),s.extent,c))}}function _(e,...r){if(this.__zooming){var o,i,a=w(this,r).event(e),s=e.changedTouches,l=s.length;for(Cr(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),o=0;o<l;++o)i=s[o],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=ft(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<h)){var c=dt(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var o=e.selection?e.selection():e;o.property("__zoom",Ir),e!==o?v(e,t,n,r):o.interrupt().each((function(){w(this,arguments).event(r).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},m.scaleBy=function(e,t,n,r){m.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,(function(){var e=o.apply(this,arguments),r=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(a),l="function"==typeof t?t.apply(this,arguments):t;return i(y(g(r,l),a,s),e,c)}),n,r)},m.translateBy=function(e,t,n,r){m.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),o.apply(this,arguments),c)}),null,r)},m.translateTo=function(e,t,n,r,a){m.transform(e,(function(){var e=o.apply(this,arguments),a=this.__zoom,s=null==r?b(e):"function"==typeof r?r.apply(this,arguments):r;return i(xr.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),r,a)},x.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=dt(this.that).datum();f.call(e,this.that,new vr(e,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:f}),t)}},m.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:br(+e),m):a},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:br(!!e),m):r},m.touchable=function(e){return arguments.length?(s="function"==typeof e?e:br(!!e),m):s},m.extent=function(e){return arguments.length?(o="function"==typeof e?e:br([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):o},m.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],m):[l[0],l[1]]},m.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],m):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},m.constrain=function(e){return arguments.length?(i=e,m):i},m.duration=function(e){return arguments.length?(u=+e,m):u},m.interpolate=function(e){return arguments.length?(d=e,m):d},m.on=function(){var e=f.on.apply(f,arguments);return e===f?m:e},m.clickDistance=function(e){return arguments.length?(p=(e=+e)*e,m):Math.sqrt(p)},m.tapDistance=function(e){return arguments.length?(h=+e,m):h},m}wr.prototype;const Rr=e.createContext(null),Mr=Rr.Provider,Tr=()=>"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.",Pr=e=>`Node type "${e}" not found. Using fallback type "default".`,Dr=()=>"The React Flow parent container needs a width and a height to render the graph.",jr=()=>"Only child nodes can use a parent extent.",Fr=()=>"Can't create edge. An edge needs a source and a target.",Lr=e=>`Marker type "${e}" doesn't exist.`,zr=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,Br=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",Vr=e=>`Edge type "${e}" not found. Using fallback type "default".`,Gr=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,Wr=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function Hr(t,n){const r=e.useContext(Rr);if(null===r)throw new Error(Wr);return X(r,t,n)}const Xr=()=>{const t=e.useContext(Rr);if(null===t)throw new Error(Wr);return e.useMemo((()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy})),[t])},$r=e=>e.userSelectionActive?"none":"all";function Zr({position:t,children:n,className:r,style:o,...i}){const a=Hr($r),s=`${t}`.split("-");return e.createElement("div",{className:V(["react-flow__panel",r,...s]),style:{...o,pointerEvents:a},...i},n)}function Yr({proOptions:t,position:n="bottom-right"}){return t?.hideAttribution?null:e.createElement(Zr,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},e.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var Ur=e.memo((({x:t,y:n,label:r,labelStyle:o={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d})=>{const f=e.useRef(null),[p,h]=e.useState({x:0,y:0,width:0,height:0}),m=V(["react-flow__edge-textwrapper",u]);return e.useEffect((()=>{if(f.current){const e=f.current.getBBox();h({x:e.x,y:e.y,width:e.width,height:e.height})}}),[r]),void 0!==r&&r?e.createElement("g",{transform:`translate(${t-p.width/2} ${n-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...d},i&&e.createElement("rect",{width:p.width+2*s[0],x:-s[0],y:-s[1],height:p.height+2*s[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),e.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:o},r),c):null}));const Jr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Kr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),qr=(e={x:0,y:0},t)=>({x:Kr(e.x,t[0][0],t[1][0]),y:Kr(e.y,t[0][1],t[1][1])}),Qr=(e,t,n)=>e<t?Kr(Math.abs(e-t),1,50)/50:e>n?-Kr(Math.abs(e-n),1,50)/50:0,eo=(e,t)=>[20*Qr(e.x,35,t.width-35),20*Qr(e.y,35,t.height-35)],to=e=>e.getRootNode?.()||window?.document,no=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),ro=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),oo=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),io=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ao=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},so=e=>!isNaN(e)&&isFinite(e),lo=Symbol.for("internals"),co=["Enter"," ","Escape"],uo=(e,t)=>{"development"===process.env.NODE_ENV&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)};function fo(e){const t=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,n=t.composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const po=e=>"clientX"in e,ho=(e,t)=>{const n=po(e),r=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:o-(t?.top??0)}},mo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0,go=({id:t,path:n,labelX:r,labelY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h=20})=>e.createElement(e.Fragment,null,e.createElement("path",{id:t,style:d,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:p}),h&&e.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),i&&so(r)&&so(o)?e.createElement(Ur,{x:r,y:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u}):null);function yo(e,t,n){return void 0===n?n:r=>{const o=t().edges.find((t=>t.id===e));o&&n(r,{...o})}}function bo({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(r-t)/2;return[i,r<t?r+a:r-a,o,a]}function vo({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:s}){const l=.125*e+.375*o+.375*a+.125*n,c=.125*t+.375*i+.375*s+.125*r;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var wo,xo,Co,ko,Eo,So;function Io({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===So.Left||e===So.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function _o({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top}){const[a,s]=Io({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,c]=Io({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,p]=vo({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:s,targetControlX:l,targetControlY:c});return[`M${e},${t} C${a},${s} ${l},${c} ${r},${o}`,u,d,f,p]}go.displayName="BaseEdge",function(e){e.Strict="strict",e.Loose="loose"}(wo||(wo={})),function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"}(xo||(xo={})),function(e){e.Partial="partial",e.Full="full"}(Co||(Co={})),function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"}(ko||(ko={})),function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"}(Eo||(Eo={})),function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"}(So||(So={}));const Ao=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i=So.Bottom,targetPosition:a=So.Top,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:g})=>{const[y,b,v]=_o({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a});return e.createElement(go,{path:y,labelX:b,labelY:v,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:g})}));Ao.displayName="SimpleBezierEdge";const No={[So.Left]:{x:-1,y:0},[So.Right]:{x:1,y:0},[So.Top]:{x:0,y:-1},[So.Bottom]:{x:0,y:1}},Oo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ro({source:e,sourcePosition:t=So.Bottom,target:n,targetPosition:r=So.Top,center:o,offset:i}){const a=No[t],s=No[r],l={x:e.x+a.x*i,y:e.y+a.y*i},c={x:n.x+s.x*i,y:n.y+s.y*i},u=(({source:e,sourcePosition:t=So.Bottom,target:n})=>t===So.Left||t===So.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),d=0!==u.x?"x":"y",f=u[d];let p,h,m=[];const g={x:0,y:0},y={x:0,y:0},[b,v,w,x]=bo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*s[d]==-1){p=o.x??b,h=o.y??v;const e=[{x:p,y:l.y},{x:p,y:c.y}],t=[{x:l.x,y:h},{x:c.x,y:h}];m=a[d]===f?"x"===d?e:t:"x"===d?t:e}else{const o=[{x:l.x,y:c.y}],u=[{x:c.x,y:l.y}];if(m="x"===d?a.x===f?u:o:a.y===f?o:u,t===r){const t=Math.abs(e[d]-n[d]);if(t<=i){const r=Math.min(i-1,i-t);a[d]===f?g[d]=(l[d]>e[d]?-1:1)*r:y[d]=(c[d]>n[d]?-1:1)*r}}if(t!==r){const e="x"===d?"y":"x",t=a[d]===s[e],n=l[e]>c[e],r=l[e]<c[e];(1===a[d]&&(!t&&n||t&&r)||1!==a[d]&&(!t&&r||t&&n))&&(m="x"===d?o:u)}const b={x:l.x+g.x,y:l.y+g.y},v={x:c.x+y.x,y:c.y+y.y};Math.max(Math.abs(b.x-m[0].x),Math.abs(v.x-m[0].x))>=Math.max(Math.abs(b.y-m[0].y),Math.abs(v.y-m[0].y))?(p=(b.x+v.x)/2,h=m[0].y):(p=m[0].x,h=(b.y+v.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...m,{x:c.x+y.x,y:c.y+y.y},n],p,h,w,x]}function Mo({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top,borderRadius:a=5,centerX:s,centerY:l,offset:c=20}){const[u,d,f,p,h]=Ro({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:s,y:l},offset:c}),m=u.reduce(((e,t,n)=>{let r="";return r=n>0&&n<u.length-1?function(e,t,n,r){const o=Math.min(Oo(e,t)/2,Oo(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+o*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+o*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+o*(e.y<n.y?-1:1)}Q ${i},${a} ${i+o*s},${a}`}(u[n-1],t,u[n+1],a):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=r}),"");return[m,d,f,p,h]}const To=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,sourcePosition:f=So.Bottom,targetPosition:p=So.Top,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,v,w]=Mo({sourceX:t,sourceY:n,sourcePosition:f,targetX:r,targetY:o,targetPosition:p,borderRadius:g?.borderRadius,offset:g?.offset});return e.createElement(go,{path:b,labelX:v,labelY:w,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:m,interactionWidth:y})}));To.displayName="SmoothStepEdge";const Po=e.memo((t=>e.createElement(To,{...t,pathOptions:e.useMemo((()=>({borderRadius:0,offset:t.pathOptions?.offset})),[t.pathOptions?.offset])})));Po.displayName="StepEdge";const Do=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h})=>{const[m,g,y]=function({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,a,s]=bo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,a,s]}({sourceX:t,sourceY:n,targetX:r,targetY:o});return e.createElement(go,{path:m,labelX:g,labelY:y,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h})}));function jo(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function Fo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case So.Left:return[t-jo(t-r,i),n];case So.Right:return[t+jo(r-t,i),n];case So.Top:return[t,n-jo(n-o,i)];case So.Bottom:return[t,n+jo(o-n,i)]}}function Lo({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top,curvature:a=.25}){const[s,l]=Fo({pos:n,x1:e,y1:t,x2:r,y2:o,c:a}),[c,u]=Fo({pos:i,x1:r,y1:o,x2:e,y2:t,c:a}),[d,f,p,h]=vo({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${l} ${c},${u} ${r},${o}`,d,f,p,h]}Do.displayName="StraightEdge";const zo=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i=So.Bottom,targetPosition:a=So.Top,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,v,w]=Lo({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a,curvature:g?.curvature});return e.createElement(go,{path:b,labelX:v,labelY:w,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:y})}));zo.displayName="BezierEdge";const Bo=e.createContext(null),Vo=Bo.Provider;Bo.Consumer;const Go=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Wo=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},Ho=({x:e,y:t},[n,r,o],i,[a,s])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?{x:a*Math.round(l.x/a),y:s*Math.round(l.y/s)}:l},Xo=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),$o=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},Zo=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const{x:r,y:o}=$o(n,t).positionAbsolute;return no(e,ro({x:r,y:o,width:n.width||0,height:n.height||0}))}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return oo(n)},Yo=(e,t,[n,r,o]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const l={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:r=!0,hidden:o=!1}=e;if(a&&!r||o)return!1;const{positionAbsolute:u}=$o(e,s),d={x:u.x,y:u.y,width:t||0,height:n||0},f=ao(l,d);(void 0===t||void 0===n||null===t||null===n||i&&f>0||f>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},Uo=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},Jo=(e,t,n,r,o,i=.1)=>{const a=t/(e.width*(1+i)),s=n/(e.height*(1+i)),l=Math.min(a,s),c=Kr(l,r,o);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Ko=(e,t=0)=>e.transition().duration(t);function qo(e,t,n,r){return(t[n]||[]).reduce(((t,o)=>(`${e.id}-${o.id}-${n}`!==r&&t.push({id:o.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+o.x+o.width/2,y:(e.positionAbsolute?.y??0)+o.y+o.height/2}),t)),[])}const Qo={source:null,target:null,sourceHandle:null,targetHandle:null},ei=()=>({handleDomNode:null,isValid:!1,connection:Qo,endHandle:null});function ti(e,t,n,r,o,i,a){const s="target"===o,l=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),c={...ei(),handleDomNode:l};if(l){const e=ni(void 0,l),o=l.getAttribute("data-nodeid"),a=l.getAttribute("data-handleid"),u=l.classList.contains("connectable"),d=l.classList.contains("connectableend"),f={source:s?o:n,sourceHandle:s?a:r,target:s?n:o,targetHandle:s?r:a};c.connection=f;u&&d&&(t===wo.Strict?s&&"source"===e||!s&&"target"===e:o!==n||a!==r)&&(c.endHandle={nodeId:o,handleId:a,type:e},c.isValid=i(f))}return c}function ni(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ri(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function oi(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function ii({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:i,setState:a,isValidConnection:s,edgeUpdaterType:l,onReconnectEnd:c}){const u=to(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:p,connectionRadius:h,onConnectStart:m,panBy:g,getNodes:y,cancelConnection:b}=i();let v,w=0;const{x:x,y:C}=ho(e),k=u?.elementFromPoint(x,C),E=ni(l,k),S=f?.getBoundingClientRect();if(!S||!E)return;let I,_=ho(e,S),A=!1,N=null,O=!1,R=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce(((e,o)=>{if(o[lo]){const{handleBounds:i}=o[lo];let a=[],s=[];i&&(a=qo(o,i,"source",`${t}-${n}-${r}`),s=qo(o,i,"target",`${t}-${n}-${r}`)),e.push(...a,...s)}return e}),[])}({nodes:y(),nodeId:n,handleId:t,handleType:E}),T=()=>{if(!p)return;const[e,t]=eo(_,S);g({x:e,y:t}),w=requestAnimationFrame(T)};function P(e){const{transform:r}=i();_=ho(e,S);const{handle:l,validHandleResult:c}=function(e,t,n,r,o,i){const{x:a,y:s}=ho(e),l=t.elementsFromPoint(a,s).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=ni(void 0,l),r=l.getAttribute("data-handleid"),a=i({nodeId:e,id:r,type:t});if(a){const i=o.find((n=>n.nodeId===e&&n.type===t&&n.id===r));return{handle:{id:r,type:t,nodeId:e,x:i?.x||n.x,y:i?.y||n.y},validHandleResult:a}}}}let c=[],u=1/0;if(o.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){const n=i(e);t<=u&&(t<u?c=[{handle:e,validHandleResult:n}]:t===u&&c.push({handle:e,validHandleResult:n}),u=t)}})),!c.length)return{handle:null,validHandleResult:ei()};if(1===c.length)return c[0];const d=c.some((({validHandleResult:e})=>e.isValid)),f=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>f?"target"===e.type:!d||t.isValid))||c[0]}(e,u,Ho(_,r,!1,[1,1]),h,M,(e=>ti(e,d,n,t,o?"target":"source",s,u)));if(v=l,A||(T(),A=!0),R=c.handleDomNode,N=c.connection,O=c.isValid,a({connectionPosition:v&&O?Xo({x:v.x,y:v.y},r):_,connectionStatus:oi(!!v,O),connectionEndHandle:c.endHandle}),!v&&!O&&!R)return ri(I);N.source!==N.target&&R&&(ri(I),I=R,R.classList.add("connecting","react-flow__handle-connecting"),R.classList.toggle("valid",O),R.classList.toggle("react-flow__handle-valid",O))}function D(e){(v||R)&&N&&O&&r?.(N),i().onConnectEnd?.(e),l&&c?.(e),ri(I),b(),cancelAnimationFrame(w),A=!1,O=!1,N=null,R=null,u.removeEventListener("mousemove",P),u.removeEventListener("mouseup",D),u.removeEventListener("touchmove",P),u.removeEventListener("touchend",D)}a({connectionPosition:_,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:E,connectionStartHandle:{nodeId:n,handleId:t,type:E},connectionEndHandle:null}),m?.(e,{nodeId:n,handleId:t,handleType:E}),u.addEventListener("mousemove",P),u.addEventListener("mouseup",D),u.addEventListener("touchmove",P),u.addEventListener("touchend",D)}const ai=()=>!0,si=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),li=e.forwardRef((({type:t="source",position:n=So.Top,isValidConnection:r,isConnectable:o=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:s,onConnect:l,children:c,className:u,onMouseDown:d,onTouchStart:f,...p},h)=>{const m=s||null,g="target"===t,y=Xr(),b=e.useContext(Bo),{connectOnClick:v,noPanClassName:w}=Hr(si,Z),{connecting:x,clickConnecting:C}=Hr(((e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:i,connectionClickStartHandle:a}=r;return{connecting:o?.nodeId===e&&o?.handleId===t&&o?.type===n||i?.nodeId===e&&i?.handleId===t&&i?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}})(b,m,t),Z);b||y.getState().onError?.("010",Br());const k=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=y.getState(),o={...t,...e};if(r){const{edges:e,setEdges:t}=y.getState();t(((e,t)=>{if(!e.source||!e.target)return uo("006",Fr()),t;let n;return n=(e=>"id"in e&&"source"in e&&"target"in e)(e)?{...e}:{...e,id:Go(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(o,e))}n?.(o),l?.(o)},E=e=>{if(!b)return;const t=po(e);i&&(t&&0===e.button||!t)&&ii({event:e,handleId:m,nodeId:b,onConnect:k,isTarget:g,getState:y.getState,setState:y.setState,isValidConnection:r||y.getState().isValidConnection||ai}),t?d?.(e):f?.(e)};return e.createElement("div",{"data-handleid":m,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${m}-${t}`,className:V(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",w,u,{source:!g,target:g,connectable:o,connectablestart:i,connectableend:a,connecting:C,connectionindicator:o&&(i&&!x||a&&x)}]),onMouseDown:E,onTouchStart:E,onClick:v?e=>{const{onClickConnectStart:n,onClickConnectEnd:o,connectionClickStartHandle:a,connectionMode:s,isValidConnection:l}=y.getState();if(!b||!a&&!i)return;if(!a)return n?.(e,{nodeId:b,handleId:m,handleType:t}),void y.setState({connectionClickStartHandle:{nodeId:b,type:t,handleId:m}});const c=to(e.target),u=r||l||ai,{connection:d,isValid:f}=ti({nodeId:b,id:m,type:t},s,a.nodeId,a.handleId||null,a.type,u,c);f&&k(d),o?.(e),y.setState({connectionClickStartHandle:null})}:void 0,ref:h,...p},c)}));li.displayName="Handle";var ci=e.memo(li);const ui=({data:t,isConnectable:n,targetPosition:r=So.Top,sourcePosition:o=So.Bottom})=>e.createElement(e.Fragment,null,e.createElement(ci,{type:"target",position:r,isConnectable:n}),t?.label,e.createElement(ci,{type:"source",position:o,isConnectable:n}));ui.displayName="DefaultNode";var di=e.memo(ui);const fi=({data:t,isConnectable:n,sourcePosition:r=So.Bottom})=>e.createElement(e.Fragment,null,t?.label,e.createElement(ci,{type:"source",position:r,isConnectable:n}));fi.displayName="InputNode";var pi=e.memo(fi);const hi=({data:t,isConnectable:n,targetPosition:r=So.Top})=>e.createElement(e.Fragment,null,e.createElement(ci,{type:"target",position:r,isConnectable:n}),t?.label);hi.displayName="OutputNode";var mi=e.memo(hi);const gi=()=>null;gi.displayName="GroupNode";const yi=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),bi=e=>e.id;function vi(e,t){return Z(e.selectedNodes.map(bi),t.selectedNodes.map(bi))&&Z(e.selectedEdges.map(bi),t.selectedEdges.map(bi))}const wi=e.memo((({onSelectionChange:t})=>{const n=Xr(),{selectedNodes:r,selectedEdges:o}=Hr(yi,vi);return e.useEffect((()=>{const e={nodes:r,edges:o};t?.(e),n.getState().onSelectionChange.forEach((t=>t(e)))}),[r,o,t]),null}));wi.displayName="SelectionListener";const xi=e=>!!e.onSelectionChange;function Ci({onSelectionChange:t}){const n=Hr(xi);return t||n?e.createElement(wi,{onSelectionChange:t}):null}const ki=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Ei(t,n){e.useEffect((()=>{void 0!==t&&n(t)}),[t])}function Si(t,n,r){e.useEffect((()=>{void 0!==n&&r({[t]:n})}),[n])}const Ii=({nodes:t,edges:n,defaultNodes:r,defaultEdges:o,onConnect:i,onConnectStart:a,onConnectEnd:s,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:u,nodesConnectable:d,nodesFocusable:f,edgesFocusable:p,edgesUpdatable:h,elevateNodesOnSelect:m,minZoom:g,maxZoom:y,nodeExtent:b,onNodesChange:v,onEdgesChange:w,elementsSelectable:x,connectionMode:C,snapGrid:k,snapToGrid:E,translateExtent:S,connectOnClick:I,defaultEdgeOptions:_,fitView:A,fitViewOptions:N,onNodesDelete:O,onEdgesDelete:R,onNodeDrag:M,onNodeDragStart:T,onNodeDragStop:P,onSelectionDrag:D,onSelectionDragStart:j,onSelectionDragStop:F,noPanClassName:L,nodeOrigin:z,rfId:B,autoPanOnConnect:V,autoPanOnNodeDrag:G,onError:W,connectionRadius:H,isValidConnection:X,nodeDragThreshold:$})=>{const{setNodes:Y,setEdges:U,setDefaultNodesAndEdges:J,setMinZoom:K,setMaxZoom:q,setTranslateExtent:Q,setNodeExtent:ee,reset:te}=Hr(ki,Z),ne=Xr();return e.useEffect((()=>{const e=o?.map((e=>({...e,..._})));return J(r,e),()=>{te()}}),[]),Si("defaultEdgeOptions",_,ne.setState),Si("connectionMode",C,ne.setState),Si("onConnect",i,ne.setState),Si("onConnectStart",a,ne.setState),Si("onConnectEnd",s,ne.setState),Si("onClickConnectStart",l,ne.setState),Si("onClickConnectEnd",c,ne.setState),Si("nodesDraggable",u,ne.setState),Si("nodesConnectable",d,ne.setState),Si("nodesFocusable",f,ne.setState),Si("edgesFocusable",p,ne.setState),Si("edgesUpdatable",h,ne.setState),Si("elementsSelectable",x,ne.setState),Si("elevateNodesOnSelect",m,ne.setState),Si("snapToGrid",E,ne.setState),Si("snapGrid",k,ne.setState),Si("onNodesChange",v,ne.setState),Si("onEdgesChange",w,ne.setState),Si("connectOnClick",I,ne.setState),Si("fitViewOnInit",A,ne.setState),Si("fitViewOnInitOptions",N,ne.setState),Si("onNodesDelete",O,ne.setState),Si("onEdgesDelete",R,ne.setState),Si("onNodeDrag",M,ne.setState),Si("onNodeDragStart",T,ne.setState),Si("onNodeDragStop",P,ne.setState),Si("onSelectionDrag",D,ne.setState),Si("onSelectionDragStart",j,ne.setState),Si("onSelectionDragStop",F,ne.setState),Si("noPanClassName",L,ne.setState),Si("nodeOrigin",z,ne.setState),Si("rfId",B,ne.setState),Si("autoPanOnConnect",V,ne.setState),Si("autoPanOnNodeDrag",G,ne.setState),Si("onError",W,ne.setState),Si("connectionRadius",H,ne.setState),Si("isValidConnection",X,ne.setState),Si("nodeDragThreshold",$,ne.setState),Ei(t,Y),Ei(n,U),Ei(g,K),Ei(y,q),Ei(S,Q),Ei(b,ee),null},_i={display:"none"},Ai={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ni="react-flow__node-desc",Oi="react-flow__edge-desc",Ri=e=>e.ariaLiveMessage;function Mi({rfId:t}){const n=Hr(Ri);return e.createElement("div",{id:`react-flow__aria-live-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Ai},n)}function Ti({rfId:t,disableKeyboardA11y:n}){return e.createElement(e.Fragment,null,e.createElement("div",{id:`${Ni}-${t}`,style:_i},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),e.createElement("div",{id:`${Oi}-${t}`,style:_i},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&e.createElement(Mi,{rfId:t}))}var Pi=(t=null,n={actInsideInputWithModifier:!0})=>{const[r,o]=e.useState(!1),i=e.useRef(!1),a=e.useRef(new Set([])),[s,l]=e.useMemo((()=>{if(null!==t){const e=(Array.isArray(t)?t:[t]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=e.reduce(((e,t)=>e.concat(...t)),[]);return[e,n]}return[[],[]]}),[t]);return e.useEffect((()=>{const e="undefined"!=typeof document?document:null,r=n?.target||e;if(null!==t){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!n.actInsideInputWithModifier)&&fo(e))return!1;const t=ji(e.code,l);a.current.add(e[t]),Di(s,a.current,!1)&&(e.preventDefault(),o(!0))},t=e=>{if((!i.current||i.current&&!n.actInsideInputWithModifier)&&fo(e))return!1;const t=ji(e.code,l);Di(s,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(e[t]),"Meta"===e.key&&a.current.clear(),i.current=!1},c=()=>{a.current.clear(),o(!1)};return r?.addEventListener("keydown",e),r?.addEventListener("keyup",t),window.addEventListener("blur",c),()=>{r?.removeEventListener("keydown",e),r?.removeEventListener("keyup",t),window.removeEventListener("blur",c)}}}),[t,o]),r};function Di(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function ji(e,t){return t.includes(e)?"code":"key"}function Fi(e,t,n,r){const o=e.parentNode||e.parentId;if(!o)return n;const i=t.get(o),a=$o(i,r);return Fi(i,t,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(i[lo]?.z??0)>(n.z??0)?i[lo]?.z??0:n.z??0},r)}function Li(e,t,n){e.forEach((r=>{const o=r.parentNode||r.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||n?.[r.id]){const{x:o,y:i,z:a}=Fi(r,e,{...r.position,z:r[lo]?.z??0},t);r.positionAbsolute={x:o,y:i},r[lo].z=a,n?.[r.id]&&(r[lo].isParent=!0)}}))}function zi(e,t,n,r){const o=new Map,i={},a=r?1e3:0;return e.forEach((e=>{const n=(so(e.zIndex)?e.zIndex:0)+(e.selected?a:0),r=t.get(e.id),s={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},l=e.parentNode||e.parentId;l&&(i[l]=!0);const c=r?.type&&r?.type!==e.type;Object.defineProperty(s,lo,{enumerable:!1,value:{handleBounds:c?void 0:r?.[lo]?.handleBounds,z:n}}),o.set(e.id,s)})),Li(o,n,i),o}function Bi(e,t={}){const{getNodes:n,width:r,height:o,minZoom:i,maxZoom:a,d3Zoom:s,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!c&&u;if(s&&l&&(f||!t.initial)){const e=n().filter((e=>{const n=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return t.nodes?.length?n&&t.nodes.some((t=>t.id===e.id)):n})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=Zo(e,d),{x:c,y:u,zoom:f}=Jo(n,r,o,t.minZoom??i,t.maxZoom??a,t.padding??.1),p=xr.translate(c,u).scale(f);return"number"==typeof t.duration&&t.duration>0?s.transform(Ko(l,t.duration),p):s.transform(l,p),!0}}return!1}function Vi(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[lo]:n[lo],selected:e.selected})})),new Map(t)}function Gi(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function Wi({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:i,onNodesChange:a,onEdgesChange:s,hasDefaultNodes:l,hasDefaultEdges:c}=n();e?.length&&(l&&r({nodeInternals:Vi(e,o)}),a?.(e)),t?.length&&(c&&r({edges:Gi(t,i)}),s?.(t))}const Hi=()=>{},Xi={zoomIn:Hi,zoomOut:Hi,zoomTo:Hi,getZoom:()=>1,setViewport:Hi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Hi,fitBounds:Hi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},$i=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function Zi(){const t=(()=>{const t=Xr(),{d3Zoom:n,d3Selection:r}=Hr($i,Z),o=e.useMemo((()=>r&&n?{zoomIn:e=>n.scaleBy(Ko(r,e?.duration),1.2),zoomOut:e=>n.scaleBy(Ko(r,e?.duration),1/1.2),zoomTo:(e,t)=>n.scaleTo(Ko(r,t?.duration),e),getZoom:()=>t.getState().transform[2],setViewport:(e,o)=>{const[i,a,s]=t.getState().transform,l=xr.translate(e.x??i,e.y??a).scale(e.zoom??s);n.transform(Ko(r,o?.duration),l)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},fitView:e=>Bi(t.getState,e),setCenter:(e,o,i)=>{const{width:a,height:s,maxZoom:l}=t.getState(),c=void 0!==i?.zoom?i.zoom:l,u=a/2-e*c,d=s/2-o*c,f=xr.translate(u,d).scale(c);n.transform(Ko(r,i?.duration),f)},fitBounds:(e,o)=>{const{width:i,height:a,minZoom:s,maxZoom:l}=t.getState(),{x:c,y:u,zoom:d}=Jo(e,i,a,s,l,o?.padding??.1),f=xr.translate(c,u).scale(d);n.transform(Ko(r,o?.duration),f)},project:e=>{const{transform:n,snapToGrid:r,snapGrid:o}=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"),Ho(e,n,r,o)},screenToFlowPosition:e=>{const{transform:n,snapToGrid:r,snapGrid:o,domNode:i}=t.getState();if(!i)return e;const{x:a,y:s}=i.getBoundingClientRect(),l={x:e.x-a,y:e.y-s};return Ho(l,n,r,o)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:o,y:i}=r.getBoundingClientRect(),a=Xo(e,n);return{x:a.x+o,y:a.y+i}},viewportInitialized:!0}:Xi),[n,r]);return o})(),n=Xr(),r=e.useCallback((()=>n.getState().getNodes().map((e=>({...e})))),[]),o=e.useCallback((e=>n.getState().nodeInternals.get(e)),[]),i=e.useCallback((()=>{const{edges:e=[]}=n.getState();return e.map((e=>({...e})))}),[]),a=e.useCallback((e=>{const{edges:t=[]}=n.getState();return t.find((t=>t.id===e))}),[]),s=e.useCallback((e=>{const{getNodes:t,setNodes:r,hasDefaultNodes:o,onNodesChange:i}=n.getState(),a=t(),s="function"==typeof e?e(a):e;if(o)r(s);else if(i){const e=0===s.length?a.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"})));i(e)}}),[]),l=e.useCallback((e=>{const{edges:t=[],setEdges:r,hasDefaultEdges:o,onEdgesChange:i}=n.getState(),a="function"==typeof e?e(t):e;if(o)r(a);else if(i){i(0===a.length?t.map((e=>({type:"remove",id:e.id}))):a.map((e=>({item:e,type:"reset"}))))}}),[]),c=e.useCallback((e=>{const t=Array.isArray(e)?e:[e],{getNodes:r,setNodes:o,hasDefaultNodes:i,onNodesChange:a}=n.getState();if(i){o([...r(),...t])}else if(a){const e=t.map((e=>({item:e,type:"add"})));a(e)}}),[]),u=e.useCallback((e=>{const t=Array.isArray(e)?e:[e],{edges:r=[],setEdges:o,hasDefaultEdges:i,onEdgesChange:a}=n.getState();if(i)o([...r,...t]);else if(a){a(t.map((e=>({item:e,type:"add"}))))}}),[]),d=e.useCallback((()=>{const{getNodes:e,edges:t=[],transform:r}=n.getState(),[o,i,a]=r;return{nodes:e().map((e=>({...e}))),edges:t.map((e=>({...e}))),viewport:{x:o,y:i,zoom:a}}}),[]),f=e.useCallback((({nodes:e,edges:t})=>{const{nodeInternals:r,getNodes:o,edges:i,hasDefaultNodes:a,hasDefaultEdges:s,onNodesDelete:l,onEdgesDelete:c,onNodesChange:u,onEdgesChange:d}=n.getState(),f=(e||[]).map((e=>e.id)),p=(t||[]).map((e=>e.id)),h=o().reduce(((e,t)=>{const n=t.parentNode||t.parentId,r=!f.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(f.includes(t.id)||r)&&e.push(t),e}),[]),m=i.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=m.filter((e=>p.includes(e.id)));if(h||g){const e=Uo(h,m),t=[...g,...e],o=t.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((s||a)&&(s&&n.setState({edges:i.filter((e=>!o.includes(e.id)))}),a&&(h.forEach((e=>{r.delete(e.id)})),n.setState({nodeInternals:new Map(r)}))),o.length>0&&(c?.(t),d&&d(o.map((e=>({id:e,type:"remove"}))))),h.length>0&&(l?.(h),u)){u(h.map((e=>({id:e.id,type:"remove"}))))}}}),[]),p=e.useCallback((e=>{const t=so((r=e).width)&&so(r.height)&&so(r.x)&&so(r.y);var r;const o=t?null:n.getState().nodeInternals.get(e.id);if(!t&&!o)return[null,null,t];return[t?e:io(o),o,t]}),[]),h=e.useCallback(((e,t=!0,r)=>{const[o,i,a]=p(e);return o?(r||n.getState().getNodes()).filter((e=>{if(!(a||e.id!==i.id&&e.positionAbsolute))return!1;const n=io(e),r=ao(n,o);return t&&r>0||r>=o.width*o.height})):[]}),[]),m=e.useCallback(((e,t,n=!0)=>{const[r]=p(e);if(!r)return!1;const o=ao(r,t);return n&&o>0||o>=r.width*r.height}),[]);return e.useMemo((()=>({...t,getNodes:r,getNode:o,getEdges:i,getEdge:a,setNodes:s,setEdges:l,addNodes:c,addEdges:u,toObject:d,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:m})),[t,r,o,i,a,s,l,c,u,d,f,h,m])}const Yi={actInsideInputWithModifier:!1};const Ui={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ji=e=>({x:e.x,y:e.y,zoom:e.k}),Ki=(e,t)=>e.target.closest(`.${t}`),qi=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Qi=e=>{const t=e.ctrlKey&&mo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},ea=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),ta=({onMove:t,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:o,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:s=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=xo.Free,zoomOnDoubleClick:u=!0,elementsSelectable:d,panOnDrag:f=!0,defaultViewport:p,translateExtent:h,minZoom:m,maxZoom:g,zoomActivationKeyCode:y,preventScrolling:b=!0,children:v,noWheelClassName:w,noPanClassName:x})=>{const C=e.useRef(),k=Xr(),E=e.useRef(!1),S=e.useRef(!1),I=e.useRef(null),_=e.useRef({x:0,y:0,zoom:0}),{d3Zoom:A,d3Selection:N,d3ZoomHandler:O,userSelectionActive:R}=Hr(ea,Z),M=Pi(y),T=e.useRef(0),P=e.useRef(!1),D=e.useRef();return function(t){const n=Xr();e.useEffect((()=>{let e;const r=()=>{if(!t.current)return;const e=Jr(t.current);0!==e.height&&0!==e.width||n.getState().onError?.("004",Dr()),n.setState({width:e.width||500,height:e.height||500})};return r(),window.addEventListener("resize",r),t.current&&(e=new ResizeObserver((()=>r())),e.observe(t.current)),()=>{window.removeEventListener("resize",r),e&&t.current&&e.unobserve(t.current)}}),[])}(I),e.useEffect((()=>{if(I.current){const e=I.current.getBoundingClientRect(),t=Or().scaleExtent([m,g]).translateExtent(h),n=dt(I.current).call(t),r=xr.translate(p.x,p.y).scale(Kr(p.zoom,m,g)),o=[[0,0],[e.width,e.height]],i=t.constrain()(r,o,h);t.transform(n,i),t.wheelDelta(Qi),k.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[i.x,i.y,i.k],domNode:I.current.closest(".react-flow")})}}),[]),e.useEffect((()=>{N&&A&&(!s||M||R?void 0!==O&&N.on("wheel.zoom",(function(e,t){if(!b&&"wheel"===e.type&&!e.ctrlKey||Ki(e,w))return null;e.preventDefault(),O.call(this,e,t)}),{passive:!1}):N.on("wheel.zoom",(e=>{if(Ki(e,w))return!1;e.preventDefault(),e.stopImmediatePropagation();const o=N.property("__zoom").k||1;if(e.ctrlKey&&a){const t=ft(e),n=Qi(e),r=o*Math.pow(2,n);return void A.scaleTo(N,r,t,e)}const i=1===e.deltaMode?20:1;let s=c===xo.Vertical?0:e.deltaX*i,u=c===xo.Horizontal?0:e.deltaY*i;!mo()&&e.shiftKey&&c!==xo.Vertical&&(s=e.deltaY*i,u=0),A.translateBy(N,-s/o*l,-u/o*l,{internal:!0});const d=Ji(N.property("__zoom")),{onViewportChangeStart:f,onViewportChange:p,onViewportChangeEnd:h}=k.getState();clearTimeout(D.current),P.current||(P.current=!0,n?.(e,d),f?.(d)),P.current&&(t?.(e,d),p?.(d),D.current=setTimeout((()=>{r?.(e,d),h?.(d),P.current=!1}),150))}),{passive:!1}))}),[R,s,c,N,A,O,M,a,b,w,n,t,r]),e.useEffect((()=>{A&&A.on("start",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;T.current=e.sourceEvent?.button;const{onViewportChangeStart:t}=k.getState(),r=Ji(e.transform);E.current=!0,_.current=r,"mousedown"===e.sourceEvent?.type&&k.setState({paneDragging:!0}),t?.(r),n?.(e.sourceEvent,r)}))}),[A,n]),e.useEffect((()=>{A&&(R&&!E.current?A.on("zoom",null):R||A.on("zoom",(e=>{const{onViewportChange:n}=k.getState();if(k.setState({transform:[e.transform.x,e.transform.y,e.transform.k]}),S.current=!(!o||!qi(f,T.current??0)),(t||n)&&!e.sourceEvent?.internal){const r=Ji(e.transform);n?.(r),t?.(e.sourceEvent,r)}})))}),[R,A,t,f,o]),e.useEffect((()=>{A&&A.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=k.getState();if(E.current=!1,k.setState({paneDragging:!1}),o&&qi(f,T.current??0)&&!S.current&&o(e.sourceEvent),S.current=!1,(r||t)&&(n=_.current,i=e.transform,n.x!==i.x||n.y!==i.y||n.zoom!==i.k)){const n=Ji(e.transform);_.current=n,clearTimeout(C.current),C.current=setTimeout((()=>{t?.(n),r?.(e.sourceEvent,n)}),s?150:0)}var n,i}))}),[A,s,f,r,o]),e.useEffect((()=>{A&&A.filter((e=>{const t=M||i,n=a&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(Ki(e,"react-flow__node")||Ki(e,"react-flow__edge")))return!0;if(!(f||t||s||u||a))return!1;if(R)return!1;if(!u&&"dblclick"===e.type)return!1;if(Ki(e,w)&&"wheel"===e.type)return!1;if(Ki(e,x)&&("wheel"!==e.type||s&&"wheel"===e.type&&!M))return!1;if(!a&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!s&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const r=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&r}))}),[R,A,i,a,s,u,f,d,M]),e.createElement("div",{className:"react-flow__renderer",ref:I,style:Ui},v)},na=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ra(){const{userSelectionActive:t,userSelectionRect:n}=Hr(na,Z);return t&&n?e.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function oa(e,t){const n=t.parentNode||t.parentId,r=e.find((e=>e.id===n));if(r){const e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style}||{},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function ia(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const r=e.filter((e=>e.id===n.id));if(0===r.length)return t.push(n),t;const o={...n};for(const e of r)if(e)switch(e.type){case"select":o.selected=e.selected;break;case"position":void 0!==e.position&&(o.position=e.position),void 0!==e.positionAbsolute&&(o.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(o.dragging=e.dragging),o.expandParent&&oa(t,o);break;case"dimensions":void 0!==e.dimensions&&(o.width=e.dimensions.width,o.height=e.dimensions.height),void 0!==e.updateStyle&&(o.style={...o.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(o.resizing=e.resizing),o.expandParent&&oa(t,o);break;case"remove":return t}return t.push(o),t}),n)}function aa(e,t){return ia(e,t)}function sa(e,t){return ia(e,t)}const la=(e,t)=>({id:e,type:"select",selected:t});function ca(e,t){return e.reduce(((e,n)=>{const r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(la(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(la(n.id,!1))),e}),[])}const ua=(e,t)=>n=>{n.target===t.current&&e?.(n)},da=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),fa=e.memo((({isSelecting:t,selectionMode:n=Co.Full,panOnDrag:r,onSelectionStart:o,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:s,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:u,onPaneMouseLeave:d,children:f})=>{const p=e.useRef(null),h=Xr(),m=e.useRef(0),g=e.useRef(0),y=e.useRef(),{userSelectionActive:b,elementsSelectable:v,dragging:w}=Hr(da,Z),x=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,g.current=0},C=e=>{a?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},k=l?e=>l(e):void 0,E=v&&(t||b);return e.createElement("div",{className:V(["react-flow__pane",{dragging:w,selection:t}]),onClick:E?void 0:ua(C,p),onContextMenu:ua((e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():s?.(e)}),p),onWheel:ua(k,p),onMouseEnter:E?void 0:c,onMouseDown:E?e=>{const{resetSelectedElements:n,domNode:r}=h.getState();if(y.current=r?.getBoundingClientRect(),!v||!t||0!==e.button||e.target!==p.current||!y.current)return;const{x:i,y:a}=ho(e,y.current);n(),h.setState({userSelectionRect:{width:0,height:0,startX:i,startY:a,x:i,y:a}}),o?.(e)}:void 0,onMouseMove:E?e=>{const{userSelectionRect:r,nodeInternals:o,edges:i,transform:a,onNodesChange:s,onEdgesChange:l,nodeOrigin:c,getNodes:u}=h.getState();if(!t||!y.current||!r)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const d=ho(e,y.current),f=r.startX??0,p=r.startY??0,b={...r,x:d.x<f?d.x:f,y:d.y<p?d.y:p,width:Math.abs(d.x-f),height:Math.abs(d.y-p)},v=u(),w=Yo(o,b,a,n===Co.Partial,!0,c),x=Uo(w,i).map((e=>e.id)),C=w.map((e=>e.id));if(m.current!==C.length){m.current=C.length;const e=ca(v,C);e.length&&s?.(e)}if(g.current!==x.length){g.current=x.length;const e=ca(i,x);e.length&&l?.(e)}h.setState({userSelectionRect:b})}:u,onMouseUp:E?e=>{if(0!==e.button)return;const{userSelectionRect:t}=h.getState();!b&&t&&e.target===p.current&&C?.(e),h.setState({nodesSelectionActive:m.current>0}),x(),i?.(e)}:void 0,onMouseLeave:E?e=>{b&&(h.setState({nodesSelectionActive:m.current>0}),i?.(e)),x()}:d,ref:p,style:Ui},f,e.createElement(ra,null))}));function pa(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return!!r&&(!!r.selected||pa(r,t))}function ha(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function ma(e,t,n,r){return Array.from(e.values()).filter((n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!pa(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent})))}function ga(e,t,n,r,o=[0,0],i){const a=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||r);let s=a;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:r,y:i}=$o(t,o).positionAbsolute;s=[[e.extent[0][0]+r,e.extent[0][1]+i],[e.extent[1][0]+r,e.extent[1][1]+i]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:r,y:i}=$o(t,o).positionAbsolute;s=t&&so(r)&&so(i)&&so(t.width)&&so(t.height)?[[r+e.width*o[0],i+e.height*o[1]],[r+t.width-e.width+e.width*o[0],i+t.height-e.height+e.height*o[1]]]:s}else i?.("005",jr()),s=a;let c={x:0,y:0};if(l){const e=n.get(l);c=$o(e,o).positionAbsolute}const u=s&&"parent"!==s?qr(t,s):t;return{position:{x:u.x-c.x,y:u.y-c.y},positionAbsolute:u}}function ya({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?r.find((t=>t.id===e)):r[0],r]}fa.displayName="Pane";const ba=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const i=Array.from(o),a=t.getBoundingClientRect(),s=a.width*r[0],l=a.height*r[1];return i.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-a.left-s)/n,y:(t.top-a.top-l)/n,...Jr(e)}}))};function va(e,t,n){return void 0===n?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function wa({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeInternals:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&a)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>r?.current?.blur()))):o([e])):l?.("012",Gr(e))}function xa(e){return(t,n,r)=>e?.(t,r)}function Ca({nodeRef:t,disabled:n=!1,noDragClassName:r,handleSelector:o,nodeId:i,isSelectable:a,selectNodesOnDrag:s}){const l=Xr(),[c,u]=e.useState(!1),d=e.useRef([]),f=e.useRef({x:null,y:null}),p=e.useRef(0),h=e.useRef(null),m=e.useRef({x:0,y:0}),g=e.useRef(null),y=e.useRef(!1),b=e.useRef(!1),v=e.useRef(!1),w=function(){const t=Xr(),n=e.useCallback((({sourceEvent:e})=>{const{transform:n,snapGrid:r,snapToGrid:o}=t.getState(),i=e.touches?e.touches[0].clientX:e.clientX,a=e.touches?e.touches[0].clientY:e.clientY,s={x:(i-n[0])/n[2],y:(a-n[1])/n[2]};return{xSnapped:o?r[0]*Math.round(s.x/r[0]):s.x,ySnapped:o?r[1]*Math.round(s.y/r[1]):s.y,...s}}),[]);return n}();return e.useEffect((()=>{if(t?.current){const e=dt(t.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:r,onSelectionDrag:o,updateNodePositions:a,nodeExtent:s,snapGrid:c,snapToGrid:p,nodeOrigin:h,onError:m}=l.getState();f.current={x:e,y:t};let y=!1,b={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&s){const e=Zo(d.current,h);b=ro(e)}if(d.current=d.current.map((r=>{const o={x:e-r.distance.x,y:t-r.distance.y};p&&(o.x=c[0]*Math.round(o.x/c[0]),o.y=c[1]*Math.round(o.y/c[1]));const i=[[s[0][0],s[0][1]],[s[1][0],s[1][1]]];d.current.length>1&&s&&!r.extent&&(i[0][0]=r.positionAbsolute.x-b.x+s[0][0],i[1][0]=r.positionAbsolute.x+(r.width??0)-b.x2+s[1][0],i[0][1]=r.positionAbsolute.y-b.y+s[0][1],i[1][1]=r.positionAbsolute.y+(r.height??0)-b.y2+s[1][1]);const a=ga(r,o,n,i,h,m);return y=y||r.position.x!==a.position.x||r.position.y!==a.position.y,r.position=a.position,r.positionAbsolute=a.positionAbsolute,r})),!y)return;a(d.current,!0,!0),u(!0);const v=i?r:xa(o);if(v&&g.current){const[e,t]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});v(g.current,e,t)}},x=()=>{if(!h.current)return;const[e,t]=eo(m.current,h.current);if(0!==e||0!==t){const{transform:n,panBy:r}=l.getState();f.current.x=(f.current.x??0)-e/n[2],f.current.y=(f.current.y??0)-t/n[2],r({x:e,y:t})&&c(f.current)}p.current=requestAnimationFrame(x)},C=e=>{const{nodeInternals:n,multiSelectionActive:r,nodesDraggable:o,unselectNodesAndEdges:c,onNodeDragStart:u,onSelectionDragStart:p}=l.getState();b.current=!0;const h=i?u:xa(p);s&&a||r||!i||n.get(i)?.selected||c(),i&&a&&s&&wa({id:i,store:l,nodeRef:t});const m=w(e);if(f.current=m,d.current=ma(n,o,m,i),h&&d.current){const[t,r]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});h(e.sourceEvent,t,r)}};if(!n){const n=function(){var e,t,n,r,o=xt,i=Ct,a=kt,s=Et,l={},c=U("start","drag","end"),u=0,d=0;function f(e){e.on("mousedown.drag",p).filter(s).on("touchstart.drag",g).on("touchmove.drag",y,pt).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(a,s){if(!r&&o.call(this,a,s)){var l=v(this,i.call(this,a,s),a,s,"mouse");l&&(dt(a.view).on("mousemove.drag",h,ht).on("mouseup.drag",m,ht),yt(a.view),mt(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function h(r){if(gt(r),!n){var o=r.clientX-e,i=r.clientY-t;n=o*o+i*i>d}l.mouse("drag",r)}function m(e){dt(e.view).on("mousemove.drag mouseup.drag",null),bt(e.view,n),gt(e),l.mouse("end",e)}function g(e,t){if(o.call(this,e,t)){var n,r,a=e.changedTouches,s=i.call(this,e,t),l=a.length;for(n=0;n<l;++n)(r=v(this,s,e,t,a[n].identifier,a[n]))&&(mt(e),r("start",e,a[n]))}}function y(e){var t,n,r=e.changedTouches,o=r.length;for(t=0;t<o;++t)(n=l[r[t].identifier])&&(gt(e),n("drag",e,r[t]))}function b(e){var t,n,o=e.changedTouches,i=o.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null}),500),t=0;t<i;++t)(n=l[o[t].identifier])&&(mt(e),n("end",e,o[t]))}function v(e,t,n,r,o,i){var s,d,p,h=c.copy(),m=ft(i||n,t);if(null!=(p=a.call(e,new wt("beforestart",{sourceEvent:n,target:f,identifier:o,active:u,x:m[0],y:m[1],dx:0,dy:0,dispatch:h}),r)))return s=p.x-m[0]||0,d=p.y-m[1]||0,function n(i,a,c){var g,y=m;switch(i){case"start":l[o]=n,g=u++;break;case"end":delete l[o],--u;case"drag":m=ft(c||a,t),g=u}h.call(i,e,new wt(i,{sourceEvent:a,subject:p,target:f,identifier:o,active:g,x:m[0]+s,y:m[1]+d,dx:m[0]-y[0],dy:m[1]-y[1],dispatch:h}),r)}}return f.filter=function(e){return arguments.length?(o="function"==typeof e?e:vt(!!e),f):o},f.container=function(e){return arguments.length?(i="function"==typeof e?e:vt(e),f):i},f.subject=function(e){return arguments.length?(a="function"==typeof e?e:vt(e),f):a},f.touchable=function(e){return arguments.length?(s="function"==typeof e?e:vt(!!e),f):s},f.on=function(){var e=c.on.apply(c,arguments);return e===c?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&C(e),v.current=!1;const r=w(e);f.current=r,h.current=t?.getBoundingClientRect()||null,m.current=ho(e.sourceEvent,h.current)})).on("drag",(e=>{const t=w(e),{autoPanOnNodeDrag:n,nodeDragThreshold:r}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!y.current&&b.current&&n&&(y.current=!0,x()),!b.current){const n=t.xSnapped-(f?.current?.x??0),o=t.ySnapped-(f?.current?.y??0);Math.sqrt(n*n+o*o)>r&&C(e)}(f.current.x!==t.xSnapped||f.current.y!==t.ySnapped)&&d.current&&b.current&&(g.current=e.sourceEvent,m.current=ho(e.sourceEvent,h.current),c(t))}})).on("end",(e=>{if(b.current&&!v.current&&(u(!1),y.current=!1,b.current=!1,cancelAnimationFrame(p.current),d.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:o}=l.getState(),a=i?r:xa(o);if(t(d.current,!1,!1),a){const[t,r]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});a(e.sourceEvent,t,r)}}})).filter((e=>{const n=e.target;return!e.button&&(!r||!ha(n,`.${r}`,t))&&(!o||ha(n,o,t))}));return e.call(n),()=>{e.on(".drag",null)}}e.on(".drag",null)}}),[t,n,r,o,a,l,i,s,w]),c}function ka(){const t=Xr(),n=e.useCallback((e=>{const{nodeInternals:n,nodeExtent:r,updateNodePositions:o,getNodes:i,snapToGrid:a,snapGrid:s,onError:l,nodesDraggable:c}=t.getState(),u=i().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),d=a?s[0]:5,f=a?s[1]:5,p=e.isShiftPressed?4:1,h=e.x*d*p,m=e.y*f*p,g=u.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+h,y:e.positionAbsolute.y+m};a&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));const{positionAbsolute:o,position:i}=ga(e,t,n,r,void 0,l);e.position=i,e.positionAbsolute=o}return e}));o(g,!0,!1)}),[]);return n}const Ea={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Sa=t=>{const n=({id:n,type:r,data:o,xPos:i,yPos:a,xPosOrigin:s,yPosOrigin:l,selected:c,onClick:u,onMouseEnter:d,onMouseMove:f,onMouseLeave:p,onContextMenu:h,onDoubleClick:m,style:g,className:y,isDraggable:b,isSelectable:v,isConnectable:w,isFocusable:x,selectNodesOnDrag:C,sourcePosition:k,targetPosition:E,hidden:S,resizeObserver:I,dragHandle:_,zIndex:A,isParent:N,noDragClassName:O,noPanClassName:R,initialized:M,disableKeyboardA11y:T,ariaLabel:P,rfId:D,hasHandleBounds:j})=>{const F=Xr(),L=e.useRef(null),z=e.useRef(null),B=e.useRef(k),G=e.useRef(E),W=e.useRef(r),H=v||b||u||d||f||p,X=ka(),$=va(n,F.getState,d),Z=va(n,F.getState,f),Y=va(n,F.getState,p),U=va(n,F.getState,h),J=va(n,F.getState,m);e.useEffect((()=>()=>{z.current&&(I?.unobserve(z.current),z.current=null)}),[]),e.useEffect((()=>{if(L.current&&!S){const e=L.current;M&&j&&z.current===e||(z.current&&I?.unobserve(z.current),I?.observe(e),z.current=e)}}),[S,M,j]),e.useEffect((()=>{const e=W.current!==r,t=B.current!==k,o=G.current!==E;L.current&&(e||t||o)&&(e&&(W.current=r),t&&(B.current=k),o&&(G.current=E),F.getState().updateNodeDimensions([{id:n,nodeElement:L.current,forceUpdate:!0}]))}),[n,r,k,E]);const K=Ca({nodeRef:L,disabled:S||!b,noDragClassName:O,handleSelector:_,nodeId:n,isSelectable:v,selectNodesOnDrag:C});return S?null:e.createElement("div",{className:V(["react-flow__node",`react-flow__node-${r}`,{[R]:b},y,{selected:c,selectable:v,parent:N,dragging:K}]),ref:L,style:{zIndex:A,transform:`translate(${s}px,${l}px)`,pointerEvents:H?"all":"none",visibility:M?"visible":"hidden",...g},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:$,onMouseMove:Z,onMouseLeave:Y,onContextMenu:U,onClick:e=>{const{nodeDragThreshold:t}=F.getState();if(v&&(!C||!b||t>0)&&wa({id:n,store:F,nodeRef:L}),u){const t=F.getState().nodeInternals.get(n);t&&u(e,{...t})}},onDoubleClick:J,onKeyDown:x?e=>{if(!fo(e)&&!T)if(co.includes(e.key)&&v){const t="Escape"===e.key;wa({id:n,store:F,unselect:t,nodeRef:L})}else b&&c&&Object.prototype.hasOwnProperty.call(Ea,e.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~a}`}),X({x:Ea[e.key].x,y:Ea[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:x?0:void 0,role:x?"button":void 0,"aria-describedby":T?void 0:`${Ni}-${D}`,"aria-label":P},e.createElement(Vo,{value:n},e.createElement(t,{id:n,data:o,type:r,xPos:i,yPos:a,selected:c,isConnectable:w,sourcePosition:k,targetPosition:E,dragging:K,dragHandle:_,zIndex:A})))};return n.displayName="NodeWrapper",e.memo(n)};const Ia=e=>{const t=e.getNodes().filter((e=>e.selected));return{...Zo(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var _a=e.memo((function({onSelectionContextMenu:t,noPanClassName:n,disableKeyboardA11y:r}){const o=Xr(),{width:i,height:a,x:s,y:l,transformString:c,userSelectionActive:u}=Hr(Ia,Z),d=ka(),f=e.useRef(null);if(e.useEffect((()=>{r||f.current?.focus({preventScroll:!0})}),[r]),Ca({nodeRef:f}),u||!i||!a)return null;const p=t?e=>{const n=o.getState().getNodes().filter((e=>e.selected));t(e,n)}:void 0;return e.createElement("div",{className:V(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c}},e.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:e=>{Object.prototype.hasOwnProperty.call(Ea,e.key)&&d({x:Ea[e.key].x,y:Ea[e.key].y,isShiftPressed:e.shiftKey})},style:{width:i,height:a,top:l,left:s}}))}));const Aa=e=>e.nodesSelectionActive,Na=({children:t,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:s,deleteKeyCode:l,onMove:c,onMoveStart:u,onMoveEnd:d,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:y,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:x,zoomOnPinch:C,panOnScroll:k,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:_,defaultViewport:A,translateExtent:N,minZoom:O,maxZoom:R,preventScrolling:M,onSelectionContextMenu:T,noWheelClassName:P,noPanClassName:D,disableKeyboardA11y:j})=>{const F=Hr(Aa),L=Pi(f),z=Pi(b),B=z||_,V=z||k,G=L||p&&!0!==B;return(({deleteKeyCode:t,multiSelectionKeyCode:n})=>{const r=Xr(),{deleteElements:o}=Zi(),i=Pi(t,Yi),a=Pi(n);e.useEffect((()=>{if(i){const{edges:e,getNodes:t}=r.getState(),n=t().filter((e=>e.selected)),i=e.filter((e=>e.selected));o({nodes:n,edges:i}),r.setState({nodesSelectionActive:!1})}}),[i]),e.useEffect((()=>{r.setState({multiSelectionActive:a})}),[a])})({deleteKeyCode:l,multiSelectionKeyCode:y}),e.createElement(ta,{onMove:c,onMoveStart:u,onMoveEnd:d,onPaneContextMenu:a,elementsSelectable:w,zoomOnScroll:x,zoomOnPinch:C,panOnScroll:V,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:!L&&B,defaultViewport:A,translateExtent:N,minZoom:O,maxZoom:R,zoomActivationKeyCode:v,preventScrolling:M,noWheelClassName:P,noPanClassName:D},e.createElement(fa,{onSelectionStart:m,onSelectionEnd:g,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:s,panOnDrag:B,isSelecting:!!G,selectionMode:h},t,F&&e.createElement(_a,{onSelectionContextMenu:T,noPanClassName:D,disableKeyboardA11y:j})))};Na.displayName="FlowRenderer";var Oa=e.memo(Na);function Ra(e){return{...{input:Sa(e.input||pi),default:Sa(e.default||di),output:Sa(e.output||mi),group:Sa(e.group||gi)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=Sa(e[n]||di),t)),{})}}const Ma=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Ta=t=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:o,elementsSelectable:i,updateNodeDimensions:a,onError:s}=Hr(Ma,Z),l=function(t){const n=Hr(e.useCallback((e=>t?Yo(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[t]));return n}(t.onlyRenderVisibleElements),c=e.useRef(),u=e.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));a(t)}));return c.current=e,e}),[]);return e.useEffect((()=>()=>{c?.current?.disconnect()}),[]),e.createElement("div",{className:"react-flow__nodes",style:Ui},l.map((a=>{let l=a.type||"default";t.nodeTypes[l]||(s?.("003",Pr(l)),l="default");const c=t.nodeTypes[l]||t.nodeTypes.default,d=!!(a.draggable||n&&void 0===a.draggable),f=!!(a.selectable||i&&void 0===a.selectable),p=!!(a.connectable||r&&void 0===a.connectable),h=!!(a.focusable||o&&void 0===a.focusable),m=t.nodeExtent?qr(a.positionAbsolute,t.nodeExtent):a.positionAbsolute,g=m?.x??0,y=m?.y??0,b=(({x:e,y:t,width:n,height:r,origin:o})=>n&&r?o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]}:{x:e,y:t})({x:g,y:y,width:a.width??0,height:a.height??0,origin:t.nodeOrigin});return e.createElement(c,{key:a.id,id:a.id,className:a.className,style:a.style,type:l,data:a.data,sourcePosition:a.sourcePosition||So.Bottom,targetPosition:a.targetPosition||So.Top,hidden:a.hidden,xPos:g,yPos:y,xPosOrigin:b.x,yPosOrigin:b.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!a.selected,isDraggable:d,isSelectable:f,isConnectable:p,isFocusable:h,resizeObserver:u,dragHandle:a.dragHandle,zIndex:a[lo]?.z??0,isParent:!!a[lo]?.isParent,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!a.width&&!!a.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:a.ariaLabel,hasHandleBounds:!!a[lo]?.handleBounds})})))};Ta.displayName="NodeRenderer";var Pa=e.memo(Ta);const Da=(e,t,n)=>n===So.Left?e-t:n===So.Right?e+t:e,ja=(e,t,n)=>n===So.Top?e-t:n===So.Bottom?e+t:e,Fa="react-flow__edgeupdater",La=({position:t,centerX:n,centerY:r,radius:o=10,onMouseDown:i,onMouseEnter:a,onMouseOut:s,type:l})=>e.createElement("circle",{onMouseDown:i,onMouseEnter:a,onMouseOut:s,className:V([Fa,`${Fa}-${l}`]),cx:Da(n,o,t),cy:ja(r,o,t),r:o,stroke:"transparent",fill:"transparent"}),za=()=>!0;var Ba=t=>{const n=({id:n,className:r,type:o,data:i,onClick:a,onEdgeDoubleClick:s,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,source:y,target:b,sourceX:v,sourceY:w,targetX:x,targetY:C,sourcePosition:k,targetPosition:E,elementsSelectable:S,hidden:I,sourceHandleId:_,targetHandleId:A,onContextMenu:N,onMouseEnter:O,onMouseMove:R,onMouseLeave:M,reconnectRadius:T,onReconnect:P,onReconnectStart:D,onReconnectEnd:j,markerEnd:F,markerStart:L,rfId:z,ariaLabel:B,isFocusable:G,isReconnectable:W,pathOptions:H,interactionWidth:X,disableKeyboardA11y:$})=>{const Z=e.useRef(null),[Y,U]=e.useState(!1),[J,K]=e.useState(!1),q=Xr(),Q=e.useMemo((()=>`url('#${Wo(L,z)}')`),[L,z]),ee=e.useMemo((()=>`url('#${Wo(F,z)}')`),[F,z]);if(I)return null;const te=yo(n,q.getState,s),ne=yo(n,q.getState,N),re=yo(n,q.getState,O),oe=yo(n,q.getState,R),ie=yo(n,q.getState,M),ae=(e,t)=>{if(0!==e.button)return;const{edges:r,isValidConnection:o}=q.getState(),i=t?b:y,a=(t?A:_)||null,s=t?"target":"source",l=o||za,c=t,u=r.find((e=>e.id===n));K(!0),D?.(e,u,s);ii({event:e,handleId:a,nodeId:i,onConnect:e=>P?.(u,e),isTarget:c,getState:q.getState,setState:q.setState,isValidConnection:l,edgeUpdaterType:s,onReconnectEnd:e=>{K(!1),j?.(e,u,s)}})},se=()=>U(!0),le=()=>U(!1),ce=!S&&!a;return e.createElement("g",{className:V(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{const{edges:t,addSelectedEdges:r,unselectNodesAndEdges:o,multiSelectionActive:i}=q.getState(),s=t.find((e=>e.id===n));s&&(S&&(q.setState({nodesSelectionActive:!1}),s.selected&&i?(o({nodes:[],edges:[s]}),Z.current?.blur()):r([n])),a&&a(e,s))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:re,onMouseMove:oe,onMouseLeave:ie,onKeyDown:G?e=>{if(!$&&co.includes(e.key)&&S){const{unselectNodesAndEdges:t,addSelectedEdges:r,edges:o}=q.getState();"Escape"===e.key?(Z.current?.blur(),t({edges:[o.find((e=>e.id===n))]})):r([n])}}:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":null===B?void 0:B||`Edge from ${y} to ${b}`,"aria-describedby":G?`${Oi}-${z}`:void 0,ref:Z},!J&&e.createElement(t,{id:n,source:y,target:b,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,data:i,style:g,sourceX:v,sourceY:w,targetX:x,targetY:C,sourcePosition:k,targetPosition:E,sourceHandleId:_,targetHandleId:A,markerStart:Q,markerEnd:ee,pathOptions:H,interactionWidth:X}),W&&e.createElement(e.Fragment,null,("source"===W||!0===W)&&e.createElement(La,{position:k,centerX:v,centerY:w,radius:T,onMouseDown:e=>ae(e,!0),onMouseEnter:se,onMouseOut:le,type:"source"}),("target"===W||!0===W)&&e.createElement(La,{position:E,centerX:x,centerY:C,radius:T,onMouseDown:e=>ae(e,!1),onMouseEnter:se,onMouseOut:le,type:"target"})))};return n.displayName="EdgeWrapper",e.memo(n)};function Va(e){return{...{default:Ba(e.default||zo),straight:Ba(e.bezier||Do),step:Ba(e.step||Po),smoothstep:Ba(e.step||To),simplebezier:Ba(e.simplebezier||Ao)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=Ba(e[n]||zo),t)),{})}}function Ga(e,t,n=null){const r=(n?.x||0)+t.x,o=(n?.y||0)+t.y,i=n?.width||t.width,a=n?.height||t.height;switch(e){case So.Top:return{x:r+i/2,y:o};case So.Right:return{x:r+i,y:o+a/2};case So.Bottom:return{x:r+i/2,y:o+a};case So.Left:return{x:r,y:o+a/2}}}function Wa(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function Ha(e){const t=e?.[lo]?.handleBounds||null,n=t&&e?.width&&e?.height&&void 0!==e?.positionAbsolute?.x&&void 0!==e?.positionAbsolute?.y;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const Xa=[{level:0,isMaxLevel:!0,edges:[]}];function $a(t,n,r){const o=Hr(e.useCallback((e=>t?e.edges.filter((t=>{const r=n.get(t.source),o=n.get(t.target);return r?.width&&r?.height&&o?.width&&o?.height&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:i,width:a,height:s,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+i)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=ro({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:a/l[2],height:s/l[2]}),d=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),f=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(d*f)>0}({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:o.width,targetHeight:o.height,width:e.width,height:e.height,transform:e.transform})})):e.edges),[t,n]));return function(e,t,n=!1){let r=-1;const o=e.reduce(((e,o)=>{const i=so(o.zIndex);let a=i?o.zIndex:0;if(n){const e=t.get(o.target),n=t.get(o.source),r=o.selected||e?.selected||n?.selected,s=Math.max(n?.[lo]?.z||0,e?.[lo]?.z||0,1e3);a=(i?o.zIndex:0)+(r?s:0)}return e[a]?e[a].push(o):e[a]=[o],r=a>r?a:r,e}),{}),i=Object.entries(o).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===r}}));return 0===i.length?Xa:i}(o,n,r)}const Za={[Eo.Arrow]:({color:t="none",strokeWidth:n=1})=>e.createElement("polyline",{style:{stroke:t,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[Eo.ArrowClosed]:({color:t="none",strokeWidth:n=1})=>e.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Ya=({id:t,type:n,color:r,width:o=12.5,height:i=12.5,markerUnits:a="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const c=function(t){const n=Xr();return e.useMemo((()=>Object.prototype.hasOwnProperty.call(Za,t)?Za[t]:(n.getState().onError?.("009",Lr(t)),null)),[t])}(n);return c?e.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${o}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0"},e.createElement(c,{color:r,strokeWidth:s})):null},Ua=({defaultColor:t,rfId:n})=>{const r=Hr(e.useCallback((({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce(((n,o)=>([o.markerStart,o.markerEnd].forEach((o=>{if(o&&"object"==typeof o){const i=Wo(o,t);r.includes(i)||(n.push({id:i,color:o.color||e,...o}),r.push(i))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:t,rfId:n}),[t,n]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return e.createElement("defs",null,r.map((t=>e.createElement(Ya,{id:t.id,key:t.id,type:t.type,color:t.color,width:t.width,height:t.height,markerUnits:t.markerUnits,strokeWidth:t.strokeWidth,orient:t.orient}))))};Ua.displayName="MarkerDefinitions";var Ja=e.memo(Ua);const Ka=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),qa=({defaultMarkerColor:t,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:o,edgeTypes:i,noPanClassName:a,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,children:y,disableKeyboardA11y:b})=>{const{edgesFocusable:v,edgesUpdatable:w,elementsSelectable:x,width:C,height:k,connectionMode:E,nodeInternals:S,onError:I}=Hr(Ka,Z),_=$a(n,S,r);return C?e.createElement(e.Fragment,null,_.map((({level:n,edges:r,isMaxLevel:y})=>e.createElement("svg",{key:n,style:{zIndex:n},width:C,height:k,className:"react-flow__edges react-flow__container"},y&&e.createElement(Ja,{defaultColor:t,rfId:o}),e.createElement("g",null,r.map((t=>{const[n,r,y]=Ha(S.get(t.source)),[C,k,_]=Ha(S.get(t.target));if(!y||!_)return null;let A=t.type||"default";i[A]||(I?.("011",Vr(A)),A="default");const N=i[A]||i.default,O=E===wo.Strict?k.target:(k.target??[]).concat(k.source??[]),R=Wa(r.source,t.sourceHandle),M=Wa(O,t.targetHandle),T=R?.position||So.Bottom,P=M?.position||So.Top,D=!!(t.focusable||v&&void 0===t.focusable),j=t.reconnectable||t.updatable,F=void 0!==p&&(j||w&&void 0===j);if(!R||!M)return I?.("008",zr(R,t)),null;const{sourceX:L,sourceY:z,targetX:B,targetY:G}=((e,t,n,r,o,i)=>{const a=Ga(n,e,t),s=Ga(i,r,o);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(n,R,T,C,M,P);return e.createElement(N,{key:t.id,id:t.id,className:V([t.className,a]),type:A,data:t.data,selected:!!t.selected,animated:!!t.animated,hidden:!!t.hidden,label:t.label,labelStyle:t.labelStyle,labelShowBg:t.labelShowBg,labelBgStyle:t.labelBgStyle,labelBgPadding:t.labelBgPadding,labelBgBorderRadius:t.labelBgBorderRadius,style:t.style,source:t.source,target:t.target,sourceHandleId:t.sourceHandle,targetHandleId:t.targetHandle,markerEnd:t.markerEnd,markerStart:t.markerStart,sourceX:L,sourceY:z,targetX:B,targetY:G,sourcePosition:T,targetPosition:P,elementsSelectable:x,onContextMenu:s,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,rfId:o,ariaLabel:t.ariaLabel,isFocusable:D,isReconnectable:F,pathOptions:"pathOptions"in t?t.pathOptions:void 0,interactionWidth:t.interactionWidth,disableKeyboardA11y:b})})))))),y):null};qa.displayName="EdgeRenderer";var Qa=e.memo(qa);const es=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function ts({children:t}){const n=Hr(es);return e.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},t)}const ns={[So.Left]:So.Right,[So.Right]:So.Left,[So.Top]:So.Bottom,[So.Bottom]:So.Top},rs=({nodeId:t,handleType:n,style:r,type:o=ko.Bezier,CustomComponent:i,connectionStatus:a})=>{const{fromNode:s,handleId:l,toX:c,toY:u,connectionMode:d}=Hr(e.useCallback((e=>({fromNode:e.nodeInternals.get(t),handleId:e.connectionHandleId,toX:(e.connectionPosition.x-e.transform[0])/e.transform[2],toY:(e.connectionPosition.y-e.transform[1])/e.transform[2],connectionMode:e.connectionMode})),[t]),Z),f=s?.[lo]?.handleBounds;let p=f?.[n];if(d===wo.Loose&&(p=p||f?.["source"===n?"target":"source"]),!s||!p)return null;const h=l?p.find((e=>e.id===l)):p[0],m=h?h.x+h.width/2:(s.width??0)/2,g=h?h.y+h.height/2:s.height??0,y=(s.positionAbsolute?.x??0)+m,b=(s.positionAbsolute?.y??0)+g,v=h?.position,w=v?ns[v]:null;if(!v||!w)return null;if(i)return e.createElement(i,{connectionLineType:o,connectionLineStyle:r,fromNode:s,fromHandle:h,fromX:y,fromY:b,toX:c,toY:u,fromPosition:v,toPosition:w,connectionStatus:a});let x="";const C={sourceX:y,sourceY:b,sourcePosition:v,targetX:c,targetY:u,targetPosition:w};return o===ko.Bezier?[x]=Lo(C):o===ko.Step?[x]=Mo({...C,borderRadius:0}):o===ko.SmoothStep?[x]=Mo(C):o===ko.SimpleBezier?[x]=_o(C):x=`M${y},${b} ${c},${u}`,e.createElement("path",{d:x,fill:"none",className:"react-flow__connection-path",style:r})};rs.displayName="ConnectionLine";const os=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function is({containerStyle:t,style:n,type:r,component:o}){const{nodeId:i,handleType:a,nodesConnectable:s,width:l,height:c,connectionStatus:u}=Hr(os,Z);return!!(i&&a&&l&&s)?e.createElement("svg",{style:t,width:l,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},e.createElement("g",{className:V(["react-flow__connection",u])},e.createElement(rs,{nodeId:i,handleType:a,style:n,type:r,CustomComponent:o,connectionStatus:u}))):null}function as(t,n){const r=e.useRef(null),o=Xr();return e.useMemo((()=>{if("development"===process.env.NODE_ENV){const e=Object.keys(t);Z(r.current,e)&&o.getState().onError?.("002",Tr()),r.current=e}return n(t)}),[t])}const ss=({nodeTypes:t,edgeTypes:n,onMove:r,onMoveStart:o,onMoveEnd:i,onInit:a,onNodeClick:s,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:u,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:y,connectionLineType:b,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:x,selectionKeyCode:C,selectionOnDrag:k,selectionMode:E,multiSelectionKeyCode:S,panActivationKeyCode:I,zoomActivationKeyCode:_,deleteKeyCode:A,onlyRenderVisibleElements:N,elementsSelectable:O,selectNodesOnDrag:R,defaultViewport:M,translateExtent:T,minZoom:P,maxZoom:D,preventScrolling:j,defaultMarkerColor:F,zoomOnScroll:L,zoomOnPinch:z,panOnScroll:B,panOnScrollSpeed:V,panOnScrollMode:G,zoomOnDoubleClick:W,panOnDrag:H,onPaneClick:X,onPaneMouseEnter:$,onPaneMouseMove:Z,onPaneMouseLeave:Y,onPaneScroll:U,onPaneContextMenu:J,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:Q,onEdgeMouseLeave:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:re,reconnectRadius:oe,noDragClassName:ie,noWheelClassName:ae,noPanClassName:se,elevateEdgesOnSelect:le,disableKeyboardA11y:ce,nodeOrigin:ue,nodeExtent:de,rfId:fe})=>{const pe=as(t,Ra),he=as(n,Va);return function(t){const n=Zi(),r=e.useRef(!1);e.useEffect((()=>{!r.current&&n.viewportInitialized&&t&&(setTimeout((()=>t(n)),1),r.current=!0)}),[t,n.viewportInitialized])}(a),e.createElement(Oa,{onPaneClick:X,onPaneMouseEnter:$,onPaneMouseMove:Z,onPaneMouseLeave:Y,onPaneContextMenu:J,onPaneScroll:U,deleteKeyCode:A,selectionKeyCode:C,selectionOnDrag:k,selectionMode:E,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:S,panActivationKeyCode:I,zoomActivationKeyCode:_,elementsSelectable:O,onMove:r,onMoveStart:o,onMoveEnd:i,zoomOnScroll:L,zoomOnPinch:z,zoomOnDoubleClick:W,panOnScroll:B,panOnScrollSpeed:V,panOnScrollMode:G,panOnDrag:H,defaultViewport:M,translateExtent:T,minZoom:P,maxZoom:D,onSelectionContextMenu:m,preventScrolling:j,noDragClassName:ie,noWheelClassName:ae,noPanClassName:se,disableKeyboardA11y:ce},e.createElement(ts,null,e.createElement(Qa,{edgeTypes:he,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:Q,onEdgeMouseLeave:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:re,reconnectRadius:oe,defaultMarkerColor:F,noPanClassName:se,elevateEdgesOnSelect:!!le,disableKeyboardA11y:ce,rfId:fe},e.createElement(is,{style:v,type:b,component:w,containerStyle:x})),e.createElement("div",{className:"react-flow__edgelabel-renderer"}),e.createElement(Pa,{nodeTypes:pe,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,selectNodesOnDrag:R,onlyRenderVisibleElements:N,noPanClassName:se,noDragClassName:ie,disableKeyboardA11y:ce,nodeOrigin:ue,nodeExtent:de,rfId:fe})))};ss.displayName="GraphView";var ls=e.memo(ss);const cs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],us={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:cs,nodeExtent:cs,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:wo.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:uo,isValidConnection:void 0},ds=()=>((e,t)=>e?$(e,t):$)(((e,t)=>({...us,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:i}=t();e({nodeInternals:zi(n,r,o,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map((e=>({...r,...e})))})},setDefaultNodesAndEdges:(n,r)=>{const o=void 0!==n,i=void 0!==r,a=o?zi(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:i?r:[],hasDefaultNodes:o,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:i,fitViewOnInitDone:a,fitViewOnInitOptions:s,domNode:l,nodeOrigin:c}=t(),u=l?.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=n.reduce(((e,t)=>{const n=o.get(t.id);if(n?.hidden)o.set(n.id,{...n,[lo]:{...n[lo],handleBounds:void 0}});else if(n){const r=Jr(t.nodeElement);!(!r.width||!r.height||n.width===r.width&&n.height===r.height&&!t.forceUpdate)&&(o.set(n.id,{...n,[lo]:{...n[lo],handleBounds:{source:ba(".source",t.nodeElement,f,c),target:ba(".target",t.nodeElement,f,c)}},...r}),e.push({id:n.id,type:"dimensions",dimensions:r}))}return e}),[]);Li(o,c);const h=a||i&&!a&&Bi(t,{initial:!0,...s});e({nodeInternals:new Map(o),fitViewOnInitDone:h}),p?.length>0&&r?.(p)},updateNodePositions:(e,n=!0,r=!1)=>{const{triggerNodeChanges:o}=t(),i=e.map((e=>{const t={id:e.id,type:"position",dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t}));o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:i,nodeOrigin:a,getNodes:s,elevateNodesOnSelect:l}=t();if(n?.length){if(i){const t=zi(aa(n,s()),o,a,l);e({nodeInternals:t})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let a,s=null;r?a=n.map((e=>la(e,!0))):(a=ca(i(),n),s=ca(o,[])),Wi({changedNodes:a,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let a,s=null;r?a=n.map((e=>la(e,!0))):(a=ca(o,n),s=ca(i(),[])),Wi({changedNodes:s,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:i}=t(),a=r||o;Wi({changedNodes:(n||i()).map((e=>(e.selected=!1,la(e.id,!1)))),changedEdges:a.map((e=>la(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();r?.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();r?.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t();Wi({changedNodes:r().filter((e=>e.selected)).map((e=>la(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>la(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach((e=>{e.positionAbsolute=qr(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{const{transform:n,width:r,height:o,d3Zoom:i,d3Selection:a,translateExtent:s}=t();if(!i||!a||!e.x&&!e.y)return!1;const l=xr.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[r,o]],u=i?.constrain()(l,c,s);i.transform(a,u);return n[0]!==u.x||n[1]!==u.y||n[2]!==u.k},cancelConnection:()=>e({connectionNodeId:us.connectionNodeId,connectionHandleId:us.connectionHandleId,connectionHandleType:us.connectionHandleType,connectionStatus:us.connectionStatus,connectionStartHandle:us.connectionStartHandle,connectionEndHandle:us.connectionEndHandle}),reset:()=>e({...us})})),Object.is),fs=({children:t})=>{const n=e.useRef(null);return n.current||(n.current=ds()),e.createElement(Mr,{value:n.current},t)};fs.displayName="ReactFlowProvider";const ps=({children:t})=>e.useContext(Rr)?e.createElement(e.Fragment,null,t):e.createElement(fs,null,t);ps.displayName="ReactFlowWrapper";const hs={input:pi,default:di,output:mi,group:gi},ms={default:zo,straight:Do,step:Po,smoothstep:To,simplebezier:Ao},gs=[0,0],ys=[15,15],bs={x:0,y:0,zoom:1},vs={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},ws=e.forwardRef((({nodes:t,edges:n,defaultNodes:r,defaultEdges:o,className:i,nodeTypes:a=hs,edgeTypes:s=ms,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:x,onNodeContextMenu:C,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:S,onNodeDragStop:I,onNodesDelete:_,onEdgesDelete:A,onSelectionChange:N,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:M,onSelectionContextMenu:T,onSelectionStart:P,onSelectionEnd:D,connectionMode:j=wo.Strict,connectionLineType:F=ko.Bezier,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:G="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:H=!1,selectionMode:X=Co.Full,panActivationKeyCode:$="Space",multiSelectionKeyCode:Z=(mo()?"Meta":"Control"),zoomActivationKeyCode:Y=(mo()?"Meta":"Control"),snapToGrid:U=!1,snapGrid:J=ys,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:q=!0,nodesDraggable:Q,nodesConnectable:ee,nodesFocusable:te,nodeOrigin:ne=gs,edgesFocusable:re,edgesUpdatable:oe,elementsSelectable:ie,defaultViewport:ae=bs,minZoom:se=.5,maxZoom:le=2,translateExtent:ce=cs,preventScrolling:ue=!0,nodeExtent:de,defaultMarkerColor:fe="#b1b1b7",zoomOnScroll:pe=!0,zoomOnPinch:he=!0,panOnScroll:me=!1,panOnScrollSpeed:ge=.5,panOnScrollMode:ye=xo.Free,zoomOnDoubleClick:be=!0,panOnDrag:ve=!0,onPaneClick:we,onPaneMouseEnter:xe,onPaneMouseMove:Ce,onPaneMouseLeave:ke,onPaneScroll:Ee,onPaneContextMenu:Se,children:Ie,onEdgeContextMenu:_e,onEdgeDoubleClick:Ae,onEdgeMouseEnter:Ne,onEdgeMouseMove:Oe,onEdgeMouseLeave:Re,onEdgeUpdate:Me,onEdgeUpdateStart:Te,onEdgeUpdateEnd:Pe,onReconnect:De,onReconnectStart:je,onReconnectEnd:Fe,reconnectRadius:Le=10,edgeUpdaterRadius:ze=10,onNodesChange:Be,onEdgesChange:Ve,noDragClassName:Ge="nodrag",noWheelClassName:We="nowheel",noPanClassName:He="nopan",fitView:Xe=!1,fitViewOptions:$e,connectOnClick:Ze=!0,attributionPosition:Ye,proOptions:Ue,defaultEdgeOptions:Je,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:qe=!1,disableKeyboardA11y:Qe=!1,autoPanOnConnect:et=!0,autoPanOnNodeDrag:tt=!0,connectionRadius:nt=20,isValidConnection:rt,onError:ot,style:it,id:at,nodeDragThreshold:st,...lt},ct)=>{const ut=at||"1";return e.createElement("div",{...lt,style:{...it,...vs},ref:ct,className:V(["react-flow",i]),"data-testid":"rf__wrapper",id:at},e.createElement(ps,null,e.createElement(ls,{onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:x,onNodeContextMenu:C,onNodeDoubleClick:k,nodeTypes:a,edgeTypes:s,connectionLineType:F,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:W,selectionOnDrag:H,selectionMode:X,deleteKeyCode:G,multiSelectionKeyCode:Z,panActivationKeyCode:$,zoomActivationKeyCode:Y,onlyRenderVisibleElements:K,selectNodesOnDrag:q,defaultViewport:ae,translateExtent:ce,minZoom:se,maxZoom:le,preventScrolling:ue,zoomOnScroll:pe,zoomOnPinch:he,zoomOnDoubleClick:be,panOnScroll:me,panOnScrollSpeed:ge,panOnScrollMode:ye,panOnDrag:ve,onPaneClick:we,onPaneMouseEnter:xe,onPaneMouseMove:Ce,onPaneMouseLeave:ke,onPaneScroll:Ee,onPaneContextMenu:Se,onSelectionContextMenu:T,onSelectionStart:P,onSelectionEnd:D,onEdgeContextMenu:_e,onEdgeDoubleClick:Ae,onEdgeMouseEnter:Ne,onEdgeMouseMove:Oe,onEdgeMouseLeave:Re,onReconnect:De??Me,onReconnectStart:je??Te,onReconnectEnd:Fe??Pe,reconnectRadius:Le??ze,defaultMarkerColor:fe,noDragClassName:Ge,noWheelClassName:We,noPanClassName:He,elevateEdgesOnSelect:qe,rfId:ut,disableKeyboardA11y:Qe,nodeOrigin:ne,nodeExtent:de}),e.createElement(Ii,{nodes:t,edges:n,defaultNodes:r,defaultEdges:o,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,nodesDraggable:Q,nodesConnectable:ee,nodesFocusable:te,edgesFocusable:re,edgesUpdatable:oe,elementsSelectable:ie,elevateNodesOnSelect:Ke,minZoom:se,maxZoom:le,nodeExtent:de,onNodesChange:Be,onEdgesChange:Ve,snapToGrid:U,snapGrid:J,connectionMode:j,translateExtent:ce,connectOnClick:Ze,defaultEdgeOptions:Je,fitView:Xe,fitViewOptions:$e,onNodesDelete:_,onEdgesDelete:A,onNodeDragStart:E,onNodeDrag:S,onNodeDragStop:I,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:M,noPanClassName:He,nodeOrigin:ne,rfId:ut,autoPanOnConnect:et,autoPanOnNodeDrag:tt,onError:ot,connectionRadius:nt,isValidConnection:rt,nodeDragThreshold:st}),e.createElement(Ci,{onSelectionChange:N}),Ie,e.createElement(Yr,{proOptions:Ue,position:Ye}),e.createElement(Ti,{rfId:ut,disableKeyboardA11y:Qe})))}));ws.displayName="ReactFlow";const xs=e=>e.getNodes();const Cs=e=>e.edges;const ks=({id:t,x:n,y:r,width:o,height:i,style:a,color:s,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,onClick:p,selected:h})=>{const{background:m,backgroundColor:g}=a||{},y=s||m||g;return e.createElement("rect",{className:V(["react-flow__minimap-node",{selected:h},u]),x:n,y:r,rx:d,ry:d,width:o,height:i,fill:y,stroke:l,strokeWidth:c,shapeRendering:f,onClick:p?e=>p(e,t):void 0})};ks.displayName="MiniMapNode";var Es=e.memo(ks);const Ss=e=>e.nodeOrigin,Is=e=>e.getNodes().filter((e=>!e.hidden&&e.width&&e.height)),_s=e=>e instanceof Function?e:()=>e;var As=e.memo((function({nodeStrokeColor:t="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:a=Es,onClick:s}){const l=Hr(Is,Z),c=Hr(Ss),u=_s(n),d=_s(t),f=_s(r),p="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return e.createElement(e.Fragment,null,l.map((t=>{const{x:n,y:r}=$o(t,c).positionAbsolute;return e.createElement(a,{key:t.id,x:n,y:r,width:t.width,height:t.height,style:t.style,selected:t.selected,className:f(t),color:u(t),borderRadius:o,strokeColor:d(t),strokeWidth:i,shapeRendering:p,onClick:s,id:t.id})})))}));const Ns=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?(r=Zo(t,e.nodeOrigin),o=n,oo(no(ro(r),ro(o)))):n,rfId:e.rfId};var r,o};function Os({style:t,className:n,nodeStrokeColor:r="transparent",nodeColor:o="#e2e2e2",nodeClassName:i="",nodeBorderRadius:a=5,nodeStrokeWidth:s=2,nodeComponent:l,maskColor:c="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:d=1,position:f="bottom-right",onClick:p,onNodeClick:h,pannable:m=!1,zoomable:g=!1,ariaLabel:y="React Flow mini map",inversePan:b=!1,zoomStep:v=10,offsetScale:w=5}){const x=Xr(),C=e.useRef(null),{boundingRect:k,viewBB:E,rfId:S}=Hr(Ns,Z),I=t?.width??200,_=t?.height??150,A=k.width/I,N=k.height/_,O=Math.max(A,N),R=O*I,M=O*_,T=w*O,P=k.x-(R-k.width)/2-T,D=k.y-(M-k.height)/2-T,j=R+2*T,F=M+2*T,L=`react-flow__minimap-desc-${S}`,z=e.useRef(0);z.current=O,e.useEffect((()=>{if(C.current){const e=dt(C.current),t=e=>{const{transform:t,d3Selection:n,d3Zoom:r}=x.getState();if("wheel"!==e.sourceEvent.type||!n||!r)return;const o=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*v,i=t[2]*Math.pow(2,o);r.scaleTo(n,i)},n=e=>{const{transform:t,d3Selection:n,d3Zoom:r,translateExtent:o,width:i,height:a}=x.getState();if("mousemove"!==e.sourceEvent.type||!n||!r)return;const s=z.current*Math.max(1,t[2])*(b?-1:1),l={x:t[0]-e.sourceEvent.movementX*s,y:t[1]-e.sourceEvent.movementY*s},c=[[0,0],[i,a]],u=xr.translate(l.x,l.y).scale(t[2]),d=r.constrain()(u,c,o);r.transform(n,d)},r=Or().on("zoom",m?n:null).on("zoom.wheel",g?t:null);return e.call(r),()=>{e.on("zoom",null)}}}),[m,g,b,v]);const B=p?e=>{const t=ft(e);p(e,{x:t[0],y:t[1]})}:void 0,G=h?(e,t)=>{const n=x.getState().nodeInternals.get(t);h(e,n)}:void 0;return e.createElement(Zr,{position:f,style:t,className:V(["react-flow__minimap",n]),"data-testid":"rf__minimap"},e.createElement("svg",{width:I,height:_,viewBox:`${P} ${D} ${j} ${F}`,role:"img","aria-labelledby":L,ref:C,onClick:B},y&&e.createElement("title",{id:L},y),e.createElement(As,{onClick:G,nodeColor:o,nodeStrokeColor:r,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:s,nodeComponent:l}),e.createElement("path",{className:"react-flow__minimap-mask",d:`M${P-T},${D-T}h${j+2*T}v${F+2*T}h${-j-2*T}z\n M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fill:c,fillRule:"evenodd",stroke:u,strokeWidth:d,pointerEvents:"none"})))}Os.displayName="MiniMap";var Rs,Ms=e.memo(Os);function Ts({color:t,dimensions:n,lineWidth:r}){return e.createElement("path",{stroke:t,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function Ps({color:t,radius:n}){return e.createElement("circle",{cx:n,cy:n,r:n,fill:t})}!function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"}(Rs||(Rs={}));const Ds={[Rs.Dots]:"#91919a",[Rs.Lines]:"#eee",[Rs.Cross]:"#e2e2e2"},js={[Rs.Dots]:1,[Rs.Lines]:1,[Rs.Cross]:6},Fs=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ls({id:t,variant:n=Rs.Dots,gap:r=20,size:o,lineWidth:i=1,offset:a=2,color:s,style:l,className:c}){const u=e.useRef(null),{transform:d,patternId:f}=Hr(Fs,Z),p=s||Ds[n],h=o||js[n],m=n===Rs.Dots,g=n===Rs.Cross,y=Array.isArray(r)?r:[r,r],b=[y[0]*d[2]||1,y[1]*d[2]||1],v=h*d[2],w=g?[v,v]:b,x=m?[v/a,v/a]:[w[0]/a,w[1]/a];return e.createElement("svg",{className:V(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},e.createElement("pattern",{id:f+t,x:d[0]%b[0],y:d[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`},m?e.createElement(Ps,{color:p,radius:v/a}):e.createElement(Ts,{dimensions:w,color:p,lineWidth:i})),e.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+t})`}))}Ls.displayName="Background";var zs=e.memo(Ls);const Bs=({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})=>[`${e}:${t}`,`${n}:${r}`].sort().join("--"),Vs=0,Gs=10,Ws=20,Hs=30,Xs=Gs,$s=e=>"string"==typeof e?e:e===Vs?"DEBUG":e===Gs?"INFO":e===Ws?"WARN":e===Hs?"ERROR":"UNKNOWN";class Zs{constructor(e,t=Gs){this.name=e,this.level=(e=>{if("number"==typeof e)return e;const t=e.toLowerCase();if("debug"===t)return Vs;if("info"===t)return Gs;if("warn"===t||"warning"===t)return Ws;if("error"===t)return Hs;throw new Error(`Unknown log level: ${e}`)})(t),this._level_name=$s(t)}set_level(e){this.level=e,this._level_name=$s(e)}_fomat_message(e,...t){return`[${this.name}] ${this._level_name}: ${e} ${t.map((e=>JSON.stringify(e,function(){const e=[];return function(t,n){if("object"!=typeof n||null===n)return n;for(;e.length>0&&e.at(-1)!==this;)e.pop();return e.includes(n)?"[Circular]":(e.push(n),n)}}()))).join(" ")}`}debug(e,...t){this.level<=Vs&&console.debug(this._fomat_message(e,...t))}info(e,...t){this.level<=Gs&&console.info(this._fomat_message(e,...t))}warn(e,...t){this.level<=Ws&&console.warn(this._fomat_message(e,...t))}error(e,...t){this.level<=Hs&&console.error(this._fomat_message(e,...t))}}const Ys=(e,t)=>("<NoValue>"===e.value&&(e.value=void 0),"<NoValue>"===e.fullvalue&&(e.fullvalue=void 0),void 0===e.try_get_full_value&&(e.try_get_full_value=()=>{t&&void 0!==e.node&&void 0!==e.id&&t.worker?.get_io_full_value({nid:e.node,ioid:e.id})}),void 0===e.hidden&&(e.hidden=!1),void 0===e.set_hidden&&(e.set_hidden=n=>{t&&void 0!==e.node&&void 0!==e.id&&t.worker?.update_io_options({nid:e.node,ioid:e.id,options:{hidden:n}})}),e),Us=(e,t,n)=>{if(((e,t)=>{const n=e.properties||{};n["frontend:size"]||(n["frontend:size"]=[200,100]);const r=n["frontend:pos"];if(!r||2!==r.length||isNaN(r[0])||null===r[0]||isNaN(r[1])||null===r[1])if(t&&t.rf_instance&&null!==t.reactflowRef){const e=t.reactflowRef.getBoundingClientRect(),r=e.left+e.width/2,o=e.top+e.height/2,i=t.rf_instance.screenToFlowPosition({x:r,y:o});n["frontend:pos"]=[i.x-n["frontend:size"][0]/2,i.y-n["frontend:size"][0]/2]}else n["frontend:pos"]=[0,0];n["frontend:collapsed"]||(n["frontend:collapsed"]=!1),e.properties=n})(e,n),void 0===(e=z(e)).id)throw new Error("Node must have an id");for(const t in e.io)e.io[t].node=e.id,Ys(e.io[t],n);return{position:{x:e.properties["frontend:pos"][0],y:e.properties["frontend:pos"][1]},data:{UseNodeStore:t},type:"default",...e}},Js=e=>{const t={...e},n=e=>{const t=o.getState();if(e.from_remote){let n=i.get_node(e.node.id,!1);if(!n)try{n=(e=>N(((t,n)=>z(B(e)))))(e.node),i.nodesstates.set(e.node.id,n)}catch(e){return void s.logger.error(`Failed to create node store ${e}`)}const r=n.getState();s.logger.info("Add node",r.id,r.name);const a=[...t.nodes,Us(r,n,s)];o.setState({nodes:a});for(const t in e.node.io){const n=e.node.io[t].id;void 0!==n&&s.worker?.get_io_value({nid:e.node.id,ioid:n})}setTimeout((()=>{s.worker?.call_hooks("node_added",{node:r.id})}),0)}},r=e=>{switch(e.type){case"add":n(e);break;case"update":(e=>{if(e.node.in_trigger&&(e.node.error=void 0),e.from_remote){const t=i.get_node(e.id,!1);if(!t)return;B(e.node);const n=t.getState(),{new_obj:r,change:o}=M(n,e.node);if(o){if(e.node.io)for(const t in e.node.io){r.io[t].fullvalue=e.node.io[t]?.fullvalue;for(const t in e.node.io){const n=e.node.io[t],o=r.io[t];n.hasOwnProperty("value")&&(void 0===n.value?o.value=null:"<NoValue>"===n.value?o.value=void 0:o.value=n.value)}}Us(r,t,s),s.logger.debug("update_action",r),t.setState(z(r))}}else s.worker&&s.worker.locally_update_node(e)})(e);break;case"delete":(e=>{s.logger.info("Deleting node",e.id),e.from_remote?o.getState().onNodesChange([{type:"remove",id:e.id}]):s.worker?.remove_node(e.id)})(e);break;case"error":(e=>{s.logger.error("Error",e),r({type:"update",id:e.id,node:{in_trigger:!1,error:e.error},from_remote:!0})})(e);break;case"trigger":(e=>{e.from_remote?r({type:"update",id:e.id,node:{in_trigger:!0,error:void 0},from_remote:!0}):s.worker?.trigger_node(e.id)})(e);break;default:s.logger.error("Unknown node action",e)}},o=(({on_node_change:e,on_edge_change:t,on_connect:n})=>{const r=e||(e=>{}),o=n||(e=>{}),i=N(((e,t)=>({nodes:[],edges:[],onNodesChange:n=>{e({nodes:aa(n,t().nodes)}),r(n)},onEdgesChange:n=>{e({edges:sa(n,t().edges)})},onConnect:e=>{null!=e.source&&null!=e.target&&o(e)}})));return i})({on_node_change:e=>{for(const t of e)switch(t.type){case"position":t.position&&r({type:"update",id:t.id,node:{properties:{"frontend:pos":[t.position.x,t.position.y]}},from_remote:!1});break;case"dimensions":t.dimensions&&r({type:"update",id:t.id,node:{properties:{"frontend:size":[t.dimensions.width,t.dimensions.height]}},from_remote:!1})}},on_edge_change:e=>{},on_connect:e=>{null!==e.source&&null!==e.target&&null!==e.sourceHandle&&null!==e.targetHandle&&s.worker&&s.worker.add_edge({src_nid:e.source,src_ioid:e.sourceHandle,trg_nid:e.target,trg_ioid:e.targetHandle,replace:!0})}}),i=(({})=>{const e=new Map;return{nodesstates:e,get_node:(t,n=!0)=>{const r=e.get(t);if(!r&&n){const n=e.keys();throw new Error(`Node ${t} not found, available nodes: ${Array.from(n)}`)}return r}}})({}),a={libstate:N(((e,t)=>({lib:{shelves:[]},external_worker:[],set:t=>e((e=>({...e,...t}))),get_lib:()=>t().lib,get_external_worker:()=>t().external_worker})))},s={local_settings:N(((e,t)=>({view_settings:{},update_view_settings:e=>{const t=s.local_settings.getState().view_settings,{new_obj:n,change:r}=M(t,e);r&&s.local_settings.setState((e=>({...e,view_settings:n})))}}))),local_state:N(((e,t)=>({selected_nodes:[],selected_edges:[],funcnodescontainerRef:null}))),options:t,lib:a,workermanager:void 0,workers:N(((e,t)=>({}))),workerstate:N(((e,t)=>({is_open:!1}))),render_options:N(((e,t)=>({}))),progress_state:N(((e,t)=>({message:"please select worker",status:"info",progress:0,blocking:!1}))),update_render_options:e=>{const t=s.render_options.getState(),{new_obj:n,change:r}=M(t,e);r&&s.render_options.setState(n)},worker:void 0,_unsubscribeFromWorker:void 0,set_worker:e=>{e!==s.worker&&(s._unsubscribeFromWorker&&(s._unsubscribeFromWorker(),s._unsubscribeFromWorker=void 0),e&&(s._unsubscribeFromWorker=e.state.subscribe((e=>{s.workerstate.setState(e)})),s.workerstate.setState(e.state.getState())),s.worker=e,e?.set_zustand(s))},nodespace:i,useReactFlowStore:o,on_node_action:r,on_edge_action:e=>{const t=o.getState();switch(e.type){case"add":if(e.from_remote){const n=t.edges,r=Bs(e);if(n.some((e=>e.id===r)))return;const i={id:r,source:e.src_nid,target:e.trg_nid,sourceHandle:e.src_ioid,targetHandle:e.trg_ioid,className:"funcnodes-edge animated"};s.logger.info("Adding edge",i),o.setState({edges:[...n,i]}),s.worker?.get_remote_node_state(e.src_nid),s.worker?.get_remote_node_state(e.trg_nid)}break;case"delete":if(e.from_remote){const n=t.edges,r=Bs(e);s.logger.info("Deleting edge",r);const i=n.filter((e=>e.id!==r));o.setState({edges:i}),s.worker?.get_remote_node_state(e.src_nid),s.worker?.get_remote_node_state(e.trg_nid)}break;default:s.logger.error("Unknown edge action",e)}},reactflowRef:null,clear_all:()=>{s.worker?.disconnect(),s.set_worker(void 0),s.workermanager?.setWorker(void 0),s.lib.libstate.getState().set({lib:{shelves:[]},external_worker:[]}),s.nodespace.nodesstates.clear(),s.useReactFlowStore.setState({nodes:[],edges:[]}),s.auto_progress()},center_node:e=>{if(!s.rf_instance)return;e=Array.isArray(e)?e:[e];const t=s.useReactFlowStore.getState().nodes.filter((t=>e.includes(t.id)));t.length>0&&s.rf_instance?.fitView({padding:.2,nodes:t})},center_all:()=>{console.log("center all",s.rf_instance),s.rf_instance?.fitView({padding:.2})},set_progress:e=>{if(""===e.message)return s.auto_progress();const t=s.progress_state.getState(),{new_obj:n,change:r}=M(t,e);r&&s.progress_state.setState(n)},auto_progress:()=>void 0===s.workermanager||s.workermanager.open?void 0===s.worker?s.set_progress({progress:0,message:"please select worker",status:"error",blocking:!1}):s.worker.is_open?void s.set_progress({progress:1,message:"running",status:"info",blocking:!1}):s.set_progress({progress:0,message:"connecting to worker",status:"info",blocking:!0}):s.set_progress({progress:0,message:"connecting to worker manager",status:"error",blocking:!1}),plugins:N(((e,t)=>({}))),add_plugin:(e,t)=>{void 0!==t&&s.plugins.setState((n=>({...n,[e]:t})))},dev_settings:{debug:!0},logger:new Zs("fn",Xs)};return s};function Ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:qs}=Object.prototype,{getPrototypeOf:Qs}=Object,el=(e=>t=>{const n=qs.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),tl=e=>(e=e.toLowerCase(),t=>el(t)===e),nl=e=>t=>typeof t===e,{isArray:rl}=Array,ol=nl("undefined");const il=tl("ArrayBuffer");const al=nl("string"),sl=nl("function"),ll=nl("number"),cl=e=>null!==e&&"object"==typeof e,ul=e=>{if("object"!==el(e))return!1;const t=Qs(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},dl=tl("Date"),fl=tl("File"),pl=tl("Blob"),hl=tl("FileList"),ml=tl("URLSearchParams"),[gl,yl,bl,vl]=["ReadableStream","Request","Response","Headers"].map(tl);function wl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),rl(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let a;for(r=0;r<i;r++)a=o[r],t.call(null,e[a],a,e)}}function xl(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const Cl="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,kl=e=>!ol(e)&&e!==Cl;const El=(Sl="undefined"!=typeof Uint8Array&&Qs(Uint8Array),e=>Sl&&e instanceof Sl);var Sl;const Il=tl("HTMLFormElement"),_l=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Al=tl("RegExp"),Nl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};wl(n,((n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)})),Object.defineProperties(e,r)},Ol="abcdefghijklmnopqrstuvwxyz",Rl="0123456789",Ml={DIGIT:Rl,ALPHA:Ol,ALPHA_DIGIT:Ol+Ol.toUpperCase()+Rl};const Tl=tl("AsyncFunction"),Pl=(Dl="function"==typeof setImmediate,jl=sl(Cl.postMessage),Dl?setImmediate:jl?((e,t)=>(Cl.addEventListener("message",(({source:n,data:r})=>{n===Cl&&r===e&&t.length&&t.shift()()}),!1),n=>{t.push(n),Cl.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e));var Dl,jl;const Fl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Cl):"undefined"!=typeof process&&process.nextTick||Pl;var Ll={isArray:rl,isArrayBuffer:il,isBuffer:function(e){return null!==e&&!ol(e)&&null!==e.constructor&&!ol(e.constructor)&&sl(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||sl(e.append)&&("formdata"===(t=el(e))||"object"===t&&sl(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&il(e.buffer),t},isString:al,isNumber:ll,isBoolean:e=>!0===e||!1===e,isObject:cl,isPlainObject:ul,isReadableStream:gl,isRequest:yl,isResponse:bl,isHeaders:vl,isUndefined:ol,isDate:dl,isFile:fl,isBlob:pl,isRegExp:Al,isFunction:sl,isStream:e=>cl(e)&&sl(e.pipe),isURLSearchParams:ml,isTypedArray:El,isFileList:hl,forEach:wl,merge:function e(){const{caseless:t}=kl(this)&&this||{},n={},r=(r,o)=>{const i=t&&xl(n,o)||o;ul(n[i])&&ul(r)?n[i]=e(n[i],r):ul(r)?n[i]=e({},r):rl(r)?n[i]=r.slice():n[i]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&wl(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(wl(t,((t,r)=>{n&&sl(t)?e[r]=Ks(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,a;const s={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:el,kindOfTest:tl,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(rl(e))return e;let t=e.length;if(!ll(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Il,hasOwnProperty:_l,hasOwnProp:_l,reduceDescriptors:Nl,freezeMethods:e=>{Nl(e,((t,n)=>{if(sl(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];sl(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return rl(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:xl,global:Cl,isContextDefined:kl,ALPHABET:Ml,generateString:(e=16,t=Ml.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&sl(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(cl(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=rl(e)?[]:{};return wl(e,((e,t)=>{const i=n(e,r+1);!ol(i)&&(o[t]=i)})),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:Tl,isThenable:e=>e&&(cl(e)||sl(e))&&sl(e.then)&&sl(e.catch),setImmediate:Pl,asap:Fl};function zl(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Ll.inherits(zl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ll.toJSONObject(this.config),code:this.code,status:this.status}}});const Bl=zl.prototype,Vl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Vl[e]={value:e}})),Object.defineProperties(zl,Vl),Object.defineProperty(Bl,"isAxiosError",{value:!0}),zl.from=(e,t,n,r,o,i)=>{const a=Object.create(Bl);return Ll.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),zl.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function Gl(e){return Ll.isPlainObject(e)||Ll.isArray(e)}function Wl(e){return Ll.endsWith(e,"[]")?e.slice(0,-2):e}function Hl(e,t,n){return e?e.concat(t).map((function(e,t){return e=Wl(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const Xl=Ll.toFlatObject(Ll,{},null,(function(e){return/^is[A-Z]/.test(e)}));function $l(e,t,n){if(!Ll.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ll.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Ll.isUndefined(t[e])}))).metaTokens,o=n.visitor||c,i=n.dots,a=n.indexes,s=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ll.isSpecCompliantForm(t);if(!Ll.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ll.isDate(e))return e.toISOString();if(!s&&Ll.isBlob(e))throw new zl("Blob is not supported. Use a Buffer instead.");return Ll.isArrayBuffer(e)||Ll.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,o){let s=e;if(e&&!o&&"object"==typeof e)if(Ll.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ll.isArray(e)&&function(e){return Ll.isArray(e)&&!e.some(Gl)}(e)||(Ll.isFileList(e)||Ll.endsWith(n,"[]"))&&(s=Ll.toArray(e)))return n=Wl(n),s.forEach((function(e,r){!Ll.isUndefined(e)&&null!==e&&t.append(!0===a?Hl([n],r,i):null===a?n:n+"[]",l(e))})),!1;return!!Gl(e)||(t.append(Hl(o,n,i),l(e)),!1)}const u=[],d=Object.assign(Xl,{defaultVisitor:c,convertValue:l,isVisitable:Gl});if(!Ll.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ll.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Ll.forEach(n,(function(n,i){!0===(!(Ll.isUndefined(n)||null===n)&&o.call(t,n,Ll.isString(i)?i.trim():i,r,d))&&e(n,r?r.concat(i):[i])})),u.pop()}}(e),t}function Zl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Yl(e,t){this._pairs=[],e&&$l(e,this,t)}const Ul=Yl.prototype;function Jl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Kl(e,t,n){if(!t)return e;const r=n&&n.encode||Jl;Ll.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let i;if(i=o?o(t,n):Ll.isURLSearchParams(t)?t.toString():new Yl(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}Ul.append=function(e,t){this._pairs.push([e,t])},Ul.toString=function(e){const t=e?function(t){return e.call(this,t,Zl)}:Zl;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class ql{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ll.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var Ql={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ec={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Yl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const tc="undefined"!=typeof window&&"undefined"!=typeof document,nc="object"==typeof navigator&&navigator||void 0,rc=tc&&(!nc||["ReactNative","NativeScript","NS"].indexOf(nc.product)<0),oc="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ic=tc&&window.location.href||"http://localhost";var ac={...Object.freeze({__proto__:null,hasBrowserEnv:tc,hasStandardBrowserEnv:rc,hasStandardBrowserWebWorkerEnv:oc,navigator:nc,origin:ic}),...ec};function sc(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const a=Number.isFinite(+i),s=o>=e.length;if(i=!i&&Ll.isArray(r)?r.length:i,s)return Ll.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a;r[i]&&Ll.isObject(r[i])||(r[i]=[]);return t(e,n,r[i],o)&&Ll.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!a}if(Ll.isFormData(e)&&Ll.isFunction(e.entries)){const n={};return Ll.forEachEntry(e,((e,r)=>{t(function(e){return Ll.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const lc={transitional:Ql,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Ll.isObject(e);o&&Ll.isHTMLForm(e)&&(e=new FormData(e));if(Ll.isFormData(e))return r?JSON.stringify(sc(e)):e;if(Ll.isArrayBuffer(e)||Ll.isBuffer(e)||Ll.isStream(e)||Ll.isFile(e)||Ll.isBlob(e)||Ll.isReadableStream(e))return e;if(Ll.isArrayBufferView(e))return e.buffer;if(Ll.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return $l(e,new ac.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return ac.isNode&&Ll.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=Ll.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return $l(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ll.isString(e))try{return(t||JSON.parse)(e),Ll.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||lc.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ll.isResponse(e)||Ll.isReadableStream(e))return e;if(e&&Ll.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw zl.from(e,zl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ac.classes.FormData,Blob:ac.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ll.forEach(["delete","get","head","post","put","patch"],(e=>{lc.headers[e]={}}));const cc=Ll.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const uc=Symbol("internals");function dc(e){return e&&String(e).trim().toLowerCase()}function fc(e){return!1===e||null==e?e:Ll.isArray(e)?e.map(fc):String(e)}function pc(e,t,n,r,o){return Ll.isFunction(r)?r.call(this,t,n):(o&&(t=n),Ll.isString(t)?Ll.isString(r)?-1!==t.indexOf(r):Ll.isRegExp(r)?r.test(t):void 0:void 0)}let hc=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=dc(t);if(!o)throw new Error("header name must be a non-empty string");const i=Ll.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=fc(e))}const i=(e,t)=>Ll.forEach(e,((e,n)=>o(e,n,t)));if(Ll.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Ll.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&cc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Ll.isHeaders(e))for(const[t,r]of e.entries())o(r,t,n);else null!=e&&o(t,e,n);return this}get(e,t){if(e=dc(e)){const n=Ll.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ll.isFunction(t))return t.call(this,e,n);if(Ll.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=dc(e)){const n=Ll.findKey(this,e);return!(!n||void 0===this[n]||t&&!pc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=dc(e)){const o=Ll.findKey(n,e);!o||t&&!pc(0,n[o],o,t)||(delete n[o],r=!0)}}return Ll.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!pc(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Ll.forEach(this,((r,o)=>{const i=Ll.findKey(n,o);if(i)return t[i]=fc(r),void delete t[o];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();a!==o&&delete t[o],t[a]=fc(r),n[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ll.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ll.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[uc]=this[uc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=dc(e);t[r]||(!function(e,t){const n=Ll.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return Ll.isArray(e)?e.forEach(r):r(e),this}};function mc(e,t){const n=this||lc,r=t||n,o=hc.from(r.headers);let i=r.data;return Ll.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function gc(e){return!(!e||!e.__CANCEL__)}function yc(e,t,n){zl.call(this,null==e?"canceled":e,zl.ERR_CANCELED,t,n),this.name="CanceledError"}function bc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new zl("Request failed with status code "+n.status,[zl.ERR_BAD_REQUEST,zl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}hc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ll.reduceDescriptors(hc.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Ll.freezeMethods(hc),Ll.inherits(yc,zl,{__CANCEL__:!0});const vc=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),c=r[a];o||(o=l),n[i]=s,r[i]=l;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),l-o<t)return;const f=c&&l-c;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const a=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),s=t-o;s>=i?a(e,t):(n=e,r||(r=setTimeout((()=>{r=null,a(n)}),i-s)))},()=>n&&a(n)]}((n=>{const i=n.loaded,a=n.lengthComputable?n.total:void 0,s=i-r,l=o(s);r=i;e({loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&i<=a?(a-i)/l:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),n)},wc=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},xc=e=>(...t)=>Ll.asap((()=>e(...t)));var Cc=ac.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ac.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ac.origin),ac.navigator&&/(msie|trident)/i.test(ac.navigator.userAgent)):()=>!0,kc=ac.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const a=[e+"="+encodeURIComponent(t)];Ll.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),Ll.isString(r)&&a.push("path="+r),Ll.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ec(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Sc=e=>e instanceof hc?{...e}:e;function Ic(e,t){t=t||{};const n={};function r(e,t,n,r){return Ll.isPlainObject(e)&&Ll.isPlainObject(t)?Ll.merge.call({caseless:r},e,t):Ll.isPlainObject(t)?Ll.merge({},t):Ll.isArray(t)?t.slice():t}function o(e,t,n,o){return Ll.isUndefined(t)?Ll.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!Ll.isUndefined(t))return r(void 0,t)}function a(e,t){return Ll.isUndefined(t)?Ll.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t,n)=>o(Sc(e),Sc(t),0,!0)};return Ll.forEach(Object.keys(Object.assign({},e,t)),(function(r){const i=l[r]||o,a=i(e[r],t[r],r);Ll.isUndefined(a)&&i!==s||(n[r]=a)})),n}var _c=e=>{const t=Ic({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:l}=t;if(t.headers=s=hc.from(s),t.url=Kl(Ec(t.baseURL,t.url),e.params,e.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Ll.isFormData(r))if(ac.hasStandardBrowserEnv||ac.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(!1!==(n=s.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];s.setContentType([e||"multipart/form-data",...t].join("; "))}if(ac.hasStandardBrowserEnv&&(o&&Ll.isFunction(o)&&(o=o(t)),o||!1!==o&&Cc(t.url))){const e=i&&a&&kc.read(a);e&&s.set(i,e)}return t};var Ac="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=_c(e);let o=r.data;const i=hc.from(r.headers).normalize();let a,s,l,c,u,{responseType:d,onUploadProgress:f,onDownloadProgress:p}=r;function h(){c&&c(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=hc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());bc((function(e){t(e),h()}),(function(e){n(e),h()}),{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new zl("Request aborted",zl.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new zl("Network Error",zl.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||Ql;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new zl(t,o.clarifyTimeoutError?zl.ETIMEDOUT:zl.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&Ll.forEach(i.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),Ll.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),d&&"json"!==d&&(m.responseType=r.responseType),p&&([l,u]=vc(p,!0),m.addEventListener("progress",l)),f&&m.upload&&([s,c]=vc(f),m.upload.addEventListener("progress",s),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(a=t=>{m&&(n(!t||t.type?new yc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===ac.protocols.indexOf(y)?n(new zl("Unsupported protocol "+y+":",zl.ERR_BAD_REQUEST,e)):m.send(o||null)}))};const Nc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,a();const t=e instanceof Error?e:this.reason;r.abort(t instanceof zl?t:new yc(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,o(new zl(`timeout ${t} of ms exceeded`,zl.ETIMEDOUT))}),t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)})),e=null)};e.forEach((e=>e.addEventListener("abort",o)));const{signal:s}=r;return s.unsubscribe=()=>Ll.asap(a),s}},Oc=function*(e,t){let n=e.byteLength;if(n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},Rc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Mc=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of Rc(e))yield*Oc(n,t)}(e,t);let i,a=0,s=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return s(),void e.close();let i=r.byteLength;if(n){let e=a+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel:e=>(s(e),o.return())},{highWaterMark:2})},Tc="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Pc=Tc&&"function"==typeof ReadableStream,Dc=Tc&&("function"==typeof TextEncoder?(jc=new TextEncoder,e=>jc.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var jc;const Fc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Lc=Pc&&Fc((()=>{let e=!1;const t=new Request(ac.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),zc=Pc&&Fc((()=>Ll.isReadableStream(new Response("").body))),Bc={stream:zc&&(e=>e.body)};var Vc;Tc&&(Vc=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Bc[e]&&(Bc[e]=Ll.isFunction(Vc[e])?t=>t[e]():(t,n)=>{throw new zl(`Response type '${e}' is not supported`,zl.ERR_NOT_SUPPORT,n)})})));const Gc=async(e,t)=>{const n=Ll.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Ll.isBlob(e))return e.size;if(Ll.isSpecCompliantForm(e)){const t=new Request(ac.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ll.isArrayBufferView(e)||Ll.isArrayBuffer(e)?e.byteLength:(Ll.isURLSearchParams(e)&&(e+=""),Ll.isString(e)?(await Dc(e)).byteLength:void 0)})(t):n};var Wc=Tc&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:a,onDownloadProgress:s,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:f}=_c(e);c=c?(c+"").toLowerCase():"text";let p,h=Nc([o,i&&i.toAbortSignal()],a);const m=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let g;try{if(l&&Lc&&"get"!==n&&"head"!==n&&0!==(g=await Gc(u,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(Ll.isFormData(r)&&(e=n.headers.get("content-type"))&&u.setContentType(e),n.body){const[e,t]=wc(g,vc(xc(l)));r=Mc(n.body,65536,e,t)}}Ll.isString(d)||(d=d?"include":"omit");const o="credentials"in Request.prototype;p=new Request(t,{...f,signal:h,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:o?d:void 0});let i=await fetch(p);const a=zc&&("stream"===c||"response"===c);if(zc&&(s||a&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=Ll.toFiniteNumber(i.headers.get("content-length")),[n,r]=s&&wc(t,vc(xc(s),!0))||[];i=new Response(Mc(i.body,65536,n,(()=>{r&&r(),m&&m()})),e)}c=c||"text";let y=await Bc[Ll.findKey(Bc,c)||"text"](i,e);return!a&&m&&m(),await new Promise(((t,n)=>{bc(t,n,{data:y,headers:hc.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:p})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new zl("Network Error",zl.ERR_NETWORK,e,p),{cause:t.cause||t});throw zl.from(t,t&&t.code,e,p)}});const Hc={http:null,xhr:Ac,fetch:Wc};Ll.forEach(Hc,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Xc=e=>`- ${e}`,$c=e=>Ll.isFunction(e)||null===e||!1===e;var Zc=e=>{e=Ll.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){let t;if(n=e[i],r=n,!$c(n)&&(r=Hc[(t=String(n)).toLowerCase()],void 0===r))throw new zl(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+i]=r}if(!r){const e=Object.entries(o).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new zl("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Xc).join("\n"):" "+Xc(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Yc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new yc(null,e)}function Uc(e){Yc(e),e.headers=hc.from(e.headers),e.data=mc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Zc(e.adapter||lc.adapter)(e).then((function(t){return Yc(e),t.data=mc.call(e,e.transformResponse,t),t.headers=hc.from(t.headers),t}),(function(t){return gc(t)||(Yc(e),t&&t.response&&(t.response.data=mc.call(e,e.transformResponse,t.response),t.response.headers=hc.from(t.response.headers))),Promise.reject(t)}))}const Jc="1.7.9",Kc={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Kc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const qc={};Kc.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new zl(r(o," has been removed"+(t?" in "+t:"")),zl.ERR_DEPRECATED);return t&&!qc[o]&&(qc[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},Kc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var Qc={assertOptions:function(e,t,n){if("object"!=typeof e)throw new zl("options must be an object",zl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],a=t[i];if(a){const t=e[i],n=void 0===t||a(t,i,e);if(!0!==n)throw new zl("option "+i+" must be "+n,zl.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new zl("Unknown option "+i,zl.ERR_BAD_OPTION)}},validators:Kc};const eu=Qc.validators;let tu=class{constructor(e){this.defaults=e,this.interceptors={request:new ql,response:new ql}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Ic(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Qc.assertOptions(n,{silentJSONParsing:eu.transitional(eu.boolean),forcedJSONParsing:eu.transitional(eu.boolean),clarifyTimeoutError:eu.transitional(eu.boolean)},!1),null!=r&&(Ll.isFunction(r)?t.paramsSerializer={serialize:r}:Qc.assertOptions(r,{encode:eu.function,serialize:eu.function},!0)),Qc.assertOptions(t,{baseUrl:eu.spelling("baseURL"),withXsrfToken:eu.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Ll.merge(o.common,o[t.method]);o&&Ll.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=hc.concat(i,o);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!s){const e=[Uc.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=a.length;let f=t;for(d=0;d<u;){const e=a[d++],t=a[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{c=Uc.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return Kl(Ec((e=Ic(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};Ll.forEach(["delete","get","head","options"],(function(e){tu.prototype[e]=function(t,n){return this.request(Ic(n||{},{method:e,url:t,data:(n||{}).data}))}})),Ll.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(Ic(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}tu.prototype[e]=t(),tu.prototype[e+"Form"]=t(!0)}));const nu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nu).forEach((([e,t])=>{nu[t]=e}));const ru=function e(t){const n=new tu(t),r=Ks(tu.prototype.request,n);return Ll.extend(r,tu.prototype,n,{allOwnKeys:!0}),Ll.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Ic(t,n))},r}(lc);ru.Axios=tu,ru.CanceledError=yc,ru.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new yc(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e((function(e){t=e})),cancel:t}}},ru.isCancel=gc,ru.VERSION=Jc,ru.toFormData=$l,ru.AxiosError=zl,ru.Cancel=ru.CanceledError,ru.all=function(e){return Promise.all(e)},ru.spread=function(e){return function(t){return e.apply(null,t)}},ru.isAxiosError=function(e){return Ll.isObject(e)&&!0===e.isAxiosError},ru.mergeConfig=Ic,ru.AxiosHeaders=hc,ru.formToJSON=e=>sc(Ll.isHTMLForm(e)?new FormData(e):e),ru.getAdapter=Zc,ru.HttpStatusCode=nu,ru.default=ru;const{Axios:ou,AxiosError:iu,CanceledError:au,isCancel:su,CancelToken:lu,VERSION:cu,all:uu,Cancel:du,isAxiosError:fu,spread:pu,toFormData:hu,AxiosHeaders:mu,HttpStatusCode:gu,formToJSON:yu,getAdapter:bu,mergeConfig:vu}=ru;let wu;const xu=new Uint8Array(16);function Cu(){if(!wu&&(wu="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!wu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return wu(xu)}const ku=[];for(let e=0;e<256;++e)ku.push((e+256).toString(16).slice(1));var Eu={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Su(e,t,n){if(Eu.randomUUID&&!e)return Eu.randomUUID();const r=(e=e||{}).random||(e.rng||Cu)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return ku[e[t+0]]+ku[e[t+1]]+ku[e[t+2]]+ku[e[t+3]]+"-"+ku[e[t+4]]+ku[e[t+5]]+"-"+ku[e[t+6]]+ku[e[t+7]]+"-"+ku[e[t+8]]+ku[e[t+9]]+"-"+ku[e[t+10]]+ku[e[t+11]]+ku[e[t+12]]+ku[e[t+13]]+ku[e[t+14]]+ku[e[t+15]]}(r)}class Iu{constructor(e){this._hooks=new Map,this._ns_event_intercepts=new Map,this._unique_cmd_outs={},this.uuid=e.uuid,this.on_error=e.on_error||(e=>{this._zustand?.logger.error(e)}),this.messagePromises=new Map,this._local_nodeupdates=new Map,this._nodeupdatetimer=setTimeout((()=>{this.sync_local_node_updates()}),5e3),this.state=N(((e,t)=>({is_open:!1}))),e.zustand&&this.set_zustand(e.zustand),e.on_sync_complete?this.on_sync_complete=e.on_sync_complete:this.on_sync_complete=async()=>{},this._responsive=!1,this._last_pong=Date.now()-36e5,setInterval((()=>{this.is_open&&this.send({type:"ping"})}),1e3),setInterval((()=>{Date.now()-this._last_pong>5e3?this._responsive=!1:this._responsive=!0}),5e3)}_receive_pong(){this._last_pong=Date.now(),this._responsive=!0}set_zustand(e){e!==this._zustand&&(this._zustand=e,e.set_worker(this),this._zustand.auto_progress(),this.stepwise_fullsync())}add_hook(e,t){const n=this._hooks.get(e)||[];n.push(t),this._hooks.set(e,n);return()=>{const n=this._hooks.get(e)||[],r=n.indexOf(t);r>=0&&n.splice(r,1)}}async call_hooks(e,t){const n=[];for(const r of this._hooks.get(e)||[]){const e=r({worker:this,data:t});e instanceof Promise&&n.push(e)}await Promise.all(n)}add_ns_event_intercept(e,t){const n=this._ns_event_intercepts.get(e)||[];n.push(t),this._ns_event_intercepts.set(e,n);return()=>{const n=this._ns_event_intercepts.get(e)||[],r=n.indexOf(t);r>=0&&n.splice(r,1)}}async intercept_ns_event(e){let t=e;for(const n of this._ns_event_intercepts.get(e.event)||[])t=await n(t);return t}get is_open(){return this.state.getState().is_open}set is_open(e){this.state.setState({is_open:e})}async stepwise_fullsync(){this._zustand&&this.is_open&&(await this.sync_lib(),await this.sync_external_worker(),await this.sync_funcnodes_plugins(),await this.sync_nodespace(),await this.sync_view_state(),await this.on_sync_complete(this))}async sync_lib(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_library",wait_for_response:!0,retries:2,unique:!0});this._zustand.lib.libstate.getState().set({lib:e})}async sync_external_worker(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_worker_dependencies",wait_for_response:!0,unique:!0});this._zustand.lib.libstate.getState().set({external_worker:e})}async sync_funcnodes_plugins(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_plugin_keys",wait_for_response:!0,unique:!0,kwargs:{type:"react"}});for(const t of e){const e=await this._send_cmd({cmd:"get_plugin",wait_for_response:!0,kwargs:{key:t,type:"react"},unique:!0});if(e.js)for(const t of e.js){const e=document.createElement("script");e.text=atob(t),document.body.appendChild(e)}if(e.css)for(const t of e.css){const e=document.createElement("style");e.innerHTML=atob(t),document.head.appendChild(e)}if(void 0!==e.module){const n=atob(e.module),r=n.length,o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=n.charCodeAt(e);const i=new Blob([o],{type:"application/javascript"}),a=URL.createObjectURL(i),s=await import(a);URL.revokeObjectURL(a),this._zustand.add_plugin(t,s.default)}}}async sync_view_state(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"view_state",wait_for_response:!0,unique:!0});e.renderoptions&&this._zustand.update_render_options(e.renderoptions);const t=e.nodes;if(t)for(const e in t){const n={};F(n,t[e]),this._zustand.on_node_action({type:"update",node:n,id:e,from_remote:!0})}}async sync_nodespace(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_nodes",kwargs:{with_frontend:!0},wait_for_response:!0,unique:!0});for(const t of e)this._receive_node_added(t);const t=await this._send_cmd({cmd:"get_edges",wait_for_response:!0,unique:!0});for(const e of t)this._receive_edge_added(...e)}async fullsync(){if(!this._zustand)return;if(!this.is_open)return;let e;for(;;)try{e=await this._send_cmd({cmd:"full_state",unique:!0});break}catch(e){this._zustand.logger.error("Error in fullsync",e)}this._zustand.logger.debug("Full state",e),this._zustand.lib.libstate.getState().set({lib:e.backend.lib,external_worker:e.worker_dependencies}),e.view.renderoptions&&this._zustand.update_render_options(e.view.renderoptions);const t=e.view.nodes;for(const n of e.backend.nodes)void 0!==t[n.id]&&F(n,t[n.id]),this._receive_node_added(n);for(const t of e.backend.edges)this._receive_edge_added(...t)}async _receive_edge_added(e,t,n,r){this._zustand&&this._zustand.on_edge_action({type:"add",from_remote:!0,src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})}async trigger_node(e){await this._send_cmd({cmd:"trigger_node",kwargs:{nid:e},wait_for_response:!1})}async add_node(e){const t=await this._send_cmd({cmd:"add_node",kwargs:{id:e}});this._receive_node_added(t)}async remove_node(e){await this._send_cmd({cmd:"remove_node",kwargs:{id:e}})}async _receive_node_added(e){this._zustand&&this._zustand.on_node_action({type:"add",node:e,id:e.id,from_remote:!0})}add_edge({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r,replace:o=!1}){return this._send_cmd({cmd:"add_edge",kwargs:{src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r,replace:o}})}remove_edge({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r}){return this._send_cmd({cmd:"remove_edge",kwargs:{src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r}})}async add_external_worker({module:e,cls_module:t,cls_name:n}){return await this._send_cmd({cmd:"add_external_worker",kwargs:{module:e,cls_module:t,cls_name:n}})}sync_local_node_updates(){clearTimeout(this._nodeupdatetimer),this._local_nodeupdates.forEach((async(e,t)=>{const n=await this._send_cmd({cmd:"update_node",kwargs:{nid:t,data:e},wait_for_response:!0});this._zustand&&this._zustand.on_node_action({type:"update",node:n,id:t,from_remote:!0})})),this._local_nodeupdates.clear(),this._nodeupdatetimer=setTimeout((()=>{this.sync_local_node_updates()}),200)}locally_update_node(e){const t=this._local_nodeupdates.get(e.id);if(t){const{new_obj:n,change:r}=M(t,e.node);r&&this._local_nodeupdates.set(e.id,n)}else this._local_nodeupdates.set(e.id,e.node);e.immediate&&this.sync_local_node_updates()}async get_remote_node_state(e){const t=await this._send_cmd({cmd:"get_node_state",kwargs:{nid:e},wait_for_response:!0});this._zustand&&this._zustand.on_node_action({type:"update",node:t,id:t.id,from_remote:!0})}set_io_value({nid:e,ioid:t,value:n,set_default:r=!1}){return this._send_cmd({cmd:"set_io_value",kwargs:{nid:e,ioid:t,value:n,set_default:r},wait_for_response:!0})}clear(){return this._send_cmd({cmd:"clear",unique:!0})}save(){return this._send_cmd({cmd:"save",wait_for_response:!0,unique:!0})}load(e){return this._send_cmd({cmd:"load_data",kwargs:{data:e},wait_for_response:!0}).then((()=>{this.stepwise_fullsync()}))}async get_io_value({nid:e,ioid:t}){const n=await this._send_cmd({cmd:"get_io_value",kwargs:{nid:e,ioid:t},wait_for_response:!0});return this._zustand?(this._zustand.on_node_action({type:"update",node:{io:{[t]:{value:n}}},id:e,from_remote:!0}),n):n}async get_ios_values({nid:e}){const t=await this._send_cmd({cmd:"get_ios_values",kwargs:{nid:e},wait_for_response:!0});if(!this._zustand)return t;const n={};for(const e in t)n[e]={value:t[e]};return this._zustand.on_node_action({type:"update",node:{io:n},id:e,from_remote:!0}),t}async get_runstate(){return await this._send_cmd({cmd:"get_runstate",wait_for_response:!0,unique:!0})}async _send_cmd({cmd:e,kwargs:t,wait_for_response:n=!0,response_timeout:r=5e3,retries:o=2,unique:i=!1}){const a={type:"cmd",cmd:e,kwargs:t||{}};if(await new Promise((async e=>{if(this._responsive)return e();const t=setInterval((()=>{this._responsive&&(clearInterval(t),e())}),100)})),n){if(i&&void 0!==this._unique_cmd_outs[a.cmd])return this._unique_cmd_outs[a.cmd];o<0&&(o=0);const t=async()=>{let t;for(;o>=0;){const n=a.id||Su();a.id=n;const i=new Promise(((t,o)=>{const i=setTimeout((()=>{o("Timeout@wait_for_response for "+e)}),r);this.messagePromises.set(n,{resolve:e=>{clearTimeout(i),t(e),this.messagePromises.delete(n)},reject:e=>{clearTimeout(i),o(e),this.messagePromises.delete(n)}})}));await this.send(a);try{t=await i;break}catch(e){if(0===o)throw delete this._unique_cmd_outs[a.cmd],e;o-=1;continue}}return delete this._unique_cmd_outs[a.cmd],t},n=t();return i&&(this._unique_cmd_outs[a.cmd]=n),n}return this.send(a)}async send(e){throw new Error("async send(data: any) not implemented")}async upload_file({files:e,onProgressCallback:t,root:n}){throw new Error("upload_file not implemented ")}async handle_large_message_hint({}){throw new Error("async handle_large_message_hint({}: LargeMessageHint) not implemented ")}async receive_workerevent({event:e,data:t}){switch(e){case"worker_error":if(!this._zustand)return;return this._zustand.logger.error(t.error);case"update_worker_dependencies":if(!this._zustand)return;return this._zustand.lib.libstate.getState().set({external_worker:t.worker_dependencies});case"lib_update":return void await this.sync_lib();case"fullsync":return void await this.stepwise_fullsync();case"external_worker_update":return await this.sync_lib(),void await this.sync_external_worker();case"starting":return void this.call_hooks("starting");case"stopping":return void this.call_hooks("stopping");default:console.warn("Unhandled worker event",e,t)}}async receive_nodespace_event(e){const{event:t,data:n}=await this.intercept_ns_event(e);switch(t){case"after_set_value":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,io:{[n.io]:{value:n.result}}},id:n.node,from_remote:!0});case"after_update_value_options":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,io:{[n.io]:{value_options:n.result}}},id:n.node,from_remote:!0});case"triggerstart":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,in_trigger:!0},id:n.node,from_remote:!0});case"triggerdone":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,in_trigger:!1},id:n.node,from_remote:!0});case"node_trigger_error":if(!this._zustand)return;return this._zustand.on_node_action({type:"error",errortype:"trigger",error:n.error,id:n.node,tb:n.tb,from_remote:!0});case"node_removed":if(!this._zustand)return;return this._zustand.on_node_action({type:"delete",id:n.node,from_remote:!0}),void this.call_hooks("node_removed",{node:n.node});case"node_added":return void this._receive_node_added(n.node);case"after_disconnect":case"after_unforward":if(!n.result)return;if(!Array.isArray(n.result))return;if(4!==n.result.length)return;if(!this._zustand)return;return this._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:n.result[0],src_ioid:n.result[1],trg_nid:n.result[2],trg_ioid:n.result[3]});case"after_connect":case"after_forward":if(!n.result)return;if(!Array.isArray(n.result))return;if(4!==n.result.length)return;return this._receive_edge_added(...n.result);case"after_add_shelf":case"after_remove_shelf":if(!n.result)return;if(!this._zustand)return;return this._zustand.lib.libstate.getState().set({lib:n.result});case"progress":if(!this._zustand)return;if(n.node)return this._zustand.on_node_action({type:"update",node:{id:n.node,progress:n.info},id:n.node,from_remote:!0});console.warn("Unhandled nodepsace event",t,n);break;default:console.warn("Unhandled nodepsace event",t,n)}}async add_lib(e,t){return await this._send_cmd({cmd:"add_package_dependency",kwargs:{name:e,version:t},wait_for_response:!1})}async remove_lib(e){return await this._send_cmd({cmd:"remove_package_dependency",kwargs:{name:e},wait_for_response:!1})}async receive(e){let t;switch(this._last_pong=Date.now(),this._responsive=!0,e.type){case"pong":return void this._receive_pong();case"nsevent":return await this.receive_nodespace_event(e);case"result":if(t=e.id&&this.messagePromises.get(e.id),t)return t.resolve(e.result);break;case"error":if(this.on_error(e.tb+"\n"+e.error),t=e.id&&this.messagePromises.get(e.id),t)return t.reject(e.error);break;case"progress":if(!this._zustand)return;this._zustand.set_progress(e);break;case"workerevent":return await this.receive_workerevent(e);case"large_message":return await this.handle_large_message_hint(e);default:console.warn("Unhandled message",e)}}disconnect(){}onclose(){this.is_open=!1,this._zustand&&this._zustand.auto_progress()}async reconnect(){}async stop(){await this._send_cmd({cmd:"stop_worker",wait_for_response:!1});const e=this.onclose.bind(this);this.onclose=()=>{e(),this._zustand&&(this._zustand.worker===this&&this._zustand.clear_all(),this.onclose=e)}}async get_io_full_value({nid:e,ioid:t}){const n=await this._send_cmd({cmd:"get_io_full_value",kwargs:{nid:e,ioid:t},wait_for_response:!0});return this._zustand?(this._zustand.on_node_action({type:"update",node:{io:{[t]:{fullvalue:n}}},id:e,from_remote:!0}),n):n}async update_io_options({nid:e,ioid:t,options:n}){const r=await this._send_cmd({cmd:"update_io_options",kwargs:{nid:e,ioid:t,...n},wait_for_response:!0});if(!this._zustand)return r;this._zustand.on_node_action({type:"update",node:{io:{[t]:{...n}}},id:e,from_remote:!0})}async get_node_status(e){return await this._send_cmd({cmd:"get_node_state",kwargs:{nid:e},wait_for_response:!0})}async get_available_modules(){return await this._send_cmd({cmd:"get_available_modules",wait_for_response:!0,unique:!0})}async update_external_worker(e,t,n){return await this._send_cmd({cmd:"update_external_worker",kwargs:{worker_id:e,class_id:t,...n},wait_for_response:!0})}async remove_external_worker(e,t){return await this._send_cmd({cmd:"remove_external_worker",kwargs:{worker_id:e,class_id:t},wait_for_response:!0})}async export({withFiles:e=!1}){return await this._send_cmd({cmd:"export_worker",wait_for_response:!0,kwargs:{with_files:e}})}async update_from_export(e){const t=await this._send_cmd({cmd:"update_from_export",kwargs:{data:e},wait_for_response:!0,response_timeout:6e5,unique:!0});return this.stepwise_fullsync().then((()=>{this._zustand?.center_all()})),t}}class _u extends Iu{constructor(e){super(e),this._websocket=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=5e3,this._reconnect=!0,this._url=e.url,new Promise((e=>{this.connect(),e(null)})),this._zustand&&this._zustand.auto_progress()}connect(){this._zustand?.logger.info("Connecting to websocket"),this.is_open=!1,this._websocket=new WebSocket(this._url),this._websocket.onopen=()=>{this.onopen()},this._websocket.onclose=()=>{this.onclose()},this._websocket.onerror=()=>{this.on_ws_error()},this._websocket.onmessage=e=>{this.onmessage(e.data)}}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}auto_reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let e=this.calculateReconnectTimeout();this._zustand?.logger.info(`Attempting to reconnect in ${e} ms`),setTimeout((()=>{this._websocket&&this._websocket.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())}),e)}else this._zustand?.logger.warn("Maximum reconnect attempts reached. Giving up.")}async onmessage(e){const t=JSON.parse(e);this._zustand?.logger.debug(`Recieved data of length: ${e.length} and data"`,t),await this.receive(t)}get http_protocol(){return this.secure_url?"https":"http"}get secure_url(){return this._url.startsWith("wss")}get url_wo_protocol(){return this._url.substring(this.secure_url?6:5)}get http_url(){var e=this.http_protocol+"://"+this.url_wo_protocol;return"/"!==e[e.length-1]&&(e+="/"),e}async upload_file({files:e,onProgressCallback:t,root:n}){const r=`${this.http_url}upload/`,o=new FormData,i=Array.isArray(e)?e:Array.from(e);for(const e of i){const t=e.webkitRelativePath||e.name,r=n?`${n}/${t}`:t;o.append("file",e,r)}try{return(await ru.post(r,o,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e=>{t&&t(e.loaded,e.total)}})).data.file}catch(e){throw new Error("Failed to upload file")}}async handle_large_message_hint({msg_id:e}){const t=this.http_url+"message/"+e,n=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}}),r=await n.json();this.receive(r)}onopen(){this._zustand?.logger.info("Websocket opened"),this.is_open=!0,this._zustand&&this._zustand.auto_progress(),this.reconnectAttempts=0,this.stepwise_fullsync()}onclose(){this._zustand?.logger.info("Websocket closed"),super.onclose(),this._reconnect&&(this._zustand?.logger.info("Websocket closed,reconnecting"),this.auto_reconnect())}on_ws_error(){this._zustand?.logger.warn("Websocket error"),this._websocket?this._websocket.close():this.auto_reconnect()}async send_large_message(e){const t=`${this.http_url}message/`;await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}async send(e){if(!this._websocket||this._websocket.readyState!==WebSocket.OPEN)return void this._zustand?.logger.warn("Websocket not connected");const t=JSON.stringify(e);if(new Blob([t]).size>1e6)return this._zustand?.logger.info("Data too large, sending via http"),await this.send_large_message(t);this._zustand?.logger.debug("Sending data",e),this._websocket.send(t)}async stop(){await super.stop(),this._reconnect=!1}close(){this._websocket&&this._websocket.close()}disconnect(){super.disconnect(),this._reconnect=!1,this.close()}async reconnect(){await super.reconnect(),this._reconnect=!0,!this._websocket||(this._zustand?.logger.info("Reconnecting"),this._websocket.readyState!==WebSocket.OPEN&&this._websocket.readyState!==WebSocket.CONNECTING||(this._websocket.readyState===WebSocket.CONNECTING&&await new Promise(((e,t)=>{if(null===this._websocket)return;let n=setTimeout((()=>{t("Timeout@reconnect")}),2e3);this._websocket.addEventListener("open",(()=>{clearTimeout(n),e(null)}),{once:!0}),this._websocket.readyState===WebSocket.OPEN&&(clearTimeout(n),e(null))})),this._websocket.readyState!==WebSocket.OPEN))?this.connect():this.stepwise_fullsync()}}class Au{constructor(e,t){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=2e3,this.wsuri=e,this.zustand=t,this.workers={},this.on_setWorker=e=>{this.zustand.set_worker(e)},this.connect()}get open(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.zustand.set_progress({progress:0,message:"connecting to worker manager",status:"info",blocking:!0}),this.zustand.logger.info("Connecting to websocket:",this.wsuri),this.ws=new WebSocket(this.wsuri),this.ws.onopen=()=>{this.onopen()},this.ws.onclose=()=>{this.onclose()},this.ws.onerror=()=>{this.on_ws_error()},this.ws.onmessage=e=>{this.onmessage(e.data)},this.connectionTimeout=setTimeout((()=>{this.ws?.readyState!==WebSocket.OPEN&&this.on_ws_error()}),5e3)}on_ws_error(){console.warn("Websocket error"),this.ws?this.ws.close():this.reconnect()}onopen(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.zustand.auto_progress(),this.ws&&this.ws.send("worker_status");const e=window.localStorage.getItem("funcnodes__active_worker");e&&this.set_active(e)}onmessage(e){let t=JSON.parse(e);if("worker_status"!==t.type)if("set_worker"!==t.type)"progress"!==t.type?this.zustand.logger.error("WorkerManager: unknown message",t):this.zustand.set_progress(t);else if("WSWorker"===t.data.type){let e="ws"+(t.data.ssl?"s":"")+"://"+t.data.host+":"+t.data.port;this.setWorker(this.workers[t.data.uuid]||new _u({url:e,zustand:this.zustand,uuid:t.data.uuid,on_sync_complete:this.zustand.options.on_sync_complete}))}else this.zustand.logger.error("WorkerManager: unknown worker type",t);else{const e={};for(let n of t.active)n.active=!0,e[n.uuid]=n;for(let n of t.inactive)n.active=!1,e[n.uuid]=n;this.zustand.workers.setState(e)}}setWorker(e){for(let t in this.workers)t!==e?.uuid&&this.workers[t].disconnect();void 0!==e&&(this.workers[e.uuid]=e,e.reconnect()),window.localStorage.setItem("funcnodes__active_worker",e?.uuid||""),void 0!==this.zustand.worker&&this.zustand.clear_all(),this.zustand.set_worker(e),this.on_setWorker(e)}async restart_worker(e){this.ws?.send(JSON.stringify({type:"restart_worker",workerid:e}))}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let e=this.calculateReconnectTimeout();this.zustand.logger.info(`Attempting to reconnect in ${e} ms`),setTimeout((()=>{this.ws&&this.ws.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())}),e)}else this.zustand.logger.warn("Maximum reconnect attempts reached. Giving up.")}onclose(){this.zustand.logger.warn("WorkerManager: onclose"),this.reconnect()}set_active(e){this.ws&&this.ws.send(JSON.stringify({type:"set_active",workerid:e}))}new_worker({name:e,reference:t,copyLib:n,copyNS:r}){e||(e=void 0),n||(n=!1),r||(r=!1),t||(t=void 0,n=!1,r=!1),this.ws&&this.ws.send(JSON.stringify({type:"new_worker",kwargs:{name:e,reference:t,copyLib:n,copyNS:r}}))}}function Nu(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Ou(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ru(...e){return t=>{let n=!1;const r=e.map((e=>{const r=Ou(e,t);return n||"function"!=typeof r||(n=!0),r}));if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Ou(e[t],null)}}}}function Mu(...e){return o.useCallback(Ru(...e),e)}var Tu,Pu={exports:{}},Du={};var ju,Fu,Lu={};
28
+ */var C=(w||(w=1,"production"===process.env.NODE_ENV?u.exports=function(){if(g)return d;g=1;var t=e,n=b(),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;return d.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=s((function(){function e(e){if(!a){if(a=!0,o=e,e=c(e),void 0!==u&&f.hasValue){var t=f.value;if(u(t,e))return i=t}return i=e}if(t=i,r(o,e))return t;var n=c(e);return void 0!==u&&u(t,n)?(o=e,t):(o=e,i=n)}var o,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var p=o(e,d[0],d[1]);return a((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p},d}():u.exports=(v||(v=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=e,n=b(),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;x.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=s((function(){function e(e){if(!a){if(a=!0,o=e,e=c(e),void 0!==u&&f.hasValue){var t=f.value;if(u(t,e))return i=t}return i=e}if(t=i,r(o,e))return t;var n=c(e);return void 0!==u&&u(t,n)?(o=e,t):(o=e,i=n)}var o,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var p=o(e,d[0],d[1]);return a((function(){f.hasValue=!0,f.value=p}),[p]),l(p),p},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),x)),u.exports),k=l(C);const{useDebugValue:E}=e,{useSyncExternalStoreWithSelector:S}=k;let I=!1;const _=e=>e;const A=e=>{"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t="function"==typeof e?s(e):e,n=(e,n)=>function(e,t=_,n){n&&!I&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),I=!0);const r=S(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return E(r),r}(t,e,n);return Object.assign(n,t),n},N=e=>e?A(e):A;function O(e){return"[object Object]"===Object.prototype.toString.call(e)}function R(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e.constructor!==t.constructor)return!1;if(e.constructor===Object||e.constructor===Array){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!r.includes(o))return!1;if(!R(e[o],t[o]))return!1}}return!(e instanceof Date&&t instanceof Date)||e.getTime()===t.getTime()}const M=(e,t)=>{let n=!1;if(!O(e))throw new Error("Target must be a plain object");if(!O(t))throw new Error("Source must be a plain object");const r={...e};return Object.keys(t).forEach((o=>{const i=t[o],a=e[o];if(O(i)&&O(a)){const{new_obj:e,change:t}=M(a,i);t&&(n=!0,r[o]=e)}else R(a,i)||(n=!0,r[o]=i)})),{new_obj:r,change:n}},T=(e,t)=>{let n=!1;if(!O(e))throw new Error("Target must be a plain object");if(!O(t))throw new Error("Source must be a plain object");const r={...e};return Object.keys(t).forEach((o=>{const i=t[o],a=e[o];if(void 0!==a||void 0!==i){if(void 0===a)return n=!0,void(r[o]=i);if(O(i)&&O(a)){const{new_obj:e,change:t}=T(a,i);t&&(n=!0,r[o]=e)}}})),{new_obj:r,change:n}},P={id:"dummy",name:"dummy",node:"dummy",full_id:"dummy",type:"any",value:void 0,is_input:!1,connected:!1,does_trigger:!0,fullvalue:void 0,try_get_full_value:void 0,render_options:{set_default:!0,type:"any"},set_hidden:void 0,hidden:!1},D=e=>{if(!e.id)throw new Error("IO must have an id but is missing for "+JSON.stringify(e));void 0===e.name&&(e.name=e.id);const{new_obj:t}=T(e,P);return"any"!==t.render_options.type&&void 0!==t.render_options.type||(t.render_options.type=t.type),t},j={id:"dummy",node_name:"dummy",properties:{"frontend:size":[200,100],"frontend:pos":[NaN,NaN],"frontend:collapsed":!1},io:{},name:"dummy",in_trigger:!1,io_order:[],progress:{ascii:!1,elapsed:0,initial:0,n:0,prefix:"idle",unit:"it",unit_divisor:1e3,unit_scale:!1}},F=(e,t)=>{e.properties=e.properties||{},t.pos&&(e.properties["frontend:pos"]=t.pos),t.size&&(e.properties["frontend:size"]=t.size),void 0!==t.collapsed&&(e.properties["frontend:collapsed"]=!!t.collapsed)},L=JSON.stringify(j),z=e=>{if(!e.id)throw new Error("Node must have an id");const t=JSON.parse(L),{new_obj:n}=T(e,t);for(const e in n.io){if(void 0===n.io[e])continue;void 0===n.io[e].id&&(n.io[e].id=e);const t=D(n.io[e]);n.io[e]=t}return n},B=e=>{if(void 0===e.io&&(e.io={}),void 0===e.io_order)if(Array.isArray(e.io)){e.io_order=e.io.map((e=>e.id));const t={};for(const n of e.io)t[n.id]=n;e.io=t}else e.io_order=Object.keys(e.io);else if(Array.isArray(e.io)){const t={};for(const n of e.io)t[n.id]=n,e.io_order.includes(n.id)||e.io_order.push(n.id);e.io=t}else for(const t in e.io)e.io_order.includes(t)||e.io_order.push(t);return e};function V(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,r=0;r<e.length;r++)""!==(n=V(e[r]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:G}=e,{useSyncExternalStoreWithSelector:W}=k,H=e=>e;function X(e,t=H,n){const r=W(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return G(r),r}const $=(e,t)=>{const n=s(e),r=(e,r=t)=>X(n,e,r);return Object.assign(r,n),r};function Z(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Y={value:()=>{}};function U(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw new Error("illegal type: "+e);r[e]=[]}return new J(r)}function J(e){this._=e}function K(e,t){for(var n,r=0,o=e.length;r<o;++r)if((n=e[r]).name===t)return n.value}function q(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Y,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}J.prototype=U.prototype={constructor:J,on:function(e,t){var n,r=this._,o=function(e,t){return e.trim().split(/^|\s+/).map((function(e){var n="",r=e.indexOf(".");if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}(e+"",r),i=-1,a=o.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++i<a;)if(n=(e=o[i]).type)r[n]=q(r[n],e.name,t);else if(null==t)for(n in r)r[n]=q(r[n],e.name,null);return this}for(;++i<a;)if((n=(e=o[i]).type)&&(n=K(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new J(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,o=new Array(n),i=0;i<n;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(r=this._[e]).length;i<n;++i)r[i].value.apply(t,o)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};var Q="http://www.w3.org/1999/xhtml",ee={svg:"http://www.w3.org/2000/svg",xhtml:Q,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function te(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),ee.hasOwnProperty(t)?{space:ee[t],local:e}:e}function ne(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Q&&t.documentElement.namespaceURI===Q?t.createElement(e):t.createElementNS(n,e)}}function re(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function oe(e){var t=te(e);return(t.local?re:ne)(t)}function ie(){}function ae(e){return null==e?ie:function(){return this.querySelector(e)}}function se(){return[]}function le(e){return null==e?se:function(){return this.querySelectorAll(e)}}function ce(e){return function(){return function(e){return null==e?[]:Array.isArray(e)?e:Array.from(e)}(e.apply(this,arguments))}}function ue(e){return function(){return this.matches(e)}}function de(e){return function(t){return t.matches(e)}}var fe=Array.prototype.find;function pe(){return this.firstElementChild}var he=Array.prototype.filter;function me(){return Array.from(this.children)}function ge(e){return new Array(e.length)}function ye(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function be(e,t,n,r,o,i){for(var a,s=0,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new ye(e,i[s]);for(;s<l;++s)(a=t[s])&&(o[s]=a)}function ve(e,t,n,r,o,i,a){var s,l,c,u=new Map,d=t.length,f=i.length,p=new Array(d);for(s=0;s<d;++s)(l=t[s])&&(p[s]=c=a.call(l,l.__data__,s,t)+"",u.has(c)?o[s]=l:u.set(c,l));for(s=0;s<f;++s)c=a.call(e,i[s],s,i)+"",(l=u.get(c))?(r[s]=l,l.__data__=i[s],u.delete(c)):n[s]=new ye(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&u.get(p[s])===l&&(o[s]=l)}function we(e){return e.__data__}function xe(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function Ce(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ke(e){return function(){this.removeAttribute(e)}}function Ee(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Se(e,t){return function(){this.setAttribute(e,t)}}function Ie(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function _e(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function Ae(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ne(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Oe(e){return function(){this.style.removeProperty(e)}}function Re(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Me(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Te(e,t){return e.style.getPropertyValue(t)||Ne(e).getComputedStyle(e,null).getPropertyValue(t)}function Pe(e){return function(){delete this[e]}}function De(e,t){return function(){this[e]=t}}function je(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Fe(e){return e.trim().split(/^|\s+/)}function Le(e){return e.classList||new ze(e)}function ze(e){this._node=e,this._names=Fe(e.getAttribute("class")||"")}function Be(e,t){for(var n=Le(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ve(e,t){for(var n=Le(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function Ge(e){return function(){Be(this,e)}}function We(e){return function(){Ve(this,e)}}function He(e,t){return function(){(t.apply(this,arguments)?Be:Ve)(this,e)}}function Xe(){this.textContent=""}function $e(e){return function(){this.textContent=e}}function Ze(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function Ye(){this.innerHTML=""}function Ue(e){return function(){this.innerHTML=e}}function Je(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function Ke(){this.nextSibling&&this.parentNode.appendChild(this)}function qe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Qe(){return null}function et(){var e=this.parentNode;e&&e.removeChild(this)}function tt(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nt(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rt(e){return function(){var t=this.__on;if(t){for(var n,r=0,o=-1,i=t.length;r<i;++r)n=t[r],e.type&&n.type!==e.type||n.name!==e.name?t[++o]=n:this.removeEventListener(n.type,n.listener,n.options);++o?t.length=o:delete this.__on}}}function ot(e,t,n){return function(){var r,o=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(o)for(var a=0,s=o.length;a<s;++a)if((r=o[a]).type===e.type&&r.name===e.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),void(r.value=t);this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function it(e,t,n){var r=Ne(e),o=r.CustomEvent;"function"==typeof o?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function at(e,t){return function(){return it(this,e,t)}}function st(e,t){return function(){return it(this,e,t.apply(this,arguments))}}ye.prototype={constructor:ye,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},ze.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var lt=[null];function ct(e,t){this._groups=e,this._parents=t}function ut(){return new ct([[document.documentElement]],lt)}function dt(e){return"string"==typeof e?new ct([[document.querySelector(e)]],[document.documentElement]):new ct([[e]],lt)}function ft(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}ct.prototype=ut.prototype={constructor:ct,select:function(e){"function"!=typeof e&&(e=ae(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a,s=t[o],l=s.length,c=r[o]=new Array(l),u=0;u<l;++u)(i=s[u])&&(a=e.call(i,i.__data__,u,s))&&("__data__"in i&&(a.__data__=i.__data__),c[u]=a);return new ct(r,this._parents)},selectAll:function(e){e="function"==typeof e?ce(e):le(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var a,s=t[i],l=s.length,c=0;c<l;++c)(a=s[c])&&(r.push(e.call(a,a.__data__,c,s)),o.push(a));return new ct(r,o)},selectChild:function(e){return this.select(null==e?pe:function(e){return function(){return fe.call(this.children,e)}}("function"==typeof e?e:de(e)))},selectChildren:function(e){return this.selectAll(null==e?me:function(e){return function(){return he.call(this.children,e)}}("function"==typeof e?e:de(e)))},filter:function(e){"function"!=typeof e&&(e=ue(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a=t[o],s=a.length,l=r[o]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new ct(r,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,we);var n=t?ve:be,r=this._parents,o=this._groups;"function"!=typeof e&&(e=function(e){return function(){return e}}(e));for(var i=o.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var u=r[c],d=o[c],f=d.length,p=xe(e.call(u,u&&u.__data__,c,r)),h=p.length,m=s[c]=new Array(h),g=a[c]=new Array(h);n(u,d,m,g,l[c]=new Array(f),p,t);for(var y,b,v=0,w=0;v<h;++v)if(y=m[v]){for(v>=w&&(w=v+1);!(b=g[w])&&++w<h;);y._next=b||null}}return(a=new ct(a,r))._enter=s,a._exit=l,a},enter:function(){return new ct(this._enter||this._groups.map(ge),this._parents)},exit:function(){return new ct(this._exit||this._groups.map(ge),this._parents)},join:function(e,t,n){var r=this.enter(),o=this,i=this.exit();return"function"==typeof e?(r=e(r))&&(r=r.selection()):r=r.append(e+""),null!=t&&(o=t(o))&&(o=o.selection()),null==n?i.remove():n(i),r&&o?r.merge(o).order():o},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,a=Math.min(o,i),s=new Array(o),l=0;l<a;++l)for(var c,u=n[l],d=r[l],f=u.length,p=s[l]=new Array(f),h=0;h<f;++h)(c=u[h]||d[h])&&(p[h]=c);for(;l<o;++l)s[l]=n[l];return new ct(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r,o=e[t],i=o.length-1,a=o[i];--i>=0;)(r=o[i])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=Ce);for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var a,s=n[i],l=s.length,c=o[i]=new Array(l),u=0;u<l;++u)(a=s[u])&&(c[u]=a);c.sort(t)}return new ct(o,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var a=r[o];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o,i=t[n],a=0,s=i.length;a<s;++a)(o=i[a])&&e.call(o,o.__data__,a,i);return this},attr:function(e,t){var n=te(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==t?n.local?Ee:ke:"function"==typeof t?n.local?Ae:_e:n.local?Ie:Se)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?Oe:"function"==typeof t?Me:Re)(e,t,null==n?"":n)):Te(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Pe:"function"==typeof t?je:De)(e,t)):this.node()[e]},classed:function(e,t){var n=Fe(e+"");if(arguments.length<2){for(var r=Le(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each(("function"==typeof t?He:t?Ge:We)(n,t))},text:function(e){return arguments.length?this.each(null==e?Xe:("function"==typeof e?Ze:$e)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?Ye:("function"==typeof e?Je:Ue)(e)):this.node().innerHTML},raise:function(){return this.each(Ke)},lower:function(){return this.each(qe)},append:function(e){var t="function"==typeof e?e:oe(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:oe(e),r=null==t?Qe:"function"==typeof t?t:ae(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(et)},clone:function(e){return this.select(e?nt:tt)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var r,o,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?ot:rt,r=0;r<a;++r)this.each(s(i[r],t,n));return this}var s=this.node().__on;if(s)for(var l,c=0,u=s.length;c<u;++c)for(r=0,l=s[c];r<a;++r)if((o=i[r]).type===l.type&&o.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?st:at)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r,o=e[t],i=0,a=o.length;i<a;++i)(r=o[i])&&(yield r)}};const pt={passive:!1},ht={capture:!0,passive:!1};function mt(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function yt(e){var t=e.document.documentElement,n=dt(e).on("dragstart.drag",gt,ht);"onselectstart"in t?n.on("selectstart.drag",gt,ht):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function bt(e,t){var n=e.document.documentElement,r=dt(e).on("dragstart.drag",null);t&&(r.on("click.drag",gt,ht),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var vt=e=>()=>e;function wt(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function xt(e){return!e.ctrlKey&&!e.button}function Ct(){return this.parentNode}function kt(e,t){return null==t?{x:e.x,y:e.y}:t}function Et(){return navigator.maxTouchPoints||"ontouchstart"in this}function St(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function It(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _t(){}wt.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var At=.7,Nt=1/At,Ot="\\s*([+-]?\\d+)\\s*",Rt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tt=/^#([0-9a-f]{3,8})$/,Pt=new RegExp(`^rgb\\(${Ot},${Ot},${Ot}\\)$`),Dt=new RegExp(`^rgb\\(${Mt},${Mt},${Mt}\\)$`),jt=new RegExp(`^rgba\\(${Ot},${Ot},${Ot},${Rt}\\)$`),Ft=new RegExp(`^rgba\\(${Mt},${Mt},${Mt},${Rt}\\)$`),Lt=new RegExp(`^hsl\\(${Rt},${Mt},${Mt}\\)$`),zt=new RegExp(`^hsla\\(${Rt},${Mt},${Mt},${Rt}\\)$`),Bt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Vt(){return this.rgb().formatHex()}function Gt(){return this.rgb().formatRgb()}function Wt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Tt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?Ht(t):3===n?new Zt(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?Xt(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?Xt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Pt.exec(e))?new Zt(t[1],t[2],t[3],1):(t=Dt.exec(e))?new Zt(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=jt.exec(e))?Xt(t[1],t[2],t[3],t[4]):(t=Ft.exec(e))?Xt(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Lt.exec(e))?Qt(t[1],t[2]/100,t[3]/100,1):(t=zt.exec(e))?Qt(t[1],t[2]/100,t[3]/100,t[4]):Bt.hasOwnProperty(e)?Ht(Bt[e]):"transparent"===e?new Zt(NaN,NaN,NaN,0):null}function Ht(e){return new Zt(e>>16&255,e>>8&255,255&e,1)}function Xt(e,t,n,r){return r<=0&&(e=t=n=NaN),new Zt(e,t,n,r)}function $t(e,t,n,r){return 1===arguments.length?function(e){return e instanceof _t||(e=Wt(e)),e?new Zt((e=e.rgb()).r,e.g,e.b,e.opacity):new Zt}(e):new Zt(e,t,n,null==r?1:r)}function Zt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function Yt(){return`#${qt(this.r)}${qt(this.g)}${qt(this.b)}`}function Ut(){const e=Jt(this.opacity);return`${1===e?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${1===e?")":`, ${e})`}`}function Jt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qt(e){return((e=Kt(e))<16?"0":"")+e.toString(16)}function Qt(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new tn(e,t,n,r)}function en(e){if(e instanceof tn)return new tn(e.h,e.s,e.l,e.opacity);if(e instanceof _t||(e=Wt(e)),!e)return new tn;if(e instanceof tn)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,s=i-o,l=(i+o)/2;return s?(a=t===i?(n-r)/s+6*(n<r):n===i?(r-t)/s+2:(t-n)/s+4,s/=l<.5?i+o:2-i-o,a*=60):s=l>0&&l<1?0:a,new tn(a,s,l,e.opacity)}function tn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function nn(e){return(e=(e||0)%360)<0?e+360:e}function rn(e){return Math.max(0,Math.min(1,e||0))}function on(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}St(_t,Wt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Vt,formatHex:Vt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return en(this).formatHsl()},formatRgb:Gt,toString:Gt}),St(Zt,$t,It(_t,{brighter(e){return e=null==e?Nt:Math.pow(Nt,e),new Zt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?At:Math.pow(At,e),new Zt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Zt(Kt(this.r),Kt(this.g),Kt(this.b),Jt(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:Yt,formatHex:Yt,formatHex8:function(){return`#${qt(this.r)}${qt(this.g)}${qt(this.b)}${qt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ut,toString:Ut})),St(tn,(function(e,t,n,r){return 1===arguments.length?en(e):new tn(e,t,n,null==r?1:r)}),It(_t,{brighter(e){return e=null==e?Nt:Math.pow(Nt,e),new tn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?At:Math.pow(At,e),new tn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Zt(on(e>=240?e-240:e+120,o,r),on(e,o,r),on(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new tn(nn(this.h),rn(this.s),rn(this.l),Jt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Jt(this.opacity);return`${1===e?"hsl(":"hsla("}${nn(this.h)}, ${100*rn(this.s)}%, ${100*rn(this.l)}%${1===e?")":`, ${e})`}`}}));var an=e=>()=>e;function sn(e){return 1==(e=+e)?ln:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):an(isNaN(t)?n:t)}}function ln(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):an(isNaN(e)?t:e)}var cn=function e(t){var n=sn(t);function r(e,t){var r=n((e=$t(e)).r,(t=$t(t)).r),o=n(e.g,t.g),i=n(e.b,t.b),a=ln(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=o(t),e.b=i(t),e.opacity=a(t),e+""}}return r.gamma=e,r}(1);function un(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var dn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fn=new RegExp(dn.source,"g");function pn(e,t){var n,r,o,i=dn.lastIndex=fn.lastIndex=0,a=-1,s=[],l=[];for(e+="",t+="";(n=dn.exec(e))&&(r=fn.exec(t));)(o=r.index)>i&&(o=t.slice(i,o),s[a]?s[a]+=o:s[++a]=o),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:un(n,r)})),i=fn.lastIndex;return i<t.length&&(o=t.slice(i),s[a]?s[a]+=o:s[++a]=o),s.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,r=0;r<t;++r)s[(n=l[r]).i]=n.x(e);return s.join("")})}var hn,mn=180/Math.PI,gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function yn(e,t,n,r,o,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*mn,skewX:Math.atan(l)*mn,scaleX:a,scaleY:s}}function bn(e,t,n,r){function o(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],l=[];return i=e(i),a=e(a),function(e,r,o,i,a,s){if(e!==o||r!==i){var l=a.push("translate(",null,t,null,n);s.push({i:l-4,x:un(e,o)},{i:l-2,x:un(r,i)})}else(o||i)&&a.push("translate("+o+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(o(n)+"rotate(",null,r)-2,x:un(e,t)})):t&&n.push(o(n)+"rotate("+t+r)}(i.rotate,a.rotate,s,l),function(e,t,n,i){e!==t?i.push({i:n.push(o(n)+"skewX(",null,r)-2,x:un(e,t)}):t&&n.push(o(n)+"skewX("+t+r)}(i.skewX,a.skewX,s,l),function(e,t,n,r,i,a){if(e!==n||t!==r){var s=i.push(o(i)+"scale(",null,",",null,")");a.push({i:s-4,x:un(e,n)},{i:s-2,x:un(t,r)})}else 1===n&&1===r||i.push(o(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,l),i=a=null,function(e){for(var t,n=-1,r=l.length;++n<r;)s[(t=l[n]).i]=t.x(e);return s.join("")}}}var vn=bn((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?gn:yn(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),wn=bn((function(e){return null==e?gn:(hn||(hn=document.createElementNS("http://www.w3.org/2000/svg","g")),hn.setAttribute("transform",e),(e=hn.transform.baseVal.consolidate())?yn((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):gn)}),", ",")",")");function xn(e){return((e=Math.exp(e))+1/e)/2}var Cn,kn,En=function e(t,n,r){function o(e,o){var i,a,s=e[0],l=e[1],c=e[2],u=o[0],d=o[1],f=o[2],p=u-s,h=d-l,m=p*p+h*h;if(m<1e-12)a=Math.log(f/c)/t,i=function(e){return[s+e*p,l+e*h,c*Math.exp(t*e*a)]};else{var g=Math.sqrt(m),y=(f*f-c*c+r*m)/(2*c*n*g),b=(f*f-c*c-r*m)/(2*f*n*g),v=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(b*b+1)-b);a=(w-v)/t,i=function(e){var r=e*a,o=xn(v),i=c/(n*g)*(o*function(e){return((e=Math.exp(2*e))-1)/(e+1)}(t*r+v)-function(e){return((e=Math.exp(e))-1/e)/2}(v));return[s+i*p,l+i*h,c*o/xn(t*r+v)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return o.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},o}(Math.SQRT2,2,4),Sn=0,In=0,_n=0,An=0,Nn=0,On=0,Rn="object"==typeof performance&&performance.now?performance:Date,Mn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tn(){return Nn||(Mn(Pn),Nn=Rn.now()+On)}function Pn(){Nn=0}function Dn(){this._call=this._time=this._next=null}function jn(e,t,n){var r=new Dn;return r.restart(e,t,n),r}function Fn(){Nn=(An=Rn.now())+On,Sn=In=0;try{!function(){Tn(),++Sn;for(var e,t=Cn;t;)(e=Nn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Sn}()}finally{Sn=0,function(){var e,t,n=Cn,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Cn=t);kn=e,zn(r)}(),Nn=0}}function Ln(){var e=Rn.now(),t=e-An;t>1e3&&(On-=t,An=e)}function zn(e){Sn||(In&&(In=clearTimeout(In)),e-Nn>24?(e<1/0&&(In=setTimeout(Fn,e-Rn.now()-On)),_n&&(_n=clearInterval(_n))):(_n||(An=Rn.now(),_n=setInterval(Ln,1e3)),Sn=1,Mn(Fn)))}function Bn(e,t,n){var r=new Dn;return t=null==t?0:+t,r.restart((n=>{r.stop(),e(n+t)}),t,n),r}Dn.prototype=jn.prototype={constructor:Dn,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Tn():+n)+(null==t?0:+t),this._next||kn===this||(kn?kn._next=this:Cn=this,kn=this),this._call=e,this._time=n,zn()},stop:function(){this._call&&(this._call=null,this._time=1/0,zn())}};var Vn=U("start","end","cancel","interrupt"),Gn=[];function Wn(e,t,n,r,o,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var r,o=e.__transition;function i(e){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var c,u,d,f;if(1!==n.state)return l();for(c in o)if((f=o[c]).name===n.name){if(3===f.state)return Bn(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete o[c]):+c<t&&(f.state=6,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete o[c])}if(Bn((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(f=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=f);r.length=u+1}}function s(t){for(var o=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=5,1),i=-1,a=r.length;++i<a;)r[i].call(e,o);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete o[t],o)return;delete e.__transition}o[t]=n,n.timer=jn(i,0,n.time)}(e,n,{name:t,index:r,group:o,on:Vn,tween:Gn,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:0})}function Hn(e,t){var n=$n(e,t);if(n.state>0)throw new Error("too late; already scheduled");return n}function Xn(e,t){var n=$n(e,t);if(n.state>3)throw new Error("too late; already running");return n}function $n(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Zn(e,t){var n,r,o,i=e.__transition,a=!0;if(i){for(o in t=null==t?null:t+"",i)(n=i[o]).name===t?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[o]):a=!1;a&&delete e.__transition}}function Yn(e,t){var n,r;return function(){var o=Xn(this,e),i=o.tween;if(i!==n)for(var a=0,s=(r=n=i).length;a<s;++a)if(r[a].name===t){(r=r.slice()).splice(a,1);break}o.tween=r}}function Un(e,t,n){var r,o;if("function"!=typeof n)throw new Error;return function(){var i=Xn(this,e),a=i.tween;if(a!==r){o=(r=a).slice();for(var s={name:t,value:n},l=0,c=o.length;l<c;++l)if(o[l].name===t){o[l]=s;break}l===c&&o.push(s)}i.tween=o}}function Jn(e,t,n){var r=e._id;return e.each((function(){var e=Xn(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return $n(e,r).value[t]}}function Kn(e,t){var n;return("number"==typeof t?un:t instanceof Wt?cn:(n=Wt(t))?(t=n,cn):pn)(e,t)}function qn(e){return function(){this.removeAttribute(e)}}function Qn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function er(e,t,n){var r,o,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===r?o:o=t(r=a,n)}}function tr(e,t,n){var r,o,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?o:o=t(r=a,n)}}function nr(e,t,n){var r,o,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttribute(e))===(s=l+"")?null:a===r&&s===o?i:(o=s,i=t(r=a,l));this.removeAttribute(e)}}function rr(e,t,n){var r,o,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttributeNS(e.space,e.local))===(s=l+"")?null:a===r&&s===o?i:(o=s,i=t(r=a,l));this.removeAttributeNS(e.space,e.local)}}function or(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,o)),n}return o._value=t,o}function ir(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,o)),n}return o._value=t,o}function ar(e,t){return function(){Hn(this,e).delay=+t.apply(this,arguments)}}function sr(e,t){return t=+t,function(){Hn(this,e).delay=t}}function lr(e,t){return function(){Xn(this,e).duration=+t.apply(this,arguments)}}function cr(e,t){return t=+t,function(){Xn(this,e).duration=t}}var ur=ut.prototype.constructor;function dr(e){return function(){this.style.removeProperty(e)}}var fr=0;function pr(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function hr(){return++fr}var mr=ut.prototype;pr.prototype={constructor:pr,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=ae(e));for(var r=this._groups,o=r.length,i=new Array(o),a=0;a<o;++a)for(var s,l,c=r[a],u=c.length,d=i[a]=new Array(u),f=0;f<u;++f)(s=c[f])&&(l=e.call(s,s.__data__,f,c))&&("__data__"in s&&(l.__data__=s.__data__),d[f]=l,Wn(d[f],t,n,f,d,$n(s,n)));return new pr(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=le(e));for(var r=this._groups,o=r.length,i=[],a=[],s=0;s<o;++s)for(var l,c=r[s],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var f,p=e.call(l,l.__data__,d,c),h=$n(l,n),m=0,g=p.length;m<g;++m)(f=p[m])&&Wn(f,t,n,m,p,h);i.push(p),a.push(l)}return new pr(i,a,t,n)},selectChild:mr.selectChild,selectChildren:mr.selectChildren,filter:function(e){"function"!=typeof e&&(e=ue(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i,a=t[o],s=a.length,l=r[o]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new pr(r,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),a=new Array(r),s=0;s<i;++s)for(var l,c=t[s],u=n[s],d=c.length,f=a[s]=new Array(d),p=0;p<d;++p)(l=c[p]||u[p])&&(f[p]=l);for(;s<r;++s)a[s]=t[s];return new pr(a,this._parents,this._name,this._id)},selection:function(){return new ur(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=hr(),r=this._groups,o=r.length,i=0;i<o;++i)for(var a,s=r[i],l=s.length,c=0;c<l;++c)if(a=s[c]){var u=$n(a,t);Wn(a,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new pr(r,this._parents,e,n)},call:mr.call,nodes:mr.nodes,node:mr.node,size:mr.size,empty:mr.empty,each:mr.each,on:function(e,t){var n=this._id;return arguments.length<2?$n(this.node(),n).on.on(e):this.each(function(e,t,n){var r,o,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?Hn:Xn;return function(){var a=i(this,e),s=a.on;s!==r&&(o=(r=s).copy()).on(t,n),a.on=o}}(n,e,t))},attr:function(e,t){var n=te(e),r="transform"===n?wn:Kn;return this.attrTween(e,"function"==typeof t?(n.local?rr:nr)(n,r,Jn(this,"attr."+e,t)):null==t?(n.local?Qn:qn)(n):(n.local?tr:er)(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var r=te(e);return this.tween(n,(r.local?or:ir)(r,t))},style:function(e,t,n){var r="transform"==(e+="")?vn:Kn;return null==t?this.styleTween(e,function(e,t){var n,r,o;return function(){var i=Te(this,e),a=(this.style.removeProperty(e),Te(this,e));return i===a?null:i===n&&a===r?o:o=t(n=i,r=a)}}(e,r)).on("end.style."+e,dr(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var r,o,i;return function(){var a=Te(this,e),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(e),l=s=Te(this,e)),a===l?null:a===r&&l===o?i:(o=l,i=t(r=a,s))}}(e,r,Jn(this,"style."+e,t))).each(function(e,t){var n,r,o,i,a="style."+t,s="end."+a;return function(){var l=Xn(this,e),c=l.on,u=null==l.value[a]?i||(i=dr(t)):void 0;c===n&&o===u||(r=(n=c).copy()).on(s,o=u),l.on=r}}(this._id,e)):this.styleTween(e,function(e,t,n){var r,o,i=n+"";return function(){var a=Te(this,e);return a===i?null:a===r?o:o=t(r=a,n)}}(e,r,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw new Error;return this.tween(r,function(e,t,n){var r,o;function i(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&function(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,i,n)),r}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(Jn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&function(e){return function(t){this.textContent=e.call(this,t)}}(r)),t}return r._value=e,r}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,o=$n(this.node(),n).tween,i=0,a=o.length;i<a;++i)if((r=o[i]).name===e)return r.value;return null}return this.each((null==t?Yn:Un)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?ar:sr)(t,e)):$n(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?lr:cr)(t,e)):$n(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){Xn(this,e).ease=t}}(t,e)):$n(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;Xn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,r=n._id,o=n.size();return new Promise((function(i,a){var s={value:a},l={value:function(){0==--o&&i()}};n.each((function(){var n=Xn(this,r),o=n.on;o!==e&&((t=(e=o).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),n.on=t})),0===o&&i()}))},[Symbol.iterator]:mr[Symbol.iterator]};var gr={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function yr(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}ut.prototype.interrupt=function(e){return this.each((function(){Zn(this,e)}))},ut.prototype.transition=function(e){var t,n;e instanceof pr?(t=e._id,e=e._name):(t=hr(),(n=gr).time=Tn(),e=null==e?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var a,s=r[i],l=s.length,c=0;c<l;++c)(a=s[c])&&Wn(a,e,t,c,s,n||yr(a,t));return new pr(r,this._parents,e,t)};var br=e=>()=>e;function vr(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function wr(e,t,n){this.k=e,this.x=t,this.y=n}wr.prototype={constructor:wr,scale:function(e){return 1===e?this:new wr(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new wr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xr=new wr(1,0,0);function Cr(e){e.stopImmediatePropagation()}function kr(e){e.preventDefault(),e.stopImmediatePropagation()}function Er(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Sr(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Ir(){return this.__zoom||xr}function _r(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ar(){return navigator.maxTouchPoints||"ontouchstart"in this}function Nr(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function Or(){var e,t,n,r=Er,o=Sr,i=Nr,a=_r,s=Ar,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=En,f=U("start","zoom","end"),p=0,h=10;function m(e){e.property("__zoom",Ir).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",S).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new wr(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,o=t[1]-n[1]*e.k;return r===e.x&&o===e.y?e:new wr(e.k,r,o)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function v(e,t,n,r){e.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,i=arguments,a=w(e,i).event(r),s=o.apply(e,i),l=null==n?b(s):"function"==typeof n?n.apply(e,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,f="function"==typeof t?t.apply(e,i):t,p=d(u.invert(l).concat(c/u.k),f.invert(l).concat(c/f.k));return function(e){if(1===e)e=f;else{var t=p(e),n=c/t[2];e=new wr(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function w(e,t,n){return!n&&e.__zooming||new x(e,t)}function x(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=o.apply(e,t),this.taps=0}function C(e,...t){if(r.apply(this,arguments)){var n=w(this,t).event(e),o=this.__zoom,s=Math.max(l[0],Math.min(l[1],o.k*Math.pow(2,a.apply(this,arguments)))),u=ft(e);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=o.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(o.k===s)return;n.mouse=[u,o.invert(u)],Zn(this),n.start()}kr(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",i(y(g(o,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function k(e,...t){if(!n&&r.apply(this,arguments)){var o=e.currentTarget,a=w(this,t,!0).event(e),s=dt(e.view).on("mousemove.zoom",(function(e){if(kr(e),!a.moved){var t=e.clientX-u,n=e.clientY-d;a.moved=t*t+n*n>p}a.event(e).zoom("mouse",i(y(a.that.__zoom,a.mouse[0]=ft(e,o),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),bt(e.view,a.moved),kr(e),a.event(e).end()}),!0),l=ft(e,o),u=e.clientX,d=e.clientY;yt(e.view),Cr(e),a.mouse=[l,this.__zoom.invert(l)],Zn(this),a.start()}}function E(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,a=ft(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),d=i(y(g(n,l),a,s),o.apply(this,t),c);kr(e),u>0?dt(this).transition().duration(u).call(v,d,a,e):dt(this).call(m.transform,d,a,e)}}function S(n,...o){if(r.apply(this,arguments)){var i,a,s,l,c=n.touches,u=c.length,d=w(this,o,n.changedTouches.length===u).event(n);for(Cr(n),a=0;a<u;++a)l=[l=ft(s=c[a],this),this.__zoom.invert(l),s.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),Zn(this),d.start())}}function I(e,...t){if(this.__zooming){var n,r,o,a,s=w(this,t).event(e),l=e.changedTouches,u=l.length;for(kr(e),n=0;n<u;++n)o=ft(r=l[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=o:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=o);if(r=s.that.__zoom,s.touch1){var d=s.touch0[0],f=s.touch0[1],p=s.touch1[0],h=s.touch1[1],m=(m=p[0]-d[0])*m+(m=p[1]-d[1])*m,b=(b=h[0]-f[0])*b+(b=h[1]-f[1])*b;r=g(r,Math.sqrt(m/b)),o=[(d[0]+p[0])/2,(d[1]+p[1])/2],a=[(f[0]+h[0])/2,(f[1]+h[1])/2]}else{if(!s.touch0)return;o=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(y(r,o,a),s.extent,c))}}function _(e,...r){if(this.__zooming){var o,i,a=w(this,r).event(e),s=e.changedTouches,l=s.length;for(Cr(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),o=0;o<l;++o)i=s[o],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=ft(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<h)){var c=dt(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var o=e.selection?e.selection():e;o.property("__zoom",Ir),e!==o?v(e,t,n,r):o.interrupt().each((function(){w(this,arguments).event(r).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},m.scaleBy=function(e,t,n,r){m.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,(function(){var e=o.apply(this,arguments),r=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(a),l="function"==typeof t?t.apply(this,arguments):t;return i(y(g(r,l),a,s),e,c)}),n,r)},m.translateBy=function(e,t,n,r){m.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),o.apply(this,arguments),c)}),null,r)},m.translateTo=function(e,t,n,r,a){m.transform(e,(function(){var e=o.apply(this,arguments),a=this.__zoom,s=null==r?b(e):"function"==typeof r?r.apply(this,arguments):r;return i(xr.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),r,a)},x.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=dt(this.that).datum();f.call(e,this.that,new vr(e,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:f}),t)}},m.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:br(+e),m):a},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:br(!!e),m):r},m.touchable=function(e){return arguments.length?(s="function"==typeof e?e:br(!!e),m):s},m.extent=function(e){return arguments.length?(o="function"==typeof e?e:br([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):o},m.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],m):[l[0],l[1]]},m.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],m):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},m.constrain=function(e){return arguments.length?(i=e,m):i},m.duration=function(e){return arguments.length?(u=+e,m):u},m.interpolate=function(e){return arguments.length?(d=e,m):d},m.on=function(){var e=f.on.apply(f,arguments);return e===f?m:e},m.clickDistance=function(e){return arguments.length?(p=(e=+e)*e,m):Math.sqrt(p)},m.tapDistance=function(e){return arguments.length?(h=+e,m):h},m}wr.prototype;const Rr=e.createContext(null),Mr=Rr.Provider,Tr=()=>"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.",Pr=e=>`Node type "${e}" not found. Using fallback type "default".`,Dr=()=>"The React Flow parent container needs a width and a height to render the graph.",jr=()=>"Only child nodes can use a parent extent.",Fr=()=>"Can't create edge. An edge needs a source and a target.",Lr=e=>`Marker type "${e}" doesn't exist.`,zr=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,Br=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",Vr=e=>`Edge type "${e}" not found. Using fallback type "default".`,Gr=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,Wr=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function Hr(t,n){const r=e.useContext(Rr);if(null===r)throw new Error(Wr);return X(r,t,n)}const Xr=()=>{const t=e.useContext(Rr);if(null===t)throw new Error(Wr);return e.useMemo((()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy})),[t])},$r=e=>e.userSelectionActive?"none":"all";function Zr({position:t,children:n,className:r,style:o,...i}){const a=Hr($r),s=`${t}`.split("-");return e.createElement("div",{className:V(["react-flow__panel",r,...s]),style:{...o,pointerEvents:a},...i},n)}function Yr({proOptions:t,position:n="bottom-right"}){return t?.hideAttribution?null:e.createElement(Zr,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},e.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var Ur=e.memo((({x:t,y:n,label:r,labelStyle:o={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d})=>{const f=e.useRef(null),[p,h]=e.useState({x:0,y:0,width:0,height:0}),m=V(["react-flow__edge-textwrapper",u]);return e.useEffect((()=>{if(f.current){const e=f.current.getBBox();h({x:e.x,y:e.y,width:e.width,height:e.height})}}),[r]),void 0!==r&&r?e.createElement("g",{transform:`translate(${t-p.width/2} ${n-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...d},i&&e.createElement("rect",{width:p.width+2*s[0],x:-s[0],y:-s[1],height:p.height+2*s[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),e.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:o},r),c):null}));const Jr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Kr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),qr=(e={x:0,y:0},t)=>({x:Kr(e.x,t[0][0],t[1][0]),y:Kr(e.y,t[0][1],t[1][1])}),Qr=(e,t,n)=>e<t?Kr(Math.abs(e-t),1,50)/50:e>n?-Kr(Math.abs(e-n),1,50)/50:0,eo=(e,t)=>[20*Qr(e.x,35,t.width-35),20*Qr(e.y,35,t.height-35)],to=e=>e.getRootNode?.()||window?.document,no=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),ro=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),oo=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),io=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ao=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},so=e=>!isNaN(e)&&isFinite(e),lo=Symbol.for("internals"),co=["Enter"," ","Escape"],uo=(e,t)=>{"development"===process.env.NODE_ENV&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)};function fo(e){const t=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,n=t.composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const po=e=>"clientX"in e,ho=(e,t)=>{const n=po(e),r=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:o-(t?.top??0)}},mo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0,go=({id:t,path:n,labelX:r,labelY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h=20})=>e.createElement(e.Fragment,null,e.createElement("path",{id:t,style:d,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:p}),h&&e.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),i&&so(r)&&so(o)?e.createElement(Ur,{x:r,y:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u}):null);function yo(e,t,n){return void 0===n?n:r=>{const o=t().edges.find((t=>t.id===e));o&&n(r,{...o})}}function bo({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(r-t)/2;return[i,r<t?r+a:r-a,o,a]}function vo({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:s}){const l=.125*e+.375*o+.375*a+.125*n,c=.125*t+.375*i+.375*s+.125*r;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var wo,xo,Co,ko,Eo,So;function Io({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===So.Left||e===So.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function _o({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top}){const[a,s]=Io({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,c]=Io({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,p]=vo({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:s,targetControlX:l,targetControlY:c});return[`M${e},${t} C${a},${s} ${l},${c} ${r},${o}`,u,d,f,p]}go.displayName="BaseEdge",function(e){e.Strict="strict",e.Loose="loose"}(wo||(wo={})),function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"}(xo||(xo={})),function(e){e.Partial="partial",e.Full="full"}(Co||(Co={})),function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"}(ko||(ko={})),function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"}(Eo||(Eo={})),function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"}(So||(So={}));const Ao=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i=So.Bottom,targetPosition:a=So.Top,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:g})=>{const[y,b,v]=_o({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a});return e.createElement(go,{path:y,labelX:b,labelY:v,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:g})}));Ao.displayName="SimpleBezierEdge";const No={[So.Left]:{x:-1,y:0},[So.Right]:{x:1,y:0},[So.Top]:{x:0,y:-1},[So.Bottom]:{x:0,y:1}},Oo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ro({source:e,sourcePosition:t=So.Bottom,target:n,targetPosition:r=So.Top,center:o,offset:i}){const a=No[t],s=No[r],l={x:e.x+a.x*i,y:e.y+a.y*i},c={x:n.x+s.x*i,y:n.y+s.y*i},u=(({source:e,sourcePosition:t=So.Bottom,target:n})=>t===So.Left||t===So.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),d=0!==u.x?"x":"y",f=u[d];let p,h,m=[];const g={x:0,y:0},y={x:0,y:0},[b,v,w,x]=bo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*s[d]==-1){p=o.x??b,h=o.y??v;const e=[{x:p,y:l.y},{x:p,y:c.y}],t=[{x:l.x,y:h},{x:c.x,y:h}];m=a[d]===f?"x"===d?e:t:"x"===d?t:e}else{const o=[{x:l.x,y:c.y}],u=[{x:c.x,y:l.y}];if(m="x"===d?a.x===f?u:o:a.y===f?o:u,t===r){const t=Math.abs(e[d]-n[d]);if(t<=i){const r=Math.min(i-1,i-t);a[d]===f?g[d]=(l[d]>e[d]?-1:1)*r:y[d]=(c[d]>n[d]?-1:1)*r}}if(t!==r){const e="x"===d?"y":"x",t=a[d]===s[e],n=l[e]>c[e],r=l[e]<c[e];(1===a[d]&&(!t&&n||t&&r)||1!==a[d]&&(!t&&r||t&&n))&&(m="x"===d?o:u)}const b={x:l.x+g.x,y:l.y+g.y},v={x:c.x+y.x,y:c.y+y.y};Math.max(Math.abs(b.x-m[0].x),Math.abs(v.x-m[0].x))>=Math.max(Math.abs(b.y-m[0].y),Math.abs(v.y-m[0].y))?(p=(b.x+v.x)/2,h=m[0].y):(p=m[0].x,h=(b.y+v.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...m,{x:c.x+y.x,y:c.y+y.y},n],p,h,w,x]}function Mo({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top,borderRadius:a=5,centerX:s,centerY:l,offset:c=20}){const[u,d,f,p,h]=Ro({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:s,y:l},offset:c}),m=u.reduce(((e,t,n)=>{let r="";return r=n>0&&n<u.length-1?function(e,t,n,r){const o=Math.min(Oo(e,t)/2,Oo(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+o*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+o*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+o*(e.y<n.y?-1:1)}Q ${i},${a} ${i+o*s},${a}`}(u[n-1],t,u[n+1],a):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=r}),"");return[m,d,f,p,h]}const To=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,sourcePosition:f=So.Bottom,targetPosition:p=So.Top,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,v,w]=Mo({sourceX:t,sourceY:n,sourcePosition:f,targetX:r,targetY:o,targetPosition:p,borderRadius:g?.borderRadius,offset:g?.offset});return e.createElement(go,{path:b,labelX:v,labelY:w,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:h,markerStart:m,interactionWidth:y})}));To.displayName="SmoothStepEdge";const Po=e.memo((t=>e.createElement(To,{...t,pathOptions:e.useMemo((()=>({borderRadius:0,offset:t.pathOptions?.offset})),[t.pathOptions?.offset])})));Po.displayName="StepEdge";const Do=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h})=>{const[m,g,y]=function({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,a,s]=bo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,a,s]}({sourceX:t,sourceY:n,targetX:r,targetY:o});return e.createElement(go,{path:m,labelX:g,labelY:y,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:u,style:d,markerEnd:f,markerStart:p,interactionWidth:h})}));function jo(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function Fo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case So.Left:return[t-jo(t-r,i),n];case So.Right:return[t+jo(r-t,i),n];case So.Top:return[t,n-jo(n-o,i)];case So.Bottom:return[t,n+jo(o-n,i)]}}function Lo({sourceX:e,sourceY:t,sourcePosition:n=So.Bottom,targetX:r,targetY:o,targetPosition:i=So.Top,curvature:a=.25}){const[s,l]=Fo({pos:n,x1:e,y1:t,x2:r,y2:o,c:a}),[c,u]=Fo({pos:i,x1:r,y1:o,x2:e,y2:t,c:a}),[d,f,p,h]=vo({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${l} ${c},${u} ${r},${o}`,d,f,p,h]}Do.displayName="StraightEdge";const zo=e.memo((({sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i=So.Bottom,targetPosition:a=So.Top,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,v,w]=Lo({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a,curvature:g?.curvature});return e.createElement(go,{path:b,labelX:v,labelY:w,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:m,interactionWidth:y})}));zo.displayName="BezierEdge";const Bo=e.createContext(null),Vo=Bo.Provider;Bo.Consumer;const Go=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Wo=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},Ho=({x:e,y:t},[n,r,o],i,[a,s])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?{x:a*Math.round(l.x/a),y:s*Math.round(l.y/s)}:l},Xo=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),$o=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},Zo=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const{x:r,y:o}=$o(n,t).positionAbsolute;return no(e,ro({x:r,y:o,width:n.width||0,height:n.height||0}))}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return oo(n)},Yo=(e,t,[n,r,o]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const l={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:r=!0,hidden:o=!1}=e;if(a&&!r||o)return!1;const{positionAbsolute:u}=$o(e,s),d={x:u.x,y:u.y,width:t||0,height:n||0},f=ao(l,d);(void 0===t||void 0===n||null===t||null===n||i&&f>0||f>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},Uo=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},Jo=(e,t,n,r,o,i=.1)=>{const a=t/(e.width*(1+i)),s=n/(e.height*(1+i)),l=Math.min(a,s),c=Kr(l,r,o);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Ko=(e,t=0)=>e.transition().duration(t);function qo(e,t,n,r){return(t[n]||[]).reduce(((t,o)=>(`${e.id}-${o.id}-${n}`!==r&&t.push({id:o.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+o.x+o.width/2,y:(e.positionAbsolute?.y??0)+o.y+o.height/2}),t)),[])}const Qo={source:null,target:null,sourceHandle:null,targetHandle:null},ei=()=>({handleDomNode:null,isValid:!1,connection:Qo,endHandle:null});function ti(e,t,n,r,o,i,a){const s="target"===o,l=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),c={...ei(),handleDomNode:l};if(l){const e=ni(void 0,l),o=l.getAttribute("data-nodeid"),a=l.getAttribute("data-handleid"),u=l.classList.contains("connectable"),d=l.classList.contains("connectableend"),f={source:s?o:n,sourceHandle:s?a:r,target:s?n:o,targetHandle:s?r:a};c.connection=f;u&&d&&(t===wo.Strict?s&&"source"===e||!s&&"target"===e:o!==n||a!==r)&&(c.endHandle={nodeId:o,handleId:a,type:e},c.isValid=i(f))}return c}function ni(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ri(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function oi(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function ii({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:i,setState:a,isValidConnection:s,edgeUpdaterType:l,onReconnectEnd:c}){const u=to(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:p,connectionRadius:h,onConnectStart:m,panBy:g,getNodes:y,cancelConnection:b}=i();let v,w=0;const{x:x,y:C}=ho(e),k=u?.elementFromPoint(x,C),E=ni(l,k),S=f?.getBoundingClientRect();if(!S||!E)return;let I,_=ho(e,S),A=!1,N=null,O=!1,R=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce(((e,o)=>{if(o[lo]){const{handleBounds:i}=o[lo];let a=[],s=[];i&&(a=qo(o,i,"source",`${t}-${n}-${r}`),s=qo(o,i,"target",`${t}-${n}-${r}`)),e.push(...a,...s)}return e}),[])}({nodes:y(),nodeId:n,handleId:t,handleType:E}),T=()=>{if(!p)return;const[e,t]=eo(_,S);g({x:e,y:t}),w=requestAnimationFrame(T)};function P(e){const{transform:r}=i();_=ho(e,S);const{handle:l,validHandleResult:c}=function(e,t,n,r,o,i){const{x:a,y:s}=ho(e),l=t.elementsFromPoint(a,s).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=ni(void 0,l),r=l.getAttribute("data-handleid"),a=i({nodeId:e,id:r,type:t});if(a){const i=o.find((n=>n.nodeId===e&&n.type===t&&n.id===r));return{handle:{id:r,type:t,nodeId:e,x:i?.x||n.x,y:i?.y||n.y},validHandleResult:a}}}}let c=[],u=1/0;if(o.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){const n=i(e);t<=u&&(t<u?c=[{handle:e,validHandleResult:n}]:t===u&&c.push({handle:e,validHandleResult:n}),u=t)}})),!c.length)return{handle:null,validHandleResult:ei()};if(1===c.length)return c[0];const d=c.some((({validHandleResult:e})=>e.isValid)),f=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>f?"target"===e.type:!d||t.isValid))||c[0]}(e,u,Ho(_,r,!1,[1,1]),h,M,(e=>ti(e,d,n,t,o?"target":"source",s,u)));if(v=l,A||(T(),A=!0),R=c.handleDomNode,N=c.connection,O=c.isValid,a({connectionPosition:v&&O?Xo({x:v.x,y:v.y},r):_,connectionStatus:oi(!!v,O),connectionEndHandle:c.endHandle}),!v&&!O&&!R)return ri(I);N.source!==N.target&&R&&(ri(I),I=R,R.classList.add("connecting","react-flow__handle-connecting"),R.classList.toggle("valid",O),R.classList.toggle("react-flow__handle-valid",O))}function D(e){(v||R)&&N&&O&&r?.(N),i().onConnectEnd?.(e),l&&c?.(e),ri(I),b(),cancelAnimationFrame(w),A=!1,O=!1,N=null,R=null,u.removeEventListener("mousemove",P),u.removeEventListener("mouseup",D),u.removeEventListener("touchmove",P),u.removeEventListener("touchend",D)}a({connectionPosition:_,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:E,connectionStartHandle:{nodeId:n,handleId:t,type:E},connectionEndHandle:null}),m?.(e,{nodeId:n,handleId:t,handleType:E}),u.addEventListener("mousemove",P),u.addEventListener("mouseup",D),u.addEventListener("touchmove",P),u.addEventListener("touchend",D)}const ai=()=>!0,si=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),li=e.forwardRef((({type:t="source",position:n=So.Top,isValidConnection:r,isConnectable:o=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:s,onConnect:l,children:c,className:u,onMouseDown:d,onTouchStart:f,...p},h)=>{const m=s||null,g="target"===t,y=Xr(),b=e.useContext(Bo),{connectOnClick:v,noPanClassName:w}=Hr(si,Z),{connecting:x,clickConnecting:C}=Hr(((e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:i,connectionClickStartHandle:a}=r;return{connecting:o?.nodeId===e&&o?.handleId===t&&o?.type===n||i?.nodeId===e&&i?.handleId===t&&i?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}})(b,m,t),Z);b||y.getState().onError?.("010",Br());const k=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=y.getState(),o={...t,...e};if(r){const{edges:e,setEdges:t}=y.getState();t(((e,t)=>{if(!e.source||!e.target)return uo("006",Fr()),t;let n;return n=(e=>"id"in e&&"source"in e&&"target"in e)(e)?{...e}:{...e,id:Go(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(o,e))}n?.(o),l?.(o)},E=e=>{if(!b)return;const t=po(e);i&&(t&&0===e.button||!t)&&ii({event:e,handleId:m,nodeId:b,onConnect:k,isTarget:g,getState:y.getState,setState:y.setState,isValidConnection:r||y.getState().isValidConnection||ai}),t?d?.(e):f?.(e)};return e.createElement("div",{"data-handleid":m,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${m}-${t}`,className:V(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",w,u,{source:!g,target:g,connectable:o,connectablestart:i,connectableend:a,connecting:C,connectionindicator:o&&(i&&!x||a&&x)}]),onMouseDown:E,onTouchStart:E,onClick:v?e=>{const{onClickConnectStart:n,onClickConnectEnd:o,connectionClickStartHandle:a,connectionMode:s,isValidConnection:l}=y.getState();if(!b||!a&&!i)return;if(!a)return n?.(e,{nodeId:b,handleId:m,handleType:t}),void y.setState({connectionClickStartHandle:{nodeId:b,type:t,handleId:m}});const c=to(e.target),u=r||l||ai,{connection:d,isValid:f}=ti({nodeId:b,id:m,type:t},s,a.nodeId,a.handleId||null,a.type,u,c);f&&k(d),o?.(e),y.setState({connectionClickStartHandle:null})}:void 0,ref:h,...p},c)}));li.displayName="Handle";var ci=e.memo(li);const ui=({data:t,isConnectable:n,targetPosition:r=So.Top,sourcePosition:o=So.Bottom})=>e.createElement(e.Fragment,null,e.createElement(ci,{type:"target",position:r,isConnectable:n}),t?.label,e.createElement(ci,{type:"source",position:o,isConnectable:n}));ui.displayName="DefaultNode";var di=e.memo(ui);const fi=({data:t,isConnectable:n,sourcePosition:r=So.Bottom})=>e.createElement(e.Fragment,null,t?.label,e.createElement(ci,{type:"source",position:r,isConnectable:n}));fi.displayName="InputNode";var pi=e.memo(fi);const hi=({data:t,isConnectable:n,targetPosition:r=So.Top})=>e.createElement(e.Fragment,null,e.createElement(ci,{type:"target",position:r,isConnectable:n}),t?.label);hi.displayName="OutputNode";var mi=e.memo(hi);const gi=()=>null;gi.displayName="GroupNode";const yi=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),bi=e=>e.id;function vi(e,t){return Z(e.selectedNodes.map(bi),t.selectedNodes.map(bi))&&Z(e.selectedEdges.map(bi),t.selectedEdges.map(bi))}const wi=e.memo((({onSelectionChange:t})=>{const n=Xr(),{selectedNodes:r,selectedEdges:o}=Hr(yi,vi);return e.useEffect((()=>{const e={nodes:r,edges:o};t?.(e),n.getState().onSelectionChange.forEach((t=>t(e)))}),[r,o,t]),null}));wi.displayName="SelectionListener";const xi=e=>!!e.onSelectionChange;function Ci({onSelectionChange:t}){const n=Hr(xi);return t||n?e.createElement(wi,{onSelectionChange:t}):null}const ki=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Ei(t,n){e.useEffect((()=>{void 0!==t&&n(t)}),[t])}function Si(t,n,r){e.useEffect((()=>{void 0!==n&&r({[t]:n})}),[n])}const Ii=({nodes:t,edges:n,defaultNodes:r,defaultEdges:o,onConnect:i,onConnectStart:a,onConnectEnd:s,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:u,nodesConnectable:d,nodesFocusable:f,edgesFocusable:p,edgesUpdatable:h,elevateNodesOnSelect:m,minZoom:g,maxZoom:y,nodeExtent:b,onNodesChange:v,onEdgesChange:w,elementsSelectable:x,connectionMode:C,snapGrid:k,snapToGrid:E,translateExtent:S,connectOnClick:I,defaultEdgeOptions:_,fitView:A,fitViewOptions:N,onNodesDelete:O,onEdgesDelete:R,onNodeDrag:M,onNodeDragStart:T,onNodeDragStop:P,onSelectionDrag:D,onSelectionDragStart:j,onSelectionDragStop:F,noPanClassName:L,nodeOrigin:z,rfId:B,autoPanOnConnect:V,autoPanOnNodeDrag:G,onError:W,connectionRadius:H,isValidConnection:X,nodeDragThreshold:$})=>{const{setNodes:Y,setEdges:U,setDefaultNodesAndEdges:J,setMinZoom:K,setMaxZoom:q,setTranslateExtent:Q,setNodeExtent:ee,reset:te}=Hr(ki,Z),ne=Xr();return e.useEffect((()=>{const e=o?.map((e=>({...e,..._})));return J(r,e),()=>{te()}}),[]),Si("defaultEdgeOptions",_,ne.setState),Si("connectionMode",C,ne.setState),Si("onConnect",i,ne.setState),Si("onConnectStart",a,ne.setState),Si("onConnectEnd",s,ne.setState),Si("onClickConnectStart",l,ne.setState),Si("onClickConnectEnd",c,ne.setState),Si("nodesDraggable",u,ne.setState),Si("nodesConnectable",d,ne.setState),Si("nodesFocusable",f,ne.setState),Si("edgesFocusable",p,ne.setState),Si("edgesUpdatable",h,ne.setState),Si("elementsSelectable",x,ne.setState),Si("elevateNodesOnSelect",m,ne.setState),Si("snapToGrid",E,ne.setState),Si("snapGrid",k,ne.setState),Si("onNodesChange",v,ne.setState),Si("onEdgesChange",w,ne.setState),Si("connectOnClick",I,ne.setState),Si("fitViewOnInit",A,ne.setState),Si("fitViewOnInitOptions",N,ne.setState),Si("onNodesDelete",O,ne.setState),Si("onEdgesDelete",R,ne.setState),Si("onNodeDrag",M,ne.setState),Si("onNodeDragStart",T,ne.setState),Si("onNodeDragStop",P,ne.setState),Si("onSelectionDrag",D,ne.setState),Si("onSelectionDragStart",j,ne.setState),Si("onSelectionDragStop",F,ne.setState),Si("noPanClassName",L,ne.setState),Si("nodeOrigin",z,ne.setState),Si("rfId",B,ne.setState),Si("autoPanOnConnect",V,ne.setState),Si("autoPanOnNodeDrag",G,ne.setState),Si("onError",W,ne.setState),Si("connectionRadius",H,ne.setState),Si("isValidConnection",X,ne.setState),Si("nodeDragThreshold",$,ne.setState),Ei(t,Y),Ei(n,U),Ei(g,K),Ei(y,q),Ei(S,Q),Ei(b,ee),null},_i={display:"none"},Ai={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ni="react-flow__node-desc",Oi="react-flow__edge-desc",Ri=e=>e.ariaLiveMessage;function Mi({rfId:t}){const n=Hr(Ri);return e.createElement("div",{id:`react-flow__aria-live-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Ai},n)}function Ti({rfId:t,disableKeyboardA11y:n}){return e.createElement(e.Fragment,null,e.createElement("div",{id:`${Ni}-${t}`,style:_i},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),e.createElement("div",{id:`${Oi}-${t}`,style:_i},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&e.createElement(Mi,{rfId:t}))}var Pi=(t=null,n={actInsideInputWithModifier:!0})=>{const[r,o]=e.useState(!1),i=e.useRef(!1),a=e.useRef(new Set([])),[s,l]=e.useMemo((()=>{if(null!==t){const e=(Array.isArray(t)?t:[t]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=e.reduce(((e,t)=>e.concat(...t)),[]);return[e,n]}return[[],[]]}),[t]);return e.useEffect((()=>{const e="undefined"!=typeof document?document:null,r=n?.target||e;if(null!==t){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!n.actInsideInputWithModifier)&&fo(e))return!1;const t=ji(e.code,l);a.current.add(e[t]),Di(s,a.current,!1)&&(e.preventDefault(),o(!0))},t=e=>{if((!i.current||i.current&&!n.actInsideInputWithModifier)&&fo(e))return!1;const t=ji(e.code,l);Di(s,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(e[t]),"Meta"===e.key&&a.current.clear(),i.current=!1},c=()=>{a.current.clear(),o(!1)};return r?.addEventListener("keydown",e),r?.addEventListener("keyup",t),window.addEventListener("blur",c),()=>{r?.removeEventListener("keydown",e),r?.removeEventListener("keyup",t),window.removeEventListener("blur",c)}}}),[t,o]),r};function Di(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function ji(e,t){return t.includes(e)?"code":"key"}function Fi(e,t,n,r){const o=e.parentNode||e.parentId;if(!o)return n;const i=t.get(o),a=$o(i,r);return Fi(i,t,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(i[lo]?.z??0)>(n.z??0)?i[lo]?.z??0:n.z??0},r)}function Li(e,t,n){e.forEach((r=>{const o=r.parentNode||r.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||n?.[r.id]){const{x:o,y:i,z:a}=Fi(r,e,{...r.position,z:r[lo]?.z??0},t);r.positionAbsolute={x:o,y:i},r[lo].z=a,n?.[r.id]&&(r[lo].isParent=!0)}}))}function zi(e,t,n,r){const o=new Map,i={},a=r?1e3:0;return e.forEach((e=>{const n=(so(e.zIndex)?e.zIndex:0)+(e.selected?a:0),r=t.get(e.id),s={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},l=e.parentNode||e.parentId;l&&(i[l]=!0);const c=r?.type&&r?.type!==e.type;Object.defineProperty(s,lo,{enumerable:!1,value:{handleBounds:c?void 0:r?.[lo]?.handleBounds,z:n}}),o.set(e.id,s)})),Li(o,n,i),o}function Bi(e,t={}){const{getNodes:n,width:r,height:o,minZoom:i,maxZoom:a,d3Zoom:s,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!c&&u;if(s&&l&&(f||!t.initial)){const e=n().filter((e=>{const n=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return t.nodes?.length?n&&t.nodes.some((t=>t.id===e.id)):n})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=Zo(e,d),{x:c,y:u,zoom:f}=Jo(n,r,o,t.minZoom??i,t.maxZoom??a,t.padding??.1),p=xr.translate(c,u).scale(f);return"number"==typeof t.duration&&t.duration>0?s.transform(Ko(l,t.duration),p):s.transform(l,p),!0}}return!1}function Vi(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[lo]:n[lo],selected:e.selected})})),new Map(t)}function Gi(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function Wi({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:i,onNodesChange:a,onEdgesChange:s,hasDefaultNodes:l,hasDefaultEdges:c}=n();e?.length&&(l&&r({nodeInternals:Vi(e,o)}),a?.(e)),t?.length&&(c&&r({edges:Gi(t,i)}),s?.(t))}const Hi=()=>{},Xi={zoomIn:Hi,zoomOut:Hi,zoomTo:Hi,getZoom:()=>1,setViewport:Hi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Hi,fitBounds:Hi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},$i=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function Zi(){const t=(()=>{const t=Xr(),{d3Zoom:n,d3Selection:r}=Hr($i,Z),o=e.useMemo((()=>r&&n?{zoomIn:e=>n.scaleBy(Ko(r,e?.duration),1.2),zoomOut:e=>n.scaleBy(Ko(r,e?.duration),1/1.2),zoomTo:(e,t)=>n.scaleTo(Ko(r,t?.duration),e),getZoom:()=>t.getState().transform[2],setViewport:(e,o)=>{const[i,a,s]=t.getState().transform,l=xr.translate(e.x??i,e.y??a).scale(e.zoom??s);n.transform(Ko(r,o?.duration),l)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},fitView:e=>Bi(t.getState,e),setCenter:(e,o,i)=>{const{width:a,height:s,maxZoom:l}=t.getState(),c=void 0!==i?.zoom?i.zoom:l,u=a/2-e*c,d=s/2-o*c,f=xr.translate(u,d).scale(c);n.transform(Ko(r,i?.duration),f)},fitBounds:(e,o)=>{const{width:i,height:a,minZoom:s,maxZoom:l}=t.getState(),{x:c,y:u,zoom:d}=Jo(e,i,a,s,l,o?.padding??.1),f=xr.translate(c,u).scale(d);n.transform(Ko(r,o?.duration),f)},project:e=>{const{transform:n,snapToGrid:r,snapGrid:o}=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"),Ho(e,n,r,o)},screenToFlowPosition:e=>{const{transform:n,snapToGrid:r,snapGrid:o,domNode:i}=t.getState();if(!i)return e;const{x:a,y:s}=i.getBoundingClientRect(),l={x:e.x-a,y:e.y-s};return Ho(l,n,r,o)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:o,y:i}=r.getBoundingClientRect(),a=Xo(e,n);return{x:a.x+o,y:a.y+i}},viewportInitialized:!0}:Xi),[n,r]);return o})(),n=Xr(),r=e.useCallback((()=>n.getState().getNodes().map((e=>({...e})))),[]),o=e.useCallback((e=>n.getState().nodeInternals.get(e)),[]),i=e.useCallback((()=>{const{edges:e=[]}=n.getState();return e.map((e=>({...e})))}),[]),a=e.useCallback((e=>{const{edges:t=[]}=n.getState();return t.find((t=>t.id===e))}),[]),s=e.useCallback((e=>{const{getNodes:t,setNodes:r,hasDefaultNodes:o,onNodesChange:i}=n.getState(),a=t(),s="function"==typeof e?e(a):e;if(o)r(s);else if(i){const e=0===s.length?a.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"})));i(e)}}),[]),l=e.useCallback((e=>{const{edges:t=[],setEdges:r,hasDefaultEdges:o,onEdgesChange:i}=n.getState(),a="function"==typeof e?e(t):e;if(o)r(a);else if(i){i(0===a.length?t.map((e=>({type:"remove",id:e.id}))):a.map((e=>({item:e,type:"reset"}))))}}),[]),c=e.useCallback((e=>{const t=Array.isArray(e)?e:[e],{getNodes:r,setNodes:o,hasDefaultNodes:i,onNodesChange:a}=n.getState();if(i){o([...r(),...t])}else if(a){const e=t.map((e=>({item:e,type:"add"})));a(e)}}),[]),u=e.useCallback((e=>{const t=Array.isArray(e)?e:[e],{edges:r=[],setEdges:o,hasDefaultEdges:i,onEdgesChange:a}=n.getState();if(i)o([...r,...t]);else if(a){a(t.map((e=>({item:e,type:"add"}))))}}),[]),d=e.useCallback((()=>{const{getNodes:e,edges:t=[],transform:r}=n.getState(),[o,i,a]=r;return{nodes:e().map((e=>({...e}))),edges:t.map((e=>({...e}))),viewport:{x:o,y:i,zoom:a}}}),[]),f=e.useCallback((({nodes:e,edges:t})=>{const{nodeInternals:r,getNodes:o,edges:i,hasDefaultNodes:a,hasDefaultEdges:s,onNodesDelete:l,onEdgesDelete:c,onNodesChange:u,onEdgesChange:d}=n.getState(),f=(e||[]).map((e=>e.id)),p=(t||[]).map((e=>e.id)),h=o().reduce(((e,t)=>{const n=t.parentNode||t.parentId,r=!f.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(f.includes(t.id)||r)&&e.push(t),e}),[]),m=i.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=m.filter((e=>p.includes(e.id)));if(h||g){const e=Uo(h,m),t=[...g,...e],o=t.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((s||a)&&(s&&n.setState({edges:i.filter((e=>!o.includes(e.id)))}),a&&(h.forEach((e=>{r.delete(e.id)})),n.setState({nodeInternals:new Map(r)}))),o.length>0&&(c?.(t),d&&d(o.map((e=>({id:e,type:"remove"}))))),h.length>0&&(l?.(h),u)){u(h.map((e=>({id:e.id,type:"remove"}))))}}}),[]),p=e.useCallback((e=>{const t=so((r=e).width)&&so(r.height)&&so(r.x)&&so(r.y);var r;const o=t?null:n.getState().nodeInternals.get(e.id);if(!t&&!o)return[null,null,t];return[t?e:io(o),o,t]}),[]),h=e.useCallback(((e,t=!0,r)=>{const[o,i,a]=p(e);return o?(r||n.getState().getNodes()).filter((e=>{if(!(a||e.id!==i.id&&e.positionAbsolute))return!1;const n=io(e),r=ao(n,o);return t&&r>0||r>=o.width*o.height})):[]}),[]),m=e.useCallback(((e,t,n=!0)=>{const[r]=p(e);if(!r)return!1;const o=ao(r,t);return n&&o>0||o>=r.width*r.height}),[]);return e.useMemo((()=>({...t,getNodes:r,getNode:o,getEdges:i,getEdge:a,setNodes:s,setEdges:l,addNodes:c,addEdges:u,toObject:d,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:m})),[t,r,o,i,a,s,l,c,u,d,f,h,m])}const Yi={actInsideInputWithModifier:!1};const Ui={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ji=e=>({x:e.x,y:e.y,zoom:e.k}),Ki=(e,t)=>e.target.closest(`.${t}`),qi=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Qi=e=>{const t=e.ctrlKey&&mo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},ea=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),ta=({onMove:t,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:o,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:s=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=xo.Free,zoomOnDoubleClick:u=!0,elementsSelectable:d,panOnDrag:f=!0,defaultViewport:p,translateExtent:h,minZoom:m,maxZoom:g,zoomActivationKeyCode:y,preventScrolling:b=!0,children:v,noWheelClassName:w,noPanClassName:x})=>{const C=e.useRef(),k=Xr(),E=e.useRef(!1),S=e.useRef(!1),I=e.useRef(null),_=e.useRef({x:0,y:0,zoom:0}),{d3Zoom:A,d3Selection:N,d3ZoomHandler:O,userSelectionActive:R}=Hr(ea,Z),M=Pi(y),T=e.useRef(0),P=e.useRef(!1),D=e.useRef();return function(t){const n=Xr();e.useEffect((()=>{let e;const r=()=>{if(!t.current)return;const e=Jr(t.current);0!==e.height&&0!==e.width||n.getState().onError?.("004",Dr()),n.setState({width:e.width||500,height:e.height||500})};return r(),window.addEventListener("resize",r),t.current&&(e=new ResizeObserver((()=>r())),e.observe(t.current)),()=>{window.removeEventListener("resize",r),e&&t.current&&e.unobserve(t.current)}}),[])}(I),e.useEffect((()=>{if(I.current){const e=I.current.getBoundingClientRect(),t=Or().scaleExtent([m,g]).translateExtent(h),n=dt(I.current).call(t),r=xr.translate(p.x,p.y).scale(Kr(p.zoom,m,g)),o=[[0,0],[e.width,e.height]],i=t.constrain()(r,o,h);t.transform(n,i),t.wheelDelta(Qi),k.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[i.x,i.y,i.k],domNode:I.current.closest(".react-flow")})}}),[]),e.useEffect((()=>{N&&A&&(!s||M||R?void 0!==O&&N.on("wheel.zoom",(function(e,t){if(!b&&"wheel"===e.type&&!e.ctrlKey||Ki(e,w))return null;e.preventDefault(),O.call(this,e,t)}),{passive:!1}):N.on("wheel.zoom",(e=>{if(Ki(e,w))return!1;e.preventDefault(),e.stopImmediatePropagation();const o=N.property("__zoom").k||1;if(e.ctrlKey&&a){const t=ft(e),n=Qi(e),r=o*Math.pow(2,n);return void A.scaleTo(N,r,t,e)}const i=1===e.deltaMode?20:1;let s=c===xo.Vertical?0:e.deltaX*i,u=c===xo.Horizontal?0:e.deltaY*i;!mo()&&e.shiftKey&&c!==xo.Vertical&&(s=e.deltaY*i,u=0),A.translateBy(N,-s/o*l,-u/o*l,{internal:!0});const d=Ji(N.property("__zoom")),{onViewportChangeStart:f,onViewportChange:p,onViewportChangeEnd:h}=k.getState();clearTimeout(D.current),P.current||(P.current=!0,n?.(e,d),f?.(d)),P.current&&(t?.(e,d),p?.(d),D.current=setTimeout((()=>{r?.(e,d),h?.(d),P.current=!1}),150))}),{passive:!1}))}),[R,s,c,N,A,O,M,a,b,w,n,t,r]),e.useEffect((()=>{A&&A.on("start",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;T.current=e.sourceEvent?.button;const{onViewportChangeStart:t}=k.getState(),r=Ji(e.transform);E.current=!0,_.current=r,"mousedown"===e.sourceEvent?.type&&k.setState({paneDragging:!0}),t?.(r),n?.(e.sourceEvent,r)}))}),[A,n]),e.useEffect((()=>{A&&(R&&!E.current?A.on("zoom",null):R||A.on("zoom",(e=>{const{onViewportChange:n}=k.getState();if(k.setState({transform:[e.transform.x,e.transform.y,e.transform.k]}),S.current=!(!o||!qi(f,T.current??0)),(t||n)&&!e.sourceEvent?.internal){const r=Ji(e.transform);n?.(r),t?.(e.sourceEvent,r)}})))}),[R,A,t,f,o]),e.useEffect((()=>{A&&A.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=k.getState();if(E.current=!1,k.setState({paneDragging:!1}),o&&qi(f,T.current??0)&&!S.current&&o(e.sourceEvent),S.current=!1,(r||t)&&(n=_.current,i=e.transform,n.x!==i.x||n.y!==i.y||n.zoom!==i.k)){const n=Ji(e.transform);_.current=n,clearTimeout(C.current),C.current=setTimeout((()=>{t?.(n),r?.(e.sourceEvent,n)}),s?150:0)}var n,i}))}),[A,s,f,r,o]),e.useEffect((()=>{A&&A.filter((e=>{const t=M||i,n=a&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(Ki(e,"react-flow__node")||Ki(e,"react-flow__edge")))return!0;if(!(f||t||s||u||a))return!1;if(R)return!1;if(!u&&"dblclick"===e.type)return!1;if(Ki(e,w)&&"wheel"===e.type)return!1;if(Ki(e,x)&&("wheel"!==e.type||s&&"wheel"===e.type&&!M))return!1;if(!a&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!s&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const r=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&r}))}),[R,A,i,a,s,u,f,d,M]),e.createElement("div",{className:"react-flow__renderer",ref:I,style:Ui},v)},na=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ra(){const{userSelectionActive:t,userSelectionRect:n}=Hr(na,Z);return t&&n?e.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function oa(e,t){const n=t.parentNode||t.parentId,r=e.find((e=>e.id===n));if(r){const e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style}||{},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function ia(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const r=e.filter((e=>e.id===n.id));if(0===r.length)return t.push(n),t;const o={...n};for(const e of r)if(e)switch(e.type){case"select":o.selected=e.selected;break;case"position":void 0!==e.position&&(o.position=e.position),void 0!==e.positionAbsolute&&(o.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(o.dragging=e.dragging),o.expandParent&&oa(t,o);break;case"dimensions":void 0!==e.dimensions&&(o.width=e.dimensions.width,o.height=e.dimensions.height),void 0!==e.updateStyle&&(o.style={...o.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(o.resizing=e.resizing),o.expandParent&&oa(t,o);break;case"remove":return t}return t.push(o),t}),n)}function aa(e,t){return ia(e,t)}function sa(e,t){return ia(e,t)}const la=(e,t)=>({id:e,type:"select",selected:t});function ca(e,t){return e.reduce(((e,n)=>{const r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(la(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(la(n.id,!1))),e}),[])}const ua=(e,t)=>n=>{n.target===t.current&&e?.(n)},da=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),fa=e.memo((({isSelecting:t,selectionMode:n=Co.Full,panOnDrag:r,onSelectionStart:o,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:s,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:u,onPaneMouseLeave:d,children:f})=>{const p=e.useRef(null),h=Xr(),m=e.useRef(0),g=e.useRef(0),y=e.useRef(),{userSelectionActive:b,elementsSelectable:v,dragging:w}=Hr(da,Z),x=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,g.current=0},C=e=>{a?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},k=l?e=>l(e):void 0,E=v&&(t||b);return e.createElement("div",{className:V(["react-flow__pane",{dragging:w,selection:t}]),onClick:E?void 0:ua(C,p),onContextMenu:ua((e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():s?.(e)}),p),onWheel:ua(k,p),onMouseEnter:E?void 0:c,onMouseDown:E?e=>{const{resetSelectedElements:n,domNode:r}=h.getState();if(y.current=r?.getBoundingClientRect(),!v||!t||0!==e.button||e.target!==p.current||!y.current)return;const{x:i,y:a}=ho(e,y.current);n(),h.setState({userSelectionRect:{width:0,height:0,startX:i,startY:a,x:i,y:a}}),o?.(e)}:void 0,onMouseMove:E?e=>{const{userSelectionRect:r,nodeInternals:o,edges:i,transform:a,onNodesChange:s,onEdgesChange:l,nodeOrigin:c,getNodes:u}=h.getState();if(!t||!y.current||!r)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const d=ho(e,y.current),f=r.startX??0,p=r.startY??0,b={...r,x:d.x<f?d.x:f,y:d.y<p?d.y:p,width:Math.abs(d.x-f),height:Math.abs(d.y-p)},v=u(),w=Yo(o,b,a,n===Co.Partial,!0,c),x=Uo(w,i).map((e=>e.id)),C=w.map((e=>e.id));if(m.current!==C.length){m.current=C.length;const e=ca(v,C);e.length&&s?.(e)}if(g.current!==x.length){g.current=x.length;const e=ca(i,x);e.length&&l?.(e)}h.setState({userSelectionRect:b})}:u,onMouseUp:E?e=>{if(0!==e.button)return;const{userSelectionRect:t}=h.getState();!b&&t&&e.target===p.current&&C?.(e),h.setState({nodesSelectionActive:m.current>0}),x(),i?.(e)}:void 0,onMouseLeave:E?e=>{b&&(h.setState({nodesSelectionActive:m.current>0}),i?.(e)),x()}:d,ref:p,style:Ui},f,e.createElement(ra,null))}));function pa(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return!!r&&(!!r.selected||pa(r,t))}function ha(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function ma(e,t,n,r){return Array.from(e.values()).filter((n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!pa(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent})))}function ga(e,t,n,r,o=[0,0],i){const a=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||r);let s=a;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:r,y:i}=$o(t,o).positionAbsolute;s=[[e.extent[0][0]+r,e.extent[0][1]+i],[e.extent[1][0]+r,e.extent[1][1]+i]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:r,y:i}=$o(t,o).positionAbsolute;s=t&&so(r)&&so(i)&&so(t.width)&&so(t.height)?[[r+e.width*o[0],i+e.height*o[1]],[r+t.width-e.width+e.width*o[0],i+t.height-e.height+e.height*o[1]]]:s}else i?.("005",jr()),s=a;let c={x:0,y:0};if(l){const e=n.get(l);c=$o(e,o).positionAbsolute}const u=s&&"parent"!==s?qr(t,s):t;return{position:{x:u.x-c.x,y:u.y-c.y},positionAbsolute:u}}function ya({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?r.find((t=>t.id===e)):r[0],r]}fa.displayName="Pane";const ba=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const i=Array.from(o),a=t.getBoundingClientRect(),s=a.width*r[0],l=a.height*r[1];return i.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-a.left-s)/n,y:(t.top-a.top-l)/n,...Jr(e)}}))};function va(e,t,n){return void 0===n?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function wa({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeInternals:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&a)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>r?.current?.blur()))):o([e])):l?.("012",Gr(e))}function xa(e){return(t,n,r)=>e?.(t,r)}function Ca({nodeRef:t,disabled:n=!1,noDragClassName:r,handleSelector:o,nodeId:i,isSelectable:a,selectNodesOnDrag:s}){const l=Xr(),[c,u]=e.useState(!1),d=e.useRef([]),f=e.useRef({x:null,y:null}),p=e.useRef(0),h=e.useRef(null),m=e.useRef({x:0,y:0}),g=e.useRef(null),y=e.useRef(!1),b=e.useRef(!1),v=e.useRef(!1),w=function(){const t=Xr(),n=e.useCallback((({sourceEvent:e})=>{const{transform:n,snapGrid:r,snapToGrid:o}=t.getState(),i=e.touches?e.touches[0].clientX:e.clientX,a=e.touches?e.touches[0].clientY:e.clientY,s={x:(i-n[0])/n[2],y:(a-n[1])/n[2]};return{xSnapped:o?r[0]*Math.round(s.x/r[0]):s.x,ySnapped:o?r[1]*Math.round(s.y/r[1]):s.y,...s}}),[]);return n}();return e.useEffect((()=>{if(t?.current){const e=dt(t.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:r,onSelectionDrag:o,updateNodePositions:a,nodeExtent:s,snapGrid:c,snapToGrid:p,nodeOrigin:h,onError:m}=l.getState();f.current={x:e,y:t};let y=!1,b={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&s){const e=Zo(d.current,h);b=ro(e)}if(d.current=d.current.map((r=>{const o={x:e-r.distance.x,y:t-r.distance.y};p&&(o.x=c[0]*Math.round(o.x/c[0]),o.y=c[1]*Math.round(o.y/c[1]));const i=[[s[0][0],s[0][1]],[s[1][0],s[1][1]]];d.current.length>1&&s&&!r.extent&&(i[0][0]=r.positionAbsolute.x-b.x+s[0][0],i[1][0]=r.positionAbsolute.x+(r.width??0)-b.x2+s[1][0],i[0][1]=r.positionAbsolute.y-b.y+s[0][1],i[1][1]=r.positionAbsolute.y+(r.height??0)-b.y2+s[1][1]);const a=ga(r,o,n,i,h,m);return y=y||r.position.x!==a.position.x||r.position.y!==a.position.y,r.position=a.position,r.positionAbsolute=a.positionAbsolute,r})),!y)return;a(d.current,!0,!0),u(!0);const v=i?r:xa(o);if(v&&g.current){const[e,t]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});v(g.current,e,t)}},x=()=>{if(!h.current)return;const[e,t]=eo(m.current,h.current);if(0!==e||0!==t){const{transform:n,panBy:r}=l.getState();f.current.x=(f.current.x??0)-e/n[2],f.current.y=(f.current.y??0)-t/n[2],r({x:e,y:t})&&c(f.current)}p.current=requestAnimationFrame(x)},C=e=>{const{nodeInternals:n,multiSelectionActive:r,nodesDraggable:o,unselectNodesAndEdges:c,onNodeDragStart:u,onSelectionDragStart:p}=l.getState();b.current=!0;const h=i?u:xa(p);s&&a||r||!i||n.get(i)?.selected||c(),i&&a&&s&&wa({id:i,store:l,nodeRef:t});const m=w(e);if(f.current=m,d.current=ma(n,o,m,i),h&&d.current){const[t,r]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});h(e.sourceEvent,t,r)}};if(!n){const n=function(){var e,t,n,r,o=xt,i=Ct,a=kt,s=Et,l={},c=U("start","drag","end"),u=0,d=0;function f(e){e.on("mousedown.drag",p).filter(s).on("touchstart.drag",g).on("touchmove.drag",y,pt).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(a,s){if(!r&&o.call(this,a,s)){var l=v(this,i.call(this,a,s),a,s,"mouse");l&&(dt(a.view).on("mousemove.drag",h,ht).on("mouseup.drag",m,ht),yt(a.view),mt(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function h(r){if(gt(r),!n){var o=r.clientX-e,i=r.clientY-t;n=o*o+i*i>d}l.mouse("drag",r)}function m(e){dt(e.view).on("mousemove.drag mouseup.drag",null),bt(e.view,n),gt(e),l.mouse("end",e)}function g(e,t){if(o.call(this,e,t)){var n,r,a=e.changedTouches,s=i.call(this,e,t),l=a.length;for(n=0;n<l;++n)(r=v(this,s,e,t,a[n].identifier,a[n]))&&(mt(e),r("start",e,a[n]))}}function y(e){var t,n,r=e.changedTouches,o=r.length;for(t=0;t<o;++t)(n=l[r[t].identifier])&&(gt(e),n("drag",e,r[t]))}function b(e){var t,n,o=e.changedTouches,i=o.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null}),500),t=0;t<i;++t)(n=l[o[t].identifier])&&(mt(e),n("end",e,o[t]))}function v(e,t,n,r,o,i){var s,d,p,h=c.copy(),m=ft(i||n,t);if(null!=(p=a.call(e,new wt("beforestart",{sourceEvent:n,target:f,identifier:o,active:u,x:m[0],y:m[1],dx:0,dy:0,dispatch:h}),r)))return s=p.x-m[0]||0,d=p.y-m[1]||0,function n(i,a,c){var g,y=m;switch(i){case"start":l[o]=n,g=u++;break;case"end":delete l[o],--u;case"drag":m=ft(c||a,t),g=u}h.call(i,e,new wt(i,{sourceEvent:a,subject:p,target:f,identifier:o,active:g,x:m[0]+s,y:m[1]+d,dx:m[0]-y[0],dy:m[1]-y[1],dispatch:h}),r)}}return f.filter=function(e){return arguments.length?(o="function"==typeof e?e:vt(!!e),f):o},f.container=function(e){return arguments.length?(i="function"==typeof e?e:vt(e),f):i},f.subject=function(e){return arguments.length?(a="function"==typeof e?e:vt(e),f):a},f.touchable=function(e){return arguments.length?(s="function"==typeof e?e:vt(!!e),f):s},f.on=function(){var e=c.on.apply(c,arguments);return e===c?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&C(e),v.current=!1;const r=w(e);f.current=r,h.current=t?.getBoundingClientRect()||null,m.current=ho(e.sourceEvent,h.current)})).on("drag",(e=>{const t=w(e),{autoPanOnNodeDrag:n,nodeDragThreshold:r}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!y.current&&b.current&&n&&(y.current=!0,x()),!b.current){const n=t.xSnapped-(f?.current?.x??0),o=t.ySnapped-(f?.current?.y??0);Math.sqrt(n*n+o*o)>r&&C(e)}(f.current.x!==t.xSnapped||f.current.y!==t.ySnapped)&&d.current&&b.current&&(g.current=e.sourceEvent,m.current=ho(e.sourceEvent,h.current),c(t))}})).on("end",(e=>{if(b.current&&!v.current&&(u(!1),y.current=!1,b.current=!1,cancelAnimationFrame(p.current),d.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:o}=l.getState(),a=i?r:xa(o);if(t(d.current,!1,!1),a){const[t,r]=ya({nodeId:i,dragItems:d.current,nodeInternals:n});a(e.sourceEvent,t,r)}}})).filter((e=>{const n=e.target;return!e.button&&(!r||!ha(n,`.${r}`,t))&&(!o||ha(n,o,t))}));return e.call(n),()=>{e.on(".drag",null)}}e.on(".drag",null)}}),[t,n,r,o,a,l,i,s,w]),c}function ka(){const t=Xr(),n=e.useCallback((e=>{const{nodeInternals:n,nodeExtent:r,updateNodePositions:o,getNodes:i,snapToGrid:a,snapGrid:s,onError:l,nodesDraggable:c}=t.getState(),u=i().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),d=a?s[0]:5,f=a?s[1]:5,p=e.isShiftPressed?4:1,h=e.x*d*p,m=e.y*f*p,g=u.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+h,y:e.positionAbsolute.y+m};a&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));const{positionAbsolute:o,position:i}=ga(e,t,n,r,void 0,l);e.position=i,e.positionAbsolute=o}return e}));o(g,!0,!1)}),[]);return n}const Ea={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Sa=t=>{const n=({id:n,type:r,data:o,xPos:i,yPos:a,xPosOrigin:s,yPosOrigin:l,selected:c,onClick:u,onMouseEnter:d,onMouseMove:f,onMouseLeave:p,onContextMenu:h,onDoubleClick:m,style:g,className:y,isDraggable:b,isSelectable:v,isConnectable:w,isFocusable:x,selectNodesOnDrag:C,sourcePosition:k,targetPosition:E,hidden:S,resizeObserver:I,dragHandle:_,zIndex:A,isParent:N,noDragClassName:O,noPanClassName:R,initialized:M,disableKeyboardA11y:T,ariaLabel:P,rfId:D,hasHandleBounds:j})=>{const F=Xr(),L=e.useRef(null),z=e.useRef(null),B=e.useRef(k),G=e.useRef(E),W=e.useRef(r),H=v||b||u||d||f||p,X=ka(),$=va(n,F.getState,d),Z=va(n,F.getState,f),Y=va(n,F.getState,p),U=va(n,F.getState,h),J=va(n,F.getState,m);e.useEffect((()=>()=>{z.current&&(I?.unobserve(z.current),z.current=null)}),[]),e.useEffect((()=>{if(L.current&&!S){const e=L.current;M&&j&&z.current===e||(z.current&&I?.unobserve(z.current),I?.observe(e),z.current=e)}}),[S,M,j]),e.useEffect((()=>{const e=W.current!==r,t=B.current!==k,o=G.current!==E;L.current&&(e||t||o)&&(e&&(W.current=r),t&&(B.current=k),o&&(G.current=E),F.getState().updateNodeDimensions([{id:n,nodeElement:L.current,forceUpdate:!0}]))}),[n,r,k,E]);const K=Ca({nodeRef:L,disabled:S||!b,noDragClassName:O,handleSelector:_,nodeId:n,isSelectable:v,selectNodesOnDrag:C});return S?null:e.createElement("div",{className:V(["react-flow__node",`react-flow__node-${r}`,{[R]:b},y,{selected:c,selectable:v,parent:N,dragging:K}]),ref:L,style:{zIndex:A,transform:`translate(${s}px,${l}px)`,pointerEvents:H?"all":"none",visibility:M?"visible":"hidden",...g},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:$,onMouseMove:Z,onMouseLeave:Y,onContextMenu:U,onClick:e=>{const{nodeDragThreshold:t}=F.getState();if(v&&(!C||!b||t>0)&&wa({id:n,store:F,nodeRef:L}),u){const t=F.getState().nodeInternals.get(n);t&&u(e,{...t})}},onDoubleClick:J,onKeyDown:x?e=>{if(!fo(e)&&!T)if(co.includes(e.key)&&v){const t="Escape"===e.key;wa({id:n,store:F,unselect:t,nodeRef:L})}else b&&c&&Object.prototype.hasOwnProperty.call(Ea,e.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~a}`}),X({x:Ea[e.key].x,y:Ea[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:x?0:void 0,role:x?"button":void 0,"aria-describedby":T?void 0:`${Ni}-${D}`,"aria-label":P},e.createElement(Vo,{value:n},e.createElement(t,{id:n,data:o,type:r,xPos:i,yPos:a,selected:c,isConnectable:w,sourcePosition:k,targetPosition:E,dragging:K,dragHandle:_,zIndex:A})))};return n.displayName="NodeWrapper",e.memo(n)};const Ia=e=>{const t=e.getNodes().filter((e=>e.selected));return{...Zo(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var _a=e.memo((function({onSelectionContextMenu:t,noPanClassName:n,disableKeyboardA11y:r}){const o=Xr(),{width:i,height:a,x:s,y:l,transformString:c,userSelectionActive:u}=Hr(Ia,Z),d=ka(),f=e.useRef(null);if(e.useEffect((()=>{r||f.current?.focus({preventScroll:!0})}),[r]),Ca({nodeRef:f}),u||!i||!a)return null;const p=t?e=>{const n=o.getState().getNodes().filter((e=>e.selected));t(e,n)}:void 0;return e.createElement("div",{className:V(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c}},e.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:e=>{Object.prototype.hasOwnProperty.call(Ea,e.key)&&d({x:Ea[e.key].x,y:Ea[e.key].y,isShiftPressed:e.shiftKey})},style:{width:i,height:a,top:l,left:s}}))}));const Aa=e=>e.nodesSelectionActive,Na=({children:t,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:s,deleteKeyCode:l,onMove:c,onMoveStart:u,onMoveEnd:d,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:y,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:x,zoomOnPinch:C,panOnScroll:k,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:_,defaultViewport:A,translateExtent:N,minZoom:O,maxZoom:R,preventScrolling:M,onSelectionContextMenu:T,noWheelClassName:P,noPanClassName:D,disableKeyboardA11y:j})=>{const F=Hr(Aa),L=Pi(f),z=Pi(b),B=z||_,V=z||k,G=L||p&&!0!==B;return(({deleteKeyCode:t,multiSelectionKeyCode:n})=>{const r=Xr(),{deleteElements:o}=Zi(),i=Pi(t,Yi),a=Pi(n);e.useEffect((()=>{if(i){const{edges:e,getNodes:t}=r.getState(),n=t().filter((e=>e.selected)),i=e.filter((e=>e.selected));o({nodes:n,edges:i}),r.setState({nodesSelectionActive:!1})}}),[i]),e.useEffect((()=>{r.setState({multiSelectionActive:a})}),[a])})({deleteKeyCode:l,multiSelectionKeyCode:y}),e.createElement(ta,{onMove:c,onMoveStart:u,onMoveEnd:d,onPaneContextMenu:a,elementsSelectable:w,zoomOnScroll:x,zoomOnPinch:C,panOnScroll:V,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:!L&&B,defaultViewport:A,translateExtent:N,minZoom:O,maxZoom:R,zoomActivationKeyCode:v,preventScrolling:M,noWheelClassName:P,noPanClassName:D},e.createElement(fa,{onSelectionStart:m,onSelectionEnd:g,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:s,panOnDrag:B,isSelecting:!!G,selectionMode:h},t,F&&e.createElement(_a,{onSelectionContextMenu:T,noPanClassName:D,disableKeyboardA11y:j})))};Na.displayName="FlowRenderer";var Oa=e.memo(Na);function Ra(e){return{...{input:Sa(e.input||pi),default:Sa(e.default||di),output:Sa(e.output||mi),group:Sa(e.group||gi)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=Sa(e[n]||di),t)),{})}}const Ma=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Ta=t=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:o,elementsSelectable:i,updateNodeDimensions:a,onError:s}=Hr(Ma,Z),l=function(t){const n=Hr(e.useCallback((e=>t?Yo(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[t]));return n}(t.onlyRenderVisibleElements),c=e.useRef(),u=e.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));a(t)}));return c.current=e,e}),[]);return e.useEffect((()=>()=>{c?.current?.disconnect()}),[]),e.createElement("div",{className:"react-flow__nodes",style:Ui},l.map((a=>{let l=a.type||"default";t.nodeTypes[l]||(s?.("003",Pr(l)),l="default");const c=t.nodeTypes[l]||t.nodeTypes.default,d=!!(a.draggable||n&&void 0===a.draggable),f=!!(a.selectable||i&&void 0===a.selectable),p=!!(a.connectable||r&&void 0===a.connectable),h=!!(a.focusable||o&&void 0===a.focusable),m=t.nodeExtent?qr(a.positionAbsolute,t.nodeExtent):a.positionAbsolute,g=m?.x??0,y=m?.y??0,b=(({x:e,y:t,width:n,height:r,origin:o})=>n&&r?o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]}:{x:e,y:t})({x:g,y:y,width:a.width??0,height:a.height??0,origin:t.nodeOrigin});return e.createElement(c,{key:a.id,id:a.id,className:a.className,style:a.style,type:l,data:a.data,sourcePosition:a.sourcePosition||So.Bottom,targetPosition:a.targetPosition||So.Top,hidden:a.hidden,xPos:g,yPos:y,xPosOrigin:b.x,yPosOrigin:b.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!a.selected,isDraggable:d,isSelectable:f,isConnectable:p,isFocusable:h,resizeObserver:u,dragHandle:a.dragHandle,zIndex:a[lo]?.z??0,isParent:!!a[lo]?.isParent,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!a.width&&!!a.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:a.ariaLabel,hasHandleBounds:!!a[lo]?.handleBounds})})))};Ta.displayName="NodeRenderer";var Pa=e.memo(Ta);const Da=(e,t,n)=>n===So.Left?e-t:n===So.Right?e+t:e,ja=(e,t,n)=>n===So.Top?e-t:n===So.Bottom?e+t:e,Fa="react-flow__edgeupdater",La=({position:t,centerX:n,centerY:r,radius:o=10,onMouseDown:i,onMouseEnter:a,onMouseOut:s,type:l})=>e.createElement("circle",{onMouseDown:i,onMouseEnter:a,onMouseOut:s,className:V([Fa,`${Fa}-${l}`]),cx:Da(n,o,t),cy:ja(r,o,t),r:o,stroke:"transparent",fill:"transparent"}),za=()=>!0;var Ba=t=>{const n=({id:n,className:r,type:o,data:i,onClick:a,onEdgeDoubleClick:s,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,source:y,target:b,sourceX:v,sourceY:w,targetX:x,targetY:C,sourcePosition:k,targetPosition:E,elementsSelectable:S,hidden:I,sourceHandleId:_,targetHandleId:A,onContextMenu:N,onMouseEnter:O,onMouseMove:R,onMouseLeave:M,reconnectRadius:T,onReconnect:P,onReconnectStart:D,onReconnectEnd:j,markerEnd:F,markerStart:L,rfId:z,ariaLabel:B,isFocusable:G,isReconnectable:W,pathOptions:H,interactionWidth:X,disableKeyboardA11y:$})=>{const Z=e.useRef(null),[Y,U]=e.useState(!1),[J,K]=e.useState(!1),q=Xr(),Q=e.useMemo((()=>`url('#${Wo(L,z)}')`),[L,z]),ee=e.useMemo((()=>`url('#${Wo(F,z)}')`),[F,z]);if(I)return null;const te=yo(n,q.getState,s),ne=yo(n,q.getState,N),re=yo(n,q.getState,O),oe=yo(n,q.getState,R),ie=yo(n,q.getState,M),ae=(e,t)=>{if(0!==e.button)return;const{edges:r,isValidConnection:o}=q.getState(),i=t?b:y,a=(t?A:_)||null,s=t?"target":"source",l=o||za,c=t,u=r.find((e=>e.id===n));K(!0),D?.(e,u,s);ii({event:e,handleId:a,nodeId:i,onConnect:e=>P?.(u,e),isTarget:c,getState:q.getState,setState:q.setState,isValidConnection:l,edgeUpdaterType:s,onReconnectEnd:e=>{K(!1),j?.(e,u,s)}})},se=()=>U(!0),le=()=>U(!1),ce=!S&&!a;return e.createElement("g",{className:V(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{const{edges:t,addSelectedEdges:r,unselectNodesAndEdges:o,multiSelectionActive:i}=q.getState(),s=t.find((e=>e.id===n));s&&(S&&(q.setState({nodesSelectionActive:!1}),s.selected&&i?(o({nodes:[],edges:[s]}),Z.current?.blur()):r([n])),a&&a(e,s))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:re,onMouseMove:oe,onMouseLeave:ie,onKeyDown:G?e=>{if(!$&&co.includes(e.key)&&S){const{unselectNodesAndEdges:t,addSelectedEdges:r,edges:o}=q.getState();"Escape"===e.key?(Z.current?.blur(),t({edges:[o.find((e=>e.id===n))]})):r([n])}}:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":null===B?void 0:B||`Edge from ${y} to ${b}`,"aria-describedby":G?`${Oi}-${z}`:void 0,ref:Z},!J&&e.createElement(t,{id:n,source:y,target:b,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,data:i,style:g,sourceX:v,sourceY:w,targetX:x,targetY:C,sourcePosition:k,targetPosition:E,sourceHandleId:_,targetHandleId:A,markerStart:Q,markerEnd:ee,pathOptions:H,interactionWidth:X}),W&&e.createElement(e.Fragment,null,("source"===W||!0===W)&&e.createElement(La,{position:k,centerX:v,centerY:w,radius:T,onMouseDown:e=>ae(e,!0),onMouseEnter:se,onMouseOut:le,type:"source"}),("target"===W||!0===W)&&e.createElement(La,{position:E,centerX:x,centerY:C,radius:T,onMouseDown:e=>ae(e,!1),onMouseEnter:se,onMouseOut:le,type:"target"})))};return n.displayName="EdgeWrapper",e.memo(n)};function Va(e){return{...{default:Ba(e.default||zo),straight:Ba(e.bezier||Do),step:Ba(e.step||Po),smoothstep:Ba(e.step||To),simplebezier:Ba(e.simplebezier||Ao)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=Ba(e[n]||zo),t)),{})}}function Ga(e,t,n=null){const r=(n?.x||0)+t.x,o=(n?.y||0)+t.y,i=n?.width||t.width,a=n?.height||t.height;switch(e){case So.Top:return{x:r+i/2,y:o};case So.Right:return{x:r+i,y:o+a/2};case So.Bottom:return{x:r+i/2,y:o+a};case So.Left:return{x:r,y:o+a/2}}}function Wa(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function Ha(e){const t=e?.[lo]?.handleBounds||null,n=t&&e?.width&&e?.height&&void 0!==e?.positionAbsolute?.x&&void 0!==e?.positionAbsolute?.y;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const Xa=[{level:0,isMaxLevel:!0,edges:[]}];function $a(t,n,r){const o=Hr(e.useCallback((e=>t?e.edges.filter((t=>{const r=n.get(t.source),o=n.get(t.target);return r?.width&&r?.height&&o?.width&&o?.height&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:i,width:a,height:s,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+o),y2:Math.max(e.y+r,t.y+i)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=ro({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:a/l[2],height:s/l[2]}),d=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),f=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(d*f)>0}({sourcePos:r.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:o.width,targetHeight:o.height,width:e.width,height:e.height,transform:e.transform})})):e.edges),[t,n]));return function(e,t,n=!1){let r=-1;const o=e.reduce(((e,o)=>{const i=so(o.zIndex);let a=i?o.zIndex:0;if(n){const e=t.get(o.target),n=t.get(o.source),r=o.selected||e?.selected||n?.selected,s=Math.max(n?.[lo]?.z||0,e?.[lo]?.z||0,1e3);a=(i?o.zIndex:0)+(r?s:0)}return e[a]?e[a].push(o):e[a]=[o],r=a>r?a:r,e}),{}),i=Object.entries(o).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===r}}));return 0===i.length?Xa:i}(o,n,r)}const Za={[Eo.Arrow]:({color:t="none",strokeWidth:n=1})=>e.createElement("polyline",{style:{stroke:t,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[Eo.ArrowClosed]:({color:t="none",strokeWidth:n=1})=>e.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Ya=({id:t,type:n,color:r,width:o=12.5,height:i=12.5,markerUnits:a="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const c=function(t){const n=Xr();return e.useMemo((()=>Object.prototype.hasOwnProperty.call(Za,t)?Za[t]:(n.getState().onError?.("009",Lr(t)),null)),[t])}(n);return c?e.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${o}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0"},e.createElement(c,{color:r,strokeWidth:s})):null},Ua=({defaultColor:t,rfId:n})=>{const r=Hr(e.useCallback((({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce(((n,o)=>([o.markerStart,o.markerEnd].forEach((o=>{if(o&&"object"==typeof o){const i=Wo(o,t);r.includes(i)||(n.push({id:i,color:o.color||e,...o}),r.push(i))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:t,rfId:n}),[t,n]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return e.createElement("defs",null,r.map((t=>e.createElement(Ya,{id:t.id,key:t.id,type:t.type,color:t.color,width:t.width,height:t.height,markerUnits:t.markerUnits,strokeWidth:t.strokeWidth,orient:t.orient}))))};Ua.displayName="MarkerDefinitions";var Ja=e.memo(Ua);const Ka=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),qa=({defaultMarkerColor:t,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:o,edgeTypes:i,noPanClassName:a,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,children:y,disableKeyboardA11y:b})=>{const{edgesFocusable:v,edgesUpdatable:w,elementsSelectable:x,width:C,height:k,connectionMode:E,nodeInternals:S,onError:I}=Hr(Ka,Z),_=$a(n,S,r);return C?e.createElement(e.Fragment,null,_.map((({level:n,edges:r,isMaxLevel:y})=>e.createElement("svg",{key:n,style:{zIndex:n},width:C,height:k,className:"react-flow__edges react-flow__container"},y&&e.createElement(Ja,{defaultColor:t,rfId:o}),e.createElement("g",null,r.map((t=>{const[n,r,y]=Ha(S.get(t.source)),[C,k,_]=Ha(S.get(t.target));if(!y||!_)return null;let A=t.type||"default";i[A]||(I?.("011",Vr(A)),A="default");const N=i[A]||i.default,O=E===wo.Strict?k.target:(k.target??[]).concat(k.source??[]),R=Wa(r.source,t.sourceHandle),M=Wa(O,t.targetHandle),T=R?.position||So.Bottom,P=M?.position||So.Top,D=!!(t.focusable||v&&void 0===t.focusable),j=t.reconnectable||t.updatable,F=void 0!==p&&(j||w&&void 0===j);if(!R||!M)return I?.("008",zr(R,t)),null;const{sourceX:L,sourceY:z,targetX:B,targetY:G}=((e,t,n,r,o,i)=>{const a=Ga(n,e,t),s=Ga(i,r,o);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(n,R,T,C,M,P);return e.createElement(N,{key:t.id,id:t.id,className:V([t.className,a]),type:A,data:t.data,selected:!!t.selected,animated:!!t.animated,hidden:!!t.hidden,label:t.label,labelStyle:t.labelStyle,labelShowBg:t.labelShowBg,labelBgStyle:t.labelBgStyle,labelBgPadding:t.labelBgPadding,labelBgBorderRadius:t.labelBgBorderRadius,style:t.style,source:t.source,target:t.target,sourceHandleId:t.sourceHandle,targetHandleId:t.targetHandle,markerEnd:t.markerEnd,markerStart:t.markerStart,sourceX:L,sourceY:z,targetX:B,targetY:G,sourcePosition:T,targetPosition:P,elementsSelectable:x,onContextMenu:s,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,reconnectRadius:g,rfId:o,ariaLabel:t.ariaLabel,isFocusable:D,isReconnectable:F,pathOptions:"pathOptions"in t?t.pathOptions:void 0,interactionWidth:t.interactionWidth,disableKeyboardA11y:b})})))))),y):null};qa.displayName="EdgeRenderer";var Qa=e.memo(qa);const es=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function ts({children:t}){const n=Hr(es);return e.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},t)}const ns={[So.Left]:So.Right,[So.Right]:So.Left,[So.Top]:So.Bottom,[So.Bottom]:So.Top},rs=({nodeId:t,handleType:n,style:r,type:o=ko.Bezier,CustomComponent:i,connectionStatus:a})=>{const{fromNode:s,handleId:l,toX:c,toY:u,connectionMode:d}=Hr(e.useCallback((e=>({fromNode:e.nodeInternals.get(t),handleId:e.connectionHandleId,toX:(e.connectionPosition.x-e.transform[0])/e.transform[2],toY:(e.connectionPosition.y-e.transform[1])/e.transform[2],connectionMode:e.connectionMode})),[t]),Z),f=s?.[lo]?.handleBounds;let p=f?.[n];if(d===wo.Loose&&(p=p||f?.["source"===n?"target":"source"]),!s||!p)return null;const h=l?p.find((e=>e.id===l)):p[0],m=h?h.x+h.width/2:(s.width??0)/2,g=h?h.y+h.height/2:s.height??0,y=(s.positionAbsolute?.x??0)+m,b=(s.positionAbsolute?.y??0)+g,v=h?.position,w=v?ns[v]:null;if(!v||!w)return null;if(i)return e.createElement(i,{connectionLineType:o,connectionLineStyle:r,fromNode:s,fromHandle:h,fromX:y,fromY:b,toX:c,toY:u,fromPosition:v,toPosition:w,connectionStatus:a});let x="";const C={sourceX:y,sourceY:b,sourcePosition:v,targetX:c,targetY:u,targetPosition:w};return o===ko.Bezier?[x]=Lo(C):o===ko.Step?[x]=Mo({...C,borderRadius:0}):o===ko.SmoothStep?[x]=Mo(C):o===ko.SimpleBezier?[x]=_o(C):x=`M${y},${b} ${c},${u}`,e.createElement("path",{d:x,fill:"none",className:"react-flow__connection-path",style:r})};rs.displayName="ConnectionLine";const os=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function is({containerStyle:t,style:n,type:r,component:o}){const{nodeId:i,handleType:a,nodesConnectable:s,width:l,height:c,connectionStatus:u}=Hr(os,Z);return!!(i&&a&&l&&s)?e.createElement("svg",{style:t,width:l,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},e.createElement("g",{className:V(["react-flow__connection",u])},e.createElement(rs,{nodeId:i,handleType:a,style:n,type:r,CustomComponent:o,connectionStatus:u}))):null}function as(t,n){const r=e.useRef(null),o=Xr();return e.useMemo((()=>{if("development"===process.env.NODE_ENV){const e=Object.keys(t);Z(r.current,e)&&o.getState().onError?.("002",Tr()),r.current=e}return n(t)}),[t])}const ss=({nodeTypes:t,edgeTypes:n,onMove:r,onMoveStart:o,onMoveEnd:i,onInit:a,onNodeClick:s,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:u,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:y,connectionLineType:b,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:x,selectionKeyCode:C,selectionOnDrag:k,selectionMode:E,multiSelectionKeyCode:S,panActivationKeyCode:I,zoomActivationKeyCode:_,deleteKeyCode:A,onlyRenderVisibleElements:N,elementsSelectable:O,selectNodesOnDrag:R,defaultViewport:M,translateExtent:T,minZoom:P,maxZoom:D,preventScrolling:j,defaultMarkerColor:F,zoomOnScroll:L,zoomOnPinch:z,panOnScroll:B,panOnScrollSpeed:V,panOnScrollMode:G,zoomOnDoubleClick:W,panOnDrag:H,onPaneClick:X,onPaneMouseEnter:$,onPaneMouseMove:Z,onPaneMouseLeave:Y,onPaneScroll:U,onPaneContextMenu:J,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:Q,onEdgeMouseLeave:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:re,reconnectRadius:oe,noDragClassName:ie,noWheelClassName:ae,noPanClassName:se,elevateEdgesOnSelect:le,disableKeyboardA11y:ce,nodeOrigin:ue,nodeExtent:de,rfId:fe})=>{const pe=as(t,Ra),he=as(n,Va);return function(t){const n=Zi(),r=e.useRef(!1);e.useEffect((()=>{!r.current&&n.viewportInitialized&&t&&(setTimeout((()=>t(n)),1),r.current=!0)}),[t,n.viewportInitialized])}(a),e.createElement(Oa,{onPaneClick:X,onPaneMouseEnter:$,onPaneMouseMove:Z,onPaneMouseLeave:Y,onPaneContextMenu:J,onPaneScroll:U,deleteKeyCode:A,selectionKeyCode:C,selectionOnDrag:k,selectionMode:E,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:S,panActivationKeyCode:I,zoomActivationKeyCode:_,elementsSelectable:O,onMove:r,onMoveStart:o,onMoveEnd:i,zoomOnScroll:L,zoomOnPinch:z,zoomOnDoubleClick:W,panOnScroll:B,panOnScrollSpeed:V,panOnScrollMode:G,panOnDrag:H,defaultViewport:M,translateExtent:T,minZoom:P,maxZoom:D,onSelectionContextMenu:m,preventScrolling:j,noDragClassName:ie,noWheelClassName:ae,noPanClassName:se,disableKeyboardA11y:ce},e.createElement(ts,null,e.createElement(Qa,{edgeTypes:he,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:Q,onEdgeMouseLeave:ee,onReconnect:te,onReconnectStart:ne,onReconnectEnd:re,reconnectRadius:oe,defaultMarkerColor:F,noPanClassName:se,elevateEdgesOnSelect:!!le,disableKeyboardA11y:ce,rfId:fe},e.createElement(is,{style:v,type:b,component:w,containerStyle:x})),e.createElement("div",{className:"react-flow__edgelabel-renderer"}),e.createElement(Pa,{nodeTypes:pe,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:h,selectNodesOnDrag:R,onlyRenderVisibleElements:N,noPanClassName:se,noDragClassName:ie,disableKeyboardA11y:ce,nodeOrigin:ue,nodeExtent:de,rfId:fe})))};ss.displayName="GraphView";var ls=e.memo(ss);const cs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],us={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:cs,nodeExtent:cs,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:wo.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:uo,isValidConnection:void 0},ds=()=>((e,t)=>e?$(e,t):$)(((e,t)=>({...us,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:i}=t();e({nodeInternals:zi(n,r,o,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map((e=>({...r,...e})))})},setDefaultNodesAndEdges:(n,r)=>{const o=void 0!==n,i=void 0!==r,a=o?zi(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:i?r:[],hasDefaultNodes:o,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:i,fitViewOnInitDone:a,fitViewOnInitOptions:s,domNode:l,nodeOrigin:c}=t(),u=l?.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=n.reduce(((e,t)=>{const n=o.get(t.id);if(n?.hidden)o.set(n.id,{...n,[lo]:{...n[lo],handleBounds:void 0}});else if(n){const r=Jr(t.nodeElement);!(!r.width||!r.height||n.width===r.width&&n.height===r.height&&!t.forceUpdate)&&(o.set(n.id,{...n,[lo]:{...n[lo],handleBounds:{source:ba(".source",t.nodeElement,f,c),target:ba(".target",t.nodeElement,f,c)}},...r}),e.push({id:n.id,type:"dimensions",dimensions:r}))}return e}),[]);Li(o,c);const h=a||i&&!a&&Bi(t,{initial:!0,...s});e({nodeInternals:new Map(o),fitViewOnInitDone:h}),p?.length>0&&r?.(p)},updateNodePositions:(e,n=!0,r=!1)=>{const{triggerNodeChanges:o}=t(),i=e.map((e=>{const t={id:e.id,type:"position",dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t}));o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:i,nodeOrigin:a,getNodes:s,elevateNodesOnSelect:l}=t();if(n?.length){if(i){const t=zi(aa(n,s()),o,a,l);e({nodeInternals:t})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let a,s=null;r?a=n.map((e=>la(e,!0))):(a=ca(i(),n),s=ca(o,[])),Wi({changedNodes:a,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:i}=t();let a,s=null;r?a=n.map((e=>la(e,!0))):(a=ca(o,n),s=ca(i(),[])),Wi({changedNodes:s,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:i}=t(),a=r||o;Wi({changedNodes:(n||i()).map((e=>(e.selected=!1,la(e.id,!1)))),changedEdges:a.map((e=>la(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();r?.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();r?.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t();Wi({changedNodes:r().filter((e=>e.selected)).map((e=>la(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>la(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach((e=>{e.positionAbsolute=qr(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{const{transform:n,width:r,height:o,d3Zoom:i,d3Selection:a,translateExtent:s}=t();if(!i||!a||!e.x&&!e.y)return!1;const l=xr.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[r,o]],u=i?.constrain()(l,c,s);i.transform(a,u);return n[0]!==u.x||n[1]!==u.y||n[2]!==u.k},cancelConnection:()=>e({connectionNodeId:us.connectionNodeId,connectionHandleId:us.connectionHandleId,connectionHandleType:us.connectionHandleType,connectionStatus:us.connectionStatus,connectionStartHandle:us.connectionStartHandle,connectionEndHandle:us.connectionEndHandle}),reset:()=>e({...us})})),Object.is),fs=({children:t})=>{const n=e.useRef(null);return n.current||(n.current=ds()),e.createElement(Mr,{value:n.current},t)};fs.displayName="ReactFlowProvider";const ps=({children:t})=>e.useContext(Rr)?e.createElement(e.Fragment,null,t):e.createElement(fs,null,t);ps.displayName="ReactFlowWrapper";const hs={input:pi,default:di,output:mi,group:gi},ms={default:zo,straight:Do,step:Po,smoothstep:To,simplebezier:Ao},gs=[0,0],ys=[15,15],bs={x:0,y:0,zoom:1},vs={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},ws=e.forwardRef((({nodes:t,edges:n,defaultNodes:r,defaultEdges:o,className:i,nodeTypes:a=hs,edgeTypes:s=ms,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:x,onNodeContextMenu:C,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:S,onNodeDragStop:I,onNodesDelete:_,onEdgesDelete:A,onSelectionChange:N,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:M,onSelectionContextMenu:T,onSelectionStart:P,onSelectionEnd:D,connectionMode:j=wo.Strict,connectionLineType:F=ko.Bezier,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:G="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:H=!1,selectionMode:X=Co.Full,panActivationKeyCode:$="Space",multiSelectionKeyCode:Z=(mo()?"Meta":"Control"),zoomActivationKeyCode:Y=(mo()?"Meta":"Control"),snapToGrid:U=!1,snapGrid:J=ys,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:q=!0,nodesDraggable:Q,nodesConnectable:ee,nodesFocusable:te,nodeOrigin:ne=gs,edgesFocusable:re,edgesUpdatable:oe,elementsSelectable:ie,defaultViewport:ae=bs,minZoom:se=.5,maxZoom:le=2,translateExtent:ce=cs,preventScrolling:ue=!0,nodeExtent:de,defaultMarkerColor:fe="#b1b1b7",zoomOnScroll:pe=!0,zoomOnPinch:he=!0,panOnScroll:me=!1,panOnScrollSpeed:ge=.5,panOnScrollMode:ye=xo.Free,zoomOnDoubleClick:be=!0,panOnDrag:ve=!0,onPaneClick:we,onPaneMouseEnter:xe,onPaneMouseMove:Ce,onPaneMouseLeave:ke,onPaneScroll:Ee,onPaneContextMenu:Se,children:Ie,onEdgeContextMenu:_e,onEdgeDoubleClick:Ae,onEdgeMouseEnter:Ne,onEdgeMouseMove:Oe,onEdgeMouseLeave:Re,onEdgeUpdate:Me,onEdgeUpdateStart:Te,onEdgeUpdateEnd:Pe,onReconnect:De,onReconnectStart:je,onReconnectEnd:Fe,reconnectRadius:Le=10,edgeUpdaterRadius:ze=10,onNodesChange:Be,onEdgesChange:Ve,noDragClassName:Ge="nodrag",noWheelClassName:We="nowheel",noPanClassName:He="nopan",fitView:Xe=!1,fitViewOptions:$e,connectOnClick:Ze=!0,attributionPosition:Ye,proOptions:Ue,defaultEdgeOptions:Je,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:qe=!1,disableKeyboardA11y:Qe=!1,autoPanOnConnect:et=!0,autoPanOnNodeDrag:tt=!0,connectionRadius:nt=20,isValidConnection:rt,onError:ot,style:it,id:at,nodeDragThreshold:st,...lt},ct)=>{const ut=at||"1";return e.createElement("div",{...lt,style:{...it,...vs},ref:ct,className:V(["react-flow",i]),"data-testid":"rf__wrapper",id:at},e.createElement(ps,null,e.createElement(ls,{onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:x,onNodeContextMenu:C,onNodeDoubleClick:k,nodeTypes:a,edgeTypes:s,connectionLineType:F,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:W,selectionOnDrag:H,selectionMode:X,deleteKeyCode:G,multiSelectionKeyCode:Z,panActivationKeyCode:$,zoomActivationKeyCode:Y,onlyRenderVisibleElements:K,selectNodesOnDrag:q,defaultViewport:ae,translateExtent:ce,minZoom:se,maxZoom:le,preventScrolling:ue,zoomOnScroll:pe,zoomOnPinch:he,zoomOnDoubleClick:be,panOnScroll:me,panOnScrollSpeed:ge,panOnScrollMode:ye,panOnDrag:ve,onPaneClick:we,onPaneMouseEnter:xe,onPaneMouseMove:Ce,onPaneMouseLeave:ke,onPaneScroll:Ee,onPaneContextMenu:Se,onSelectionContextMenu:T,onSelectionStart:P,onSelectionEnd:D,onEdgeContextMenu:_e,onEdgeDoubleClick:Ae,onEdgeMouseEnter:Ne,onEdgeMouseMove:Oe,onEdgeMouseLeave:Re,onReconnect:De??Me,onReconnectStart:je??Te,onReconnectEnd:Fe??Pe,reconnectRadius:Le??ze,defaultMarkerColor:fe,noDragClassName:Ge,noWheelClassName:We,noPanClassName:He,elevateEdgesOnSelect:qe,rfId:ut,disableKeyboardA11y:Qe,nodeOrigin:ne,nodeExtent:de}),e.createElement(Ii,{nodes:t,edges:n,defaultNodes:r,defaultEdges:o,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,nodesDraggable:Q,nodesConnectable:ee,nodesFocusable:te,edgesFocusable:re,edgesUpdatable:oe,elementsSelectable:ie,elevateNodesOnSelect:Ke,minZoom:se,maxZoom:le,nodeExtent:de,onNodesChange:Be,onEdgesChange:Ve,snapToGrid:U,snapGrid:J,connectionMode:j,translateExtent:ce,connectOnClick:Ze,defaultEdgeOptions:Je,fitView:Xe,fitViewOptions:$e,onNodesDelete:_,onEdgesDelete:A,onNodeDragStart:E,onNodeDrag:S,onNodeDragStop:I,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:M,noPanClassName:He,nodeOrigin:ne,rfId:ut,autoPanOnConnect:et,autoPanOnNodeDrag:tt,onError:ot,connectionRadius:nt,isValidConnection:rt,nodeDragThreshold:st}),e.createElement(Ci,{onSelectionChange:N}),Ie,e.createElement(Yr,{proOptions:Ue,position:Ye}),e.createElement(Ti,{rfId:ut,disableKeyboardA11y:Qe})))}));ws.displayName="ReactFlow";const xs=e=>e.getNodes();const Cs=e=>e.edges;const ks=({id:t,x:n,y:r,width:o,height:i,style:a,color:s,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,onClick:p,selected:h})=>{const{background:m,backgroundColor:g}=a||{},y=s||m||g;return e.createElement("rect",{className:V(["react-flow__minimap-node",{selected:h},u]),x:n,y:r,rx:d,ry:d,width:o,height:i,fill:y,stroke:l,strokeWidth:c,shapeRendering:f,onClick:p?e=>p(e,t):void 0})};ks.displayName="MiniMapNode";var Es=e.memo(ks);const Ss=e=>e.nodeOrigin,Is=e=>e.getNodes().filter((e=>!e.hidden&&e.width&&e.height)),_s=e=>e instanceof Function?e:()=>e;var As=e.memo((function({nodeStrokeColor:t="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:a=Es,onClick:s}){const l=Hr(Is,Z),c=Hr(Ss),u=_s(n),d=_s(t),f=_s(r),p="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return e.createElement(e.Fragment,null,l.map((t=>{const{x:n,y:r}=$o(t,c).positionAbsolute;return e.createElement(a,{key:t.id,x:n,y:r,width:t.width,height:t.height,style:t.style,selected:t.selected,className:f(t),color:u(t),borderRadius:o,strokeColor:d(t),strokeWidth:i,shapeRendering:p,onClick:s,id:t.id})})))}));const Ns=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?(r=Zo(t,e.nodeOrigin),o=n,oo(no(ro(r),ro(o)))):n,rfId:e.rfId};var r,o};function Os({style:t,className:n,nodeStrokeColor:r="transparent",nodeColor:o="#e2e2e2",nodeClassName:i="",nodeBorderRadius:a=5,nodeStrokeWidth:s=2,nodeComponent:l,maskColor:c="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:d=1,position:f="bottom-right",onClick:p,onNodeClick:h,pannable:m=!1,zoomable:g=!1,ariaLabel:y="React Flow mini map",inversePan:b=!1,zoomStep:v=10,offsetScale:w=5}){const x=Xr(),C=e.useRef(null),{boundingRect:k,viewBB:E,rfId:S}=Hr(Ns,Z),I=t?.width??200,_=t?.height??150,A=k.width/I,N=k.height/_,O=Math.max(A,N),R=O*I,M=O*_,T=w*O,P=k.x-(R-k.width)/2-T,D=k.y-(M-k.height)/2-T,j=R+2*T,F=M+2*T,L=`react-flow__minimap-desc-${S}`,z=e.useRef(0);z.current=O,e.useEffect((()=>{if(C.current){const e=dt(C.current),t=e=>{const{transform:t,d3Selection:n,d3Zoom:r}=x.getState();if("wheel"!==e.sourceEvent.type||!n||!r)return;const o=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*v,i=t[2]*Math.pow(2,o);r.scaleTo(n,i)},n=e=>{const{transform:t,d3Selection:n,d3Zoom:r,translateExtent:o,width:i,height:a}=x.getState();if("mousemove"!==e.sourceEvent.type||!n||!r)return;const s=z.current*Math.max(1,t[2])*(b?-1:1),l={x:t[0]-e.sourceEvent.movementX*s,y:t[1]-e.sourceEvent.movementY*s},c=[[0,0],[i,a]],u=xr.translate(l.x,l.y).scale(t[2]),d=r.constrain()(u,c,o);r.transform(n,d)},r=Or().on("zoom",m?n:null).on("zoom.wheel",g?t:null);return e.call(r),()=>{e.on("zoom",null)}}}),[m,g,b,v]);const B=p?e=>{const t=ft(e);p(e,{x:t[0],y:t[1]})}:void 0,G=h?(e,t)=>{const n=x.getState().nodeInternals.get(t);h(e,n)}:void 0;return e.createElement(Zr,{position:f,style:t,className:V(["react-flow__minimap",n]),"data-testid":"rf__minimap"},e.createElement("svg",{width:I,height:_,viewBox:`${P} ${D} ${j} ${F}`,role:"img","aria-labelledby":L,ref:C,onClick:B},y&&e.createElement("title",{id:L},y),e.createElement(As,{onClick:G,nodeColor:o,nodeStrokeColor:r,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:s,nodeComponent:l}),e.createElement("path",{className:"react-flow__minimap-mask",d:`M${P-T},${D-T}h${j+2*T}v${F+2*T}h${-j-2*T}z\n M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fill:c,fillRule:"evenodd",stroke:u,strokeWidth:d,pointerEvents:"none"})))}Os.displayName="MiniMap";var Rs,Ms=e.memo(Os);function Ts({color:t,dimensions:n,lineWidth:r}){return e.createElement("path",{stroke:t,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function Ps({color:t,radius:n}){return e.createElement("circle",{cx:n,cy:n,r:n,fill:t})}!function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"}(Rs||(Rs={}));const Ds={[Rs.Dots]:"#91919a",[Rs.Lines]:"#eee",[Rs.Cross]:"#e2e2e2"},js={[Rs.Dots]:1,[Rs.Lines]:1,[Rs.Cross]:6},Fs=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ls({id:t,variant:n=Rs.Dots,gap:r=20,size:o,lineWidth:i=1,offset:a=2,color:s,style:l,className:c}){const u=e.useRef(null),{transform:d,patternId:f}=Hr(Fs,Z),p=s||Ds[n],h=o||js[n],m=n===Rs.Dots,g=n===Rs.Cross,y=Array.isArray(r)?r:[r,r],b=[y[0]*d[2]||1,y[1]*d[2]||1],v=h*d[2],w=g?[v,v]:b,x=m?[v/a,v/a]:[w[0]/a,w[1]/a];return e.createElement("svg",{className:V(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},e.createElement("pattern",{id:f+t,x:d[0]%b[0],y:d[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`},m?e.createElement(Ps,{color:p,radius:v/a}):e.createElement(Ts,{dimensions:w,color:p,lineWidth:i})),e.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+t})`}))}Ls.displayName="Background";var zs=e.memo(Ls);const Bs=({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})=>[`${e}:${t}`,`${n}:${r}`].sort().join("--"),Vs=0,Gs=10,Ws=20,Hs=30,Xs=Gs,$s=e=>"string"==typeof e?e:e===Vs?"DEBUG":e===Gs?"INFO":e===Ws?"WARN":e===Hs?"ERROR":"UNKNOWN";class Zs{constructor(e,t=Gs){this.name=e,this.level=(e=>{if("number"==typeof e)return e;const t=e.toLowerCase();if("debug"===t)return Vs;if("info"===t)return Gs;if("warn"===t||"warning"===t)return Ws;if("error"===t)return Hs;throw new Error(`Unknown log level: ${e}`)})(t),this._level_name=$s(t)}set_level(e){this.level=e,this._level_name=$s(e)}_fomat_message(e,...t){return`[${this.name}] ${this._level_name}: ${e} ${t.map((e=>JSON.stringify(e,function(){const e=[];return function(t,n){if("object"!=typeof n||null===n)return n;for(;e.length>0&&e.at(-1)!==this;)e.pop();return e.includes(n)?"[Circular]":(e.push(n),n)}}()))).join(" ")}`}debug(e,...t){this.level<=Vs&&console.debug(this._fomat_message(e,...t))}info(e,...t){this.level<=Gs&&console.info(this._fomat_message(e,...t))}warn(e,...t){this.level<=Ws&&console.warn(this._fomat_message(e,...t))}error(e,...t){this.level<=Hs&&console.error(this._fomat_message(e,...t))}}const Ys=(e,t)=>("<NoValue>"===e.value&&(e.value=void 0),"<NoValue>"===e.fullvalue&&(e.fullvalue=void 0),void 0===e.try_get_full_value&&(e.try_get_full_value=()=>{t&&void 0!==e.node&&void 0!==e.id&&t.worker?.get_io_full_value({nid:e.node,ioid:e.id})}),void 0===e.hidden&&(e.hidden=!1),void 0===e.set_hidden&&(e.set_hidden=n=>{t&&void 0!==e.node&&void 0!==e.id&&t.worker?.update_io_options({nid:e.node,ioid:e.id,options:{hidden:n}})}),e),Us=(e,t,n)=>{if(((e,t)=>{const n=e.properties||{};n["frontend:size"]||(n["frontend:size"]=[200,100]);const r=n["frontend:pos"];if(!r||2!==r.length||isNaN(r[0])||null===r[0]||isNaN(r[1])||null===r[1])if(t&&t.rf_instance&&null!==t.reactflowRef){const e=t.reactflowRef.getBoundingClientRect(),r=e.left+e.width/2,o=e.top+e.height/2,i=t.rf_instance.screenToFlowPosition({x:r,y:o});n["frontend:pos"]=[i.x-n["frontend:size"][0]/2,i.y-n["frontend:size"][0]/2]}else n["frontend:pos"]=[0,0];n["frontend:collapsed"]||(n["frontend:collapsed"]=!1),e.properties=n})(e,n),void 0===(e=z(e)).id)throw new Error("Node must have an id");for(const t in e.io)e.io[t].node=e.id,Ys(e.io[t],n);return{position:{x:e.properties["frontend:pos"][0],y:e.properties["frontend:pos"][1]},data:{UseNodeStore:t},type:"default",...e}},Js=e=>{const t={...e},n=e=>{const t=o.getState();if(e.from_remote){let n=i.get_node(e.node.id,!1);if(!n)try{n=(e=>N(((t,n)=>z(B(e)))))(e.node),i.nodesstates.set(e.node.id,n)}catch(e){return void s.logger.error(`Failed to create node store ${e}`)}const r=n.getState();s.logger.info("Add node",r.id,r.name);const a=[...t.nodes,Us(r,n,s)];o.setState({nodes:a});for(const t in e.node.io){const n=e.node.io[t].id;void 0!==n&&s.worker?.get_io_value({nid:e.node.id,ioid:n})}setTimeout((()=>{s.worker?.call_hooks("node_added",{node:r.id})}),0)}},r=e=>{switch(e.type){case"add":n(e);break;case"update":(e=>{if(e.node.in_trigger&&(e.node.error=void 0),e.from_remote){const t=i.get_node(e.id,!1);if(!t)return;B(e.node);const n=t.getState(),{new_obj:r,change:o}=M(n,e.node);if(o){if(e.node.io)for(const t in e.node.io){r.io[t].fullvalue=e.node.io[t]?.fullvalue;for(const t in e.node.io){const n=e.node.io[t],o=r.io[t];n.hasOwnProperty("value")&&(void 0===n.value?o.value=null:"<NoValue>"===n.value?o.value=void 0:o.value=n.value)}}Us(r,t,s),s.logger.debug("update_action",r),t.setState(z(r))}}else s.worker&&s.worker.locally_update_node(e)})(e);break;case"delete":(e=>{s.logger.info("Deleting node",e.id),e.from_remote?o.getState().onNodesChange([{type:"remove",id:e.id}]):s.worker?.remove_node(e.id)})(e);break;case"error":(e=>{s.logger.error("Error",e),r({type:"update",id:e.id,node:{in_trigger:!1,error:e.error},from_remote:!0})})(e);break;case"trigger":(e=>{e.from_remote?r({type:"update",id:e.id,node:{in_trigger:!0,error:void 0},from_remote:!0}):s.worker?.trigger_node(e.id)})(e);break;default:s.logger.error("Unknown node action",e)}},o=(({on_node_change:e,on_edge_change:t,on_connect:n})=>{const r=e||(e=>{}),o=n||(e=>{}),i=N(((e,t)=>({nodes:[],edges:[],onNodesChange:n=>{e({nodes:aa(n,t().nodes)}),r(n)},onEdgesChange:n=>{e({edges:sa(n,t().edges)})},onConnect:e=>{null!=e.source&&null!=e.target&&o(e)}})));return i})({on_node_change:e=>{for(const t of e)switch(t.type){case"position":t.position&&r({type:"update",id:t.id,node:{properties:{"frontend:pos":[t.position.x,t.position.y]}},from_remote:!1});break;case"dimensions":t.dimensions&&r({type:"update",id:t.id,node:{properties:{"frontend:size":[t.dimensions.width,t.dimensions.height]}},from_remote:!1})}},on_edge_change:e=>{},on_connect:e=>{null!==e.source&&null!==e.target&&null!==e.sourceHandle&&null!==e.targetHandle&&s.worker&&s.worker.add_edge({src_nid:e.source,src_ioid:e.sourceHandle,trg_nid:e.target,trg_ioid:e.targetHandle,replace:!0})}}),i=(({})=>{const e=new Map;return{nodesstates:e,get_node:(t,n=!0)=>{const r=e.get(t);if(!r&&n){const n=e.keys();throw new Error(`Node ${t} not found, available nodes: ${Array.from(n)}`)}return r}}})({}),a={libstate:N(((e,t)=>({lib:{shelves:[]},external_worker:[],set:t=>e((e=>({...e,...t}))),get_lib:()=>t().lib,get_external_worker:()=>t().external_worker})))},s={local_settings:N(((e,t)=>({view_settings:{},update_view_settings:e=>{const t=s.local_settings.getState().view_settings,{new_obj:n,change:r}=M(t,e);r&&s.local_settings.setState((e=>({...e,view_settings:n})))}}))),local_state:N(((e,t)=>({selected_nodes:[],selected_edges:[],funcnodescontainerRef:null}))),options:t,lib:a,workermanager:void 0,workers:N(((e,t)=>({}))),workerstate:N(((e,t)=>({is_open:!1}))),render_options:N(((e,t)=>({}))),progress_state:N(((e,t)=>({message:"please select worker",status:"info",progress:0,blocking:!1}))),update_render_options:e=>{const t=s.render_options.getState(),{new_obj:n,change:r}=M(t,e);r&&s.render_options.setState(n)},worker:void 0,_unsubscribeFromWorker:void 0,set_worker:e=>{e!==s.worker&&(s._unsubscribeFromWorker&&(s._unsubscribeFromWorker(),s._unsubscribeFromWorker=void 0),e&&(s._unsubscribeFromWorker=e.state.subscribe((e=>{s.workerstate.setState(e)})),s.workerstate.setState(e.state.getState())),s.worker=e,e?.set_zustand(s))},nodespace:i,useReactFlowStore:o,on_node_action:r,on_edge_action:e=>{const t=o.getState();switch(e.type){case"add":if(e.from_remote){const n=t.edges,r=Bs(e);if(n.some((e=>e.id===r)))return;const i={id:r,source:e.src_nid,target:e.trg_nid,sourceHandle:e.src_ioid,targetHandle:e.trg_ioid,className:"funcnodes-edge animated"};s.logger.info("Adding edge",i),o.setState({edges:[...n,i]}),s.worker?.get_remote_node_state(e.src_nid),s.worker?.get_remote_node_state(e.trg_nid)}break;case"delete":if(e.from_remote){const n=t.edges,r=Bs(e);s.logger.info("Deleting edge",r);const i=n.filter((e=>e.id!==r));o.setState({edges:i}),s.worker?.get_remote_node_state(e.src_nid),s.worker?.get_remote_node_state(e.trg_nid)}break;default:s.logger.error("Unknown edge action",e)}},reactflowRef:null,clear_all:()=>{s.worker?.disconnect(),s.set_worker(void 0),s.workermanager?.setWorker(void 0),s.lib.libstate.getState().set({lib:{shelves:[]},external_worker:[]}),s.nodespace.nodesstates.clear(),s.useReactFlowStore.setState({nodes:[],edges:[]}),s.auto_progress()},center_node:e=>{if(!s.rf_instance)return;e=Array.isArray(e)?e:[e];const t=s.useReactFlowStore.getState().nodes.filter((t=>e.includes(t.id)));t.length>0&&s.rf_instance?.fitView({padding:.2,nodes:t})},center_all:()=>{console.log("center all",s.rf_instance),s.rf_instance?.fitView({padding:.2})},set_progress:e=>{if(""===e.message)return s.auto_progress();const t=s.progress_state.getState(),{new_obj:n,change:r}=M(t,e);r&&s.progress_state.setState(n)},auto_progress:()=>void 0===s.workermanager||s.workermanager.open?void 0===s.worker?s.set_progress({progress:0,message:"please select worker",status:"error",blocking:!1}):s.worker.is_open?void s.set_progress({progress:1,message:"running",status:"info",blocking:!1}):s.set_progress({progress:0,message:"connecting to worker",status:"info",blocking:!0}):s.set_progress({progress:0,message:"connecting to worker manager",status:"error",blocking:!1}),plugins:N(((e,t)=>({}))),add_plugin:(e,t)=>{void 0!==t&&s.plugins.setState((n=>({...n,[e]:t})))},dev_settings:{debug:!0},logger:new Zs("fn",Xs)};return s};function Ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:qs}=Object.prototype,{getPrototypeOf:Qs}=Object,el=(e=>t=>{const n=qs.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),tl=e=>(e=e.toLowerCase(),t=>el(t)===e),nl=e=>t=>typeof t===e,{isArray:rl}=Array,ol=nl("undefined");const il=tl("ArrayBuffer");const al=nl("string"),sl=nl("function"),ll=nl("number"),cl=e=>null!==e&&"object"==typeof e,ul=e=>{if("object"!==el(e))return!1;const t=Qs(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},dl=tl("Date"),fl=tl("File"),pl=tl("Blob"),hl=tl("FileList"),ml=tl("URLSearchParams"),[gl,yl,bl,vl]=["ReadableStream","Request","Response","Headers"].map(tl);function wl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),rl(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let a;for(r=0;r<i;r++)a=o[r],t.call(null,e[a],a,e)}}function xl(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const Cl="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,kl=e=>!ol(e)&&e!==Cl;const El=(Sl="undefined"!=typeof Uint8Array&&Qs(Uint8Array),e=>Sl&&e instanceof Sl);var Sl;const Il=tl("HTMLFormElement"),_l=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Al=tl("RegExp"),Nl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};wl(n,((n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)})),Object.defineProperties(e,r)},Ol="abcdefghijklmnopqrstuvwxyz",Rl="0123456789",Ml={DIGIT:Rl,ALPHA:Ol,ALPHA_DIGIT:Ol+Ol.toUpperCase()+Rl};const Tl=tl("AsyncFunction"),Pl=(Dl="function"==typeof setImmediate,jl=sl(Cl.postMessage),Dl?setImmediate:jl?((e,t)=>(Cl.addEventListener("message",(({source:n,data:r})=>{n===Cl&&r===e&&t.length&&t.shift()()}),!1),n=>{t.push(n),Cl.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e));var Dl,jl;const Fl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Cl):"undefined"!=typeof process&&process.nextTick||Pl;var Ll={isArray:rl,isArrayBuffer:il,isBuffer:function(e){return null!==e&&!ol(e)&&null!==e.constructor&&!ol(e.constructor)&&sl(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||sl(e.append)&&("formdata"===(t=el(e))||"object"===t&&sl(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&il(e.buffer),t},isString:al,isNumber:ll,isBoolean:e=>!0===e||!1===e,isObject:cl,isPlainObject:ul,isReadableStream:gl,isRequest:yl,isResponse:bl,isHeaders:vl,isUndefined:ol,isDate:dl,isFile:fl,isBlob:pl,isRegExp:Al,isFunction:sl,isStream:e=>cl(e)&&sl(e.pipe),isURLSearchParams:ml,isTypedArray:El,isFileList:hl,forEach:wl,merge:function e(){const{caseless:t}=kl(this)&&this||{},n={},r=(r,o)=>{const i=t&&xl(n,o)||o;ul(n[i])&&ul(r)?n[i]=e(n[i],r):ul(r)?n[i]=e({},r):rl(r)?n[i]=r.slice():n[i]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&wl(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(wl(t,((t,r)=>{n&&sl(t)?e[r]=Ks(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,a;const s={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:el,kindOfTest:tl,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(rl(e))return e;let t=e.length;if(!ll(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Il,hasOwnProperty:_l,hasOwnProp:_l,reduceDescriptors:Nl,freezeMethods:e=>{Nl(e,((t,n)=>{if(sl(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];sl(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return rl(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:xl,global:Cl,isContextDefined:kl,ALPHABET:Ml,generateString:(e=16,t=Ml.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&sl(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(cl(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=rl(e)?[]:{};return wl(e,((e,t)=>{const i=n(e,r+1);!ol(i)&&(o[t]=i)})),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:Tl,isThenable:e=>e&&(cl(e)||sl(e))&&sl(e.then)&&sl(e.catch),setImmediate:Pl,asap:Fl};function zl(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Ll.inherits(zl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ll.toJSONObject(this.config),code:this.code,status:this.status}}});const Bl=zl.prototype,Vl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Vl[e]={value:e}})),Object.defineProperties(zl,Vl),Object.defineProperty(Bl,"isAxiosError",{value:!0}),zl.from=(e,t,n,r,o,i)=>{const a=Object.create(Bl);return Ll.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),zl.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function Gl(e){return Ll.isPlainObject(e)||Ll.isArray(e)}function Wl(e){return Ll.endsWith(e,"[]")?e.slice(0,-2):e}function Hl(e,t,n){return e?e.concat(t).map((function(e,t){return e=Wl(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const Xl=Ll.toFlatObject(Ll,{},null,(function(e){return/^is[A-Z]/.test(e)}));function $l(e,t,n){if(!Ll.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ll.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Ll.isUndefined(t[e])}))).metaTokens,o=n.visitor||c,i=n.dots,a=n.indexes,s=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ll.isSpecCompliantForm(t);if(!Ll.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ll.isDate(e))return e.toISOString();if(!s&&Ll.isBlob(e))throw new zl("Blob is not supported. Use a Buffer instead.");return Ll.isArrayBuffer(e)||Ll.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,o){let s=e;if(e&&!o&&"object"==typeof e)if(Ll.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ll.isArray(e)&&function(e){return Ll.isArray(e)&&!e.some(Gl)}(e)||(Ll.isFileList(e)||Ll.endsWith(n,"[]"))&&(s=Ll.toArray(e)))return n=Wl(n),s.forEach((function(e,r){!Ll.isUndefined(e)&&null!==e&&t.append(!0===a?Hl([n],r,i):null===a?n:n+"[]",l(e))})),!1;return!!Gl(e)||(t.append(Hl(o,n,i),l(e)),!1)}const u=[],d=Object.assign(Xl,{defaultVisitor:c,convertValue:l,isVisitable:Gl});if(!Ll.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ll.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),Ll.forEach(n,(function(n,i){!0===(!(Ll.isUndefined(n)||null===n)&&o.call(t,n,Ll.isString(i)?i.trim():i,r,d))&&e(n,r?r.concat(i):[i])})),u.pop()}}(e),t}function Zl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Yl(e,t){this._pairs=[],e&&$l(e,this,t)}const Ul=Yl.prototype;function Jl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Kl(e,t,n){if(!t)return e;const r=n&&n.encode||Jl;Ll.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let i;if(i=o?o(t,n):Ll.isURLSearchParams(t)?t.toString():new Yl(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}Ul.append=function(e,t){this._pairs.push([e,t])},Ul.toString=function(e){const t=e?function(t){return e.call(this,t,Zl)}:Zl;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class ql{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ll.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var Ql={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ec={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Yl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const tc="undefined"!=typeof window&&"undefined"!=typeof document,nc="object"==typeof navigator&&navigator||void 0,rc=tc&&(!nc||["ReactNative","NativeScript","NS"].indexOf(nc.product)<0),oc="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ic=tc&&window.location.href||"http://localhost";var ac={...Object.freeze({__proto__:null,hasBrowserEnv:tc,hasStandardBrowserEnv:rc,hasStandardBrowserWebWorkerEnv:oc,navigator:nc,origin:ic}),...ec};function sc(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const a=Number.isFinite(+i),s=o>=e.length;if(i=!i&&Ll.isArray(r)?r.length:i,s)return Ll.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a;r[i]&&Ll.isObject(r[i])||(r[i]=[]);return t(e,n,r[i],o)&&Ll.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!a}if(Ll.isFormData(e)&&Ll.isFunction(e.entries)){const n={};return Ll.forEachEntry(e,((e,r)=>{t(function(e){return Ll.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const lc={transitional:Ql,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Ll.isObject(e);o&&Ll.isHTMLForm(e)&&(e=new FormData(e));if(Ll.isFormData(e))return r?JSON.stringify(sc(e)):e;if(Ll.isArrayBuffer(e)||Ll.isBuffer(e)||Ll.isStream(e)||Ll.isFile(e)||Ll.isBlob(e)||Ll.isReadableStream(e))return e;if(Ll.isArrayBufferView(e))return e.buffer;if(Ll.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return $l(e,new ac.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return ac.isNode&&Ll.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=Ll.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return $l(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ll.isString(e))try{return(t||JSON.parse)(e),Ll.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||lc.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ll.isResponse(e)||Ll.isReadableStream(e))return e;if(e&&Ll.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw zl.from(e,zl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ac.classes.FormData,Blob:ac.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ll.forEach(["delete","get","head","post","put","patch"],(e=>{lc.headers[e]={}}));const cc=Ll.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const uc=Symbol("internals");function dc(e){return e&&String(e).trim().toLowerCase()}function fc(e){return!1===e||null==e?e:Ll.isArray(e)?e.map(fc):String(e)}function pc(e,t,n,r,o){return Ll.isFunction(r)?r.call(this,t,n):(o&&(t=n),Ll.isString(t)?Ll.isString(r)?-1!==t.indexOf(r):Ll.isRegExp(r)?r.test(t):void 0:void 0)}let hc=class{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=dc(t);if(!o)throw new Error("header name must be a non-empty string");const i=Ll.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=fc(e))}const i=(e,t)=>Ll.forEach(e,((e,n)=>o(e,n,t)));if(Ll.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Ll.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&cc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Ll.isHeaders(e))for(const[t,r]of e.entries())o(r,t,n);else null!=e&&o(t,e,n);return this}get(e,t){if(e=dc(e)){const n=Ll.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ll.isFunction(t))return t.call(this,e,n);if(Ll.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=dc(e)){const n=Ll.findKey(this,e);return!(!n||void 0===this[n]||t&&!pc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=dc(e)){const o=Ll.findKey(n,e);!o||t&&!pc(0,n[o],o,t)||(delete n[o],r=!0)}}return Ll.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!pc(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Ll.forEach(this,((r,o)=>{const i=Ll.findKey(n,o);if(i)return t[i]=fc(r),void delete t[o];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();a!==o&&delete t[o],t[a]=fc(r),n[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ll.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ll.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[uc]=this[uc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=dc(e);t[r]||(!function(e,t){const n=Ll.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return Ll.isArray(e)?e.forEach(r):r(e),this}};function mc(e,t){const n=this||lc,r=t||n,o=hc.from(r.headers);let i=r.data;return Ll.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function gc(e){return!(!e||!e.__CANCEL__)}function yc(e,t,n){zl.call(this,null==e?"canceled":e,zl.ERR_CANCELED,t,n),this.name="CanceledError"}function bc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new zl("Request failed with status code "+n.status,[zl.ERR_BAD_REQUEST,zl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}hc.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ll.reduceDescriptors(hc.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Ll.freezeMethods(hc),Ll.inherits(yc,zl,{__CANCEL__:!0});const vc=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),c=r[a];o||(o=l),n[i]=s,r[i]=l;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),l-o<t)return;const f=c&&l-c;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const a=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),s=t-o;s>=i?a(e,t):(n=e,r||(r=setTimeout((()=>{r=null,a(n)}),i-s)))},()=>n&&a(n)]}((n=>{const i=n.loaded,a=n.lengthComputable?n.total:void 0,s=i-r,l=o(s);r=i;e({loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&i<=a?(a-i)/l:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),n)},wc=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},xc=e=>(...t)=>Ll.asap((()=>e(...t)));var Cc=ac.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ac.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ac.origin),ac.navigator&&/(msie|trident)/i.test(ac.navigator.userAgent)):()=>!0,kc=ac.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const a=[e+"="+encodeURIComponent(t)];Ll.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),Ll.isString(r)&&a.push("path="+r),Ll.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ec(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Sc=e=>e instanceof hc?{...e}:e;function Ic(e,t){t=t||{};const n={};function r(e,t,n,r){return Ll.isPlainObject(e)&&Ll.isPlainObject(t)?Ll.merge.call({caseless:r},e,t):Ll.isPlainObject(t)?Ll.merge({},t):Ll.isArray(t)?t.slice():t}function o(e,t,n,o){return Ll.isUndefined(t)?Ll.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function i(e,t){if(!Ll.isUndefined(t))return r(void 0,t)}function a(e,t){return Ll.isUndefined(t)?Ll.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t,n)=>o(Sc(e),Sc(t),0,!0)};return Ll.forEach(Object.keys(Object.assign({},e,t)),(function(r){const i=l[r]||o,a=i(e[r],t[r],r);Ll.isUndefined(a)&&i!==s||(n[r]=a)})),n}var _c=e=>{const t=Ic({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:l}=t;if(t.headers=s=hc.from(s),t.url=Kl(Ec(t.baseURL,t.url),e.params,e.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Ll.isFormData(r))if(ac.hasStandardBrowserEnv||ac.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(!1!==(n=s.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];s.setContentType([e||"multipart/form-data",...t].join("; "))}if(ac.hasStandardBrowserEnv&&(o&&Ll.isFunction(o)&&(o=o(t)),o||!1!==o&&Cc(t.url))){const e=i&&a&&kc.read(a);e&&s.set(i,e)}return t};var Ac="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=_c(e);let o=r.data;const i=hc.from(r.headers).normalize();let a,s,l,c,u,{responseType:d,onUploadProgress:f,onDownloadProgress:p}=r;function h(){c&&c(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=hc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());bc((function(e){t(e),h()}),(function(e){n(e),h()}),{data:d&&"text"!==d&&"json"!==d?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new zl("Request aborted",zl.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new zl("Network Error",zl.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||Ql;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new zl(t,o.clarifyTimeoutError?zl.ETIMEDOUT:zl.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&Ll.forEach(i.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),Ll.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),d&&"json"!==d&&(m.responseType=r.responseType),p&&([l,u]=vc(p,!0),m.addEventListener("progress",l)),f&&m.upload&&([s,c]=vc(f),m.upload.addEventListener("progress",s),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(a=t=>{m&&(n(!t||t.type?new yc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===ac.protocols.indexOf(y)?n(new zl("Unsupported protocol "+y+":",zl.ERR_BAD_REQUEST,e)):m.send(o||null)}))};const Nc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,a();const t=e instanceof Error?e:this.reason;r.abort(t instanceof zl?t:new yc(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,o(new zl(`timeout ${t} of ms exceeded`,zl.ETIMEDOUT))}),t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)})),e=null)};e.forEach((e=>e.addEventListener("abort",o)));const{signal:s}=r;return s.unsubscribe=()=>Ll.asap(a),s}},Oc=function*(e,t){let n=e.byteLength;if(n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},Rc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Mc=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of Rc(e))yield*Oc(n,t)}(e,t);let i,a=0,s=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return s(),void e.close();let i=r.byteLength;if(n){let e=a+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel:e=>(s(e),o.return())},{highWaterMark:2})},Tc="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Pc=Tc&&"function"==typeof ReadableStream,Dc=Tc&&("function"==typeof TextEncoder?(jc=new TextEncoder,e=>jc.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var jc;const Fc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Lc=Pc&&Fc((()=>{let e=!1;const t=new Request(ac.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),zc=Pc&&Fc((()=>Ll.isReadableStream(new Response("").body))),Bc={stream:zc&&(e=>e.body)};var Vc;Tc&&(Vc=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Bc[e]&&(Bc[e]=Ll.isFunction(Vc[e])?t=>t[e]():(t,n)=>{throw new zl(`Response type '${e}' is not supported`,zl.ERR_NOT_SUPPORT,n)})})));const Gc=async(e,t)=>{const n=Ll.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Ll.isBlob(e))return e.size;if(Ll.isSpecCompliantForm(e)){const t=new Request(ac.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ll.isArrayBufferView(e)||Ll.isArrayBuffer(e)?e.byteLength:(Ll.isURLSearchParams(e)&&(e+=""),Ll.isString(e)?(await Dc(e)).byteLength:void 0)})(t):n};var Wc=Tc&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:a,onDownloadProgress:s,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:f}=_c(e);c=c?(c+"").toLowerCase():"text";let p,h=Nc([o,i&&i.toAbortSignal()],a);const m=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let g;try{if(l&&Lc&&"get"!==n&&"head"!==n&&0!==(g=await Gc(u,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(Ll.isFormData(r)&&(e=n.headers.get("content-type"))&&u.setContentType(e),n.body){const[e,t]=wc(g,vc(xc(l)));r=Mc(n.body,65536,e,t)}}Ll.isString(d)||(d=d?"include":"omit");const o="credentials"in Request.prototype;p=new Request(t,{...f,signal:h,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:o?d:void 0});let i=await fetch(p);const a=zc&&("stream"===c||"response"===c);if(zc&&(s||a&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=Ll.toFiniteNumber(i.headers.get("content-length")),[n,r]=s&&wc(t,vc(xc(s),!0))||[];i=new Response(Mc(i.body,65536,n,(()=>{r&&r(),m&&m()})),e)}c=c||"text";let y=await Bc[Ll.findKey(Bc,c)||"text"](i,e);return!a&&m&&m(),await new Promise(((t,n)=>{bc(t,n,{data:y,headers:hc.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:p})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new zl("Network Error",zl.ERR_NETWORK,e,p),{cause:t.cause||t});throw zl.from(t,t&&t.code,e,p)}});const Hc={http:null,xhr:Ac,fetch:Wc};Ll.forEach(Hc,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Xc=e=>`- ${e}`,$c=e=>Ll.isFunction(e)||null===e||!1===e;var Zc=e=>{e=Ll.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){let t;if(n=e[i],r=n,!$c(n)&&(r=Hc[(t=String(n)).toLowerCase()],void 0===r))throw new zl(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+i]=r}if(!r){const e=Object.entries(o).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new zl("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Xc).join("\n"):" "+Xc(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Yc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new yc(null,e)}function Uc(e){Yc(e),e.headers=hc.from(e.headers),e.data=mc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Zc(e.adapter||lc.adapter)(e).then((function(t){return Yc(e),t.data=mc.call(e,e.transformResponse,t),t.headers=hc.from(t.headers),t}),(function(t){return gc(t)||(Yc(e),t&&t.response&&(t.response.data=mc.call(e,e.transformResponse,t.response),t.response.headers=hc.from(t.response.headers))),Promise.reject(t)}))}const Jc="1.7.9",Kc={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Kc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const qc={};Kc.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new zl(r(o," has been removed"+(t?" in "+t:"")),zl.ERR_DEPRECATED);return t&&!qc[o]&&(qc[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}},Kc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var Qc={assertOptions:function(e,t,n){if("object"!=typeof e)throw new zl("options must be an object",zl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],a=t[i];if(a){const t=e[i],n=void 0===t||a(t,i,e);if(!0!==n)throw new zl("option "+i+" must be "+n,zl.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new zl("Unknown option "+i,zl.ERR_BAD_OPTION)}},validators:Kc};const eu=Qc.validators;let tu=class{constructor(e){this.defaults=e,this.interceptors={request:new ql,response:new ql}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Ic(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Qc.assertOptions(n,{silentJSONParsing:eu.transitional(eu.boolean),forcedJSONParsing:eu.transitional(eu.boolean),clarifyTimeoutError:eu.transitional(eu.boolean)},!1),null!=r&&(Ll.isFunction(r)?t.paramsSerializer={serialize:r}:Qc.assertOptions(r,{encode:eu.function,serialize:eu.function},!0)),Qc.assertOptions(t,{baseUrl:eu.spelling("baseURL"),withXsrfToken:eu.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Ll.merge(o.common,o[t.method]);o&&Ll.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=hc.concat(i,o);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!s){const e=[Uc.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=a.length;let f=t;for(d=0;d<u;){const e=a[d++],t=a[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{c=Uc.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return Kl(Ec((e=Ic(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};Ll.forEach(["delete","get","head","options"],(function(e){tu.prototype[e]=function(t,n){return this.request(Ic(n||{},{method:e,url:t,data:(n||{}).data}))}})),Ll.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(Ic(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}tu.prototype[e]=t(),tu.prototype[e+"Form"]=t(!0)}));const nu={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nu).forEach((([e,t])=>{nu[t]=e}));const ru=function e(t){const n=new tu(t),r=Ks(tu.prototype.request,n);return Ll.extend(r,tu.prototype,n,{allOwnKeys:!0}),Ll.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Ic(t,n))},r}(lc);ru.Axios=tu,ru.CanceledError=yc,ru.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new yc(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e((function(e){t=e})),cancel:t}}},ru.isCancel=gc,ru.VERSION=Jc,ru.toFormData=$l,ru.AxiosError=zl,ru.Cancel=ru.CanceledError,ru.all=function(e){return Promise.all(e)},ru.spread=function(e){return function(t){return e.apply(null,t)}},ru.isAxiosError=function(e){return Ll.isObject(e)&&!0===e.isAxiosError},ru.mergeConfig=Ic,ru.AxiosHeaders=hc,ru.formToJSON=e=>sc(Ll.isHTMLForm(e)?new FormData(e):e),ru.getAdapter=Zc,ru.HttpStatusCode=nu,ru.default=ru;const{Axios:ou,AxiosError:iu,CanceledError:au,isCancel:su,CancelToken:lu,VERSION:cu,all:uu,Cancel:du,isAxiosError:fu,spread:pu,toFormData:hu,AxiosHeaders:mu,HttpStatusCode:gu,formToJSON:yu,getAdapter:bu,mergeConfig:vu}=ru;let wu;const xu=new Uint8Array(16);function Cu(){if(!wu&&(wu="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!wu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return wu(xu)}const ku=[];for(let e=0;e<256;++e)ku.push((e+256).toString(16).slice(1));var Eu={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Su(e,t,n){if(Eu.randomUUID&&!e)return Eu.randomUUID();const r=(e=e||{}).random||(e.rng||Cu)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return ku[e[t+0]]+ku[e[t+1]]+ku[e[t+2]]+ku[e[t+3]]+"-"+ku[e[t+4]]+ku[e[t+5]]+"-"+ku[e[t+6]]+ku[e[t+7]]+"-"+ku[e[t+8]]+ku[e[t+9]]+"-"+ku[e[t+10]]+ku[e[t+11]]+ku[e[t+12]]+ku[e[t+13]]+ku[e[t+14]]+ku[e[t+15]]}(r)}class Iu{constructor(e){this._hooks=new Map,this._ns_event_intercepts=new Map,this._unique_cmd_outs={},this.uuid=e.uuid,this.on_error=e.on_error||(e=>{this._zustand?.logger.error(e)}),this.messagePromises=new Map,this._local_nodeupdates=new Map,this._nodeupdatetimer=setTimeout((()=>{this.sync_local_node_updates()}),5e3),this.state=N(((e,t)=>({is_open:!1}))),e.zustand&&this.set_zustand(e.zustand),e.on_sync_complete?this.on_sync_complete=e.on_sync_complete:this.on_sync_complete=async()=>{},this._responsive=!1,this._last_pong=Date.now()-36e5,setInterval((()=>{this.is_open&&this.send({type:"ping"})}),1e3),setInterval((()=>{Date.now()-this._last_pong>5e3?this._responsive=!1:this._responsive=!0}),5e3)}_receive_pong(){this._last_pong=Date.now(),this._responsive=!0}set_zustand(e){e!==this._zustand&&(this._zustand=e,e.set_worker(this),this._zustand.auto_progress(),this.stepwise_fullsync())}add_hook(e,t){const n=this._hooks.get(e)||[];n.push(t),this._hooks.set(e,n);return()=>{const n=this._hooks.get(e)||[],r=n.indexOf(t);r>=0&&n.splice(r,1)}}async call_hooks(e,t){const n=[];for(const r of this._hooks.get(e)||[]){const e=r({worker:this,data:t});e instanceof Promise&&n.push(e)}await Promise.all(n)}add_ns_event_intercept(e,t){const n=this._ns_event_intercepts.get(e)||[];n.push(t),this._ns_event_intercepts.set(e,n);return()=>{const n=this._ns_event_intercepts.get(e)||[],r=n.indexOf(t);r>=0&&n.splice(r,1)}}async intercept_ns_event(e){let t=e;for(const n of this._ns_event_intercepts.get(e.event)||[])t=await n(t);return t}get is_open(){return this.state.getState().is_open}set is_open(e){this.state.setState({is_open:e})}async stepwise_fullsync(){this._zustand&&this.is_open&&(await this.sync_lib(),await this.sync_external_worker(),await this.sync_funcnodes_plugins(),await this.sync_nodespace(),await this.sync_view_state(),await this.on_sync_complete(this))}async sync_lib(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_library",wait_for_response:!0,retries:2,unique:!0});this._zustand.lib.libstate.getState().set({lib:e})}async sync_external_worker(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_worker_dependencies",wait_for_response:!0,unique:!0});this._zustand.lib.libstate.getState().set({external_worker:e})}async sync_funcnodes_plugins(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_plugin_keys",wait_for_response:!0,unique:!0,kwargs:{type:"react"}});for(const t of e){const e=await this._send_cmd({cmd:"get_plugin",wait_for_response:!0,kwargs:{key:t,type:"react"},unique:!0});if(e.js)for(const t of e.js){const e=document.createElement("script");e.text=atob(t),document.body.appendChild(e)}if(e.css)for(const t of e.css){const e=document.createElement("style");e.innerHTML=atob(t),document.head.appendChild(e)}if(void 0!==e.module){const n=atob(e.module),r=n.length,o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=n.charCodeAt(e);const i=new Blob([o],{type:"application/javascript"}),a=URL.createObjectURL(i),s=await import(a);URL.revokeObjectURL(a),this._zustand.add_plugin(t,s.default)}}}async sync_view_state(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"view_state",wait_for_response:!0,unique:!0});e.renderoptions&&this._zustand.update_render_options(e.renderoptions);const t=e.nodes;if(t)for(const e in t){const n={};F(n,t[e]),this._zustand.on_node_action({type:"update",node:n,id:e,from_remote:!0})}}async sync_nodespace(){if(!this._zustand)return;if(!this.is_open)return;const e=await this._send_cmd({cmd:"get_nodes",kwargs:{with_frontend:!0},wait_for_response:!0,unique:!0});for(const t of e)this._receive_node_added(t);const t=await this._send_cmd({cmd:"get_edges",wait_for_response:!0,unique:!0});for(const e of t)this._receive_edge_added(...e)}async fullsync(){if(!this._zustand)return;if(!this.is_open)return;let e;for(;;)try{e=await this._send_cmd({cmd:"full_state",unique:!0});break}catch(e){this._zustand.logger.error("Error in fullsync",e)}this._zustand.logger.debug("Full state",e),this._zustand.lib.libstate.getState().set({lib:e.backend.lib,external_worker:e.worker_dependencies}),e.view.renderoptions&&this._zustand.update_render_options(e.view.renderoptions);const t=e.view.nodes;for(const n of e.backend.nodes)void 0!==t[n.id]&&F(n,t[n.id]),this._receive_node_added(n);for(const t of e.backend.edges)this._receive_edge_added(...t)}async _receive_edge_added(e,t,n,r){this._zustand&&this._zustand.on_edge_action({type:"add",from_remote:!0,src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})}async trigger_node(e){await this._send_cmd({cmd:"trigger_node",kwargs:{nid:e},wait_for_response:!1})}async add_node(e){const t=await this._send_cmd({cmd:"add_node",kwargs:{id:e}});this._receive_node_added(t)}async remove_node(e){await this._send_cmd({cmd:"remove_node",kwargs:{id:e}})}async _receive_node_added(e){this._zustand&&this._zustand.on_node_action({type:"add",node:e,id:e.id,from_remote:!0})}add_edge({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r,replace:o=!1}){return this._send_cmd({cmd:"add_edge",kwargs:{src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r,replace:o}})}remove_edge({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r}){return this._send_cmd({cmd:"remove_edge",kwargs:{src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r}})}async add_external_worker({module:e,cls_module:t,cls_name:n}){return await this._send_cmd({cmd:"add_external_worker",kwargs:{module:e,cls_module:t,cls_name:n}})}sync_local_node_updates(){clearTimeout(this._nodeupdatetimer),this._local_nodeupdates.forEach((async(e,t)=>{const n=await this._send_cmd({cmd:"update_node",kwargs:{nid:t,data:e},wait_for_response:!0});this._zustand&&this._zustand.on_node_action({type:"update",node:n,id:t,from_remote:!0})})),this._local_nodeupdates.clear(),this._nodeupdatetimer=setTimeout((()=>{this.sync_local_node_updates()}),200)}locally_update_node(e){const t=this._local_nodeupdates.get(e.id);if(t){const{new_obj:n,change:r}=M(t,e.node);r&&this._local_nodeupdates.set(e.id,n)}else this._local_nodeupdates.set(e.id,e.node);e.immediate&&this.sync_local_node_updates()}async get_remote_node_state(e){const t=await this._send_cmd({cmd:"get_node_state",kwargs:{nid:e},wait_for_response:!0});this._zustand&&this._zustand.on_node_action({type:"update",node:t,id:t.id,from_remote:!0})}set_io_value({nid:e,ioid:t,value:n,set_default:r=!1}){return this._send_cmd({cmd:"set_io_value",kwargs:{nid:e,ioid:t,value:n,set_default:r},wait_for_response:!0})}clear(){return this._send_cmd({cmd:"clear",unique:!0})}save(){return this._send_cmd({cmd:"save",wait_for_response:!0,unique:!0})}load(e){return this._send_cmd({cmd:"load_data",kwargs:{data:e},wait_for_response:!0}).then((()=>{this.stepwise_fullsync()}))}async get_io_value({nid:e,ioid:t}){const n=await this._send_cmd({cmd:"get_io_value",kwargs:{nid:e,ioid:t},wait_for_response:!0});return this._zustand?(this._zustand.on_node_action({type:"update",node:{io:{[t]:{value:n}}},id:e,from_remote:!0}),n):n}async get_ios_values({nid:e}){const t=await this._send_cmd({cmd:"get_ios_values",kwargs:{nid:e},wait_for_response:!0});if(!this._zustand)return t;const n={};for(const e in t)n[e]={value:t[e]};return this._zustand.on_node_action({type:"update",node:{io:n},id:e,from_remote:!0}),t}async get_runstate(){return await this._send_cmd({cmd:"get_runstate",wait_for_response:!0,unique:!0})}async _send_cmd({cmd:e,kwargs:t,wait_for_response:n=!0,response_timeout:r=5e3,retries:o=2,unique:i=!1}){const a={type:"cmd",cmd:e,kwargs:t||{}};if(await new Promise((async e=>{if(this._responsive)return e();const t=setInterval((()=>{this._responsive&&(clearInterval(t),e())}),100)})),n){if(i&&void 0!==this._unique_cmd_outs[a.cmd])return this._unique_cmd_outs[a.cmd];o<0&&(o=0);const t=async()=>{let t;for(;o>=0;){const n=a.id||Su();a.id=n;const i=new Promise(((t,o)=>{const i=setTimeout((()=>{o("Timeout@wait_for_response for "+e)}),r);this.messagePromises.set(n,{resolve:e=>{clearTimeout(i),t(e),this.messagePromises.delete(n)},reject:e=>{clearTimeout(i),o(e),this.messagePromises.delete(n)}})}));await this.send(a);try{t=await i;break}catch(e){if(0===o)throw delete this._unique_cmd_outs[a.cmd],e;o-=1;continue}}return delete this._unique_cmd_outs[a.cmd],t},n=t();return i&&(this._unique_cmd_outs[a.cmd]=n),n}return this.send(a)}async send(e){throw new Error("async send(data: any) not implemented")}async upload_file({files:e,onProgressCallback:t,root:n}){throw new Error("upload_file not implemented ")}async handle_large_message_hint({}){throw new Error("async handle_large_message_hint({}: LargeMessageHint) not implemented ")}async receive_workerevent({event:e,data:t}){switch(e){case"worker_error":if(!this._zustand)return;return this._zustand.logger.error(t.error);case"update_worker_dependencies":if(!this._zustand)return;return this._zustand.lib.libstate.getState().set({external_worker:t.worker_dependencies});case"lib_update":return void await this.sync_lib();case"fullsync":return void await this.stepwise_fullsync();case"external_worker_update":return await this.sync_lib(),void await this.sync_external_worker();case"starting":return void this.call_hooks("starting");case"stopping":return void this.call_hooks("stopping");default:console.warn("Unhandled worker event",e,t)}}async receive_nodespace_event(e){const{event:t,data:n}=await this.intercept_ns_event(e);switch(t){case"after_set_value":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,io:{[n.io]:{value:n.result}}},id:n.node,from_remote:!0});case"after_update_value_options":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,io:{[n.io]:{value_options:n.result}}},id:n.node,from_remote:!0});case"triggerstart":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,in_trigger:!0},id:n.node,from_remote:!0});case"triggerdone":if(!this._zustand)return;return this._zustand.on_node_action({type:"update",node:{id:n.node,in_trigger:!1},id:n.node,from_remote:!0});case"node_trigger_error":if(!this._zustand)return;return this._zustand.on_node_action({type:"error",errortype:"trigger",error:n.error,id:n.node,tb:n.tb,from_remote:!0});case"node_removed":if(!this._zustand)return;return this._zustand.on_node_action({type:"delete",id:n.node,from_remote:!0}),void this.call_hooks("node_removed",{node:n.node});case"node_added":return void this._receive_node_added(n.node);case"after_disconnect":case"after_unforward":if(!n.result)return;if(!Array.isArray(n.result))return;if(4!==n.result.length)return;if(!this._zustand)return;return this._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:n.result[0],src_ioid:n.result[1],trg_nid:n.result[2],trg_ioid:n.result[3]});case"after_connect":case"after_forward":if(!n.result)return;if(!Array.isArray(n.result))return;if(4!==n.result.length)return;return this._receive_edge_added(...n.result);case"after_add_shelf":case"after_remove_shelf":if(!n.result)return;if(!this._zustand)return;return this._zustand.lib.libstate.getState().set({lib:n.result});case"progress":if(!this._zustand)return;if(n.node)return this._zustand.on_node_action({type:"update",node:{id:n.node,progress:n.info},id:n.node,from_remote:!0});console.warn("Unhandled nodepsace event",t,n);break;default:console.warn("Unhandled nodepsace event",t,n)}}async add_lib(e,t){return await this._send_cmd({cmd:"add_package_dependency",kwargs:{name:e,version:t},wait_for_response:!1})}async remove_lib(e){return await this._send_cmd({cmd:"remove_package_dependency",kwargs:{name:e},wait_for_response:!1})}async receive(e){let t;switch(this._last_pong=Date.now(),this._responsive=!0,e.type){case"pong":return void this._receive_pong();case"nsevent":return await this.receive_nodespace_event(e);case"result":if(t=e.id&&this.messagePromises.get(e.id),t)return t.resolve(e.result);break;case"error":if(this.on_error(e.tb+"\n"+e.error),t=e.id&&this.messagePromises.get(e.id),t)return t.reject(e.error);break;case"progress":if(!this._zustand)return;this._zustand.set_progress(e);break;case"workerevent":return await this.receive_workerevent(e);case"large_message":return await this.handle_large_message_hint(e);default:console.warn("Unhandled message",e)}}disconnect(){}onclose(){this.is_open=!1,this._zustand&&this._zustand.auto_progress()}async reconnect(){}async stop(){await this._send_cmd({cmd:"stop_worker",wait_for_response:!1});const e=this.onclose.bind(this);this.onclose=()=>{e(),this._zustand&&(this._zustand.worker===this&&this._zustand.clear_all(),this.onclose=e)}}async get_io_full_value({nid:e,ioid:t}){const n=await this._send_cmd({cmd:"get_io_full_value",kwargs:{nid:e,ioid:t},wait_for_response:!0});return this._zustand?(this._zustand.on_node_action({type:"update",node:{io:{[t]:{fullvalue:n}}},id:e,from_remote:!0}),n):n}async update_io_options({nid:e,ioid:t,options:n}){const r=await this._send_cmd({cmd:"update_io_options",kwargs:{nid:e,ioid:t,...n},wait_for_response:!0});if(!this._zustand)return r;this._zustand.on_node_action({type:"update",node:{io:{[t]:{...n}}},id:e,from_remote:!0})}async get_node_status(e){return await this._send_cmd({cmd:"get_node_state",kwargs:{nid:e},wait_for_response:!0})}async get_available_modules(){return await this._send_cmd({cmd:"get_available_modules",wait_for_response:!0,unique:!0})}async update_external_worker(e,t,n){return await this._send_cmd({cmd:"update_external_worker",kwargs:{worker_id:e,class_id:t,...n},wait_for_response:!0})}async remove_external_worker(e,t){return await this._send_cmd({cmd:"remove_external_worker",kwargs:{worker_id:e,class_id:t},wait_for_response:!0})}async export({withFiles:e=!1}){return await this._send_cmd({cmd:"export_worker",wait_for_response:!0,kwargs:{with_files:e}})}async update_from_export(e){const t=this.add_hook("node_added",(async({})=>{this._zustand?.center_all()}));try{const t=await this._send_cmd({cmd:"update_from_export",kwargs:{data:e},wait_for_response:!0,response_timeout:6e5,unique:!0});return await new Promise((e=>{setTimeout((()=>{e()}),1e3)})),await this.stepwise_fullsync(),t}finally{t()}}}class _u extends Iu{constructor(e){super(e),this._websocket=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=5e3,this._reconnect=!0,this._url=e.url,new Promise((e=>{this.connect(),e(null)})),this._zustand&&this._zustand.auto_progress()}connect(){this._zustand?.logger.info("Connecting to websocket"),this.is_open=!1,this._websocket=new WebSocket(this._url),this._websocket.onopen=()=>{this.onopen()},this._websocket.onclose=()=>{this.onclose()},this._websocket.onerror=()=>{this.on_ws_error()},this._websocket.onmessage=e=>{this.onmessage(e.data)}}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}auto_reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let e=this.calculateReconnectTimeout();this._zustand?.logger.info(`Attempting to reconnect in ${e} ms`),setTimeout((()=>{this._websocket&&this._websocket.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())}),e)}else this._zustand?.logger.warn("Maximum reconnect attempts reached. Giving up.")}async onmessage(e){const t=JSON.parse(e);this._zustand?.logger.debug(`Recieved data of length: ${e.length} and data"`,t),await this.receive(t)}get http_protocol(){return this.secure_url?"https":"http"}get secure_url(){return this._url.startsWith("wss")}get url_wo_protocol(){return this._url.substring(this.secure_url?6:5)}get http_url(){var e=this.http_protocol+"://"+this.url_wo_protocol;return"/"!==e[e.length-1]&&(e+="/"),e}async upload_file({files:e,onProgressCallback:t,root:n}){const r=`${this.http_url}upload/`,o=new FormData,i=Array.isArray(e)?e:Array.from(e);for(const e of i){const t=e.webkitRelativePath||e.name,r=n?`${n}/${t}`:t;o.append("file",e,r)}try{return(await ru.post(r,o,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e=>{t&&t(e.loaded,e.total)}})).data.file}catch(e){throw new Error("Failed to upload file")}}async handle_large_message_hint({msg_id:e}){const t=this.http_url+"message/"+e,n=await fetch(t,{method:"GET",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}}),r=await n.json();this.receive(r)}onopen(){this._zustand?.logger.info("Websocket opened"),this.is_open=!0,this._zustand&&this._zustand.auto_progress(),this.reconnectAttempts=0,this.stepwise_fullsync()}onclose(){this._zustand?.logger.info("Websocket closed"),super.onclose(),this._reconnect&&(this._zustand?.logger.info("Websocket closed,reconnecting"),this.auto_reconnect())}on_ws_error(){this._zustand?.logger.warn("Websocket error"),this._websocket?this._websocket.close():this.auto_reconnect()}async send_large_message(e){const t=`${this.http_url}message/`;await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}async send(e){if(!this._websocket||this._websocket.readyState!==WebSocket.OPEN)return void this._zustand?.logger.warn("Websocket not connected");const t=JSON.stringify(e);if(new Blob([t]).size>1e6)return this._zustand?.logger.info("Data too large, sending via http"),await this.send_large_message(t);this._zustand?.logger.debug("Sending data",e),this._websocket.send(t)}async stop(){await super.stop(),this._reconnect=!1}close(){this._websocket&&this._websocket.close()}disconnect(){super.disconnect(),this._reconnect=!1,this.close()}async reconnect(){await super.reconnect(),this._reconnect=!0,!this._websocket||(this._zustand?.logger.info("Reconnecting"),this._websocket.readyState!==WebSocket.OPEN&&this._websocket.readyState!==WebSocket.CONNECTING||(this._websocket.readyState===WebSocket.CONNECTING&&await new Promise(((e,t)=>{if(null===this._websocket)return;let n=setTimeout((()=>{t("Timeout@reconnect")}),2e3);this._websocket.addEventListener("open",(()=>{clearTimeout(n),e(null)}),{once:!0}),this._websocket.readyState===WebSocket.OPEN&&(clearTimeout(n),e(null))})),this._websocket.readyState!==WebSocket.OPEN))?this.connect():this.stepwise_fullsync()}}class Au{constructor(e,t){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=2e3,this.wsuri=e,this.zustand=t,this.workers={},this.on_setWorker=e=>{this.zustand.set_worker(e)},this.connect()}get open(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.zustand.set_progress({progress:0,message:"connecting to worker manager",status:"info",blocking:!0}),this.zustand.logger.info("Connecting to websocket:",this.wsuri),this.ws=new WebSocket(this.wsuri),this.ws.onopen=()=>{this.onopen()},this.ws.onclose=()=>{this.onclose()},this.ws.onerror=()=>{this.on_ws_error()},this.ws.onmessage=e=>{this.onmessage(e.data)},this.connectionTimeout=setTimeout((()=>{this.ws?.readyState!==WebSocket.OPEN&&this.on_ws_error()}),5e3)}on_ws_error(){console.warn("Websocket error"),this.ws?this.ws.close():this.reconnect()}onopen(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.zustand.auto_progress(),this.ws&&this.ws.send("worker_status");const e=window.localStorage.getItem("funcnodes__active_worker");e&&this.set_active(e)}onmessage(e){let t=JSON.parse(e);if("worker_status"!==t.type)if("set_worker"!==t.type)"progress"!==t.type?this.zustand.logger.error("WorkerManager: unknown message",t):this.zustand.set_progress(t);else if("WSWorker"===t.data.type){let e="ws"+(t.data.ssl?"s":"")+"://"+t.data.host+":"+t.data.port;this.setWorker(this.workers[t.data.uuid]||new _u({url:e,zustand:this.zustand,uuid:t.data.uuid,on_sync_complete:this.zustand.options.on_sync_complete}))}else this.zustand.logger.error("WorkerManager: unknown worker type",t);else{const e={};for(let n of t.active)n.active=!0,e[n.uuid]=n;for(let n of t.inactive)n.active=!1,e[n.uuid]=n;this.zustand.workers.setState(e)}}setWorker(e){for(let t in this.workers)t!==e?.uuid&&this.workers[t].disconnect();void 0!==e&&(this.workers[e.uuid]=e,e.reconnect()),window.localStorage.setItem("funcnodes__active_worker",e?.uuid||""),void 0!==this.zustand.worker&&this.zustand.clear_all(),this.zustand.set_worker(e),this.on_setWorker(e)}async restart_worker(e){this.ws?.send(JSON.stringify({type:"restart_worker",workerid:e}))}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let e=this.calculateReconnectTimeout();this.zustand.logger.info(`Attempting to reconnect in ${e} ms`),setTimeout((()=>{this.ws&&this.ws.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())}),e)}else this.zustand.logger.warn("Maximum reconnect attempts reached. Giving up.")}onclose(){this.zustand.logger.warn("WorkerManager: onclose"),this.reconnect()}set_active(e){this.ws&&this.ws.send(JSON.stringify({type:"set_active",workerid:e}))}new_worker({name:e,reference:t,copyLib:n,copyNS:r}){e||(e=void 0),n||(n=!1),r||(r=!1),t||(t=void 0,n=!1,r=!1),this.ws&&this.ws.send(JSON.stringify({type:"new_worker",kwargs:{name:e,reference:t,copyLib:n,copyNS:r}}))}}function Nu(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Ou(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ru(...e){return t=>{let n=!1;const r=e.map((e=>{const r=Ou(e,t);return n||"function"!=typeof r||(n=!0),r}));if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Ou(e[t],null)}}}}function Mu(...e){return o.useCallback(Ru(...e),e)}var Tu,Pu={exports:{}},Du={};var ju,Fu,Lu={};
29
29
  /**
30
30
  * @license React
31
31
  * react-jsx-runtime.development.js
@@ -153,5 +153,5 @@ function(e,t){const n=nF(e,t);return"production"!==process.env.NODE_ENV?(...t)=>
153
153
  * content-type
154
154
  * Copyright(c) 2015 Douglas Christopher Wilson
155
155
  * MIT Licensed
156
- */var OB=function(){if(AB)return NB;AB=1;var e=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,t=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,n=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,r=/\\([\u000b\u0020-\u00ff])/g,o=/([\\"])/g,i=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function a(e){var r=String(e);if(n.test(r))return r;if(r.length>0&&!t.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(o,"\\$1")+'"'}function s(e){this.parameters=Object.create(null),this.type=e}return NB.format=function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!i.test(r))throw new TypeError("invalid type");var o=r;if(t&&"object"==typeof t)for(var s,l=Object.keys(t).sort(),c=0;c<l.length;c++){if(s=l[c],!n.test(s))throw new TypeError("invalid parameter name");o+="; "+s+"="+a(t[s])}return o},NB.parse=function(t){if(!t)throw new TypeError("argument string is required");var n="object"==typeof t?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(t):t;if("string"!=typeof n)throw new TypeError("argument string is required to be a string");var o=n.indexOf(";"),a=-1!==o?n.slice(0,o).trim():n.trim();if(!i.test(a))throw new TypeError("invalid media type");var l=new s(a.toLowerCase());if(-1!==o){var c,u,d;for(e.lastIndex=o;u=e.exec(n);){if(u.index!==o)throw new TypeError("invalid parameter format");o+=u[0].length,c=u[1].toLowerCase(),34===(d=u[2]).charCodeAt(0)&&-1!==(d=d.slice(1,-1)).indexOf("\\")&&(d=d.replace(r,"$1")),l.parameters[c]=d}if(o!==n.length)throw new TypeError("invalid parameter format")}return l},NB}(),RB=new Map,MB=function(e){return e.cloneNode(!0)},TB=function(){return"file:"===window.location.protocol},PB=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&2===r.readyState){var t=r.getResponseHeader("Content-Type");if(!t)throw new Error("Content type not found");var o=OB.parse(t).type;if("image/svg+xml"!==o&&"text/plain"!==o)throw new Error("Invalid content type: ".concat(o))}if(4===r.readyState){if(404===r.status||null===r.responseXML)throw new Error(TB()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(!(200===r.status||TB()&&0===r.status))throw new Error("There was a problem injecting the SVG: "+r.status+" "+r.statusText);n(null,r)}}catch(e){if(r.abort(),!(e instanceof Error))throw e;n(e,r)}},r.open("GET",e),r.withCredentials=t,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.send()},DB={},jB=function(e,t){DB[e]=DB[e]||[],DB[e].push(t)},FB=function(e,t,n){if(RB.has(e)){var r=RB.get(e);if(void 0===r)return void jB(e,n);if(r instanceof SVGSVGElement)return void n(null,MB(r))}RB.set(e,void 0),jB(e,n),PB(e,t,(function(t,n){var r;t?RB.set(e,t):(null===(r=n.responseXML)||void 0===r?void 0:r.documentElement)instanceof SVGSVGElement&&RB.set(e,n.responseXML.documentElement),function(e){for(var t=function(t,n){setTimeout((function(){if(Array.isArray(DB[e])){var n=RB.get(e),r=DB[e][t];n instanceof SVGSVGElement&&r(null,MB(n)),n instanceof Error&&r(n),t===DB[e].length-1&&delete DB[e]}}),0)},n=0,r=DB[e].length;n<r;n++)t(n)}(e)}))},LB=function(e,t,n){PB(e,t,(function(e,t){var r;e?n(e):(null===(r=t.responseXML)||void 0===r?void 0:r.documentElement)instanceof SVGSVGElement&&n(null,t.responseXML.documentElement)}))},zB=0,BB=[],VB={},GB="http://www.w3.org/1999/xlink",WB=function(e,t,n,r,o,i,a){var s=e.getAttribute("data-src")||e.getAttribute("src");if(s){if(-1!==BB.indexOf(e))return BB.splice(BB.indexOf(e),1),void(e=null);BB.push(e),e.setAttribute("src",""),(r?FB:LB)(s,o,(function(r,o){if(!o)return BB.splice(BB.indexOf(e),1),e=null,void a(r);var l=e.getAttribute("id");l&&o.setAttribute("id",l);var c=e.getAttribute("title");c&&o.setAttribute("title",c);var u=e.getAttribute("width");u&&o.setAttribute("width",u);var d=e.getAttribute("height");d&&o.setAttribute("height",d);var f=Array.from(new Set(Ad(Ad(Ad([],(o.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();o.setAttribute("class",f);var p=e.getAttribute("style");p&&o.setAttribute("style",p),o.setAttribute("data-src",s);var h=[].filter.call(e.attributes,(function(e){return/^data-\w[\w-]*$/.test(e.name)}));if(Array.prototype.forEach.call(h,(function(e){e.name&&e.value&&o.setAttribute(e.name,e.value)})),n){var m,g,y,b,v,w={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(w).forEach((function(e){m=e,y=w[e];for(var t=function(e,t){var n;b=g[e].id,v=b+"-"+ ++zB,Array.prototype.forEach.call(y,(function(e){for(var t=0,r=(n=o.querySelectorAll("["+e+'*="'+b+'"]')).length;t<r;t++){var i=n[t].getAttribute(e);i&&!i.match(new RegExp('url\\("?#'+b+'"?\\)'))||n[t].setAttribute(e,"url(#"+v+")")}}));for(var r=o.querySelectorAll("[*|href]"),i=[],a=0,s=r.length;a<s;a++){var l=r[a].getAttributeNS(GB,"href");l&&l.toString()==="#"+g[e].id&&i.push(r[a])}for(var c=0,u=i.length;c<u;c++)i[c].setAttributeNS(GB,"href","#"+v);g[e].id=v},n=0,r=(g=o.querySelectorAll(m+"[id]")).length;n<r;n++)t(n)}))}o.removeAttribute("xmlns:a");for(var x,C,k=o.querySelectorAll("script"),E=[],S=0,I=k.length;S<I;S++)(C=k[S].getAttribute("type"))&&"application/ecmascript"!==C&&"application/javascript"!==C&&"text/javascript"!==C||((x=k[S].innerText||k[S].textContent)&&E.push(x),o.removeChild(k[S]));if(E.length>0&&("always"===t||"once"===t&&!VB[s])){for(var _=0,A=E.length;_<A;_++)new Function(E[_])(window);VB[s]=!0}var N=o.querySelectorAll("style");if(Array.prototype.forEach.call(N,(function(e){e.textContent+=""})),o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o.setAttribute("xmlns:xlink",GB),i(o),!e.parentNode)return BB.splice(BB.indexOf(e),1),e=null,void a(new Error("Parent node is null"));e.parentNode.replaceChild(o,e),BB.splice(BB.indexOf(e),1),e=null,a(null,o)}))}else a(new Error("Invalid data-src or src attribute"))},HB=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],XB="http://www.w3.org/2000/svg",$B="http://www.w3.org/1999/xlink",ZB=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}Kz(t,e);var n=t.prototype;return n.renderSVG=function(){var e=this;if(this.reactWrapper instanceof function(e){return((null==e?void 0:e.ownerDocument)||document).defaultView||window}(this.reactWrapper).Node){var t,n,r=this.props,o=r.desc,i=r.evalScripts,a=r.httpRequestWithCredentials,s=r.renumerateIRIElements,l=r.src,c=r.title,u=r.useRequestCache,d=this.props.onError,f=this.props.beforeInjection,p=this.props.afterInjection,h=this.props.wrapper;"svg"===h?((t=document.createElementNS(XB,h)).setAttribute("xmlns",XB),t.setAttribute("xmlns:xlink",$B),n=document.createElementNS(XB,h)):(t=document.createElement(h),n=document.createElement(h)),t.appendChild(n),n.dataset.src=l,this.nonReactWrapper=this.reactWrapper.appendChild(t);var m=function(t){e.removeSVG(),e._isMounted?e.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){d(t)})):d(t)};!function(e,t){var n=void 0===t?{}:t,r=n.afterAll,o=void 0===r?function(){}:r,i=n.afterEach,a=void 0===i?function(){}:i,s=n.beforeEach,l=void 0===s?function(){}:s,c=n.cacheRequests,u=void 0===c||c,d=n.evalScripts,f=void 0===d?"never":d,p=n.httpRequestWithCredentials,h=void 0!==p&&p,m=n.renumerateIRIElements,g=void 0===m||m;if(e&&"length"in e)for(var y=0,b=0,v=e.length;b<v;b++)WB(e[b],f,g,u,h,l,(function(t,n){a(t,n),e&&"length"in e&&e.length===++y&&o(y)}));else e?WB(e,f,g,u,h,l,(function(t,n){a(t,n),o(1),e=null})):o(0)}(n,{afterEach:function(t,n){t?m(t):e._isMounted&&e.setState((function(){return{isLoading:!1}}),(function(){try{p(n)}catch(e){m(e)}}))},beforeEach:function(e){if(e.setAttribute("role","img"),o){var t=e.querySelector(":scope > desc");t&&e.removeChild(t);var n=document.createElement("desc");n.innerHTML=o,e.prepend(n)}if(c){var r=e.querySelector(":scope > title");r&&e.removeChild(r);var i=document.createElement("title");i.innerHTML=c,e.prepend(i)}try{f(e)}catch(e){m(e)}},cacheRequests:u,evalScripts:i,httpRequestWithCredentials:a,renumerateIRIElements:s})}},n.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},n.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},n.componentDidUpdate=function(e){var t=this;(function(e,t){for(var n in e)if(!(n in t))return!0;for(var r in t)if(e[r]!==t[r])return!0;return!1})(bR({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},n.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},n.render=function(){var e=this.props;e.afterInjection,e.beforeInjection,e.desc,e.evalScripts;var t=e.fallback;e.httpRequestWithCredentials;var n=e.loading;e.renumerateIRIElements,e.src,e.title,e.useRequestCache;var r=e.wrapper,i=mR(e,HB),a=r;return o.createElement(a,bR({},i,{ref:this.refCallback},"svg"===r?{xmlns:XB,xmlnsXlink:$B}:{}),this.state.isLoading&&n&&o.createElement(n,null),this.state.hasError&&t&&o.createElement(t,null))},t}(o.Component);ZB.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"},ZB.propTypes={afterInjection:ey.func,beforeInjection:ey.func,desc:ey.string,evalScripts:ey.oneOf(["always","once","never"]),fallback:ey.oneOfType([ey.func,ey.object,ey.string]),httpRequestWithCredentials:ey.bool,loading:ey.oneOfType([ey.func,ey.object,ey.string]),onError:ey.func,renumerateIRIElements:ey.bool,src:ey.string.isRequired,title:ey.string,useRequestCache:ey.bool,wrapper:ey.oneOf(["div","span","svg"])};const YB=({value:e,renderoptions:t})=>(void 0===t&&(t={}),void 0===t.format&&(t.format="jpeg"),o.createElement("img",{src:"data:image/"+t.format+";base64, "+e,style:{maxWidth:"100%",maxHeight:"100%"}})),UB=({value:e})=>o.createElement(ZB,{src:`data:image/svg+xml;base64,${btoa(e)}`,style:{maxWidth:"100%",maxHeight:"100%"},beforeInjection:e=>{e.classList.add("svg-class-name"),e.setAttribute("style","max-width: 100%; max-height: 100%;"),e.setAttribute("width","100%"),e.setAttribute("height","100%")}}),JB=({io:e})=>{let t=e.fullvalue;if(null==t&&(t=e.value),void 0===t&&(t=""),"string"!=typeof t||t.length%4!=0)return o.createElement("div",null,t);const n=Math.round(3*t.length/4);return o.createElement("div",null,o.createElement("pre",null,"Bytes(",n,")"))},KB=({io:e})=>{let t=e.fullvalue;return void 0===t&&(t=e.value),void 0===t&&(t={}),o.createElement(MD,{data:t})},qB={float:({io:e,inputconverter:t})=>lD({io:e,inputconverter:t,parser:parseFloat}),int:({io:e,inputconverter:t})=>lD({io:e,inputconverter:t,parser:parseInt}),bool:({io:t,inputconverter:n})=>{const r=e.useContext(zV),i=void 0===t.value,a=e.useRef(null);e.useEffect((()=>{a.current&&(a.current.indeterminate=i)}),[a,i]);return o.createElement("input",{ref:a,type:"checkbox",className:"styledcheckbox booleaninput",checked:!!n[1](t.value),onChange:e=>{let o=e.target.checked;try{o=n[0](e.target.checked)}catch(e){}r.worker?.set_io_value({nid:t.node,ioid:t.id,value:o,set_default:t.render_options.set_default})},disabled:t.connected})},string:cD,str:cD,color:({io:t})=>{const n=e.useContext(zV),r=t.value_options?.colorspace||"hex";let i=!1;return"string"!=typeof t.type&&"anyOf"in t.type&&void 0!==t.type.anyOf&&(i=t.type.anyOf.some((e=>"None"===e))),o.createElement(QN,{onChange:e=>{let o="<NoValue>";e&&(o=e[r]?e[r]():e.hex()),null===e&&(o=null),n.worker?.set_io_value({nid:t.node,ioid:t.id,value:o,set_default:t.render_options.set_default})},inicolordata:t.value,allow_null:i,inicolorspace:r})},select:hD,enum:hD,bytes:JB},QB={Inputrenderer:qB,Outputrenderer:{},HandlePreviewRenderer:{bytes:JB},DataOverlayRenderer:{},DataPreviewViewRenderer:{string:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),t=void 0===t?"":JSON.stringify(e.value).replace(/\\n/g,"\n"),o.createElement("div",null,o.createElement("pre",null,t))},table:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=[]),o.createElement(_B,{tabledata:t})},image:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=""),o.createElement(YB,{value:t})},svg:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=""),o.createElement(UB,{value:t})},dict:KB,bytes:JB},DataViewRenderer:{},InLineRenderer:{bytes:({io:e})=>{let t=e.fullvalue;null==t&&(t=e.value),t=void 0===t?"":JSON.stringify(e.value).replace(/\\n/g,"\n");return`Bytes(${Math.round(3*t.length/4)})`}}},eV=(e,t)=>{const n=t.options||{},r=void 0===n.overwrite||n.overwrite;switch(t.type){case"EXTEND_INPUT_RENDER":return!r&&e.Inputrenderer[t.payload.type]?e:{...e,Inputrenderer:{...e.Inputrenderer,[t.payload.type]:t.payload.component}};case"EXTEND_OUTPUT_RENDER":return!r&&e.Outputrenderer[t.payload.type]?e:{...e,Outputrenderer:{...e.Outputrenderer,[t.payload.type]:t.payload.component}};case"EXTEND_HANDLE_PREVIEW_RENDER":return!r&&e.HandlePreviewRenderer[t.payload.type]?e:{...e,HandlePreviewRenderer:{...e.HandlePreviewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_OVERLAY_RENDER":return!r&&e.DataOverlayRenderer[t.payload.type]?e:{...e,DataOverlayRenderer:{...e.DataOverlayRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_PREVIEW_RENDER":return!r&&e.DataPreviewViewRenderer[t.payload.type]?e:{...e,DataPreviewViewRenderer:{...e.DataPreviewViewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_VIEW_RENDER":return!r&&e.DataViewRenderer[t.payload.type]?e:{...e,DataViewRenderer:{...e.DataViewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_FROM_PLUGIN":let n=!1;const o=[[t.payload.plugin.input_renderers||{},e.Inputrenderer],[t.payload.plugin.output_renderers||{},e.Outputrenderer],[t.payload.plugin.handle_preview_renderers||{},e.HandlePreviewRenderer],[t.payload.plugin.data_overlay_renderers||{},e.DataOverlayRenderer],[t.payload.plugin.data_preview_renderers||{},e.DataPreviewViewRenderer],[t.payload.plugin.data_view_renderers||{},e.DataViewRenderer]];for(const[e,t]of o){if(Object.keys(e).length>0)if(r)n=!0;else for(const r in e)if(!t[r]){n=!0;break}if(n)break}if(!n)return e;for(const[e,t]of o)for(const n in e)!r&&t[n]||(t[n]=e[n]);return{...e};default:return e}},tV=({children:t,plugins:n,fnrf_zst:r})=>{const[i,a]=e.useReducer(eV,QB),s=(e,t)=>{a({type:"EXTEND_FROM_PLUGIN",payload:{plugin:e},options:t})};return e.useEffect((()=>{for(const e in n){const t=n[e].RendererPlugin;t&&s(t);const i=n[e].renderpluginfactory;i&&s(i({React:o,fnrf_zst:r}))}}),[n]),o.createElement(nV.Provider,{value:{Inputrenderer:i.Inputrenderer,Outputrenderer:i.Outputrenderer,HandlePreviewRenderer:i.HandlePreviewRenderer,DataOverlayRenderer:i.DataOverlayRenderer,DataPreviewViewRenderer:i.DataPreviewViewRenderer,DataViewRenderer:i.DataViewRenderer,InLineRenderer:i.InLineRenderer,extendInputRenderMapping:(e,t,n)=>{a({type:"EXTEND_INPUT_RENDER",payload:{type:e,component:t},options:n})},extendOutputRenderMapping:(e,t,n)=>{a({type:"EXTEND_OUTPUT_RENDER",payload:{type:e,component:t},options:n})},extendHandlePreviewRenderMapping:(e,t,n)=>{a({type:"EXTEND_HANDLE_PREVIEW_RENDER",payload:{type:e,component:t},options:n})},extendDataOverlayRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_OVERLAY_RENDER",payload:{type:e,component:t},options:n})},extendDataPreviewRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_PREVIEW_RENDER",payload:{type:e,component:t},options:n})},extendDataViewRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_VIEW_RENDER",payload:{type:e,component:t},options:n})},extendFromPlugin:s}},t)},nV=e.createContext({Inputrenderer:QB.Inputrenderer,Outputrenderer:QB.Outputrenderer,HandlePreviewRenderer:QB.HandlePreviewRenderer,DataOverlayRenderer:QB.DataOverlayRenderer,DataPreviewViewRenderer:QB.DataPreviewViewRenderer,DataViewRenderer:QB.DataViewRenderer,InLineRenderer:QB.InLineRenderer,extendInputRenderMapping:(e,t,n)=>{},extendOutputRenderMapping:(e,t,n)=>{},extendHandlePreviewRenderMapping:(e,t,n)=>{},extendDataOverlayRenderMapping:(e,t,n)=>{},extendDataPreviewRenderMapping:(e,t,n)=>{},extendDataViewRenderMapping:(e,t,n)=>{},extendFromPlugin:(e,t)=>{}}),rV=({component:e,...t})=>o.createElement(e,{...t}),oV=t=>{const n=e.useContext(zV).render_options(),[r]=iV(t.type,n.typemap||{});if(!r)return KB;const{DataOverlayRenderer:o,DataPreviewViewRenderer:i}=e.useContext(nV);return o[r]?o[r]:i[r]?i[r]:KB},iV=(e,t)=>{if("string"==typeof e)return e in t?[t[e],e]:[e,e];if("allOf"in e&&void 0!==e.allOf)return[void 0,void 0];if("anyOf"in e&&void 0!==e.anyOf){const n=e.anyOf.map((e=>iV(e,t)));for(const e of n)switch(e[0]){case"bool":return["bool",e[1]];case"enum":return["enum",e[1]];case"float":return["float",e[1]];case"int":return["int",e[1]];case"string":case"str":return["string",e[1]]}return[void 0,void 0]}return"type"in e&&void 0!==e.type&&"enum"===e.type?["enum","enum"]:[void 0,void 0]},aV=({io:t,typestring:n,preview:r,...i})=>{const[a,s]=e.useState(!1),[l,c]=e.useState(!1),u=o.useContext(zV),[d,f]=t?(t=>{const n=e.useContext(zV).render_options(),[r]=iV(t.type,n.typemap||{}),{HandlePreviewRenderer:o,DataPreviewViewRenderer:i}=e.useContext(nV),a=oV(t);return r?o[r]?[o[r],a]:i[r]?[i[r],a]:[KB,a]:[KB,a]})(t):[void 0,void 0],p=u.local_state((()=>u.reactflowRef));return o.createElement(GN,{open:a||l,onOpenChange:c},o.createElement(WN,{asChild:!0},o.createElement(ci,{id:t.id,"data-type":n,...i})),o.createElement(HN,{container:p},o.createElement(XN,{className:"iotooltipcontent",sideOffset:5},o.createElement("div",{className:"iotooltip_container"},o.createElement("div",{className:"iotooltip_header"},a?o.createElement(Xy,{onClick:()=>s(!1)}):o.createElement(Hy,{onClick:()=>s(!0)}),f&&o.createElement(Uy,{title:t.full_id,trigger:o.createElement(jy,null),onOpenChange:e=>{e&&t.try_get_full_value&&t.try_get_full_value(),s(e)}},o.createElement(rV,{component:f,io:t}))),d?o.createElement(rV,{component:d,io:t}):`no preview available for "${n}"`),o.createElement($N,{className:"iotooltipcontentarrow"}))))},sV={"":[e=>e,e=>e],str_to_json:[e=>JSON.parse(e),e=>"string"==typeof e?e:JSON.stringify(e)],str_to_list:[e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch(t){try{return JSON.parse("["+e+"]")}catch(e){}}throw new Error("Invalid list")},e=>JSON.stringify(e)]},lV=({io:t})=>{const n=e.useContext(zV).render_options(),[r,i]=iV(t.render_options.type,n.typemap||{}),{Inputrenderer:a}=e.useContext(nV),s=r?t.value_options?.options?hD:a[r]:void 0,l=sV[(i&&n.inputconverter?.[i])??""];return o.createElement("div",{className:"nodeinput","data-type":r},o.createElement(aV,{io:t,typestring:r,position:So.Left,type:"target"}),s&&o.createElement("div",{className:"iovaluefield nodrag","data-type":r},o.createElement(s,{io:t,inputconverter:l})),o.createElement("div",{className:"ioname"},t.name),o.createElement(aV,{io:t,typestring:r,position:So.Right,type:"source"}))},cV=({io:t,typestring:n})=>{const{InLineRenderer:r}=e.useContext(nV);if(n&&r[n])return o.createElement("div",null,r[n]({io:t}));let i=t.fullvalue;return null==i&&(i=t.value),i=void 0===i?"":JSON.stringify(i).replace(/\\n/g,"\n"),i.length>63&&(i=i.slice(0,60)+"..."),o.createElement("div",null,i)},uV=({io:t})=>{const n=e.useContext(zV).render_options(),[r]=iV(t.type,n.typemap||{}),{Outputrenderer:i}=e.useContext(nV),a=r?i[r]:void 0;return o.createElement("div",{className:"nodeoutput","data-type":r},o.createElement(aV,{io:t,typestring:r,position:So.Right,type:"source"}),o.createElement("div",{className:"ioname"},t.name),a?o.createElement("div",{className:"iovaluefield nodrag"},o.createElement(a,{io:t})):o.createElement("div",{className:"iovaluefield"},o.createElement(cV,{io:t,typestring:r})))};function dV(e){return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`}function fV(e,t){const n=["","K","M","G","T"];let r=0;for(;e>=t&&r<n.length-1;)e/=t,r++;return[e.toFixed(2),n[r]]}const pV=({state:t,className:n="reacttqdm",...r})=>{const i=e.useRef(null),a=e.useRef(null);e.useEffect((()=>{const e=()=>{i.current&&a.current&&function(e,t,n={}){const{maxFontSize:r=100,minFontSize:o=6,decrementFactor:i=.9}=n;if(!e||!t)return;if(i>=1||i<=0)throw new Error("decrementFactor must be between 0 and 1");const a=e.getBoundingClientRect(),s=a.width,l=a.height;let c=r;t.style.whiteSpace="nowrap",t.style.display="inline-block",t.style.fontSize=c+"px";let u=t.getBoundingClientRect();for(;(u.width>s||u.height>l)&&c>o;)c*=i,t.style.fontSize=c+"px",u=t.getBoundingClientRect()}(i.current,a.current,{maxFontSize:12,decrementFactor:.9})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[t]);const s=t.total?t.n/t.total*100:0;return o.createElement("div",{ref:i,className:n,...r},o.createElement("div",{style:{position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}},o.createElement("div",{className:n+"-bar",style:{position:"absolute",width:"100%",height:"100%",overflow:"hidden"}},o.createElement("div",{className:n+"-progress",style:{width:`${s}%`,height:"100%"}})),o.createElement("div",{className:n+"-text",ref:a},function(e={n:0,elapsed:0,ascii:!1,unit:"it",unit_scale:!1,unit_divisor:1e3}){let t=e.total??null;const{n:n,unit_scale:r,elapsed:o,unit:i,unit_divisor:a,prefix:s="",rate:l,postfix:c=null,initial:u=0}=e;null!==t&&n>=t+.5&&(t=null);let d=n,f=t,p=l;r&&!0!==r&&1!==r&&(null!==t&&(f=t*r),d=n*r,void 0!==l&&(p=l*r));const h=dV(o);void 0===p&&o>0&&(p=(d-u)/o);const m=p?1/p:void 0,[g,y]=p?fV(p,a):[void 0,""],[b,v]=m?fV(m,1e3):[void 0,""],w=m&&m>1?b?`${b}${v}s/`+i:"?":(g||"?")+`${y}${i}/s`,x=r?fV(d,a).join(""):d.toString(),C=r&&null!==f?fV(f,a).join(""):f?.toString()??"?",k=p?dV(p&&null!==f?(f-d)/p:0):"?",E=s?`${s}: `:"";if(null!==t){const e=` ${x}/${C} [${h} < ${k}, ${w}${c??""}]`;return`${E}${(d/t*100).toFixed(0)}%${e}`}return`${E}${x}${i} [${h}, ${w}${c??""}]`}(t))))},hV=({node_data:t})=>{const n=e.useContext(zV);return o.createElement("div",{className:"nodeheader",title:t.description||t.node_name},o.createElement("div",{className:"nodeheader_element"},o.createElement(Zy,{fontSize:"inherit",className:"triggerbutton",onClick:()=>{n.on_node_action({type:"trigger",from_remote:!1,id:t.id})}}),o.createElement($y,{fontSize:"inherit",onClick:async()=>{n.logger.info("nodestatus",await(n.worker?.get_node_status(t.id)))}})),o.createElement("div",{className:"nodeheader_element nodeheader_title"},o.createElement("div",{className:"nodeheader_title_text"},t.node_name)),o.createElement("div",{className:"nodeheader_element"},o.createElement(Gy,{fontSize:"inherit"})))},mV=({node_data:t})=>{const n=t.render_options?.data?.src?t.io[t.render_options?.data?.src]:void 0,[r,i]=n?(t=>{const n=e.useContext(zV).render_options(),[r]=iV(t.type,n.typemap||{}),o=oV(t),{DataPreviewViewRenderer:i,DataViewRenderer:a}=e.useContext(nV);return r?a[r]?[a[r],o]:i[r]?[i[r],o]:[KB,o]:[KB,o]})(n):[void 0,void 0];return o.createElement("div",{className:"nodrag nodedatabody","data-src":t.render_options?.data?.src||""},r&&n&&o.createElement(Uy,{title:n.full_id,trigger:o.createElement("div",{className:"nodedatabutton"},o.createElement(rV,{component:r,io:n})),onOpenChange:e=>{e&&n?.try_get_full_value&&n?.try_get_full_value()}},o.createElement(rV,{component:i,io:n})))},gV=({node_data:e})=>{const t=Object.values(e.io).filter((e=>e.is_input)),n=Object.values(e.io).filter((e=>!e.is_input));return e.render_options,o.createElement("div",{className:"nodebody"},n.map((e=>e.hidden?null:o.createElement(uV,{key:e.id,io:e}))),o.createElement(mV,{node_data:e}),t.map((e=>e.hidden?null:o.createElement(lV,{key:e.id,io:e}))))},yV=({node_data:t})=>{const[n,r]=e.useState(t.name);e.useEffect((()=>{r(t.name)}),[t]);const i=e.useContext(zV);return o.createElement("input",{className:"nodename_input",value:n,onChange:e=>{r(e.target.value)},onBlur:e=>{const n=e.target.value;i.on_node_action({type:"update",from_remote:!1,id:t.id,node:{name:n}})}})},bV=({node_data:e})=>e.progress?o.createElement(pV,{style:{height:"idle"===e.progress.prefix?"0px":void 0},state:e.progress,className:"nodeprogress"}):null,vV=({node_data:e})=>o.createElement("div",{className:"nodefooter"},e.error&&o.createElement("div",{className:"nodeerror"},e.error),o.createElement(bV,{node_data:e})),wV=({io:e})=>{const t=o.useContext(zV).render_options(),[n,r]=iV(e.render_options.type,t.typemap||{}),{Inputrenderer:i}=o.useContext(nV),a=n?e.value_options?.options?hD:i[n]:void 0,s=sV[(r&&t.inputconverter?.[r])??""];return o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,e.name),a&&o.createElement(a,{io:e,inputconverter:s}),o.createElement("div",null,o.createElement("label",null,"hidden:",o.createElement("input",{className:"styledcheckbox",type:"checkbox",disabled:e.connected,onChange:t=>{e.set_hidden?.(t.target.checked)},checked:e.hidden}))))},xV=({io:e})=>o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,e.name),o.createElement("div",null,o.createElement("label",null,"hidden:",o.createElement("input",{className:"styledcheckbox",type:"checkbox",disabled:e.connected,onChange:t=>{e.set_hidden?.(t.target.checked)},checked:e.hidden})))),CV=({nodestore:e})=>{const t=e(),n=Object.values(t.io).filter((e=>e.is_input)),r=Object.values(t.io).filter((e=>!e.is_input));return o.createElement("div",{className:"nodesettings_content"},o.createElement("div",{className:"nodesettings_section"},o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,"Name"),o.createElement("div",null,o.createElement(yV,{node_data:t})))),o.createElement("div",{className:"nodesettings_section"},o.createElement("div",null,"Inputs"),n.map((e=>o.createElement(wV,{io:e,key:e.id})))),o.createElement("div",{className:"nodesettings_section"},o.createElement("div",null,"Outputs"),r.map((e=>o.createElement(xV,{io:e,key:e.id})))))},kV=()=>{const e=o.useContext(zV),t=e.local_state((e=>e.selected_nodes));if(0===t.length)return o.createElement("div",null,"Node Settings");if(t.length>1)return o.createElement("div",null,"Multiple Nodes Selected");const n=e.nodespace.get_node(t[0]);return n?o.createElement(CV,{nodestore:n}):o.createElement("div",null,"Node not found")},EV=()=>{const e=o.useContext(zV),t=e.local_settings((e=>e.view_settings.expand_node_props)),n=e.local_settings((e=>e.update_view_settings));return o.createElement(bC,{maxSize:"300px",direction:"left",expanded:void 0!==t&&t,containerClassName:"pos-right pos-top bg1 h-12",className:"nodesettings_content",onExpandChange:e=>{n({expand_node_props:e})}},o.createElement(kV,null))},SV=e=>({nodes:e.nodes,edges:e.edges,onNodesChange:e.onNodesChange,onEdgesChange:e.onEdgesChange,onConnect:e.onConnect}),IV={default:({data:t})=>{const n=t.UseNodeStore(),r=n.properties["frontend:collapsed"]||!1,{visualTrigger:i}=(t=>{const n=e.useContext(zV),[r,o]=e.useState(!1);return e.useEffect((()=>{n.worker?.call_hooks("node_mounted",t.id)}),[n.worker,t.id]),e.useEffect((()=>{let e;return t.in_trigger&&!r?o(!0):r&&(e=setTimeout((()=>o(!1)),200)),()=>clearTimeout(e)}),[t.in_trigger,r]),{visualTrigger:r}})(n);return o.createElement(o.Fragment,null,o.createElement("div",{className:"innernode"+(i?" intrigger":"")+(n.error?" error":"")},o.createElement(hV,{node_data:n}),o.createElement(yV,{node_data:n}),r?null:o.createElement(gV,{node_data:n}),o.createElement(vV,{node_data:n})))}},_V={default:({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:s,data:l,...c})=>{const[u]=Lo({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:i,targetPosition:s});return o.createElement(o.Fragment,null,o.createElement(go,{id:e,path:u,...c}))}},AV=()=>{const t=Zi();return e.useContext(zV).rf_instance=t,o.createElement(o.Fragment,null)},NV=()=>{const t=e.useContext(zV),n=Pi("Delete"),r=Hr(Cs,Z),i=Hr(xs,Z);if(n){for(const e of r)if(e.selected){if(!t.worker)return o.createElement(o.Fragment,null);if(!e.source||!e.target)return o.createElement(o.Fragment,null);if(!e.sourceHandle||!e.targetHandle)return o.createElement(o.Fragment,null);t.worker.remove_edge({src_nid:e.source,src_ioid:e.sourceHandle,trg_nid:e.target,trg_ioid:e.targetHandle})}for(const e of i)if(e.selected){if(!t.worker)return o.createElement(o.Fragment,null);t.worker.remove_node(e.id)}}return o.createElement(o.Fragment,null)},OV=({id:t,top:n,left:r,right:i,bottom:a,...s})=>{const{getNode:l,setNodes:c,addNodes:u,setEdges:d}=Zi(),f=e.useContext(zV),p=e.useCallback((()=>{const e=l(t);if(!e)return;const n={x:e.position.x+50,y:e.position.y+50};u({...e,id:`${e.id}-copy`,position:n})}),[t,l,u]),h=e.useCallback((()=>{f.on_node_action({type:"delete",id:t,from_remote:!1})}),[t,c,d]),m=f.nodespace.get_node(t,!1);if(!m)return o.createElement(o.Fragment,null," ");const g=m();return o.createElement("div",{style:{top:n,left:r,right:i,bottom:a},className:"context-menu",...s},o.createElement("p",{style:{fontWeight:"bold"}},o.createElement("small",null,g.name)),o.createElement("button",{onClick:p},"duplicate"),o.createElement("button",{onClick:h},"delete"))},RV=t=>{const n=e.useContext(zV),r=e.useRef(null);e.useEffect((()=>{n.reactflowRef=r.current}),[r]);const[i,a]=e.useState(null),s=e.useCallback((()=>a(null)),[a]),{nodes:l,edges:c,onNodesChange:u,onEdgesChange:d,onConnect:f}=n.useReactFlowStore(dN(SV));return o.createElement("div",{className:"reactflowlayer"},o.createElement(ws,{nodes:l,edges:c,onNodesChange:u,onEdgesChange:d,onConnect:f,nodeTypes:IV,edgeTypes:_V,minZoom:t.minZoom,maxZoom:t.maxZoom,fitView:!0,onSelectionChange:({nodes:e,edges:t})=>{const r=n.local_state.getState();n.local_state.setState({...r,selected_nodes:e.map((e=>e.id)),selected_edges:t.map((e=>e.id))})},ref:r,onPaneClick:s,panOnDrag:!t.static},o.createElement(AV,null),o.createElement(NV,null),o.createElement(zs,{color:"#888",gap:16,size:1}),t.minimap&&o.createElement(Ms,{nodeStrokeWidth:3,pannable:!t.static,zoomable:!t.static,zoomStep:3}),i&&o.createElement(OV,{onClick:s,...i})))},MV=e.createContext(void 0),TV=e.forwardRef(((t,n)=>{const{asChild:r,children:a,className:s,style:l,...c}=t,[u,d]=e.useState(!1),f=e.useRef(null),[p,h]=e.useState(null),[m,g]=e.useState({}),y=t.htime||300,b=t.vtime||300,v=t.hdelay||0,w=t.vdelay||200;e.useImperativeHandle(n,(()=>f.current),[]);let x;if(r&&o.isValidElement(a)){const e=a,t=[e.props.className,s,"smooth-expand",u?"smooth-expand-expanded":""].filter(Boolean).join(" "),n={...e.props.style,...l,...m};x=o.cloneElement(e,{ref:f,className:t,style:n,...c})}else x=o.createElement("div",{ref:f,...c,className:`smooth-expand ${u?"smooth-expand-expanded":""} ${s||""}`,style:{...l,...m}},a);const C=o.createElement(MV.Provider,{value:{isExpanded:u,toggleExpand:async()=>{f.current&&(u?await(async()=>{if(!f.current)return;if(!p)return;const e={transitionProperty:"width, left, height, top",transitionDuration:`${y}ms, ${y}ms, ${b}ms, ${b}ms`};g((t=>({...t,...e})));const[t,n,r,o]=p,i=new Promise((e=>{setTimeout((()=>{g((e=>({...e,left:`${t}px`,width:`${r}px`}))),e()}),w)})),a=new Promise((e=>{setTimeout((()=>{g((e=>({...e,top:`${n}px`,height:`${o}px`}))),e()}),v)})),s=Math.max(y+v,b+w),l=new Promise((e=>{setTimeout((()=>{e()}),s)}));await Promise.all([i,a,l]),f.current.style.transition="",g({}),d(!1)})():await(async()=>{if(!f.current)return;f.current.style.transition="none",f.current.style.position="",f.current.style.top="",f.current.style.left="",f.current.style.width="",f.current.style.height="";const e=f.current.getBoundingClientRect();h([e.left,e.top,e.width,e.height]),f.current.style.transition="none",g({position:"absolute",top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`}),g((e=>({...e,transitionProperty:"width, left, height, top",transitionDuration:`${y}ms, ${y}ms, ${b}ms, ${b}ms`}))),d(!0);const t=new Promise((e=>{setTimeout((()=>{g((e=>({...e,left:"0px",width:"100vw"}))),e()}),v)})),n=new Promise((e=>{setTimeout((()=>{g((e=>({...e,top:"0px",height:"100vh"}))),e()}),w)})),r=Math.max(y+v,b+w),o=new Promise((e=>{setTimeout((()=>{e()}),r)}));await Promise.all([t,n,o])})())}}},x);return u?i.createPortal(C,document.body):C}));TV.Trigger=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Trigger must be used within a SmoothExpandComponent");return o.createElement("div",{style:{cursor:"pointer"},onClick:n.toggleExpand},t)},TV.Expanded=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Expanded must be used within a SmoothExpandComponent");return n.isExpanded?o.createElement(o.Fragment,null,t):null},TV.Collapsed=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Collapsed must be used within a SmoothExpandComponent");return n.isExpanded?null:o.createElement(o.Fragment,null,t)};const PV=o.createContext(void 0),DV=e.forwardRef(((t,n)=>{const{asChild:r,children:i,className:a,style:s,...l}=t,c=e.useRef(null);e.useImperativeHandle(n,(()=>c.current),[]);const[u,d]=e.useState(!1),f=e.useCallback((async()=>{try{const e=c.current;if(!e)return;if(u){const e=document;e.exitFullscreen?await e.exitFullscreen():e.mozCancelFullScreen?await e.mozCancelFullScreen():e.webkitExitFullscreen?await e.webkitExitFullscreen():e.msExitFullscreen&&await e.msExitFullscreen(),d(!1)}else e.requestFullscreen?await e.requestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.msRequestFullscreen&&await e.msRequestFullscreen(),d(!0)}catch(e){console.error("Error toggling fullscreen",e)}}),[u]);let p;if(e.useEffect((()=>{const e=()=>{const e=document.fullscreenElement;d(!!e)};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}),[]),r&&o.isValidElement(i)){const e=i,t=[e.props.className,a].filter(Boolean).join(" "),n={...e.props.style,...s};p=o.cloneElement(e,{ref:c,className:t,style:n,...l})}else p=o.createElement("div",{ref:c,...l,className:a,style:s},i);return o.createElement(PV.Provider,{value:{isFullScreen:u,toggleFullscreen:f}},p)}));DV.Trigger=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Trigger must be used within a FullScreenComponent");return o.createElement("div",{style:{cursor:"pointer"},onClick:t.toggleFullscreen},e)},DV.InFullScreen=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Expanded must be used within a FullScreenComponent");return t.isFullScreen?o.createElement(o.Fragment,null,e):null},DV.OutFullScreen=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Collapsed must be used within a FullScreenComponent");return t.isFullScreen?null:o.createElement(o.Fragment,null,e)};const jV=({fnrf_zst:t,header:n,flow:r,library:i})=>{const[a,s]=e.useState(t.options.worker),l=o.useRef(null);t.workermanager&&(t.workermanager.on_setWorker=s),t.set_worker(a),o.useEffect((()=>{t.auto_progress()}),[]),o.useEffect((()=>{t.local_state.setState({funcnodescontainerRef:l.current})}),[l]);const c=t.plugins();return o.createElement(tV,{plugins:c,fnrf_zst:t},o.createElement(zV.Provider,{value:t},o.createElement(TV,{asChild:!0},o.createElement(DV,{asChild:!0},o.createElement(mC,{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",flex:1}},o.createElement("div",{ref:l,className:"funcnodesreactflowcontainer funcnodescontainer"},n.show&&o.createElement(EC,{...n}),o.createElement("div",{className:"funcnodesreactflowbody"},o.createElement(RV,{...r}),a&&i.show&&o.createElement(cN,null),a&&r.showNodeSettings&&o.createElement(EV,null)),o.createElement("div",{className:"funcnodesflaotingmenu"},o.createElement(DV.OutFullScreen,null,r.allowExpand&&o.createElement(TV.Trigger,null,o.createElement(TV.Expanded,null,o.createElement(Ly,{size:"xl",style:{padding:"4px"}})),o.createElement(TV.Collapsed,null,o.createElement(zy,{size:"xl",style:{padding:"4px"}})))),r.allowFullScreen&&o.createElement(DV.Trigger,null,o.createElement(DV.OutFullScreen,null,o.createElement(jy,{size:"xl",style:{padding:"4px"}})),o.createElement(DV.InFullScreen,null,o.createElement(Fy,{size:"xl",style:{padding:"4px"}}))))))))))},FV={},LV={id:"",debug:!1,useWorkerManager:!0,show_library:!0,header:{show:!0,showmenu:!0},flow:{minimap:!0,static:!1,minZoom:.1,maxZoom:5,allowFullScreen:!0,allowExpand:!0,showNodeSettings:!0},library:{show:!0}},zV=e.createContext(Js(LV)),BV=e=>{let t=T(e,{...LV,id:Su()}).new_obj;if(!t.useWorkerManager&&void 0===t.worker)return o.createElement("div",null,"Error: If you don't use a worker manager, you must provide a default worker.");if(e.useWorkerManager&&void 0===e.workermanager_url)return o.createElement("div",null,"Error: If you use a worker manager, you must provide a worker manager url.");if(void 0===window.fnrf_zst&&(window.fnrf_zst=FV),void 0===FV[t.id]){const e=Js(t);FV[t.id]=e}if(t.worker&&t.worker.set_zustand(FV[t.id]),FV[t.id].options.debug=t.debug,t.useWorkerManager){const e=new Au(t.workermanager_url,FV[t.id]);FV[t.id].workermanager=e}return o.createElement(jV,{fnrf_zst:FV[t.id],header:t.header,library:t.library,flow:t.flow})},VV={set_io_value:({nid:t,ioid:n,value:r,set_default:o=!1})=>{const i=e.useContext(zV);i.worker?.set_io_value({nid:t,ioid:n,value:r,set_default:o})}};exports.FuncNodesContext=zV,exports.FuncNodesReactFlowZustand=Js,exports.FuncNodesWorker=Iu,exports.FuncnodesReactFlow=BV,exports.ReactFlowLayer=RV,exports.RenderMappingProvider=tV,exports.WebSocketWorker=_u,exports.assert_full_node=z,exports.deep_update=T,exports.default=e=>{const t=new Zs("FuncNodes",e.debug?"debug":"info");t.debug("Initalizing FuncNodes with props:",e);let n=T(e,{...LV,id:Su()}).new_obj;if(void 0===e.worker&&void 0!==e.worker_url&&(n.useWorkerManager=!1,n.worker=new _u({url:e.worker_url,uuid:n.id,on_sync_complete:n.on_sync_complete})),void 0!==n.worker){const e=Js(n);n.worker.set_zustand(e)}if(void 0!==e.fnw_url){if(void 0===n.worker)throw new Error("defining fnw_url requires a worker to be defined");const t=async function(e,t=!0){try{const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch from URL: ${n.status} ${n.statusText}`);const r=await n.blob();return await new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const r=o.result;"string"!=typeof r&&(n("Failed to convert URL to Base64: No result from FileReader"),n(o.error)),e(t?r.split(",")[1]:r)},o.onerror=()=>n(o.error),o.readAsDataURL(r)}))}catch(e){throw console.error("Error converting URL to Base64:",e),e}}(e.fnw_url),r=n.worker.on_sync_complete,o=async e=>{const n=await t;e.on_sync_complete=r,await e.update_from_export(n)};n.worker.on_sync_complete=o}return t.debug("Initalizing FuncnodesReactFlow with props:",n),o.createElement("div",{className:"FuncnodesApp"},o.createElement(BV,{...n}))},exports.helperfunctions=VV;
156
+ */var OB=function(){if(AB)return NB;AB=1;var e=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,t=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,n=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,r=/\\([\u000b\u0020-\u00ff])/g,o=/([\\"])/g,i=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function a(e){var r=String(e);if(n.test(r))return r;if(r.length>0&&!t.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(o,"\\$1")+'"'}function s(e){this.parameters=Object.create(null),this.type=e}return NB.format=function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!i.test(r))throw new TypeError("invalid type");var o=r;if(t&&"object"==typeof t)for(var s,l=Object.keys(t).sort(),c=0;c<l.length;c++){if(s=l[c],!n.test(s))throw new TypeError("invalid parameter name");o+="; "+s+"="+a(t[s])}return o},NB.parse=function(t){if(!t)throw new TypeError("argument string is required");var n="object"==typeof t?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(t):t;if("string"!=typeof n)throw new TypeError("argument string is required to be a string");var o=n.indexOf(";"),a=-1!==o?n.slice(0,o).trim():n.trim();if(!i.test(a))throw new TypeError("invalid media type");var l=new s(a.toLowerCase());if(-1!==o){var c,u,d;for(e.lastIndex=o;u=e.exec(n);){if(u.index!==o)throw new TypeError("invalid parameter format");o+=u[0].length,c=u[1].toLowerCase(),34===(d=u[2]).charCodeAt(0)&&-1!==(d=d.slice(1,-1)).indexOf("\\")&&(d=d.replace(r,"$1")),l.parameters[c]=d}if(o!==n.length)throw new TypeError("invalid parameter format")}return l},NB}(),RB=new Map,MB=function(e){return e.cloneNode(!0)},TB=function(){return"file:"===window.location.protocol},PB=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&2===r.readyState){var t=r.getResponseHeader("Content-Type");if(!t)throw new Error("Content type not found");var o=OB.parse(t).type;if("image/svg+xml"!==o&&"text/plain"!==o)throw new Error("Invalid content type: ".concat(o))}if(4===r.readyState){if(404===r.status||null===r.responseXML)throw new Error(TB()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(!(200===r.status||TB()&&0===r.status))throw new Error("There was a problem injecting the SVG: "+r.status+" "+r.statusText);n(null,r)}}catch(e){if(r.abort(),!(e instanceof Error))throw e;n(e,r)}},r.open("GET",e),r.withCredentials=t,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.send()},DB={},jB=function(e,t){DB[e]=DB[e]||[],DB[e].push(t)},FB=function(e,t,n){if(RB.has(e)){var r=RB.get(e);if(void 0===r)return void jB(e,n);if(r instanceof SVGSVGElement)return void n(null,MB(r))}RB.set(e,void 0),jB(e,n),PB(e,t,(function(t,n){var r;t?RB.set(e,t):(null===(r=n.responseXML)||void 0===r?void 0:r.documentElement)instanceof SVGSVGElement&&RB.set(e,n.responseXML.documentElement),function(e){for(var t=function(t,n){setTimeout((function(){if(Array.isArray(DB[e])){var n=RB.get(e),r=DB[e][t];n instanceof SVGSVGElement&&r(null,MB(n)),n instanceof Error&&r(n),t===DB[e].length-1&&delete DB[e]}}),0)},n=0,r=DB[e].length;n<r;n++)t(n)}(e)}))},LB=function(e,t,n){PB(e,t,(function(e,t){var r;e?n(e):(null===(r=t.responseXML)||void 0===r?void 0:r.documentElement)instanceof SVGSVGElement&&n(null,t.responseXML.documentElement)}))},zB=0,BB=[],VB={},GB="http://www.w3.org/1999/xlink",WB=function(e,t,n,r,o,i,a){var s=e.getAttribute("data-src")||e.getAttribute("src");if(s){if(-1!==BB.indexOf(e))return BB.splice(BB.indexOf(e),1),void(e=null);BB.push(e),e.setAttribute("src",""),(r?FB:LB)(s,o,(function(r,o){if(!o)return BB.splice(BB.indexOf(e),1),e=null,void a(r);var l=e.getAttribute("id");l&&o.setAttribute("id",l);var c=e.getAttribute("title");c&&o.setAttribute("title",c);var u=e.getAttribute("width");u&&o.setAttribute("width",u);var d=e.getAttribute("height");d&&o.setAttribute("height",d);var f=Array.from(new Set(Ad(Ad(Ad([],(o.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();o.setAttribute("class",f);var p=e.getAttribute("style");p&&o.setAttribute("style",p),o.setAttribute("data-src",s);var h=[].filter.call(e.attributes,(function(e){return/^data-\w[\w-]*$/.test(e.name)}));if(Array.prototype.forEach.call(h,(function(e){e.name&&e.value&&o.setAttribute(e.name,e.value)})),n){var m,g,y,b,v,w={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(w).forEach((function(e){m=e,y=w[e];for(var t=function(e,t){var n;b=g[e].id,v=b+"-"+ ++zB,Array.prototype.forEach.call(y,(function(e){for(var t=0,r=(n=o.querySelectorAll("["+e+'*="'+b+'"]')).length;t<r;t++){var i=n[t].getAttribute(e);i&&!i.match(new RegExp('url\\("?#'+b+'"?\\)'))||n[t].setAttribute(e,"url(#"+v+")")}}));for(var r=o.querySelectorAll("[*|href]"),i=[],a=0,s=r.length;a<s;a++){var l=r[a].getAttributeNS(GB,"href");l&&l.toString()==="#"+g[e].id&&i.push(r[a])}for(var c=0,u=i.length;c<u;c++)i[c].setAttributeNS(GB,"href","#"+v);g[e].id=v},n=0,r=(g=o.querySelectorAll(m+"[id]")).length;n<r;n++)t(n)}))}o.removeAttribute("xmlns:a");for(var x,C,k=o.querySelectorAll("script"),E=[],S=0,I=k.length;S<I;S++)(C=k[S].getAttribute("type"))&&"application/ecmascript"!==C&&"application/javascript"!==C&&"text/javascript"!==C||((x=k[S].innerText||k[S].textContent)&&E.push(x),o.removeChild(k[S]));if(E.length>0&&("always"===t||"once"===t&&!VB[s])){for(var _=0,A=E.length;_<A;_++)new Function(E[_])(window);VB[s]=!0}var N=o.querySelectorAll("style");if(Array.prototype.forEach.call(N,(function(e){e.textContent+=""})),o.setAttribute("xmlns","http://www.w3.org/2000/svg"),o.setAttribute("xmlns:xlink",GB),i(o),!e.parentNode)return BB.splice(BB.indexOf(e),1),e=null,void a(new Error("Parent node is null"));e.parentNode.replaceChild(o,e),BB.splice(BB.indexOf(e),1),e=null,a(null,o)}))}else a(new Error("Invalid data-src or src attribute"))},HB=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],XB="http://www.w3.org/2000/svg",$B="http://www.w3.org/1999/xlink",ZB=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}Kz(t,e);var n=t.prototype;return n.renderSVG=function(){var e=this;if(this.reactWrapper instanceof function(e){return((null==e?void 0:e.ownerDocument)||document).defaultView||window}(this.reactWrapper).Node){var t,n,r=this.props,o=r.desc,i=r.evalScripts,a=r.httpRequestWithCredentials,s=r.renumerateIRIElements,l=r.src,c=r.title,u=r.useRequestCache,d=this.props.onError,f=this.props.beforeInjection,p=this.props.afterInjection,h=this.props.wrapper;"svg"===h?((t=document.createElementNS(XB,h)).setAttribute("xmlns",XB),t.setAttribute("xmlns:xlink",$B),n=document.createElementNS(XB,h)):(t=document.createElement(h),n=document.createElement(h)),t.appendChild(n),n.dataset.src=l,this.nonReactWrapper=this.reactWrapper.appendChild(t);var m=function(t){e.removeSVG(),e._isMounted?e.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){d(t)})):d(t)};!function(e,t){var n=void 0===t?{}:t,r=n.afterAll,o=void 0===r?function(){}:r,i=n.afterEach,a=void 0===i?function(){}:i,s=n.beforeEach,l=void 0===s?function(){}:s,c=n.cacheRequests,u=void 0===c||c,d=n.evalScripts,f=void 0===d?"never":d,p=n.httpRequestWithCredentials,h=void 0!==p&&p,m=n.renumerateIRIElements,g=void 0===m||m;if(e&&"length"in e)for(var y=0,b=0,v=e.length;b<v;b++)WB(e[b],f,g,u,h,l,(function(t,n){a(t,n),e&&"length"in e&&e.length===++y&&o(y)}));else e?WB(e,f,g,u,h,l,(function(t,n){a(t,n),o(1),e=null})):o(0)}(n,{afterEach:function(t,n){t?m(t):e._isMounted&&e.setState((function(){return{isLoading:!1}}),(function(){try{p(n)}catch(e){m(e)}}))},beforeEach:function(e){if(e.setAttribute("role","img"),o){var t=e.querySelector(":scope > desc");t&&e.removeChild(t);var n=document.createElement("desc");n.innerHTML=o,e.prepend(n)}if(c){var r=e.querySelector(":scope > title");r&&e.removeChild(r);var i=document.createElement("title");i.innerHTML=c,e.prepend(i)}try{f(e)}catch(e){m(e)}},cacheRequests:u,evalScripts:i,httpRequestWithCredentials:a,renumerateIRIElements:s})}},n.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},n.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},n.componentDidUpdate=function(e){var t=this;(function(e,t){for(var n in e)if(!(n in t))return!0;for(var r in t)if(e[r]!==t[r])return!0;return!1})(bR({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},n.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},n.render=function(){var e=this.props;e.afterInjection,e.beforeInjection,e.desc,e.evalScripts;var t=e.fallback;e.httpRequestWithCredentials;var n=e.loading;e.renumerateIRIElements,e.src,e.title,e.useRequestCache;var r=e.wrapper,i=mR(e,HB),a=r;return o.createElement(a,bR({},i,{ref:this.refCallback},"svg"===r?{xmlns:XB,xmlnsXlink:$B}:{}),this.state.isLoading&&n&&o.createElement(n,null),this.state.hasError&&t&&o.createElement(t,null))},t}(o.Component);ZB.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"},ZB.propTypes={afterInjection:ey.func,beforeInjection:ey.func,desc:ey.string,evalScripts:ey.oneOf(["always","once","never"]),fallback:ey.oneOfType([ey.func,ey.object,ey.string]),httpRequestWithCredentials:ey.bool,loading:ey.oneOfType([ey.func,ey.object,ey.string]),onError:ey.func,renumerateIRIElements:ey.bool,src:ey.string.isRequired,title:ey.string,useRequestCache:ey.bool,wrapper:ey.oneOf(["div","span","svg"])};const YB=({value:e,renderoptions:t})=>(void 0===t&&(t={}),void 0===t.format&&(t.format="jpeg"),o.createElement("img",{src:"data:image/"+t.format+";base64, "+e,style:{maxWidth:"100%",maxHeight:"100%"}})),UB=({value:e})=>o.createElement(ZB,{src:`data:image/svg+xml;base64,${btoa(e)}`,style:{maxWidth:"100%",maxHeight:"100%"},beforeInjection:e=>{e.classList.add("svg-class-name"),e.setAttribute("style","max-width: 100%; max-height: 100%;"),e.setAttribute("width","100%"),e.setAttribute("height","100%")}}),JB=({io:e})=>{let t=e.fullvalue;if(null==t&&(t=e.value),void 0===t&&(t=""),"string"!=typeof t||t.length%4!=0)return o.createElement("div",null,t);const n=Math.round(3*t.length/4);return o.createElement("div",null,o.createElement("pre",null,"Bytes(",n,")"))},KB=({io:e})=>{let t=e.fullvalue;return void 0===t&&(t=e.value),void 0===t&&(t={}),o.createElement(MD,{data:t})},qB={float:({io:e,inputconverter:t})=>lD({io:e,inputconverter:t,parser:parseFloat}),int:({io:e,inputconverter:t})=>lD({io:e,inputconverter:t,parser:parseInt}),bool:({io:t,inputconverter:n})=>{const r=e.useContext(zV),i=void 0===t.value,a=e.useRef(null);e.useEffect((()=>{a.current&&(a.current.indeterminate=i)}),[a,i]);return o.createElement("input",{ref:a,type:"checkbox",className:"styledcheckbox booleaninput",checked:!!n[1](t.value),onChange:e=>{let o=e.target.checked;try{o=n[0](e.target.checked)}catch(e){}r.worker?.set_io_value({nid:t.node,ioid:t.id,value:o,set_default:t.render_options.set_default})},disabled:t.connected})},string:cD,str:cD,color:({io:t})=>{const n=e.useContext(zV),r=t.value_options?.colorspace||"hex";let i=!1;return"string"!=typeof t.type&&"anyOf"in t.type&&void 0!==t.type.anyOf&&(i=t.type.anyOf.some((e=>"None"===e))),o.createElement(QN,{onChange:e=>{let o="<NoValue>";e&&(o=e[r]?e[r]():e.hex()),null===e&&(o=null),n.worker?.set_io_value({nid:t.node,ioid:t.id,value:o,set_default:t.render_options.set_default})},inicolordata:t.value,allow_null:i,inicolorspace:r})},select:hD,enum:hD,bytes:JB},QB={Inputrenderer:qB,Outputrenderer:{},HandlePreviewRenderer:{bytes:JB},DataOverlayRenderer:{},DataPreviewViewRenderer:{string:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),t=void 0===t?"":JSON.stringify(e.value).replace(/\\n/g,"\n"),o.createElement("div",null,o.createElement("pre",null,t))},table:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=[]),o.createElement(_B,{tabledata:t})},image:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=""),o.createElement(YB,{value:t})},svg:({io:e})=>{let t=e.fullvalue;return null==t&&(t=e.value),void 0===t&&(t=""),o.createElement(UB,{value:t})},dict:KB,bytes:JB},DataViewRenderer:{},InLineRenderer:{bytes:({io:e})=>{let t=e.fullvalue;null==t&&(t=e.value),t=void 0===t?"":JSON.stringify(e.value).replace(/\\n/g,"\n");return`Bytes(${Math.round(3*t.length/4)})`}}},eV=(e,t)=>{const n=t.options||{},r=void 0===n.overwrite||n.overwrite;switch(t.type){case"EXTEND_INPUT_RENDER":return!r&&e.Inputrenderer[t.payload.type]?e:{...e,Inputrenderer:{...e.Inputrenderer,[t.payload.type]:t.payload.component}};case"EXTEND_OUTPUT_RENDER":return!r&&e.Outputrenderer[t.payload.type]?e:{...e,Outputrenderer:{...e.Outputrenderer,[t.payload.type]:t.payload.component}};case"EXTEND_HANDLE_PREVIEW_RENDER":return!r&&e.HandlePreviewRenderer[t.payload.type]?e:{...e,HandlePreviewRenderer:{...e.HandlePreviewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_OVERLAY_RENDER":return!r&&e.DataOverlayRenderer[t.payload.type]?e:{...e,DataOverlayRenderer:{...e.DataOverlayRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_PREVIEW_RENDER":return!r&&e.DataPreviewViewRenderer[t.payload.type]?e:{...e,DataPreviewViewRenderer:{...e.DataPreviewViewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_DATA_VIEW_RENDER":return!r&&e.DataViewRenderer[t.payload.type]?e:{...e,DataViewRenderer:{...e.DataViewRenderer,[t.payload.type]:t.payload.component}};case"EXTEND_FROM_PLUGIN":let n=!1;const o=[[t.payload.plugin.input_renderers||{},e.Inputrenderer],[t.payload.plugin.output_renderers||{},e.Outputrenderer],[t.payload.plugin.handle_preview_renderers||{},e.HandlePreviewRenderer],[t.payload.plugin.data_overlay_renderers||{},e.DataOverlayRenderer],[t.payload.plugin.data_preview_renderers||{},e.DataPreviewViewRenderer],[t.payload.plugin.data_view_renderers||{},e.DataViewRenderer]];for(const[e,t]of o){if(Object.keys(e).length>0)if(r)n=!0;else for(const r in e)if(!t[r]){n=!0;break}if(n)break}if(!n)return e;for(const[e,t]of o)for(const n in e)!r&&t[n]||(t[n]=e[n]);return{...e};default:return e}},tV=({children:t,plugins:n,fnrf_zst:r})=>{const[i,a]=e.useReducer(eV,QB),s=(e,t)=>{a({type:"EXTEND_FROM_PLUGIN",payload:{plugin:e},options:t})};return e.useEffect((()=>{for(const e in n){const t=n[e].RendererPlugin;t&&s(t);const i=n[e].renderpluginfactory;i&&s(i({React:o,fnrf_zst:r}))}}),[n]),o.createElement(nV.Provider,{value:{Inputrenderer:i.Inputrenderer,Outputrenderer:i.Outputrenderer,HandlePreviewRenderer:i.HandlePreviewRenderer,DataOverlayRenderer:i.DataOverlayRenderer,DataPreviewViewRenderer:i.DataPreviewViewRenderer,DataViewRenderer:i.DataViewRenderer,InLineRenderer:i.InLineRenderer,extendInputRenderMapping:(e,t,n)=>{a({type:"EXTEND_INPUT_RENDER",payload:{type:e,component:t},options:n})},extendOutputRenderMapping:(e,t,n)=>{a({type:"EXTEND_OUTPUT_RENDER",payload:{type:e,component:t},options:n})},extendHandlePreviewRenderMapping:(e,t,n)=>{a({type:"EXTEND_HANDLE_PREVIEW_RENDER",payload:{type:e,component:t},options:n})},extendDataOverlayRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_OVERLAY_RENDER",payload:{type:e,component:t},options:n})},extendDataPreviewRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_PREVIEW_RENDER",payload:{type:e,component:t},options:n})},extendDataViewRenderMapping:(e,t,n)=>{a({type:"EXTEND_DATA_VIEW_RENDER",payload:{type:e,component:t},options:n})},extendFromPlugin:s}},t)},nV=e.createContext({Inputrenderer:QB.Inputrenderer,Outputrenderer:QB.Outputrenderer,HandlePreviewRenderer:QB.HandlePreviewRenderer,DataOverlayRenderer:QB.DataOverlayRenderer,DataPreviewViewRenderer:QB.DataPreviewViewRenderer,DataViewRenderer:QB.DataViewRenderer,InLineRenderer:QB.InLineRenderer,extendInputRenderMapping:(e,t,n)=>{},extendOutputRenderMapping:(e,t,n)=>{},extendHandlePreviewRenderMapping:(e,t,n)=>{},extendDataOverlayRenderMapping:(e,t,n)=>{},extendDataPreviewRenderMapping:(e,t,n)=>{},extendDataViewRenderMapping:(e,t,n)=>{},extendFromPlugin:(e,t)=>{}}),rV=({component:e,...t})=>o.createElement(e,{...t}),oV=t=>{const n=e.useContext(zV),{DataOverlayRenderer:r,DataPreviewViewRenderer:o}=e.useContext(nV);if(void 0===t)return;const i=n.render_options(),[a]=iV(t.type,i.typemap||{});return a?r[a]?r[a]:o[a]?o[a]:KB:KB},iV=(e,t)=>{if("string"==typeof e)return e in t?[t[e],e]:[e,e];if("allOf"in e&&void 0!==e.allOf)return[void 0,void 0];if("anyOf"in e&&void 0!==e.anyOf){const n=e.anyOf.map((e=>iV(e,t)));for(const e of n)switch(e[0]){case"bool":return["bool",e[1]];case"enum":return["enum",e[1]];case"float":return["float",e[1]];case"int":return["int",e[1]];case"string":case"str":return["string",e[1]]}return[void 0,void 0]}return"type"in e&&void 0!==e.type&&"enum"===e.type?["enum","enum"]:[void 0,void 0]},aV=({io:t,typestring:n,preview:r,...i})=>{const[a,s]=e.useState(!1),[l,c]=e.useState(!1),u=o.useContext(zV),[d,f]=(t=>{const n=e.useContext(zV).render_options(),{HandlePreviewRenderer:r,DataPreviewViewRenderer:o}=e.useContext(nV),i=oV(t);let a;if(t){const[e]=iV(t.type,n.typemap||{});a=e?r[e]?r[e]:o[e]?o[e]:KB:KB}return[a,i]})(t),p=u.local_state((()=>u.reactflowRef));return o.createElement(GN,{open:a||l,onOpenChange:c},o.createElement(WN,{asChild:!0},o.createElement(ci,{id:t.id,"data-type":n,...i})),o.createElement(HN,{container:p},o.createElement(XN,{className:"iotooltipcontent",sideOffset:5},o.createElement("div",{className:"iotooltip_container"},o.createElement("div",{className:"iotooltip_header"},a?o.createElement(Xy,{onClick:()=>s(!1)}):o.createElement(Hy,{onClick:()=>s(!0)}),f&&o.createElement(Uy,{title:t.full_id,trigger:o.createElement(jy,null),onOpenChange:e=>{e&&t.try_get_full_value&&t.try_get_full_value(),s(e)}},o.createElement(rV,{component:f,io:t}))),d?o.createElement(rV,{component:d,io:t}):`no preview available for "${n}"`),o.createElement($N,{className:"iotooltipcontentarrow"}))))},sV={"":[e=>e,e=>e],str_to_json:[e=>JSON.parse(e),e=>"string"==typeof e?e:JSON.stringify(e)],str_to_list:[e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch(t){try{return JSON.parse("["+e+"]")}catch(e){}}throw new Error("Invalid list")},e=>JSON.stringify(e)]},lV=({io:t})=>{const n=e.useContext(zV).render_options(),[r,i]=iV(t.render_options.type,n.typemap||{}),{Inputrenderer:a}=e.useContext(nV),s=r?t.value_options?.options?hD:a[r]:void 0,l=sV[(i&&n.inputconverter?.[i])??""];return o.createElement("div",{className:"nodeinput","data-type":r},o.createElement(aV,{io:t,typestring:r,position:So.Left,type:"target"}),s&&o.createElement("div",{className:"iovaluefield nodrag","data-type":r},o.createElement(s,{io:t,inputconverter:l})),o.createElement("div",{className:"ioname"},t.name),o.createElement(aV,{io:t,typestring:r,position:So.Right,type:"source"}))},cV=({io:t,typestring:n})=>{const{InLineRenderer:r}=e.useContext(nV);if(n&&r[n])return o.createElement("div",null,r[n]({io:t}));let i=t.fullvalue;return null==i&&(i=t.value),i=void 0===i?"":JSON.stringify(i).replace(/\\n/g,"\n"),i.length>63&&(i=i.slice(0,60)+"..."),o.createElement("div",null,i)},uV=({io:t})=>{const n=e.useContext(zV).render_options(),[r]=iV(t.type,n.typemap||{}),{Outputrenderer:i}=e.useContext(nV),a=r?i[r]:void 0;return o.createElement("div",{className:"nodeoutput","data-type":r},o.createElement(aV,{io:t,typestring:r,position:So.Right,type:"source"}),o.createElement("div",{className:"ioname"},t.name),a?o.createElement("div",{className:"iovaluefield nodrag"},o.createElement(a,{io:t})):o.createElement("div",{className:"iovaluefield"},o.createElement(cV,{io:t,typestring:r})))};function dV(e){return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`}function fV(e,t){const n=["","K","M","G","T"];let r=0;for(;e>=t&&r<n.length-1;)e/=t,r++;return[e.toFixed(2),n[r]]}const pV=({state:t,className:n="reacttqdm",...r})=>{const i=e.useRef(null),a=e.useRef(null);e.useEffect((()=>{const e=()=>{i.current&&a.current&&function(e,t,n={}){const{maxFontSize:r=100,minFontSize:o=6,decrementFactor:i=.9}=n;if(!e||!t)return;if(i>=1||i<=0)throw new Error("decrementFactor must be between 0 and 1");const a=e.getBoundingClientRect(),s=a.width,l=a.height;let c=r;t.style.whiteSpace="nowrap",t.style.display="inline-block",t.style.fontSize=c+"px";let u=t.getBoundingClientRect();for(;(u.width>s||u.height>l)&&c>o;)c*=i,t.style.fontSize=c+"px",u=t.getBoundingClientRect()}(i.current,a.current,{maxFontSize:12,decrementFactor:.9})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[t]);const s=t.total?t.n/t.total*100:0;return o.createElement("div",{ref:i,className:n,...r},o.createElement("div",{style:{position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}},o.createElement("div",{className:n+"-bar",style:{position:"absolute",width:"100%",height:"100%",overflow:"hidden"}},o.createElement("div",{className:n+"-progress",style:{width:`${s}%`,height:"100%"}})),o.createElement("div",{className:n+"-text",ref:a},function(e={n:0,elapsed:0,ascii:!1,unit:"it",unit_scale:!1,unit_divisor:1e3}){let t=e.total??null;const{n:n,unit_scale:r,elapsed:o,unit:i,unit_divisor:a,prefix:s="",rate:l,postfix:c=null,initial:u=0}=e;null!==t&&n>=t+.5&&(t=null);let d=n,f=t,p=l;r&&!0!==r&&1!==r&&(null!==t&&(f=t*r),d=n*r,void 0!==l&&(p=l*r));const h=dV(o);void 0===p&&o>0&&(p=(d-u)/o);const m=p?1/p:void 0,[g,y]=p?fV(p,a):[void 0,""],[b,v]=m?fV(m,1e3):[void 0,""],w=m&&m>1?b?`${b}${v}s/`+i:"?":(g||"?")+`${y}${i}/s`,x=r?fV(d,a).join(""):d.toString(),C=r&&null!==f?fV(f,a).join(""):f?.toString()??"?",k=p?dV(p&&null!==f?(f-d)/p:0):"?",E=s?`${s}: `:"";if(null!==t){const e=` ${x}/${C} [${h} < ${k}, ${w}${c??""}]`;return`${E}${(d/t*100).toFixed(0)}%${e}`}return`${E}${x}${i} [${h}, ${w}${c??""}]`}(t))))},hV=({node_data:t})=>{const n=e.useContext(zV);return o.createElement("div",{className:"nodeheader",title:t.description||t.node_name},o.createElement("div",{className:"nodeheader_element"},o.createElement(Zy,{fontSize:"inherit",className:"triggerbutton",onClick:()=>{n.on_node_action({type:"trigger",from_remote:!1,id:t.id})}}),o.createElement($y,{fontSize:"inherit",onClick:async()=>{n.logger.info("nodestatus",await(n.worker?.get_node_status(t.id)))}})),o.createElement("div",{className:"nodeheader_element nodeheader_title"},o.createElement("div",{className:"nodeheader_title_text"},t.node_name)),o.createElement("div",{className:"nodeheader_element"},o.createElement(Gy,{fontSize:"inherit"})))},mV=({node_data:t})=>{const n=t.render_options?.data?.src?t.io[t.render_options?.data?.src]:void 0,[r,i]=(t=>{const n=e.useContext(zV),r=oV(t),{DataPreviewViewRenderer:o,DataViewRenderer:i}=e.useContext(nV),a=n.render_options();if(void 0===t)return[void 0,r];const[s]=iV(t.type,a.typemap||{});return s?i[s]?[i[s],r]:o[s]?[o[s],r]:[KB,r]:[KB,r]})(n);return o.createElement("div",{className:"nodrag nodedatabody","data-src":t.render_options?.data?.src||""},r&&n&&o.createElement(Uy,{title:n.full_id,trigger:o.createElement("div",{className:"nodedatabutton"},o.createElement(rV,{component:r,io:n})),onOpenChange:e=>{e&&n?.try_get_full_value&&n?.try_get_full_value()}},i&&o.createElement(rV,{component:i,io:n})))},gV=({node_data:e})=>{const t=Object.values(e.io).filter((e=>e.is_input)),n=Object.values(e.io).filter((e=>!e.is_input));return e.render_options,o.createElement("div",{className:"nodebody"},n.map((e=>e.hidden?null:o.createElement(uV,{key:e.id,io:e}))),o.createElement(mV,{node_data:e}),t.map((e=>e.hidden?null:o.createElement(lV,{key:e.id,io:e}))))},yV=({node_data:t})=>{const[n,r]=e.useState(t.name);e.useEffect((()=>{r(t.name)}),[t]);const i=e.useContext(zV);return o.createElement("input",{className:"nodename_input",value:n,onChange:e=>{r(e.target.value)},onBlur:e=>{const n=e.target.value;i.on_node_action({type:"update",from_remote:!1,id:t.id,node:{name:n}})}})},bV=({node_data:e})=>e.progress?o.createElement(pV,{style:{height:"idle"===e.progress.prefix?"0px":void 0},state:e.progress,className:"nodeprogress"}):null,vV=({node_data:e})=>o.createElement("div",{className:"nodefooter"},e.error&&o.createElement("div",{className:"nodeerror"},e.error),o.createElement(bV,{node_data:e})),wV=({io:e})=>{const t=o.useContext(zV).render_options(),[n,r]=iV(e.render_options.type,t.typemap||{}),{Inputrenderer:i}=o.useContext(nV),a=n?e.value_options?.options?hD:i[n]:void 0,s=sV[(r&&t.inputconverter?.[r])??""];return o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,e.name),a&&o.createElement(a,{io:e,inputconverter:s}),o.createElement("div",null,o.createElement("label",null,"hidden:",o.createElement("input",{className:"styledcheckbox",type:"checkbox",disabled:e.connected,onChange:t=>{e.set_hidden?.(t.target.checked)},checked:e.hidden}))))},xV=({io:e})=>o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,e.name),o.createElement("div",null,o.createElement("label",null,"hidden:",o.createElement("input",{className:"styledcheckbox",type:"checkbox",disabled:e.connected,onChange:t=>{e.set_hidden?.(t.target.checked)},checked:e.hidden})))),CV=({nodestore:e})=>{const t=e(),n=Object.values(t.io).filter((e=>e.is_input)),r=Object.values(t.io).filter((e=>!e.is_input));return o.createElement("div",{className:"nodesettings_content"},o.createElement("div",{className:"nodesettings_section"},o.createElement("div",{className:"nodesettings_component"},o.createElement("div",null,"Name"),o.createElement("div",null,o.createElement(yV,{node_data:t})))),o.createElement("div",{className:"nodesettings_section"},o.createElement("div",null,"Inputs"),n.map((e=>o.createElement(wV,{io:e,key:e.id})))),o.createElement("div",{className:"nodesettings_section"},o.createElement("div",null,"Outputs"),r.map((e=>o.createElement(xV,{io:e,key:e.id})))))},kV=()=>{const e=o.useContext(zV),t=e.local_state((e=>e.selected_nodes));if(0===t.length)return o.createElement("div",null,"Node Settings");if(t.length>1)return o.createElement("div",null,"Multiple Nodes Selected");const n=e.nodespace.get_node(t[0]);return n?o.createElement(CV,{nodestore:n}):o.createElement("div",null,"Node not found")},EV=()=>{const e=o.useContext(zV),t=e.local_settings((e=>e.view_settings.expand_node_props)),n=e.local_settings((e=>e.update_view_settings));return o.createElement(bC,{maxSize:"300px",direction:"left",expanded:void 0!==t&&t,containerClassName:"pos-right pos-top bg1 h-12",className:"nodesettings_content",onExpandChange:e=>{n({expand_node_props:e})}},o.createElement(kV,null))},SV=e=>({nodes:e.nodes,edges:e.edges,onNodesChange:e.onNodesChange,onEdgesChange:e.onEdgesChange,onConnect:e.onConnect}),IV={default:({data:t})=>{const n=t.UseNodeStore(),r=n.properties["frontend:collapsed"]||!1,{visualTrigger:i}=(t=>{const n=e.useContext(zV),[r,o]=e.useState(!1);return e.useEffect((()=>{n.worker?.call_hooks("node_mounted",t.id)}),[n.worker,t.id]),e.useEffect((()=>{let e;return t.in_trigger&&!r?o(!0):r&&(e=setTimeout((()=>o(!1)),200)),()=>clearTimeout(e)}),[t.in_trigger,r]),{visualTrigger:r}})(n);return o.createElement(o.Fragment,null,o.createElement("div",{className:"innernode"+(i?" intrigger":"")+(n.error?" error":"")},o.createElement(hV,{node_data:n}),o.createElement(yV,{node_data:n}),r?null:o.createElement(gV,{node_data:n}),o.createElement(vV,{node_data:n})))}},_V={default:({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:s,data:l,...c})=>{const[u]=Lo({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:i,targetPosition:s});return o.createElement(o.Fragment,null,o.createElement(go,{id:e,path:u,...c}))}},AV=()=>{const t=Zi();return e.useContext(zV).rf_instance=t,o.createElement(o.Fragment,null)},NV=()=>{const t=e.useContext(zV),n=Pi("Delete"),r=Hr(Cs,Z),i=Hr(xs,Z);if(n){for(const e of r)if(e.selected){if(!t.worker)return o.createElement(o.Fragment,null);if(!e.source||!e.target)return o.createElement(o.Fragment,null);if(!e.sourceHandle||!e.targetHandle)return o.createElement(o.Fragment,null);t.worker.remove_edge({src_nid:e.source,src_ioid:e.sourceHandle,trg_nid:e.target,trg_ioid:e.targetHandle})}for(const e of i)if(e.selected){if(!t.worker)return o.createElement(o.Fragment,null);t.worker.remove_node(e.id)}}return o.createElement(o.Fragment,null)},OV=({id:t,top:n,left:r,right:i,bottom:a,...s})=>{const{getNode:l,setNodes:c,addNodes:u,setEdges:d}=Zi(),f=e.useContext(zV),p=e.useCallback((()=>{const e=l(t);if(!e)return;const n={x:e.position.x+50,y:e.position.y+50};u({...e,id:`${e.id}-copy`,position:n})}),[t,l,u]),h=e.useCallback((()=>{f.on_node_action({type:"delete",id:t,from_remote:!1})}),[t,c,d]),m=f.nodespace.get_node(t,!1);if(!m)return o.createElement(o.Fragment,null," ");const g=m();return o.createElement("div",{style:{top:n,left:r,right:i,bottom:a},className:"context-menu",...s},o.createElement("p",{style:{fontWeight:"bold"}},o.createElement("small",null,g.name)),o.createElement("button",{onClick:p},"duplicate"),o.createElement("button",{onClick:h},"delete"))},RV=t=>{const n=e.useContext(zV),r=e.useRef(null);e.useEffect((()=>{n.reactflowRef=r.current}),[r]);const[i,a]=e.useState(null),s=e.useCallback((()=>a(null)),[a]),{nodes:l,edges:c,onNodesChange:u,onEdgesChange:d,onConnect:f}=n.useReactFlowStore(dN(SV));return o.createElement("div",{className:"reactflowlayer"},o.createElement(ws,{nodes:l,edges:c,onNodesChange:u,onEdgesChange:d,onConnect:f,nodeTypes:IV,edgeTypes:_V,minZoom:t.minZoom,maxZoom:t.maxZoom,fitView:!0,onSelectionChange:({nodes:e,edges:t})=>{const r=n.local_state.getState();n.local_state.setState({...r,selected_nodes:e.map((e=>e.id)),selected_edges:t.map((e=>e.id))})},ref:r,onPaneClick:s,panOnDrag:!t.static},o.createElement(AV,null),o.createElement(NV,null),o.createElement(zs,{color:"#888",gap:16,size:1}),t.minimap&&o.createElement(Ms,{nodeStrokeWidth:3,pannable:!t.static,zoomable:!t.static,zoomStep:3}),i&&o.createElement(OV,{onClick:s,...i})))},MV=e.createContext(void 0),TV=e.forwardRef(((t,n)=>{const{asChild:r,children:a,className:s,style:l,...c}=t,[u,d]=e.useState(!1),f=e.useRef(null),[p,h]=e.useState(null),[m,g]=e.useState({}),y=t.htime||300,b=t.vtime||300,v=t.hdelay||0,w=t.vdelay||200;e.useImperativeHandle(n,(()=>f.current),[]);let x;if(r&&o.isValidElement(a)){const e=a,t=[e.props.className,s,"smooth-expand",u?"smooth-expand-expanded":""].filter(Boolean).join(" "),n={...e.props.style,...l,...m};x=o.cloneElement(e,{ref:f,className:t,style:n,...c})}else x=o.createElement("div",{ref:f,...c,className:`smooth-expand ${u?"smooth-expand-expanded":""} ${s||""}`,style:{...l,...m}},a);const C=o.createElement(MV.Provider,{value:{isExpanded:u,toggleExpand:async()=>{f.current&&(u?await(async()=>{if(!f.current)return;if(!p)return;const e={transitionProperty:"width, left, height, top",transitionDuration:`${y}ms, ${y}ms, ${b}ms, ${b}ms`};g((t=>({...t,...e})));const[t,n,r,o]=p,i=new Promise((e=>{setTimeout((()=>{g((e=>({...e,left:`${t}px`,width:`${r}px`}))),e()}),w)})),a=new Promise((e=>{setTimeout((()=>{g((e=>({...e,top:`${n}px`,height:`${o}px`}))),e()}),v)})),s=Math.max(y+v,b+w),l=new Promise((e=>{setTimeout((()=>{e()}),s)}));await Promise.all([i,a,l]),f.current.style.transition="",g({}),d(!1)})():await(async()=>{if(!f.current)return;f.current.style.transition="none",f.current.style.position="",f.current.style.top="",f.current.style.left="",f.current.style.width="",f.current.style.height="";const e=f.current.getBoundingClientRect();h([e.left,e.top,e.width,e.height]),f.current.style.transition="none",g({position:"absolute",top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`}),g((e=>({...e,transitionProperty:"width, left, height, top",transitionDuration:`${y}ms, ${y}ms, ${b}ms, ${b}ms`}))),d(!0);const t=new Promise((e=>{setTimeout((()=>{g((e=>({...e,left:"0px",width:"100vw"}))),e()}),v)})),n=new Promise((e=>{setTimeout((()=>{g((e=>({...e,top:"0px",height:"100vh"}))),e()}),w)})),r=Math.max(y+v,b+w),o=new Promise((e=>{setTimeout((()=>{e()}),r)}));await Promise.all([t,n,o])})())}}},x);return u?i.createPortal(C,document.body):C}));TV.Trigger=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Trigger must be used within a SmoothExpandComponent");return o.createElement("div",{style:{cursor:"pointer"},onClick:n.toggleExpand},t)},TV.Expanded=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Expanded must be used within a SmoothExpandComponent");return n.isExpanded?o.createElement(o.Fragment,null,t):null},TV.Collapsed=function({children:t}){const n=e.useContext(MV);if(!n)throw new Error("SmoothExpandComponent.Collapsed must be used within a SmoothExpandComponent");return n.isExpanded?null:o.createElement(o.Fragment,null,t)};const PV=o.createContext(void 0),DV=e.forwardRef(((t,n)=>{const{asChild:r,children:i,className:a,style:s,...l}=t,c=e.useRef(null);e.useImperativeHandle(n,(()=>c.current),[]);const[u,d]=e.useState(!1),f=e.useCallback((async()=>{try{const e=c.current;if(!e)return;if(u){const e=document;e.exitFullscreen?await e.exitFullscreen():e.mozCancelFullScreen?await e.mozCancelFullScreen():e.webkitExitFullscreen?await e.webkitExitFullscreen():e.msExitFullscreen&&await e.msExitFullscreen(),d(!1)}else e.requestFullscreen?await e.requestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.msRequestFullscreen&&await e.msRequestFullscreen(),d(!0)}catch(e){console.error("Error toggling fullscreen",e)}}),[u]);let p;if(e.useEffect((()=>{const e=()=>{const e=document.fullscreenElement;d(!!e)};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}),[]),r&&o.isValidElement(i)){const e=i,t=[e.props.className,a].filter(Boolean).join(" "),n={...e.props.style,...s};p=o.cloneElement(e,{ref:c,className:t,style:n,...l})}else p=o.createElement("div",{ref:c,...l,className:a,style:s},i);return o.createElement(PV.Provider,{value:{isFullScreen:u,toggleFullscreen:f}},p)}));DV.Trigger=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Trigger must be used within a FullScreenComponent");return o.createElement("div",{style:{cursor:"pointer"},onClick:t.toggleFullscreen},e)},DV.InFullScreen=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Expanded must be used within a FullScreenComponent");return t.isFullScreen?o.createElement(o.Fragment,null,e):null},DV.OutFullScreen=function({children:e}){const t=o.useContext(PV);if(!t)throw new Error("FullScreenComponent.Collapsed must be used within a FullScreenComponent");return t.isFullScreen?null:o.createElement(o.Fragment,null,e)};const jV=({fnrf_zst:t,header:n,flow:r,library:i})=>{const[a,s]=e.useState(t.options.worker),l=o.useRef(null);t.workermanager&&(t.workermanager.on_setWorker=s),t.set_worker(a),o.useEffect((()=>{t.auto_progress()}),[]),o.useEffect((()=>{t.local_state.setState({funcnodescontainerRef:l.current})}),[l]);const c=t.plugins();return o.createElement(tV,{plugins:c,fnrf_zst:t},o.createElement(zV.Provider,{value:t},o.createElement(TV,{asChild:!0},o.createElement(DV,{asChild:!0},o.createElement(mC,{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",flex:1}},o.createElement("div",{ref:l,className:"funcnodesreactflowcontainer funcnodescontainer"},n.show&&o.createElement(EC,{...n}),o.createElement("div",{className:"funcnodesreactflowbody"},o.createElement(RV,{...r}),a&&i.show&&o.createElement(cN,null),a&&r.showNodeSettings&&o.createElement(EV,null)),o.createElement("div",{className:"funcnodesflaotingmenu"},o.createElement(DV.OutFullScreen,null,r.allowExpand&&o.createElement(TV.Trigger,null,o.createElement(TV.Expanded,null,o.createElement(Ly,{size:"xl",style:{padding:"4px"}})),o.createElement(TV.Collapsed,null,o.createElement(zy,{size:"xl",style:{padding:"4px"}})))),r.allowFullScreen&&o.createElement(DV.Trigger,null,o.createElement(DV.OutFullScreen,null,o.createElement(jy,{size:"xl",style:{padding:"4px"}})),o.createElement(DV.InFullScreen,null,o.createElement(Fy,{size:"xl",style:{padding:"4px"}}))))))))))},FV={},LV={id:"",debug:!1,useWorkerManager:!0,show_library:!0,header:{show:!0,showmenu:!0},flow:{minimap:!0,static:!1,minZoom:.1,maxZoom:5,allowFullScreen:!0,allowExpand:!0,showNodeSettings:!0},library:{show:!0}},zV=e.createContext(Js(LV)),BV=e=>{let t=T(e,{...LV,id:Su()}).new_obj;if(!t.useWorkerManager&&void 0===t.worker)return o.createElement("div",null,"Error: If you don't use a worker manager, you must provide a default worker.");if(e.useWorkerManager&&void 0===e.workermanager_url)return o.createElement("div",null,"Error: If you use a worker manager, you must provide a worker manager url.");if(void 0===window.fnrf_zst&&(window.fnrf_zst=FV),void 0===FV[t.id]){const e=Js(t);FV[t.id]=e}if(t.worker&&t.worker.set_zustand(FV[t.id]),FV[t.id].options.debug=t.debug,t.useWorkerManager){const e=new Au(t.workermanager_url,FV[t.id]);FV[t.id].workermanager=e}return o.createElement(jV,{fnrf_zst:FV[t.id],header:t.header,library:t.library,flow:t.flow})},VV={set_io_value:({nid:t,ioid:n,value:r,set_default:o=!1})=>{const i=e.useContext(zV);i.worker?.set_io_value({nid:t,ioid:n,value:r,set_default:o})}};exports.FuncNodesContext=zV,exports.FuncNodesReactFlowZustand=Js,exports.FuncNodesWorker=Iu,exports.FuncnodesReactFlow=BV,exports.ReactFlowLayer=RV,exports.RenderMappingProvider=tV,exports.WebSocketWorker=_u,exports.assert_full_node=z,exports.deep_update=T,exports.default=e=>{const t=new Zs("FuncNodes",e.debug?"debug":"info");t.debug("Initalizing FuncNodes with props:",e);let n=T(e,{...LV,id:Su()}).new_obj;if(void 0===e.worker&&void 0!==e.worker_url&&(n.useWorkerManager=!1,n.worker=new _u({url:e.worker_url,uuid:n.id,on_sync_complete:n.on_sync_complete})),void 0!==n.worker){const e=Js(n);n.worker.set_zustand(e)}if(void 0!==e.fnw_url){if(void 0===n.worker)throw new Error("defining fnw_url requires a worker to be defined");const t=async function(e,t=!0){try{const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch from URL: ${n.status} ${n.statusText}`);const r=await n.blob();return await new Promise(((e,n)=>{const o=new FileReader;o.onload=()=>{const r=o.result;"string"!=typeof r&&(n("Failed to convert URL to Base64: No result from FileReader"),n(o.error)),e(t?r.split(",")[1]:r)},o.onerror=()=>n(o.error),o.readAsDataURL(r)}))}catch(e){throw console.error("Error converting URL to Base64:",e),e}}(e.fnw_url),r=n.worker.on_sync_complete,o=async e=>{const n=await t;e.on_sync_complete=r,await e.update_from_export(n)};n.worker.on_sync_complete=o}return t.debug("Initalizing FuncnodesReactFlow with props:",n),o.createElement("div",{className:"FuncnodesApp"},o.createElement(BV,{...n}))},exports.helperfunctions=VV;
157
157
  //# sourceMappingURL=index.umd.js.map