@timo9378/flow2code 0.1.9 → 0.2.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +15 -2
  3. package/dist/cli.js +74 -7
  4. package/dist/compiler.cjs +32 -2
  5. package/dist/compiler.d.cts +6 -0
  6. package/dist/compiler.d.ts +6 -0
  7. package/dist/compiler.js +32 -2
  8. package/dist/server.d.ts +1 -1
  9. package/dist/server.js +1227 -1010
  10. package/out/404.html +1 -1
  11. package/out/__next.__PAGE__.txt +4 -4
  12. package/out/__next._full.txt +13 -13
  13. package/out/__next._head.txt +4 -4
  14. package/out/__next._index.txt +6 -6
  15. package/out/__next._tree.txt +2 -2
  16. package/out/_next/static/chunks/05328cd26bdc795c.js +176 -0
  17. package/out/_next/static/chunks/06e01c846ae01892.js +1 -0
  18. package/out/_next/static/chunks/1011f174944c0ca2.js +70 -0
  19. package/out/_next/static/chunks/1570e9ba5f1b44ed.js +5 -0
  20. package/out/_next/static/chunks/6167fccccde2e675.css +1 -0
  21. package/out/_next/static/chunks/{b112c2f519e4b429.js → 7cd04052abfadac1.js} +1 -1
  22. package/out/_next/static/chunks/8091c1216a95d294.js +1 -0
  23. package/out/_next/static/chunks/98d53aae29c36c6b.js +1 -0
  24. package/out/_next/static/chunks/a6dad97d9634a72d.js.map +1 -1
  25. package/out/_next/static/chunks/{b163b5d7cccbcf42.js → b05daf00cdc6058f.js} +1 -1
  26. package/out/_next/static/chunks/b3419ee3e3a616d9.js +1 -0
  27. package/out/_next/static/chunks/{acf223168ac429f7.js → be40d79540010a0d.js} +1 -1
  28. package/out/_next/static/chunks/{turbopack-576234c945ffdc44.js → turbopack-9da9810f42c97265.js} +1 -1
  29. package/out/_not-found/__next._full.txt +11 -11
  30. package/out/_not-found/__next._head.txt +4 -4
  31. package/out/_not-found/__next._index.txt +6 -6
  32. package/out/_not-found/__next._not-found/__PAGE__.txt +2 -2
  33. package/out/_not-found/__next._not-found.txt +3 -3
  34. package/out/_not-found/__next._tree.txt +2 -2
  35. package/out/_not-found.html +1 -1
  36. package/out/_not-found.txt +11 -11
  37. package/out/index.html +2 -2
  38. package/out/index.txt +13 -13
  39. package/package.json +130 -124
  40. package/out/_next/static/chunks/0bc0a50347ee5f3c.js +0 -51
  41. package/out/_next/static/chunks/58bf94a9d7047ec0.js +0 -125
  42. package/out/_next/static/chunks/6b84376656bd9887.js +0 -1
  43. package/out/_next/static/chunks/83ab8820627f8bfe.css +0 -1
  44. package/out/_next/static/chunks/ab8888d4b78b94be.js +0 -5
  45. package/out/_next/static/chunks/b6e8711267bccbbd.js +0 -1
  46. package/out/_next/static/chunks/fbca595129527827.js +0 -1
  47. package/scripts/publish-all.sh +0 -56
  48. /package/out/_next/static/{Ma0MmC8j1mxpQbtLwNajF → dSp6-CaehEDKVU9OSJABu}/_buildManifest.js +0 -0
  49. /package/out/_next/static/{Ma0MmC8j1mxpQbtLwNajF → dSp6-CaehEDKVU9OSJABu}/_clientMiddlewareManifest.json +0 -0
  50. /package/out/_next/static/{Ma0MmC8j1mxpQbtLwNajF → dSp6-CaehEDKVU9OSJABu}/_ssgManifest.js +0 -0
@@ -1,51 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,25661,(e,t,n)=>{"use strict";var r=e.r(49021),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=r.useState,i=r.useEffect,s=r.useLayoutEffect,l=r.useDebugValue;function d(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}var c="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),o=r[0].inst,c=r[1];return s(function(){o.value=n,o.getSnapshot=t,d(o)&&c({inst:o})},[e,n,t]),i(function(){return d(o)&&c({inst:o}),e(function(){d(o)&&c({inst:o})})},[e]),l(n),n};n.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:c},56032,(e,t,n)=>{"use strict";t.exports=e.r(25661)},20206,(e,t,n)=>{"use strict";var r=e.r(49021),o=e.r(56032),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=o.useSyncExternalStore,s=r.useRef,l=r.useEffect,d=r.useMemo,c=r.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var u=s(null);if(null===u.current){var p={hasValue:!1,value:null};u.current=p}else p=u.current;var f=i(e,(u=d(function(){function e(e){if(!l){if(l=!0,i=e,e=r(e),void 0!==o&&p.hasValue){var t=p.value;if(o(t,e))return s=t}return s=e}if(t=s,a(i,e))return t;var n=r(e);return void 0!==o&&o(t,n)?(i=e,t):(i=e,s=n)}var i,s,l=!1,d=void 0===n?null:n;return[function(){return e(t())},null===d?void 0:function(){return e(d())}]},[t,n,r,o]))[0],u[1]);return l(function(){p.hasValue=!0,p.value=f},[f]),c(f),f}},96482,(e,t,n)=>{"use strict";t.exports=e.r(20206)},52683,e=>{"use strict";let t,n,r,o;var a,i,s,l,d,c,u,p,f,h,m,g,x,v,y,b,w,S,C,j,N,E,k,_,T=e.i(75984),I=e.i(49021);function R(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)""!==(r=R(e[n]))&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}e.i(9698);var P={value:()=>{}};function M(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw Error("illegal type: "+e);r[e]=[]}return new A(r)}function A(e){this._=e}function O(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=P,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}function D(){}function L(e){return null==e?D:function(){return this.querySelector(e)}}function z(){return[]}function $(e){return null==e?z:function(){return this.querySelectorAll(e)}}function H(e){return function(){return this.matches(e)}}function F(e){return function(t){return t.matches(e)}}A.prototype=M.prototype={constructor:A,on:function(e,t){var n,r=this._,o=(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!r.hasOwnProperty(e))throw Error("unknown type: "+e);return{type:e,name:t}}),a=-1,i=o.length;if(arguments.length<2){for(;++a<i;)if((n=(e=o[a]).type)&&(n=function(e,t){for(var n,r=0,o=e.length;r<o;++r)if((n=e[r]).name===t)return n.value}(r[n],e.name)))return n;return}if(null!=t&&"function"!=typeof t)throw Error("invalid callback: "+t);for(;++a<i;)if(n=(e=o[a]).type)r[n]=O(r[n],e.name,t);else if(null==t)for(n in r)r[n]=O(r[n],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new A(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,o=Array(n),a=0;a<n;++a)o[a]=arguments[a+2];if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(r=this._[e],a=0,n=r.length;a<n;++a)r[a].value.apply(t,o)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(var r=this._[e],o=0,a=r.length;o<a;++o)r[o].value.apply(t,n)}};var B=Array.prototype.find;function V(){return this.firstElementChild}var U=Array.prototype.filter;function K(){return Array.from(this.children)}function W(e){return Array(e.length)}function X(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function G(e,t,n,r,o,a){for(var i,s=0,l=t.length,d=a.length;s<d;++s)(i=t[s])?(i.__data__=a[s],r[s]=i):n[s]=new X(e,a[s]);for(;s<l;++s)(i=t[s])&&(o[s]=i)}function Y(e,t,n,r,o,a,i){var s,l,d,c=new Map,u=t.length,p=a.length,f=Array(u);for(s=0;s<u;++s)(l=t[s])&&(f[s]=d=i.call(l,l.__data__,s,t)+"",c.has(d)?o[s]=l:c.set(d,l));for(s=0;s<p;++s)d=i.call(e,a[s],s,a)+"",(l=c.get(d))?(r[s]=l,l.__data__=a[s],c.delete(d)):n[s]=new X(e,a[s]);for(s=0;s<u;++s)(l=t[s])&&c.get(f[s])===l&&(o[s]=l)}function q(e){return e.__data__}function Z(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}X.prototype={constructor:X,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)}};var J="http://www.w3.org/1999/xhtml";let Q={svg:"http://www.w3.org/2000/svg",xhtml:J,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ee(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),Q.hasOwnProperty(t)?{space:Q[t],local:e}:e}function et(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function en(e,t){return e.style.getPropertyValue(t)||et(e).getComputedStyle(e,null).getPropertyValue(t)}function er(e){return e.trim().split(/^|\s+/)}function eo(e){return e.classList||new ea(e)}function ea(e){this._node=e,this._names=er(e.getAttribute("class")||"")}function ei(e,t){for(var n=eo(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function es(e,t){for(var n=eo(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function el(){this.textContent=""}function ed(){this.innerHTML=""}function ec(){this.nextSibling&&this.parentNode.appendChild(this)}function eu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ep(e){var t=ee(e);return(t.local?function(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===J&&t.documentElement.namespaceURI===J?t.createElement(e):t.createElementNS(n,e)}})(t)}function ef(){return null}function eh(){var e=this.parentNode;e&&e.removeChild(this)}function em(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eg(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ex(e){return function(){var t=this.__on;if(t){for(var n,r=0,o=-1,a=t.length;r<a;++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 ev(e,t,n){return function(){var r,o=this.__on,a=function(e){t.call(this,e,this.__data__)};if(o){for(var i=0,s=o.length;i<s;++i)if((r=o[i]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),r.value=t;return}}this.addEventListener(e.type,a,n),r={type:e.type,name:e.name,value:t,listener:a,options:n},o?o.push(r):this.__on=[r]}}function ey(e,t,n){var r=et(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)}ea.prototype={add:function(e){0>this._names.indexOf(e)&&(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 eb=[null];function ew(e,t){this._groups=e,this._parents=t}function eS(){return new ew([[document.documentElement]],eb)}function eC(e){return"string"==typeof e?new ew([[document.querySelector(e)]],[document.documentElement]):new ew([[e]],eb)}function ej(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]}ew.prototype=eS.prototype={constructor:ew,select:function(e){"function"!=typeof e&&(e=L(e));for(var t=this._groups,n=t.length,r=Array(n),o=0;o<n;++o)for(var a,i,s=t[o],l=s.length,d=r[o]=Array(l),c=0;c<l;++c)(a=s[c])&&(i=e.call(a,a.__data__,c,s))&&("__data__"in a&&(i.__data__=a.__data__),d[c]=i);return new ew(r,this._parents)},selectAll:function(e){if("function"==typeof e){var t;t=e,e=function(){var e;return e=t.apply(this,arguments),null==e?[]:Array.isArray(e)?e:Array.from(e)}}else e=$(e);for(var n=this._groups,r=n.length,o=[],a=[],i=0;i<r;++i)for(var s,l=n[i],d=l.length,c=0;c<d;++c)(s=l[c])&&(o.push(e.call(s,s.__data__,c,l)),a.push(s));return new ew(o,a)},selectChild:function(e){var t;return this.select(null==e?V:(t="function"==typeof e?e:F(e),function(){return B.call(this.children,t)}))},selectChildren:function(e){var t;return this.selectAll(null==e?K:(t="function"==typeof e?e:F(e),function(){return U.call(this.children,t)}))},filter:function(e){"function"!=typeof e&&(e=H(e));for(var t=this._groups,n=t.length,r=Array(n),o=0;o<n;++o)for(var a,i=t[o],s=i.length,l=r[o]=[],d=0;d<s;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&l.push(a);return new ew(r,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,q);var n=t?Y:G,r=this._parents,o=this._groups;"function"!=typeof e&&(v=e,e=function(){return v});for(var a=o.length,i=Array(a),s=Array(a),l=Array(a),d=0;d<a;++d){var c=r[d],u=o[d],p=u.length,f="object"==typeof(x=e.call(c,c&&c.__data__,d,r))&&"length"in x?x:Array.from(x),h=f.length,m=s[d]=Array(h),g=i[d]=Array(h);n(c,u,m,g,l[d]=Array(p),f,t);for(var x,v,y,b,w=0,S=0;w<h;++w)if(y=m[w]){for(w>=S&&(S=w+1);!(b=g[S])&&++S<h;);y._next=b||null}}return(i=new ew(i,r))._enter=s,i._exit=l,i},enter:function(){return new ew(this._enter||this._groups.map(W),this._parents)},exit:function(){return new ew(this._exit||this._groups.map(W),this._parents)},join:function(e,t,n){var r=this.enter(),o=this,a=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?a.remove():n(a),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,a=r.length,i=Math.min(o,a),s=Array(o),l=0;l<i;++l)for(var d,c=n[l],u=r[l],p=c.length,f=s[l]=Array(p),h=0;h<p;++h)(d=c[h]||u[h])&&(f[h]=d);for(;l<o;++l)s[l]=n[l];return new ew(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],a=o.length-1,i=o[a];--a>=0;)(r=o[a])&&(i&&4^r.compareDocumentPosition(i)&&i.parentNode.insertBefore(r,i),i=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=Z);for(var n=this._groups,r=n.length,o=Array(r),a=0;a<r;++a){for(var i,s=n[a],l=s.length,d=o[a]=Array(l),c=0;c<l;++c)(i=s[c])&&(d[c]=i);d.sort(t)}return new ew(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,a=r.length;o<a;++o){var i=r[o];if(i)return i}return null},size:function(){let e=0;for(let 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,a=t[n],i=0,s=a.length;i<s;++i)(o=a[i])&&e.call(o,o.__data__,i,a);return this},attr:function(e,t){var n=ee(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?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}}:"function"==typeof t?n.local?function(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(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}:n.local?function(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}:function(e,t){return function(){this.setAttribute(e,t)}})(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):en(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=er(e+"");if(arguments.length<2){for(var r=eo(this.node()),o=-1,a=n.length;++o<a;)if(!r.contains(n[o]))return!1;return!0}return this.each(("function"==typeof t?function(e,t){return function(){(t.apply(this,arguments)?ei:es)(this,e)}}:t?function(e){return function(){ei(this,e)}}:function(e){return function(){es(this,e)}})(n,t))},text:function(e){return arguments.length?this.each(null==e?el:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}:function(e){return function(){this.textContent=e}})(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?ed:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}:function(e){return function(){this.innerHTML=e}})(e)):this.node().innerHTML},raise:function(){return this.each(ec)},lower:function(){return this.each(eu)},append:function(e){var t="function"==typeof e?e:ep(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})},insert:function(e,t){var n="function"==typeof e?e:ep(e),r=null==t?ef:"function"==typeof t?t:L(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(eh)},clone:function(e){return this.select(e?eg:em)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var r,o,a=(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}}),i=a.length;if(arguments.length<2){var s=this.node().__on;if(s){for(var l,d=0,c=s.length;d<c;++d)for(r=0,l=s[d];r<i;++r)if((o=a[r]).type===l.type&&o.name===l.name)return l.value}return}for(r=0,s=t?ev:ex;r<i;++r)this.each(s(a[r],t,n));return this},dispatch:function(e,t){return this.each(("function"==typeof t?function(e,t){return function(){return ey(this,e,t.apply(this,arguments))}}:function(e,t){return function(){return ey(this,e,t)}})(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r,o=e[t],a=0,i=o.length;a<i;++a)(r=o[a])&&(yield r)}};let eN={passive:!1},eE={capture:!0,passive:!1};function ek(e){e.stopImmediatePropagation()}function e_(e){e.preventDefault(),e.stopImmediatePropagation()}function eT(e){var t=e.document.documentElement,n=eC(e).on("dragstart.drag",e_,eE);"onselectstart"in t?n.on("selectstart.drag",e_,eE):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function eI(e,t){var n=e.document.documentElement,r=eC(e).on("dragstart.drag",null);t&&(r.on("click.drag",e_,eE),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}let eR=e=>()=>e;function eP(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:a,x:i,y:s,dx:l,dy:d,dispatch:c}){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:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:c}})}function eM(e){return!e.ctrlKey&&!e.button}function eA(){return this.parentNode}function eO(e,t){return null==t?{x:e.x,y:e.y}:t}function eD(){return navigator.maxTouchPoints||"ontouchstart"in this}function eL(){var e,t,n,r,o=eM,a=eA,i=eO,s=eD,l={},d=M("start","drag","end"),c=0,u=0;function p(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",g).on("touchmove.drag",x,eN).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,s){if(!r&&o.call(this,i,s)){var l=y(this,a.call(this,i,s),i,s,"mouse");l&&(eC(i.view).on("mousemove.drag",h,eE).on("mouseup.drag",m,eE),eT(i.view),ek(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function h(r){if(e_(r),!n){var o=r.clientX-e,a=r.clientY-t;n=o*o+a*a>u}l.mouse("drag",r)}function m(e){eC(e.view).on("mousemove.drag mouseup.drag",null),eI(e.view,n),e_(e),l.mouse("end",e)}function g(e,t){if(o.call(this,e,t)){var n,r,i=e.changedTouches,s=a.call(this,e,t),l=i.length;for(n=0;n<l;++n)(r=y(this,s,e,t,i[n].identifier,i[n]))&&(ek(e),r("start",e,i[n]))}}function x(e){var t,n,r=e.changedTouches,o=r.length;for(t=0;t<o;++t)(n=l[r[t].identifier])&&(e_(e),n("drag",e,r[t]))}function v(e){var t,n,o=e.changedTouches,a=o.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),t=0;t<a;++t)(n=l[o[t].identifier])&&(ek(e),n("end",e,o[t]))}function y(e,t,n,r,o,a){var s,u,f,h=d.copy(),m=ej(a||n,t);if(null!=(f=i.call(e,new eP("beforestart",{sourceEvent:n,target:p,identifier:o,active:c,x:m[0],y:m[1],dx:0,dy:0,dispatch:h}),r)))return s=f.x-m[0]||0,u=f.y-m[1]||0,function n(a,i,d){var g,x=m;switch(a){case"start":l[o]=n,g=c++;break;case"end":delete l[o],--c;case"drag":m=ej(d||i,t),g=c}h.call(a,e,new eP(a,{sourceEvent:i,subject:f,target:p,identifier:o,active:g,x:m[0]+s,y:m[1]+u,dx:m[0]-x[0],dy:m[1]-x[1],dispatch:h}),r)}}return p.filter=function(e){return arguments.length?(o="function"==typeof e?e:eR(!!e),p):o},p.container=function(e){return arguments.length?(a="function"==typeof e?e:eR(e),p):a},p.subject=function(e){return arguments.length?(i="function"==typeof e?e:eR(e),p):i},p.touchable=function(e){return arguments.length?(s="function"==typeof e?e:eR(!!e),p):s},p.on=function(){var e=d.on.apply(d,arguments);return e===d?p:e},p.clickDistance=function(e){return arguments.length?(u=(e*=1)*e,p):Math.sqrt(u)},p}function ez(e){return((e=Math.exp(e))+1/e)/2}eP.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};let e$=function e(t,n,r){function o(e,o){var a,i,s=e[0],l=e[1],d=e[2],c=o[0],u=o[1],p=o[2],f=c-s,h=u-l,m=f*f+h*h;if(m<1e-12)i=Math.log(p/d)/t,a=function(e){return[s+e*f,l+e*h,d*Math.exp(t*e*i)]};else{var g=Math.sqrt(m),x=(p*p-d*d+r*m)/(2*d*n*g),v=(p*p-d*d-r*m)/(2*p*n*g),y=Math.log(Math.sqrt(x*x+1)-x);i=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,a=function(e){var r,o,a=e*i,c=ez(y),u=d/(n*g)*(c*(((r=Math.exp(2*(r=t*a+y)))-1)/(r+1))-((o=Math.exp(o=y))-1/o)/2);return[s+u*f,l+u*h,d*c/ez(t*a+y)]}}return a.duration=1e3*i*t/Math.SQRT2,a}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);var eH,eF,eB=0,eV=0,eU=0,eK=0,eW=0,eX=0,eG="object"==typeof performance&&performance.now?performance:Date,eY="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function eq(){return eW||(eY(eZ),eW=eG.now()+eX)}function eZ(){eW=0}function eJ(){this._call=this._time=this._next=null}function eQ(e,t,n){var r=new eJ;return r.restart(e,t,n),r}function e0(){eW=(eK=eG.now())+eX,eB=eV=0;try{eq(),++eB;for(var e,t=eH;t;)(e=eW-t._time)>=0&&t._call.call(void 0,e),t=t._next;--eB}finally{eB=0,function(){for(var e,t,n=eH,r=1/0;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:eH=t);eF=e,e2(r)}(),eW=0}}function e1(){var e=eG.now(),t=e-eK;t>1e3&&(eX-=t,eK=e)}function e2(e){!eB&&(eV&&(eV=clearTimeout(eV)),e-eW>24?(e<1/0&&(eV=setTimeout(e0,e-eG.now()-eX)),eU&&(eU=clearInterval(eU))):(eU||(eK=eG.now(),eU=setInterval(e1,1e3)),eB=1,eY(e0)))}function e5(e,t,n){var r=new eJ;return t=null==t?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}eJ.prototype=eQ.prototype={constructor:eJ,restart:function(e,t,n){if("function"!=typeof e)throw TypeError("callback is not a function");n=(null==n?eq():+n)+(null==t?0:+t),this._next||eF===this||(eF?eF._next=this:eH=this,eF=this),this._call=e,this._time=n,e2()},stop:function(){this._call&&(this._call=null,this._time=1/0,e2())}};var e3=M("start","end","cancel","interrupt"),e4=[];function e6(e,t,n,r,o,a){var i=e.__transition;if(i){if(n in i)return}else e.__transition={};!function(e,t,n){var r,o=e.__transition;function a(l){var d,c,u,p;if(1!==n.state)return s();for(d in o)if((p=o[d]).name===n.name){if(3===p.state)return e5(a);4===p.state?(p.state=6,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[d]):+d<t&&(p.state=6,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[d])}if(e5(function(){3===n.state&&(n.state=4,n.timer.restart(i,n.delay,n.time),i(l))}),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(d=0,n.state=3,r=Array(u=n.tween.length),c=-1;d<u;++d)(p=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++c]=p);r.length=c+1}}function i(t){for(var o=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(s),n.state=5,1),a=-1,i=r.length;++a<i;)r[a].call(e,o);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),s())}function s(){for(var r in n.state=6,n.timer.stop(),delete o[t],o)return;delete e.__transition}o[t]=n,n.timer=eQ(function(e){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)},0,n.time)}(e,n,{name:t,index:r,group:o,on:e3,tween:e4,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function e8(e,t){var n=e7(e,t);if(n.state>0)throw Error("too late; already scheduled");return n}function e9(e,t){var n=e7(e,t);if(n.state>3)throw Error("too late; already running");return n}function e7(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error("transition not found");return n}function te(e,t){var n,r,o,a=e.__transition,i=!0;if(a){for(o in t=null==t?null:t+"",a){if((n=a[o]).name!==t){i=!1;continue}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 a[o]}i&&delete e.__transition}}function tt(e,t){return e*=1,t*=1,function(n){return e*(1-n)+t*n}}var tn=180/Math.PI,tr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function to(e,t,n,r,o,a){var i,s,l;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(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,i=-i),{translateX:o,translateY:a,rotate:Math.atan2(t,e)*tn,skewX:Math.atan(l)*tn,scaleX:i,scaleY:s}}function ta(e,t,n,r){function o(e){return e.length?e.pop()+" ":""}return function(a,i){var s,l,d,c,u=[],p=[];return a=e(a),i=e(i),!function(e,r,o,a,i,s){if(e!==o||r!==a){var l=i.push("translate(",null,t,null,n);s.push({i:l-4,x:tt(e,o)},{i:l-2,x:tt(r,a)})}else(o||a)&&i.push("translate("+o+t+a+n)}(a.translateX,a.translateY,i.translateX,i.translateY,u,p),s=a.rotate,l=i.rotate,s!==l?(s-l>180?l+=360:l-s>180&&(s+=360),p.push({i:u.push(o(u)+"rotate(",null,r)-2,x:tt(s,l)})):l&&u.push(o(u)+"rotate("+l+r),d=a.skewX,c=i.skewX,d!==c?p.push({i:u.push(o(u)+"skewX(",null,r)-2,x:tt(d,c)}):c&&u.push(o(u)+"skewX("+c+r),!function(e,t,n,r,a,i){if(e!==n||t!==r){var s=a.push(o(a)+"scale(",null,",",null,")");i.push({i:s-4,x:tt(e,n)},{i:s-2,x:tt(t,r)})}else(1!==n||1!==r)&&a.push(o(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,i.scaleX,i.scaleY,u,p),a=i=null,function(e){for(var t,n=-1,r=p.length;++n<r;)u[(t=p[n]).i]=t.x(e);return u.join("")}}}var ti=ta(function(e){let t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?tr:to(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),ts=ta(function(e){return null==e?tr:(y||(y=document.createElementNS("http://www.w3.org/2000/svg","g")),y.setAttribute("transform",e),e=y.transform.baseVal.consolidate())?to((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):tr},", ",")",")");function tl(e,t,n){var r=e._id;return e.each(function(){var e=e9(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)}),function(e){return e7(e,r).value[t]}}function td(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function tc(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function tu(){}var tp="\\s*([+-]?\\d+)\\s*",tf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",th="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",tm=/^#([0-9a-f]{3,8})$/,tg=RegExp(`^rgb\\(${tp},${tp},${tp}\\)$`),tx=RegExp(`^rgb\\(${th},${th},${th}\\)$`),tv=RegExp(`^rgba\\(${tp},${tp},${tp},${tf}\\)$`),ty=RegExp(`^rgba\\(${th},${th},${th},${tf}\\)$`),tb=RegExp(`^hsl\\(${tf},${th},${th}\\)$`),tw=RegExp(`^hsla\\(${tf},${th},${th},${tf}\\)$`),tS={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function tC(){return this.rgb().formatHex()}function tj(){return this.rgb().formatRgb()}function tN(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=tm.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?tE(t):3===n?new tT(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?tk(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?tk(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=tg.exec(e))?new tT(t[1],t[2],t[3],1):(t=tx.exec(e))?new tT(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=tv.exec(e))?tk(t[1],t[2],t[3],t[4]):(t=ty.exec(e))?tk(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=tb.exec(e))?tO(t[1],t[2]/100,t[3]/100,1):(t=tw.exec(e))?tO(t[1],t[2]/100,t[3]/100,t[4]):tS.hasOwnProperty(e)?tE(tS[e]):"transparent"===e?new tT(NaN,NaN,NaN,0):null}function tE(e){return new tT(e>>16&255,e>>8&255,255&e,1)}function tk(e,t,n,r){return r<=0&&(e=t=n=NaN),new tT(e,t,n,r)}function t_(e,t,n,r){var o;return 1==arguments.length?((o=e)instanceof tu||(o=tN(o)),o)?new tT((o=o.rgb()).r,o.g,o.b,o.opacity):new tT:new tT(e,t,n,null==r?1:r)}function tT(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function tI(){return`#${tA(this.r)}${tA(this.g)}${tA(this.b)}`}function tR(){let e=tP(this.opacity);return`${1===e?"rgb(":"rgba("}${tM(this.r)}, ${tM(this.g)}, ${tM(this.b)}${1===e?")":`, ${e})`}`}function tP(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tM(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tA(e){return((e=tM(e))<16?"0":"")+e.toString(16)}function tO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new tL(e,t,n,r)}function tD(e){if(e instanceof tL)return new tL(e.h,e.s,e.l,e.opacity);if(e instanceof tu||(e=tN(e)),!e)return new tL;if(e instanceof tL)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),a=Math.max(t,n,r),i=NaN,s=a-o,l=(a+o)/2;return s?(i=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=l<.5?a+o:2-a-o,i*=60):s=l>0&&l<1?0:i,new tL(i,s,l,e.opacity)}function tL(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function tz(e){return(e=(e||0)%360)<0?e+360:e}function t$(e){return Math.max(0,Math.min(1,e||0))}function tH(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function tF(e,t,n,r,o){var a=e*e,i=a*e;return((1-3*e+3*a-i)*t+(4-6*a+3*i)*n+(1+3*e+3*a-3*i)*r+i*o)/6}td(tu,tN,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:tC,formatHex:tC,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return tD(this).formatHsl()},formatRgb:tj,toString:tj}),td(tT,t_,tc(tu,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new tT(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new tT(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new tT(tM(this.r),tM(this.g),tM(this.b),tP(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:tI,formatHex:tI,formatHex8:function(){return`#${tA(this.r)}${tA(this.g)}${tA(this.b)}${tA((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:tR,toString:tR})),td(tL,function(e,t,n,r){return 1==arguments.length?tD(e):new tL(e,t,n,null==r?1:r)},tc(tu,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new tL(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new tL(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new tT(tH(e>=240?e-240:e+120,o,r),tH(e,o,r),tH(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new tL(tz(this.h),t$(this.s),t$(this.l),tP(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(){let e=tP(this.opacity);return`${1===e?"hsl(":"hsla("}${tz(this.h)}, ${100*t$(this.s)}%, ${100*t$(this.l)}%${1===e?")":`, ${e})`}`}}));let tB=e=>()=>e;function tV(e,t){var n=t-e;return n?function(t){return e+t*n}:tB(isNaN(e)?t:e)}let tU=function e(t){var n,r=1==(n=+t)?tV:function(e,t){var r,o,a;return t-e?(r=e,o=t,r=Math.pow(r,a=n),o=Math.pow(o,a)-r,a=1/a,function(e){return Math.pow(r+e*o,a)}):tB(isNaN(e)?t:e)};function o(e,t){var n=r((e=t_(e)).r,(t=t_(t)).r),o=r(e.g,t.g),a=r(e.b,t.b),i=tV(e.opacity,t.opacity);return function(t){return e.r=n(t),e.g=o(t),e.b=a(t),e.opacity=i(t),e+""}}return o.gamma=e,o}(1);function tK(e){return function(t){var n,r,o=t.length,a=Array(o),i=Array(o),s=Array(o);for(n=0;n<o;++n)r=t_(t[n]),a[n]=r.r||0,i[n]=r.g||0,s[n]=r.b||0;return a=e(a),i=e(i),s=e(s),r.opacity=1,function(e){return r.r=a(e),r.g=i(e),r.b=s(e),r+""}}}tK(function(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),o=e[r],a=e[r+1],i=r>0?e[r-1]:2*o-a,s=r<t-1?e[r+2]:2*a-o;return tF((n-r/t)*t,i,o,a,s)}}),tK(function(e){var t=e.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*t),o=e[(r+t-1)%t],a=e[r%t],i=e[(r+1)%t],s=e[(r+2)%t];return tF((n-r/t)*t,o,a,i,s)}});var tW=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,tX=RegExp(tW.source,"g");function tG(e,t){var n,r,o,a,i,s=tW.lastIndex=tX.lastIndex=0,l=-1,d=[],c=[];for(e+="",t+="";(o=tW.exec(e))&&(a=tX.exec(t));)(i=a.index)>s&&(i=t.slice(s,i),d[l]?d[l]+=i:d[++l]=i),(o=o[0])===(a=a[0])?d[l]?d[l]+=a:d[++l]=a:(d[++l]=null,c.push({i:l,x:tt(o,a)})),s=tX.lastIndex;return s<t.length&&(i=t.slice(s),d[l]?d[l]+=i:d[++l]=i),d.length<2?c[0]?(n=c[0].x,function(e){return n(e)+""}):(r=t,function(){return r}):(t=c.length,function(e){for(var n,r=0;r<t;++r)d[(n=c[r]).i]=n.x(e);return d.join("")})}function tY(e,t){var n;return("number"==typeof t?tt:t instanceof tN?tU:(n=tN(t))?(t=n,tU):tG)(e,t)}var tq=eS.prototype.constructor;function tZ(e){return function(){this.style.removeProperty(e)}}var tJ=0;function tQ(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}var t0=eS.prototype;tQ.prototype=(function(e){return eS().transition(e)}).prototype={constructor:tQ,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=L(e));for(var r=this._groups,o=r.length,a=Array(o),i=0;i<o;++i)for(var s,l,d=r[i],c=d.length,u=a[i]=Array(c),p=0;p<c;++p)(s=d[p])&&(l=e.call(s,s.__data__,p,d))&&("__data__"in s&&(l.__data__=s.__data__),u[p]=l,e6(u[p],t,n,p,u,e7(s,n)));return new tQ(a,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=$(e));for(var r=this._groups,o=r.length,a=[],i=[],s=0;s<o;++s)for(var l,d=r[s],c=d.length,u=0;u<c;++u)if(l=d[u]){for(var p,f=e.call(l,l.__data__,u,d),h=e7(l,n),m=0,g=f.length;m<g;++m)(p=f[m])&&e6(p,t,n,m,f,h);a.push(f),i.push(l)}return new tQ(a,i,t,n)},selectChild:t0.selectChild,selectChildren:t0.selectChildren,filter:function(e){"function"!=typeof e&&(e=H(e));for(var t=this._groups,n=t.length,r=Array(n),o=0;o<n;++o)for(var a,i=t[o],s=i.length,l=r[o]=[],d=0;d<s;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&l.push(a);return new tQ(r,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,o=n.length,a=Math.min(r,o),i=Array(r),s=0;s<a;++s)for(var l,d=t[s],c=n[s],u=d.length,p=i[s]=Array(u),f=0;f<u;++f)(l=d[f]||c[f])&&(p[f]=l);for(;s<r;++s)i[s]=t[s];return new tQ(i,this._parents,this._name,this._id)},selection:function(){return new tq(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=++tJ,r=this._groups,o=r.length,a=0;a<o;++a)for(var i,s=r[a],l=s.length,d=0;d<l;++d)if(i=s[d]){var c=e7(i,t);e6(i,e,n,d,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new tQ(r,this._parents,e,n)},call:t0.call,nodes:t0.nodes,node:t0.node,size:t0.size,empty:t0.empty,each:t0.each,on:function(e,t){var n,r,o,a,i,s,l=this._id;return arguments.length<2?e7(this.node(),l).on.on(e):this.each((n=l,r=e,o=t,s=(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e})?e8:e9,function(){var e=s(this,n),t=e.on;t!==a&&(i=(a=t).copy()).on(r,o),e.on=i}))},attr:function(e,t){var n=ee(e),r="transform"===n?ts:tY;return this.attrTween(e,"function"==typeof t?(n.local?function(e,t,n){var r,o,a;return function(){var i,s,l=n(this);return null==l?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local))===(s=l+"")?null:i===r&&s===o?a:(o=s,a=t(r=i,l))}}:function(e,t,n){var r,o,a;return function(){var i,s,l=n(this);return null==l?void this.removeAttribute(e):(i=this.getAttribute(e))===(s=l+"")?null:i===r&&s===o?a:(o=s,a=t(r=i,l))}})(n,r,tl(this,"attr."+e,t)):null==t?(n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}})(n):(n.local?function(e,t,n){var r,o,a=n+"";return function(){var i=this.getAttributeNS(e.space,e.local);return i===a?null:i===r?o:o=t(r=i,n)}}:function(e,t,n){var r,o,a=n+"";return function(){var i=this.getAttribute(e);return i===a?null:i===r?o:o=t(r=i,n)}})(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 Error();var r=ee(e);return this.tween(n,(r.local?function(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(t){this.setAttributeNS(e.space,e.local,o.call(this,t))}),n}return o._value=t,o}:function(e,t){var n,r;function o(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&function(t){this.setAttribute(e,o.call(this,t))}),n}return o._value=t,o})(r,t))},style:function(e,t,n){var r,o,a,i,s,l,d,c,u,p,f,h,m,g,x,v,y,b,w,S,C,j="transform"==(e+="")?ti:tY;return null==t?this.styleTween(e,(r=e,function(){var e=en(this,r),t=(this.style.removeProperty(r),en(this,r));return e===t?null:e===o&&t===a?i:i=j(o=e,a=t)})).on("end.style."+e,tZ(e)):"function"==typeof t?this.styleTween(e,(s=e,l=tl(this,"style."+e,t),function(){var e=en(this,s),t=l(this),n=t+"";return null==t&&(this.style.removeProperty(s),n=t=en(this,s)),e===n?null:e===d&&n===c?u:(c=n,u=j(d=e,t))})).each((p=this._id,y="end."+(v="style."+(f=e)),function(){var e=e9(this,p),t=e.on,n=null==e.value[v]?x||(x=tZ(f)):void 0;(t!==h||g!==n)&&(m=(h=t).copy()).on(y,g=n),e.on=m})):this.styleTween(e,(b=e,C=t+"",function(){var e=en(this,b);return e===C?null:e===w?S:S=j(w=e,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 Error();return this.tween(r,function(e,t,n){var r,o;function a(){var a=t.apply(this,arguments);return a!==o&&(r=(o=a)&&function(t){this.style.setProperty(e,a.call(this,t),n)}),r}return a._value=t,a}(e,t,null==n?"":n))},text:function(e){var t,n;return this.tween("text","function"==typeof e?(t=tl(this,"text",e),function(){var e=t(this);this.textContent=null==e?"":e}):(n=null==e?"":e+"",function(){this.textContent=n}))},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 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){this.textContent=r.call(this,e)}),t}return r._value=e,r}(e))},remove:function(){var e;return this.on("end.remove",(e=this._id,function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,o=e7(this.node(),n).tween,a=0,i=o.length;a<i;++a)if((r=o[a]).name===e)return r.value;return null}return this.each((null==t?function(e,t){var n,r;return function(){var o=e9(this,e),a=o.tween;if(a!==n){r=n=a;for(var i=0,s=r.length;i<s;++i)if(r[i].name===t){(r=r.slice()).splice(i,1);break}}o.tween=r}}:function(e,t,n){var r,o;if("function"!=typeof n)throw Error();return function(){var a=e9(this,e),i=a.tween;if(i!==r){o=(r=i).slice();for(var s={name:t,value:n},l=0,d=o.length;l<d;++l)if(o[l].name===t){o[l]=s;break}l===d&&o.push(s)}a.tween=o}})(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){e8(this,e).delay=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){e8(this,e).delay=t}})(t,e)):e7(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){e9(this,e).duration=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){e9(this,e).duration=t}})(t,e)):e7(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw Error();return function(){e9(this,e).ease=t}}(t,e)):e7(this.node(),t).ease},easeVarying:function(e){var t;if("function"!=typeof e)throw Error();return this.each((t=this._id,function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw Error();e9(this,t).ease=n}))},end:function(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(a,i){var s={value:i},l={value:function(){0==--o&&a()}};n.each(function(){var n=e9(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&&a()})},[Symbol.iterator]:t0[Symbol.iterator]};var t1={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};eS.prototype.interrupt=function(e){return this.each(function(){te(this,e)})},eS.prototype.transition=function(e){var t,n;e instanceof tQ?(t=e._id,e=e._name):(t=++tJ,(n=t1).time=eq(),e=null==e?null:e+"");for(var r=this._groups,o=r.length,a=0;a<o;++a)for(var i,s=r[a],l=s.length,d=0;d<l;++d)(i=s[d])&&e6(i,e,t,d,s,n||function(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}(i,t));return new tQ(r,this._parents,e,t)};let t2=e=>()=>e;function t5(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 t3(e,t,n){this.k=e,this.x=t,this.y=n}t3.prototype={constructor:t3,scale:function(e){return 1===e?this:new t3(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new t3(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 t4=new t3(1,0,0);function t6(e){for(;!e.__zoom;)if(!(e=e.parentNode))return t4;return e.__zoom}function t8(e){e.stopImmediatePropagation()}function t9(e){e.preventDefault(),e.stopImmediatePropagation()}function t7(e){return(!e.ctrlKey||"wheel"===e.type)&&!e.button}function ne(){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 nt(){return this.__zoom||t4}function nn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function nr(){return navigator.maxTouchPoints||"ontouchstart"in this}function no(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function na(){var e,t,n,r=t7,o=ne,a=no,i=nn,s=nr,l=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],c=250,u=e$,p=M("start","zoom","end"),f=0,h=10;function m(e){e.property("__zoom",nt).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",C).on("dblclick.zoom",j).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",k).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 t3(t,e.x,e.y)}function x(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 t3(e.k,r,o)}function v(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function y(e,t,n,r){e.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var e=arguments,a=b(this,e).event(r),i=o.apply(this,e),s=null==n?v(i):"function"==typeof n?n.apply(this,e):n,l=Math.max(i[1][0]-i[0][0],i[1][1]-i[0][1]),d=this.__zoom,c="function"==typeof t?t.apply(this,e):t,p=u(d.invert(s).concat(l/d.k),c.invert(s).concat(l/c.k));return function(e){if(1===e)e=c;else{var t=p(e),n=l/t[2];e=new t3(n,s[0]-t[0]*n,s[1]-t[1]*n)}a.zoom(null,e)}})}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=o.apply(e,t),this.taps=0}function S(e,...t){if(r.apply(this,arguments)){var n=b(this,t).event(e),o=this.__zoom,s=Math.max(l[0],Math.min(l[1],o.k*Math.pow(2,i.apply(this,arguments)))),c=ej(e);if(n.wheel)(n.mouse[0][0]!==c[0]||n.mouse[0][1]!==c[1])&&(n.mouse[1]=o.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(o.k===s)return;n.mouse=[c,o.invert(c)],te(this),n.start()}t9(e),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",a(x(g(o,s),n.mouse[0],n.mouse[1]),n.extent,d))}}function C(e,...t){if(!n&&r.apply(this,arguments)){var o=e.currentTarget,i=b(this,t,!0).event(e),s=eC(e.view).on("mousemove.zoom",function(e){if(t9(e),!i.moved){var t=e.clientX-c,n=e.clientY-u;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",a(x(i.that.__zoom,i.mouse[0]=ej(e,o),i.mouse[1]),i.extent,d))},!0).on("mouseup.zoom",function(e){s.on("mousemove.zoom mouseup.zoom",null),eI(e.view,i.moved),t9(e),i.event(e).end()},!0),l=ej(e,o),c=e.clientX,u=e.clientY;eT(e.view),t8(e),i.mouse=[l,this.__zoom.invert(l)],te(this),i.start()}}function j(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,i=ej(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(i),l=n.k*(e.shiftKey?.5:2),u=a(x(g(n,l),i,s),o.apply(this,t),d);t9(e),c>0?eC(this).transition().duration(c).call(y,u,i,e):eC(this).call(m.transform,u,i,e)}}function N(n,...o){if(r.apply(this,arguments)){var a,i,s,l,d=n.touches,c=d.length,u=b(this,o,n.changedTouches.length===c).event(n);for(t8(n),i=0;i<c;++i)l=[l=ej(s=d[i],this),this.__zoom.invert(l),s.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,a=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(u.taps<2&&(t=l[0],e=setTimeout(function(){e=null},500)),te(this),u.start())}}function E(e,...t){if(this.__zooming){var n,r,o,i,s=b(this,t).event(e),l=e.changedTouches,c=l.length;for(t9(e),n=0;n<c;++n)o=ej(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 u=s.touch0[0],p=s.touch0[1],f=s.touch1[0],h=s.touch1[1],m=(m=f[0]-u[0])*m+(m=f[1]-u[1])*m,v=(v=h[0]-p[0])*v+(v=h[1]-p[1])*v;r=g(r,Math.sqrt(m/v)),o=[(u[0]+f[0])/2,(u[1]+f[1])/2],i=[(p[0]+h[0])/2,(p[1]+h[1])/2]}else{if(!s.touch0)return;o=s.touch0[0],i=s.touch0[1]}s.zoom("touch",a(x(r,o,i),s.extent,d))}}function k(e,...r){if(this.__zooming){var o,a,i=b(this,r).event(e),s=e.changedTouches,l=s.length;for(t8(e),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),o=0;o<l;++o)a=s[o],i.touch0&&i.touch0[2]===a.identifier?delete i.touch0:i.touch1&&i.touch1[2]===a.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps&&(a=ej(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<h)){var d=eC(this).on("dblclick.zoom");d&&d.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var o=e.selection?e.selection():e;o.property("__zoom",nt),e!==o?y(e,t,n,r):o.interrupt().each(function(){b(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(){var e=this.__zoom.k,n="function"==typeof t?t.apply(this,arguments):t;return e*n},n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,function(){var e=o.apply(this,arguments),r=this.__zoom,i=null==n?v(e):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return a(x(g(r,l),i,s),e,d)},n,r)},m.translateBy=function(e,t,n,r){m.transform(e,function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),o.apply(this,arguments),d)},null,r)},m.translateTo=function(e,t,n,r,i){m.transform(e,function(){var e=o.apply(this,arguments),i=this.__zoom,s=null==r?v(e):"function"==typeof r?r.apply(this,arguments):r;return a(t4.translate(s[0],s[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,d)},r,i)},w.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=eC(this.that).datum();p.call(e,this.that,new t5(e,{sourceEvent:this.sourceEvent,target:m,type:e,transform:this.that.__zoom,dispatch:p}),t)}},m.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:t2(+e),m):i},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:t2(!!e),m):r},m.touchable=function(e){return arguments.length?(s="function"==typeof e?e:t2(!!e),m):s},m.extent=function(e){return arguments.length?(o="function"==typeof e?e:t2([[+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?(d[0][0]=+e[0][0],d[1][0]=+e[1][0],d[0][1]=+e[0][1],d[1][1]=+e[1][1],m):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},m.constrain=function(e){return arguments.length?(a=e,m):a},m.duration=function(e){return arguments.length?(c=+e,m):c},m.interpolate=function(e){return arguments.length?(u=e,m):u},m.on=function(){var e=p.on.apply(p,arguments);return e===p?m:e},m.clickDistance=function(e){return arguments.length?(f=(e*=1)*e,m):Math.sqrt(f)},m.tapDistance=function(e){return arguments.length?(h=+e,m):h},m}function ni(e,t){var n,r,o=typeof t;return null==t||"boolean"===o?tB(t):("number"===o?tt:"string"===o?(r=tN(t))?(t=r,tU):tG:t instanceof tN?tU:t instanceof Date?function(e,t){var n=new Date;return e*=1,t*=1,function(r){return n.setTime(e*(1-r)+t*r),n}}:!ArrayBuffer.isView(n=t)||n instanceof DataView?Array.isArray(t)?function(e,t){var n,r=t?t.length:0,o=e?Math.min(r,e.length):0,a=Array(o),i=Array(r);for(n=0;n<o;++n)a[n]=ni(e[n],t[n]);for(;n<r;++n)i[n]=t[n];return function(e){for(n=0;n<o;++n)i[n]=a[n](e);return i}}:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?function(e,t){var n,r={},o={};for(n in(null===e||"object"!=typeof e)&&(e={}),(null===t||"object"!=typeof t)&&(t={}),t)n in e?r[n]=ni(e[n],t[n]):o[n]=t[n];return function(e){for(n in r)o[n]=r[n](e);return o}}:tt:function(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,o=t.slice();return function(a){for(n=0;n<r;++n)o[n]=e[n]*(1-a)+t[n]*a;return o}})(e,t)}t6.prototype=t3.prototype;let ns=[[-1/0,-1/0],[1/0,1/0]],nl=["Enter"," ","Escape"],nd={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(a=b||(b={})).Strict="strict",a.Loose="loose",(i=w||(w={})).Free="free",i.Vertical="vertical",i.Horizontal="horizontal",(s=S||(S={})).Partial="partial",s.Full="full";let nc={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(l=C||(C={})).Bezier="default",l.Straight="straight",l.Step="step",l.SmoothStep="smoothstep",l.SimpleBezier="simplebezier",(d=j||(j={})).Arrow="arrow",d.ArrowClosed="arrowclosed",(c=N||(N={})).Left="left",c.Top="top",c.Right="right",c.Bottom="bottom";let nu={[N.Left]:N.Right,[N.Right]:N.Left,[N.Top]:N.Bottom,[N.Bottom]:N.Top};function np(e){return null===e?null:e?"valid":"invalid"}let nf=e=>"id"in e&&"source"in e&&"target"in e,nh=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),nm=(e,t=[0,0])=>{let{width:n,height:r}=nV(e),o=e.origin??t,a=n*o[0],i=r*o[1];return{x:e.position.x-a,y:e.position.y-i}},ng=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(void 0===t.filter||t.filter(e))&&(n=nE(n,nI(e)),r=!0)}),r?n_(n):{x:0,y:0,width:0,height:0}},nx=(e,t,[n,r,o]=[0,0,1],a=!1,i=!1)=>{let s={...nL(t,[n,r,o]),width:t.width/o,height:t.height/o},l=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(i&&!n||r)continue;let o=e.width??t.width??t.initialWidth??null,d=e.height??t.height??t.initialHeight??null,c=nP(s,nT(t)),u=(o??0)*(d??0),p=a&&c>0;(!t.internals.handleBounds||p||c>=u||t.dragging)&&l.push(t)}return l};async function nv({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:a},i){let s,l;if(0===e.size)return Promise.resolve(!0);let d=nH(ng((s=new Map,l=i?.nodes?new Set(i.nodes.map(e=>e.id)):null,e.forEach(e=>{e.measured.width&&e.measured.height&&(i?.includeHiddenNodes||!e.hidden)&&(!l||l.has(e.id))&&s.set(e.id,e)}),s)),t,n,i?.minZoom??o,i?.maxZoom??a,i?.padding??.1);return await r.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function ny({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:a}){let i=n.get(e),s=i.parentId?n.get(i.parentId):void 0,{x:l,y:d}=s?s.internals.positionAbsolute:{x:0,y:0},c=i.origin??r,u=i.extent||o;if("parent"!==i.extent||i.expandParent)s&&nB(i.extent)&&(u=[[i.extent[0][0]+l,i.extent[0][1]+d],[i.extent[1][0]+l,i.extent[1][1]+d]]);else if(s){let e=s.measured.width,t=s.measured.height;e&&t&&(u=[[l,d],[l+e,d+t]])}else a?.("005","Only child nodes can use a parent extent.");let p=nB(u)?nS(t,u,i.measured):t;return(void 0===i.measured.width||void 0===i.measured.height)&&a?.("015","It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."),{position:{x:p.x-l+(i.measured.width??0)*c[0],y:p.y-d+(i.measured.height??0)*c[1]},positionAbsolute:p}}async function nb({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){let a,i=new Set(e.map(e=>e.id)),s=[];for(let e of n){if(!1===e.deletable)continue;let t=i.has(e.id),n=!t&&e.parentId&&s.find(t=>t.id===e.parentId);(t||n)&&s.push(e)}let l=new Set(t.map(e=>e.id)),d=r.filter(e=>!1!==e.deletable),c=(a=new Set,s.forEach(e=>{a.add(e.id)}),d.filter(e=>a.has(e.source)||a.has(e.target)));for(let e of d)l.has(e.id)&&!c.find(t=>t.id===e.id)&&c.push(e);if(!o)return{edges:c,nodes:s};let u=await o({nodes:s,edges:c});return"boolean"==typeof u?u?{edges:c,nodes:s}:{edges:[],nodes:[]}:u}let nw=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),nS=(e={x:0,y:0},t,n)=>({x:nw(e.x,t[0][0],t[1][0]-(n?.width??0)),y:nw(e.y,t[0][1],t[1][1]-(n?.height??0))});function nC(e,t,n){let{width:r,height:o}=nV(n),{x:a,y:i}=n.internals.positionAbsolute;return nS(e,[[a,i],[a+r,i+o]],t)}let nj=(e,t,n)=>e<t?nw(Math.abs(e-t),1,t)/t:e>n?-nw(Math.abs(e-n),1,t)/t:0,nN=(e,t,n=15,r=40)=>[nj(e.x,r,t.width-r)*n,nj(e.y,r,t.height-r)*n],nE=(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)}),nk=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),n_=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),nT=(e,t=[0,0])=>{let{x:n,y:r}=nh(e)?e.internals.positionAbsolute:nm(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},nI=(e,t=[0,0])=>{let{x:n,y:r}=nh(e)?e.internals.positionAbsolute:nm(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},nR=(e,t)=>n_(nE(nk(e),nk(t))),nP=(e,t)=>Math.ceil(Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))),nM=e=>nA(e.width)&&nA(e.height)&&nA(e.x)&&nA(e.y),nA=e=>!isNaN(e)&&isFinite(e),nO=(e,t)=>{},nD=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),nL=({x:e,y:t},[n,r,o],a=!1,i=[1,1])=>{let s={x:(e-n)/o,y:(t-r)/o};return a?nD(s,i):s},nz=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function n$(e,t){if("number"==typeof e)return Math.floor((t-t/(1+e))*.5);if("string"==typeof e&&e.endsWith("px")){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if("string"==typeof e&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let nH=(e,t,n,r,o,a)=>{let i=function(e,t,n){if("string"==typeof e||"number"==typeof e){let r=n$(e,n),o=n$(e,t);return{top:r,right:o,bottom:r,left:o,x:2*o,y:2*r}}if("object"==typeof e){let r=n$(e.top??e.y??0,n),o=n$(e.bottom??e.y??0,n),a=n$(e.left??e.x??0,t),i=n$(e.right??e.x??0,t);return{top:r,right:i,bottom:o,left:a,x:a+i,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(a,t,n),s=nw(Math.min((t-i.x)/e.width,(n-i.y)/e.height),r,o),l=e.x+e.width/2,d=e.y+e.height/2,c=t/2-l*s,u=n/2-d*s,p=function(e,t,n,r,o,a){let{x:i,y:s}=nz(e,[t,n,r]),{x:l,y:d}=nz({x:e.x+e.width,y:e.y+e.height},[t,n,r]);return{left:Math.floor(i),top:Math.floor(s),right:Math.floor(o-l),bottom:Math.floor(a-d)}}(e,c,u,s,t,n),f={left:Math.min(p.left-i.left,0),top:Math.min(p.top-i.top,0),right:Math.min(p.right-i.right,0),bottom:Math.min(p.bottom-i.bottom,0)};return{x:c-f.left+f.right,y:u-f.top+f.bottom,zoom:s}},nF=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function nB(e){return null!=e&&"parent"!==e}function nV(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function nU(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function nK(e,t={width:0,height:0},n,r,o){let a={...e},i=r.get(n);if(i){let e=i.origin||o;a.x+=i.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function nW(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function nX(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){let{x:a,y:i}=nJ(e),s=nL({x:a-(o?.left??0),y:i-(o?.top??0)},r),{x:l,y:d}=n?nD(s,t):s;return{xSnapped:l,ySnapped:d,...s}}let nG=e=>({width:e.offsetWidth,height:e.offsetHeight}),nY=e=>e?.getRootNode?.()||window?.document,nq=["INPUT","SELECT","TEXTAREA"];function nZ(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1&&(nq.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey"))}let nJ=(e,t)=>{let n="clientX"in 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)}},nQ=(e,t,n,r,o)=>{let a=t.querySelectorAll(`.${e}`);return a&&a.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:o,position:t.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...nG(t)}}):null};function n0({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:a,targetControlX:i,targetControlY:s}){let l=.125*e+.375*o+.375*i+.125*n,d=.125*t+.375*a+.375*s+.125*r,c=Math.abs(l-e),u=Math.abs(d-t);return[l,d,c,u]}function n1(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function n2({pos:e,x1:t,y1:n,x2:r,y2:o,c:a}){switch(e){case N.Left:return[t-n1(t-r,a),n];case N.Right:return[t+n1(r-t,a),n];case N.Top:return[t,n-n1(n-o,a)];case N.Bottom:return[t,n+n1(o-n,a)]}}function n5({sourceX:e,sourceY:t,sourcePosition:n=N.Bottom,targetX:r,targetY:o,targetPosition:a=N.Top,curvature:i=.25}){let[s,l]=n2({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[d,c]=n2({pos:a,x1:r,y1:o,x2:e,y2:t,c:i}),[u,p,f,h]=n0({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:d,targetControlY:c});return[`M${e},${t} C${s},${l} ${d},${c} ${r},${o}`,u,p,f,h]}function n3({sourceX:e,sourceY:t,targetX:n,targetY:r}){let o=Math.abs(n-e)/2,a=Math.abs(r-t)/2;return[n<e?n+o:n-o,r<t?r+a:r-a,o,a]}let n4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,n6=(e,t,n={})=>{let r,o;if(!e.source||!e.target)return nO("006","Can't create edge. An edge needs a source and a target."),t;let a=n.getEdgeId||n4;return(o=r=nf(e)?{...e}:{...e,id:a(e)},t.some(e=>e.source===o.source&&e.target===o.target&&(e.sourceHandle===o.sourceHandle||!e.sourceHandle&&!o.sourceHandle)&&(e.targetHandle===o.targetHandle||!e.targetHandle&&!o.targetHandle)))?t:(null===r.sourceHandle&&delete r.sourceHandle,null===r.targetHandle&&delete r.targetHandle,t.concat(r))};function n8({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[o,a,i,s]=n3({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,a,i,s]}let n9={[N.Left]:{x:-1,y:0},[N.Right]:{x:1,y:0},[N.Top]:{x:0,y:-1},[N.Bottom]:{x:0,y:1}},n7=({source:e,sourcePosition:t=N.Bottom,target:n})=>t===N.Left||t===N.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},re=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function rt({sourceX:e,sourceY:t,sourcePosition:n=N.Bottom,targetX:r,targetY:o,targetPosition:a=N.Top,borderRadius:i=5,centerX:s,centerY:l,offset:d=20,stepPosition:c=.5}){let[u,p,f,h,m]=function({source:e,sourcePosition:t=N.Bottom,target:n,targetPosition:r=N.Top,center:o,offset:a,stepPosition:i}){let s,l,d=n9[t],c=n9[r],u={x:e.x+d.x*a,y:e.y+d.y*a},p={x:n.x+c.x*a,y:n.y+c.y*a},f=n7({source:u,sourcePosition:t,target:p}),h=0!==f.x?"x":"y",m=f[h],g=[],x={x:0,y:0},v={x:0,y:0},[,,y,b]=n3({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(d[h]*c[h]==-1){"x"===h?(s=o.x??u.x+(p.x-u.x)*i,l=o.y??(u.y+p.y)/2):(s=o.x??(u.x+p.x)/2,l=o.y??u.y+(p.y-u.y)*i);let e=[{x:s,y:u.y},{x:s,y:p.y}],t=[{x:u.x,y:l},{x:p.x,y:l}];g=d[h]===m?"x"===h?e:t:"x"===h?t:e}else{let o=[{x:u.x,y:p.y}],i=[{x:p.x,y:u.y}];if(g="x"===h?d.x===m?i:o:d.y===m?o:i,t===r){let t=Math.abs(e[h]-n[h]);if(t<=a){let r=Math.min(a-1,a-t);d[h]===m?x[h]=(u[h]>e[h]?-1:1)*r:v[h]=(p[h]>n[h]?-1:1)*r}}if(t!==r){let e="x"===h?"y":"x",t=d[h]===c[e],n=u[e]>p[e],r=u[e]<p[e];(1===d[h]&&(!t&&n||t&&r)||1!==d[h]&&(!t&&r||t&&n))&&(g="x"===h?o:i)}let f={x:u.x+x.x,y:u.y+x.y},y={x:p.x+v.x,y:p.y+v.y};Math.max(Math.abs(f.x-g[0].x),Math.abs(y.x-g[0].x))>=Math.max(Math.abs(f.y-g[0].y),Math.abs(y.y-g[0].y))?(s=(f.x+y.x)/2,l=g[0].y):(s=g[0].x,l=(f.y+y.y)/2)}return[[e,{x:u.x+x.x,y:u.y+x.y},...g,{x:p.x+v.x,y:p.y+v.y},n],s,l,y,b]}({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:a,center:{x:s,y:l},offset:d,stepPosition:c});return[u.reduce((e,t,n)=>e+(n>0&&n<u.length-1?function(e,t,n,r){let o=Math.min(re(e,t)/2,re(t,n)/2,r),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+o*t},${i}Q ${a},${i} ${a},${i+o*r}`}let s=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${a},${i+o*l}Q ${a},${i} ${a+o*s},${i}`}(u[n-1],t,u[n+1],i):`${0===n?"M":"L"}${t.x} ${t.y}`),""),p,f,h,m]}function rn(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function rr(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,"source"===r.type?t.push(r):"target"===r.type&&n.push(r);return{source:t,target:n}}function ro(e,t,n=N.Left,r=!1){let o=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:s}=t??nV(e);if(r)return{x:o+i/2,y:a+s/2};switch(t?.position??n){case N.Top:return{x:o+i/2,y:a};case N.Right:return{x:o+i,y:a+s/2};case N.Bottom:return{x:o+i/2,y:a+s};case N.Left:return{x:o,y:a+s/2}}}function ra(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function ri(e,t){if(!e)return"";if("string"==typeof e)return e;let n=t?`${t}__`:"";return`${n}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("&")}`}let rs={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},rl={...rs,checkEquality:!0};function rd(e,t){let n={...e};for(let e in t)void 0!==t[e]&&(n[e]=t[e]);return n}function rc(e){return"manual"===e}function ru(e,t,n,r={}){let o=rd(rl,r),a={i:0},i=new Map(t),s=o?.elevateNodesOnSelect&&!rc(o.zIndexMode)?1e3:0,l=e.length>0;for(let d of(t.clear(),n.clear(),e)){let e=i.get(d.id);if(o.checkEquality&&d===e?.internals.userNode)t.set(d.id,e);else{let n=nS(nm(d,o.nodeOrigin),nB(d.extent)?d.extent:o.nodeExtent,nV(d));e={...o.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:n,handleBounds:function(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let o={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};"source"===t.type?n.push(o):"target"===t.type&&r.push(o)}return{source:n,target:r}}(d,e),z:rf(d,s,o.zIndexMode),userNode:d}},t.set(d.id,e)}void 0!==e.measured&&void 0!==e.measured.width&&void 0!==e.measured.height||e.hidden||(l=!1),d.parentId&&rp(e,t,n,r,a)}return l}function rp(e,t,n,r,o){let{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:s,zIndexMode:l}=rd(rs,r),d=e.parentId,c=t.get(d);if(!c)return void console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}(e,n),o&&!c.parentId&&void 0===c.internals.rootParentIndex&&"auto"===l&&(c.internals.rootParentIndex=++o.i,c.internals.z=c.internals.z+10*o.i),o&&void 0!==c.internals.rootParentIndex&&(o.i=c.internals.rootParentIndex);let{x:u,y:p,z:f}=function(e,t,n,r,o,a){let{x:i,y:s}=t.internals.positionAbsolute,l=nV(e),d=nm(e,n),c=nB(e.extent)?nS(d,e.extent,l):d,u=nS({x:i+c.x,y:s+c.y},r,l);"parent"===e.extent&&(u=nC(u,l,t));let p=rf(e,o,a),f=t.internals.z??0;return{x:u.x,y:u.y,z:f>=p?f+1:p}}(e,c,i,s,a&&!rc(l)?1e3:0,l),{positionAbsolute:h}=e.internals,m=u!==h.x||p!==h.y;(m||f!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:u,y:p}:h,z:f}})}function rf(e,t,n){let r=nA(e.zIndex)?e.zIndex:0;return rc(n)?r:r+(e.selected?t:0)}function rh(e,t,n,r=[0,0]){let o=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=nR(a.get(n.parentId)?.expandedRect??nT(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},i)=>{let s=a.internals.positionAbsolute,l=nV(a),d=a.origin??r,c=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,u=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,p=Math.max(l.width,Math.round(t.width)),f=Math.max(l.height,Math.round(t.height)),h=(p-l.width)*d[0],m=(f-l.height)*d[1];(c>0||u>0||h||m)&&(o.push({id:i,type:"position",position:{x:a.position.x-c+h,y:a.position.y-u+m}}),n.get(i)?.forEach(t=>{e.some(e=>e.id===t.id)||o.push({id:t.id,type:"position",position:{x:t.position.x+c,y:t.position.y+u}})})),(l.width<t.width||l.height<t.height||c||u)&&o.push({id:i,type:"dimensions",setAttributes:!0,dimensions:{width:p+(c?d[0]*c-h:0),height:f+(u?d[1]*u-m:0)}})}),o}async function rm({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,a]],r);return Promise.resolve(!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]))}function rg(e,t,n,r,o,a){let i=o,s=r.get(i)||new Map;r.set(i,s.set(n,t)),i=`${o}-${e}`;let l=r.get(i)||new Map;if(r.set(i,l.set(n,t)),a){i=`${o}-${e}-${a}`;let s=r.get(i)||new Map;r.set(i,s.set(n,t))}}function rx(e,t,n){for(let r of(e.clear(),t.clear(),n)){let{source:n,target:o,sourceHandle:a=null,targetHandle:i=null}=r,s={edgeId:r.id,source:n,target:o,sourceHandle:a,targetHandle:i},l=`${n}-${a}--${o}-${i}`;rg("source",s,`${o}-${i}--${n}-${a}`,e,n,a),rg("target",s,l,e,o,i),t.set(r.id,r)}}function rv(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)break;r=r?.parentElement}while(r)return!1}function ry({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let o=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&o.push({...t,position:a.position,dragging:r})}if(!e)return[o[0],o];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:o[0],o]}function rb(e,t,n,r,o,a=!1){let i=r.get(e);if(!i)return null;let s="strict"===o?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],l=(n?s?.find(e=>e.id===n):s?.[0])??null;return l&&a?{...l,...ro(i,l,l.position,!0)}:l}function rw(e,t){return e?e:t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null}let rS=()=>!0;function rC(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:a,doc:i,lib:s,flowId:l,isValidConnection:d=rS,nodeLookup:c}){let u="target"===a,p=t?i.querySelector(`.${s}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:f,y:h}=nJ(e),m=i.elementFromPoint(f,h),g=m?.classList.contains(`${s}-flow__handle`)?m:p,x={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=rw(void 0,g),t=g.getAttribute("data-nodeid"),a=g.getAttribute("data-handleid"),i=g.classList.contains("connectable"),s=g.classList.contains("connectableend");if(!t||!e)return x;let l={source:u?t:r,sourceHandle:u?a:o,target:u?r:t,targetHandle:u?o:a};x.connection=l,x.isValid=i&&s&&(n===b.Strict?u&&"source"===e||!u&&"target"===e:t!==r||a!==o)&&d(l),x.toHandle=rb(t,e,a,c,n,!0)}return x}let rj=function(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:a,isTarget:i,domNode:s,nodeLookup:l,lib:d,autoPanOnConnect:c,flowId:u,panBy:p,cancelConnection:f,onConnectStart:h,onConnect:m,onConnectEnd:g,isValidConnection:x=rS,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:w,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:j}){let E,k=nY(e.target),_=0,{x:T,y:I}=nJ(e),R=rw(a,j),P=s?.getBoundingClientRect(),M=!1;if(!P||!R)return;let A=rb(o,R,r,l,t);if(!A)return;let O=nJ(e,P),D=!1,L=null,z=!1,$=null,H={...A,nodeId:o,type:R,position:A.position},F=l.get(o),B={inProgress:!0,isValid:null,from:ro(F,H,N.Left,!0),fromHandle:H,fromPosition:H.position,fromNode:F,to:O,toHandle:null,toPosition:nu[H.position],toNode:null,pointer:O};function V(){M=!0,y(B),h?.(e,{nodeId:o,handleId:r,handleType:R})}function U(e){var a,s;let f;if(!M){let{x:t,y:n}=nJ(e),r=t-T,o=n-I;if(!(r*r+o*o>C*C))return;V()}if(!w()||!H)return void K(e);let h=b();E=function(e,t,n,r){let o=[],a=1/0;for(let i of function(e,t,n){let r=[],o={x:e.x-n,y:e.y-n,width:2*n,height:2*n};for(let e of t.values())nP(o,nT(e))>0&&r.push(e);return r}(e,n,t+250))for(let n of[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]]){if(r.nodeId===n.nodeId&&r.type===n.type&&r.id===n.id)continue;let{x:s,y:l}=ro(i,n,n.position,!0),d=Math.sqrt(Math.pow(s-e.x,2)+Math.pow(l-e.y,2));d>t||(d<a?(o=[{...n,x:s,y:l}],a=d):d===a&&o.push({...n,x:s,y:l}))}if(!o.length)return null;if(o.length>1){let e="source"===r.type?"target":"source";return o.find(t=>t.type===e)??o[0]}return o[0]}(nL(O=nJ(e,P),h,!1,[1,1]),n,l,H),D||(!function e(){if(!c||!P)return;let[t,n]=nN(O,P,S);p({x:t,y:n}),_=requestAnimationFrame(e)}(),D=!0);let m=rC(e,{handle:E,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:x,doc:k,lib:d,flowId:u,nodeLookup:l});$=m.handleDomNode,L=m.connection,a=!!E,s=m.isValid,f=null,s?f=!0:a&&!s&&(f=!1),z=f;let g=l.get(o),v=g?ro(g,H,N.Left,!0):B.from,j={...B,from:v,isValid:z,to:m.toHandle&&z?nz({x:m.toHandle.x,y:m.toHandle.y},h):O,toHandle:m.toHandle,toPosition:z&&m.toHandle?m.toHandle.position:nu[H.position],toNode:m.toHandle?l.get(m.toHandle.nodeId):null,pointer:O};y(j),B=j}function K(e){if(!("touches"in e)||!(e.touches.length>0)){if(M){(E||$)&&L&&z&&m?.(L);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}f(),cancelAnimationFrame(_),D=!1,z=!1,L=null,$=null,k.removeEventListener("mousemove",U),k.removeEventListener("mouseup",K),k.removeEventListener("touchmove",U),k.removeEventListener("touchend",K)}}0===C&&V(),k.addEventListener("mousemove",U),k.addEventListener("mouseup",K),k.addEventListener("touchmove",U),k.addEventListener("touchend",K)},rN=e=>({x:e.x,y:e.y,zoom:e.k}),rE=({x:e,y:t,zoom:n})=>t4.translate(e,t).scale(n),rk=(e,t)=>e.target.closest(`.${t}`),r_=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),rT=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rI=(e,t=0,n=rT,r=()=>{})=>{let o="number"==typeof t&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},rR=e=>{let t=e.ctrlKey&&nF()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function rP(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:e.includes("left"),affectsY:e.includes("top")}}function rM(e,t){return Math.max(0,t-e)}function rA(e,t){return Math.max(0,e-t)}function rO(e,t,n){return Math.max(0,t-e,e-n)}(u=E||(E={})).Line="line",u.Handle="handle";let rD={width:0,height:0,x:0,y:0},rL={...rD,pointerX:0,pointerY:0,aspectRatio:1};var rz=e.i(96482);let r$={get url(){return`file://${e.P("node_modules/.pnpm/zustand@4.5.7_@types+react@19.2.14_react@19.2.4/node_modules/zustand/esm/vanilla.mjs")}`}},rH=e=>{let t,n=new Set,r=(e,r)=>{let o="function"==typeof e?e(t):e;if(!Object.is(o,t)){let e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>i,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{(r$.env?r$.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},i=t=e(r,o,a);return a},{useDebugValue:rF}=I.default,{useSyncExternalStoreWithSelector:rB}=rz.default,rV=e=>e;function rU(e,t=rV,n){let r=rB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return rF(r),r}let rK=(e,t)=>{let n=e?rH(e):rH,r=(e,r=t)=>rU(n,e,r);return Object.assign(r,n),r};function rW(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(let[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(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var rX=e.i(26147);let rG=(0,I.createContext)(null),rY=rG.Provider,rq="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001";function rZ(e,t){let n=(0,I.useContext)(rG);if(null===n)throw Error(rq);return rU(n,e,t)}function rJ(){let e=(0,I.useContext)(rG);if(null===e)throw Error(rq);return(0,I.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}let rQ={display:"none"},r0={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},r1="react-flow__node-desc",r2="react-flow__edge-desc",r5=e=>e.ariaLiveMessage,r3=e=>e.ariaLabelConfig;function r4({rfId:e}){let t=rZ(r5);return(0,T.jsx)("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:r0,children:t})}function r6({rfId:e,disableKeyboardA11y:t}){let n=rZ(r3);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("div",{id:`${r1}-${e}`,style:rQ,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,T.jsx)("div",{id:`${r2}-${e}`,style:rQ,children:n["edge.a11yDescription.default"]}),!t&&(0,T.jsx)(r4,{rfId:e})]})}let r8=(0,I.forwardRef)(({position:e="top-left",children:t,className:n,style:r,...o},a)=>{let i=`${e}`.split("-");return(0,T.jsx)("div",{className:R(["react-flow__panel",n,...i]),style:r,ref:a,...o,children:t})});function r9({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:(0,T.jsx)(r8,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:(0,T.jsx)("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}r8.displayName="Panel";let r7=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},oe=e=>e.id;function ot(e,t){return rW(e.selectedNodes.map(oe),t.selectedNodes.map(oe))&&rW(e.selectedEdges.map(oe),t.selectedEdges.map(oe))}function on({onSelectionChange:e}){let t=rJ(),{selectedNodes:n,selectedEdges:r}=rZ(r7,ot);return(0,I.useEffect)(()=>{let o={nodes:n,edges:r};e?.(o),t.getState().onSelectionChangeHandlers.forEach(e=>e(o))},[n,r,e]),null}let or=e=>!!e.onSelectionChangeHandlers;function oo({onSelectionChange:e}){let t=rZ(or);return e||t?(0,T.jsx)(on,{onSelectionChange:e}):null}let oa=[0,0],oi={x:0,y:0,zoom:1},os=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode","rfId"],ol=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),od={translateExtent:ns,nodeOrigin:oa,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function oc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:a,setNodeExtent:i,reset:s,setDefaultNodesAndEdges:l}=rZ(ol,rW),d=rJ();(0,I.useEffect)(()=>(l(e.defaultNodes,e.defaultEdges),()=>{c.current=od,s()}),[]);let c=(0,I.useRef)(od);return(0,I.useEffect)(()=>{for(let s of os){let l=e[s];if(l!==c.current[s]&&void 0!==e[s])if("nodes"===s)t(l);else if("edges"===s)n(l);else if("minZoom"===s)r(l);else if("maxZoom"===s)o(l);else if("translateExtent"===s)a(l);else if("nodeExtent"===s)i(l);else if("ariaLabelConfig"===s)d.setState({ariaLabelConfig:{...nd,...l||{}}});else"fitView"===s?d.setState({fitViewQueued:l}):"fitViewOptions"===s?d.setState({fitViewOptions:l}):d.setState({[s]:l})}c.current=e},os.map(t=>e[t])),null}function ou(){return"u"<typeof window||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}let op="u">typeof document?document:null;function of(e=null,t={target:op,actInsideInputWithModifier:!0}){let[n,r]=(0,I.useState)(!1),o=(0,I.useRef)(!1),a=(0,I.useRef)(new Set([])),[i,s]=(0,I.useMemo)(()=>{if(null!==e){let t=(Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).map(e=>e.replace("+","\n").replace("\n\n","\n+").split("\n")),n=t.reduce((e,t)=>e.concat(...t),[]);return[t,n]}return[[],[]]},[e]);return(0,I.useEffect)(()=>{let n=t?.target??op,l=t?.actInsideInputWithModifier??!0;if(null!==e){let e=e=>{if(o.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!o.current||o.current&&!l)&&nZ(e))return!1;let n=om(e.code,s);if(a.current.add(e[n]),oh(i,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName==="BUTTON"||n?.nodeName==="A";!1!==t.preventDefault&&(o.current||!a)&&e.preventDefault(),r(!0)}},d=e=>{let t=om(e.code,s);oh(i,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),"Meta"===e.key&&a.current.clear(),o.current=!1},c=()=>{a.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",d),window.addEventListener("blur",c),window.addEventListener("contextmenu",c),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",d),window.removeEventListener("blur",c),window.removeEventListener("contextmenu",c)}}},[e,r]),n}function oh(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function om(e,t){return t.includes(e)?"code":"key"}function og(e,t){let n=[],r=new Map,o=[];for(let t of e)if("add"===t.type){o.push(t);continue}else if("remove"===t.type||"replace"===t.type)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}let o={...e};for(let e of t){var a=e,i=o;switch(a.type){case"select":i.selected=a.selected;break;case"position":void 0!==a.position&&(i.position=a.position),void 0!==a.dragging&&(i.dragging=a.dragging);break;case"dimensions":void 0!==a.dimensions&&(i.measured={...a.dimensions},a.setAttributes&&((!0===a.setAttributes||"width"===a.setAttributes)&&(i.width=a.dimensions.width),(!0===a.setAttributes||"height"===a.setAttributes)&&(i.height=a.dimensions.height))),"boolean"==typeof a.resizing&&(i.resizing=a.resizing)}}n.push(o)}return o.length&&o.forEach(e=>{void 0!==e.index?n.splice(e.index,0,{...e.item}):n.push({...e.item})}),n}function ox(e,t){return{id:e,type:"select",selected:t}}function ov(e,t=new Set,n=!1){let r=[];for(let[o,a]of e){let e=t.has(o);(void 0!==a.selected||e)&&a.selected!==e&&(n&&(a.selected=e),r.push(ox(a.id,e)))}return r}function oy({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,o]of e.entries()){let e=t.get(o.id),a=e?.internals?.userNode??e;void 0!==a&&a!==o&&n.push({id:o.id,item:o,type:"replace"}),void 0===a&&n.push({item:o,type:"add",index:r})}for(let[e]of t)void 0===r.get(e)&&n.push({id:e,type:"remove"});return n}function ob(e){return{id:e.id,type:"remove"}}let ow=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e);function oS(e){return(0,I.forwardRef)(e)}let oC="u">typeof window?I.useLayoutEffect:I.useEffect;function oj(e){let[t,n]=(0,I.useState)(BigInt(0)),[r]=(0,I.useState)(()=>{var e;let t;return e=()=>n(e=>e+BigInt(1)),t=[],{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}});return oC(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}let oN=(0,I.createContext)(null);function oE({children:e}){let t=rJ(),n=oj((0,I.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:o,onNodesChange:a,nodeLookup:i,fitViewQueued:s,onNodesChangeMiddlewareMap:l}=t.getState(),d=n;for(let t of e)d="function"==typeof t?t(d):t;let c=oy({items:d,lookup:i});for(let e of l.values())c=e(c);o&&r(d),c.length>0?a?.(c):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=oj((0,I.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:o,onEdgesChange:a,edgeLookup:i}=t.getState(),s=n;for(let t of e)s="function"==typeof t?t(s):t;o?r(s):a&&a(oy({items:s,lookup:i}))},[])),o=(0,I.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,T.jsx)(oN.Provider,{value:o,children:e})}let ok=e=>!!e.panZoom;function o_(){let e,t=(e=rJ(),(0,I.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,o,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:o,minZoom:a,maxZoom:i,panZoom:s}=e.getState(),l=nH(t,r,o,a,i,n?.padding??.1);return s?(await s.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:o,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;let{x:s,y:l}=i.getBoundingClientRect(),d={x:t.x-s,y:t.y-l},c=n.snapGrid??o;return nL(d,r,n.snapToGrid??a,c)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:o,y:a}=r.getBoundingClientRect(),i=nz(t,n);return{x:i.x+o,y:i.y+a}}}),[])),n=rJ(),r=function(){let e=(0,I.useContext)(oN);if(!e)throw Error("useBatchContext must be used within a BatchProvider");return e}(),o=rZ(ok),a=(0,I.useMemo)(()=>{let e=e=>n.getState().nodeLookup.get(e),t=e=>{r.nodeQueue.push(e)},o=e=>{r.edgeQueue.push(e)},a=e=>{let{nodeLookup:t,nodeOrigin:r}=n.getState(),o=ow(e)?e:t.get(e.id),a=o.parentId?nK(o.position,o.measured,o.parentId,t,r):o.position;return nT({...o,position:a,width:o.measured?.width??o.width,height:o.measured?.height??o.height})},i=(e,n,r={replace:!1})=>{t(t=>t.map(t=>{if(t.id===e){let e="function"==typeof n?n(t):n;return r.replace&&ow(e)?e:{...t,...e}}return t}))},s=(e,t,n={replace:!1})=>{o(r=>r.map(r=>{if(r.id===e){let e="function"==typeof t?t(r):t;return n.replace&&nf(e)?e:{...r,...e}}return r}))};return{getNodes:()=>n.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=n.getState();return e.map(e=>({...e}))},getEdge:e=>n.getState().edgeLookup.get(e),setNodes:t,setEdges:o,addNodes:e=>{let t=Array.isArray(e)?e:[e];r.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];r.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:t=[],transform:r}=n.getState(),[o,a,i]=r;return{nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),viewport:{x:o,y:a,zoom:i}}},deleteElements:async({nodes:e=[],edges:t=[]})=>{let{nodes:r,edges:o,onNodesDelete:a,onEdgesDelete:i,triggerNodeChanges:s,triggerEdgeChanges:l,onDelete:d,onBeforeDelete:c}=n.getState(),{nodes:u,edges:p}=await nb({nodesToRemove:e,edgesToRemove:t,nodes:r,edges:o,onBeforeDelete:c}),f=p.length>0,h=u.length>0;if(f){let e=p.map(ob);i?.(p),l(e)}if(h){let e=u.map(ob);a?.(u),s(e)}return(h||f)&&d?.({nodes:u,edges:p}),{deletedNodes:u,deletedEdges:p}},getIntersectingNodes:(e,t=!0,r)=>{let o=nM(e),i=o?e:a(e),s=void 0!==r;return i?(r||n.getState().nodes).filter(r=>{let a=n.getState().nodeLookup.get(r.id);if(a&&!o&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let l=nT(s?r:a),d=nP(l,i);return t&&d>0||d>=l.width*l.height||d>=i.width*i.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=nM(e)?e:a(e);if(!r)return!1;let o=nP(r,t);return n&&o>0||o>=t.width*t.height||o>=r.width*r.height},updateNode:i,updateNodeData:(e,t,n={replace:!1})=>{i(e,e=>{let r="function"==typeof t?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r="function"==typeof t?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:t,nodeOrigin:r}=n.getState();return((e,t={nodeOrigin:[0,0]})=>0===e.length?{x:0,y:0,width:0,height:0}:n_(e.reduce((e,n)=>{let r="string"==typeof n,o=t.nodeLookup||r?void 0:n;return t.nodeLookup&&(o=r?t.nodeLookup.get(n):nh(n)?n:t.nodeLookup.get(n.id)),nE(e,o?nI(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})))(e,{nodeLookup:t,nodeOrigin:r})},getHandleConnections:({type:e,id:t,nodeId:r})=>Array.from(n.getState().connectionLookup.get(`${r}-${e}${t?`-${t}`:""}`)?.values()??[]),getNodeConnections:({type:e,handleId:t,nodeId:r})=>Array.from(n.getState().connectionLookup.get(`${r}${e?t?`-${e}-${t}`:`-${e}`:""}`)?.values()??[]),fitView:async e=>{let t,o,a=n.getState().fitViewResolver??{promise:new Promise((e,n)=>{t=e,o=n}),resolve:t,reject:o};return n.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:a}),r.nodeQueue.push(e=>[...e]),a.promise}}},[]);return(0,I.useMemo)(()=>({...a,...t,viewportInitialized:o}),[o])}let oT=e=>e.selected,oI="u">typeof window?window:void 0,oR={position:"absolute",width:"100%",height:"100%",top:0,left:0},oP=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function oM({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:a=w.Free,zoomOnDoubleClick:i=!0,panOnDrag:s=!0,defaultViewport:l,translateExtent:d,minZoom:c,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:f=!0,children:h,noWheelClassName:m,noPanClassName:g,onViewportChange:x,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let S,C=rJ(),j=(0,I.useRef)(null),{userSelectionActive:N,lib:E,connectionInProgress:k}=rZ(oP,rW),_=of(p),R=(0,I.useRef)();S=rJ(),(0,I.useEffect)(()=>{let e=()=>{if(!j.current||!(j.current.checkVisibility?.()??!0))return!1;let e=nG(j.current);(0===e.height||0===e.width)&&S.getState().onError?.("004","The React Flow parent container needs a width and a height to render the graph."),S.setState({width:e.width||500,height:e.height||500})};if(j.current){e(),window.addEventListener("resize",e);let t=new ResizeObserver(()=>e());return t.observe(j.current),()=>{window.removeEventListener("resize",e),t&&j.current&&t.unobserve(j.current)}}},[]);let P=(0,I.useCallback)(e=>{x?.({x:e[0],y:e[1],zoom:e[2]}),v||C.setState({transform:e})},[x,v]);return(0,I.useEffect)(()=>{if(j.current){R.current=function({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:s,onDraggingChange:l}){let d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=e.getBoundingClientRect(),u=na().scaleExtent([t,n]).translateExtent(r),p=eC(e).call(u);x({x:o.x,y:o.y,zoom:nw(o.zoom,t,n)},[[0,0],[c.width,c.height]],r);let f=p.on("wheel.zoom"),h=p.on("dblclick.zoom");function m(e,t){return p?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?ni:e$).transform(rI(p,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g(){u.on("zoom",null)}async function x(e,t,n){let r=rE(e),o=u?.constrain()(r,t,n);return o&&await m(o),new Promise(e=>e(o))}return u.wheelDelta(rR),{update:function({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:o,panOnDrag:c,panOnScrollMode:m,panOnScrollSpeed:x,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:S,zoomActivationKeyPressed:C,lib:j,onTransformChange:N,connectionInProgress:E,paneClickDistance:k,selectionOnDrag:_}){r&&!d.isZoomingOrPanning&&g();let T=o&&!C&&!r;u.clickDistance(_?1/0:!nA(k)||k<0?0:k);let I=T?function({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:s,onPanZoom:l,onPanZoomEnd:d}){return c=>{if(rk(c,t))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();let u=n.property("__zoom").k||1;if(c.ctrlKey&&i){let e=ej(c),t=u*Math.pow(2,rR(c));r.scaleTo(n,t,e,c);return}let p=1===c.deltaMode?20:1,f=o===w.Vertical?0:c.deltaX*p,h=o===w.Horizontal?0:c.deltaY*p;!nF()&&c.shiftKey&&o!==w.Vertical&&(f=c.deltaY*p,h=0),r.translateBy(n,-(f/u)*a,-(h/u)*a,{internal:!0});let m=rN(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(c,m),e.panScrollTimeout=setTimeout(()=>{d?.(c,m),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(c,m))}}({zoomPanValues:d,noWheelClassName:e,d3Selection:p,d3Zoom:u,panOnScrollMode:m,panOnScrollSpeed:x,zoomOnPinch:y,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:s}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){let a="wheel"===r.type,i=!t&&a&&!r.ctrlKey,s=rk(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),i||s)return null;r.preventDefault(),n.call(this,r,o)}}({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:f});if(p.on("wheel.zoom",I,{passive:!1}),!r){let e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let o=rN(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,o)}}({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:i});u.on("start",e);let t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return a=>{e.usedRightMouseButton=!!(n&&r_(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),o&&!a.sourceEvent?.internal&&o?.(a.sourceEvent,rN(a.transform))}}({zoomPanValues:d,panOnDrag:c,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:N});u.on("zoom",t);let r=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&r_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){let t=rN(i.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(i.sourceEvent,t)},150*!!n)}}}({zoomPanValues:d,panOnDrag:c,panOnScroll:o,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:l});u.on("end",r)}let R=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:s,noPanClassName:l,lib:d,connectionInProgress:c}){return u=>{let p=e||t,f=n&&u.ctrlKey,h="wheel"===u.type;if(1===u.button&&"mousedown"===u.type&&(rk(u,`${d}-flow__node`)||rk(u,`${d}-flow__edge`)))return!0;if(!r&&!p&&!o&&!a&&!n||i||c&&!h||rk(u,s)&&h||rk(u,l)&&(!h||o&&h&&!e)||!n&&u.ctrlKey&&h)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!p&&!o&&!f&&h||!r&&("mousedown"===u.type||"touchstart"===u.type)||Array.isArray(r)&&!r.includes(u.button)&&"mousedown"===u.type)return!1;let m=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||h)&&m}}({zoomActivationKeyPressed:C,panOnDrag:c,zoomOnScroll:b,panOnScroll:o,zoomOnDoubleClick:S,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:j,connectionInProgress:E});u.filter(R),S?p.on("dblclick.zoom",h):p.on("dblclick.zoom",null)},destroy:g,setViewport:async function e(e,t){let n=rE(e);return await m(n,t),new Promise(e=>e(n))},setViewportConstrained:x,getViewport:function(){let e=p?t6(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){return p?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?ni:e$).scaleTo(rI(p,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},scaleBy:function(e,t){return p?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?ni:e$).scaleBy(rI(p,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},setScaleExtent:function(e){u?.scaleExtent(e)},setTranslateExtent:function(e){u?.translateExtent(e)},syncViewport:function(e){if(p){let t=rE(e),n=p.property("__zoom");(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&u?.transform(p,t,null,{sync:!0})}},setClickDistance:function(e){let t=!nA(e)||e<0?0:e;u?.clickDistance(t)}}}({domNode:j.current,minZoom:c,maxZoom:u,translateExtent:d,viewport:l,onDraggingChange:e=>C.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=C.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=C.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=C.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=R.current.getViewport();return C.setState({panZoom:R.current,transform:[e,t,n],domNode:j.current.closest(".react-flow")}),()=>{R.current?.destroy()}}},[]),(0,I.useEffect)(()=>{R.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:s,zoomActivationKeyPressed:_,preventScrolling:f,noPanClassName:g,userSelectionActive:N,noWheelClassName:m,lib:E,onTransformChange:P,connectionInProgress:k,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,o,a,i,s,_,f,g,N,m,E,P,k,b,y]),(0,T.jsx)("div",{className:"react-flow__renderer",ref:j,style:oR,children:h})}let oA=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function oO(){let{userSelectionActive:e,userSelectionRect:t}=rZ(oA,rW);return e&&t?(0,T.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}let oD=(e,t)=>n=>{n.target===t.current&&e?.(n)},oL=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function oz({isSelecting:e,selectionKeyPressed:t,selectionMode:n=S.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:l,onPaneContextMenu:d,onPaneScroll:c,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:f,children:h}){let m=rJ(),{userSelectionActive:g,elementsSelectable:x,dragging:v,connectionInProgress:y}=rZ(oL,rW),b=x&&(e||g),w=(0,I.useRef)(null),C=(0,I.useRef)(),j=(0,I.useRef)(new Set),N=(0,I.useRef)(new Set),E=(0,I.useRef)(!1),k=e=>{if(E.current||y){E.current=!1;return}l?.(e),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},_=!0===r||Array.isArray(r)&&r.includes(0);return(0,T.jsxs)("div",{className:R(["react-flow__pane",{draggable:_,dragging:v,selection:e}]),onClick:b?void 0:oD(k,w),onContextMenu:oD(e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():d?.(e)},w),onWheel:oD(c?e=>c(e):void 0,w),onPointerEnter:b?void 0:u,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:l,connectionLookup:d,triggerNodeChanges:c,triggerEdgeChanges:u,defaultEdgeOptions:p,resetSelectedElements:f}=m.getState();if(!C.current||!r)return;let{x:h,y:g}=nJ(e.nativeEvent,C.current),{startX:x,startY:v}=r;if(!E.current){if(Math.hypot(h-x,g-v)<=(t?0:o))return;f(),i?.(e)}E.current=!0;let y={startX:x,startY:v,x:h<x?h:x,y:g<v?g:v,width:Math.abs(h-x),height:Math.abs(g-v)},b=j.current,w=N.current;j.current=new Set(nx(s,y,a,n===S.Partial,!0).map(e=>e.id)),N.current=new Set;let k=p?.selectable??!0;for(let e of j.current){let t=d.get(e);if(t)for(let{edgeId:e}of t.values()){let t=l.get(e);t&&(t.selectable??k)&&N.current.add(e)}}nW(b,j.current)||c(ov(s,j.current,!0)),nW(w,N.current)||u(ov(l,N.current)),m.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:p,onPointerUp:b?e=>{0===e.button&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===w.current&&m.getState().userSelectionRect&&k?.(e),m.setState({userSelectionActive:!1,userSelectionRect:null}),E.current&&(s?.(e),m.setState({nodesSelectionActive:j.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=m.getState();if(C.current=r?.getBoundingClientRect(),!C.current)return;let o=n.target===w.current;if(!o&&n.target.closest(".nokey")||!e||!(a&&o||t)||0!==n.button||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),E.current=!1;let{x:i,y:s}=nJ(n.nativeEvent,C.current);m.setState({userSelectionRect:{width:0,height:0,startX:i,startY:s,x:i,y:s}}),o||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{E.current&&(e.stopPropagation(),E.current=!1)}:void 0,onPointerLeave:f,ref:w,style:oR,children:[h,(0,T.jsx)(oO,{})]})}function o$({id:e,store:t,unselect:n=!1,nodeRef:r}){let o,{addSelectedNodes:a,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:d}=t.getState(),c=l.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):a([e])):d?.("012",(o=e,`Node with id "${o}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`))}function oH({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:a,nodeClickDistance:i}){let s=rJ(),[l,d]=(0,I.useState)(!1),c=(0,I.useRef)();return(0,I.useEffect)(()=>{c.current=function({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let a={x:null,y:null},i=0,s=new Map,l=!1,d={x:0,y:0},c=null,u=!1,p=null,f=!1,h=!1,m=null;return{update:function({noDragClassName:g,handleSelector:x,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:w=0}){function S({x:e,y:n}){let{nodeLookup:o,nodeExtent:i,snapGrid:l,snapToGrid:d,nodeOrigin:c,onNodeDrag:u,onSelectionDrag:p,onError:f,updateNodePositions:g}=t();a={x:e,y:n};let x=!1,v=s.size>1,y=v&&i?nk(ng(s)):null,w=v&&d?function({dragItems:e,snapGrid:t,x:n,y:r}){let o=e.values().next().value;if(!o)return null;let a={x:n-o.distance.x,y:r-o.distance.y},i=nD(a,t);return{x:i.x-a.x,y:i.y-a.y}}({dragItems:s,snapGrid:l,x:e,y:n}):null;for(let[t,r]of s){if(!o.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};d&&(a=w?{x:Math.round(a.x+w.x),y:Math.round(a.y+w.y)}:nD(a,l));let s=null;if(v&&i&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+i[0][0],n=e.x+r.measured.width-y.x2+i[1][0];s=[[t,e.y-y.y+i[0][1]],[n,e.y+r.measured.height-y.y2+i[1][1]]]}let{position:u,positionAbsolute:p}=ny({nodeId:t,nextPosition:a,nodeLookup:o,nodeExtent:s||i,nodeOrigin:c,onError:f});x=x||r.position.x!==u.x||r.position.y!==u.y,r.position=u,r.internals.positionAbsolute=p}if(h=h||x,x&&(g(s,!0),m&&(r||u||!b&&p))){let[e,t]=ry({nodeId:b,dragItems:s,nodeLookup:o});r?.(m,s,e,t),u?.(m,e,t),b||p?.(m,t)}}async function C(){if(!c)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:o}=t();if(!o){l=!1,cancelAnimationFrame(i);return}let[s,u]=nN(d,c,r);(0!==s||0!==u)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-u/e[2],await n({x:s,y:u})&&S(a)),i=requestAnimationFrame(C)}function j(r){let{nodeLookup:o,multiSelectionActive:i,nodesDraggable:l,transform:d,snapGrid:p,snapToGrid:f,selectNodesOnDrag:h,onNodeDragStart:m,onSelectionDragStart:g,unselectNodesAndEdges:x}=t();u=!0,h&&y||i||!b||o.get(b)?.selected||x(),y&&h&&b&&e?.(b);let v=nX(r.sourceEvent,{transform:d,snapGrid:p,snapToGrid:f,containerBounds:c});if(a=v,(s=function(e,t,n,r){let o=new Map;for(let[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!function e(t,n){if(!t.parentId)return!1;let r=n.get(t.parentId);return!!r&&(!!r.selected||e(r,n))}(i,e))&&(i.draggable||t&&void 0===i.draggable)){let t=e.get(a);t&&o.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return o}(o,l,v,b)).size>0&&(n||m||!b&&g)){let[e,t]=ry({nodeId:b,dragItems:s,nodeLookup:o});n?.(r.sourceEvent,s,e,t),m?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}p=eC(v);let N=eL().clickDistance(w).on("start",e=>{let{domNode:n,nodeDragThreshold:r,transform:o,snapGrid:i,snapToGrid:s}=t();c=n?.getBoundingClientRect()||null,f=!1,h=!1,m=e.sourceEvent,0===r&&j(e),a=nX(e.sourceEvent,{transform:o,snapGrid:i,snapToGrid:s,containerBounds:c}),d=nJ(e.sourceEvent,c)}).on("drag",e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:o,snapToGrid:i,nodeDragThreshold:p,nodeLookup:h}=t(),g=nX(e.sourceEvent,{transform:r,snapGrid:o,snapToGrid:i,containerBounds:c});if(m=e.sourceEvent,("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1||b&&!h.has(b))&&(f=!0),!f){if(!l&&n&&u&&(l=!0,C()),!u){let t=nJ(e.sourceEvent,c),n=t.x-d.x,r=t.y-d.y;Math.sqrt(n*n+r*r)>p&&j(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&u&&(d=nJ(e.sourceEvent,c),S(g))}}).on("end",e=>{if(u&&!f&&(l=!1,u=!1,cancelAnimationFrame(i),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:i}=t();if(h&&(r(s,!1),h=!1),o||a||!b&&i){let[t,r]=ry({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});o?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||i?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!rv(t,`.${g}`,v))&&(!x||rv(t,x,v))});p.call(N)},destroy:function(){p?.on(".drag",null)}}}({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{o$({id:t,store:s,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),(0,I.useEffect)(()=>{if(!t&&e.current&&c.current)return c.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:o,nodeClickDistance:i}),()=>{c.current?.destroy()}},[n,r,t,a,e,o,i]),l}function oF(){let e=rJ();return(0,I.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:o,nodesDraggable:a,onError:i,updateNodePositions:s,nodeLookup:l,nodeOrigin:d}=e.getState(),c=new Map,u=e=>e.selected&&(e.draggable||a&&void 0===e.draggable),p=r?o[0]:5,f=r?o[1]:5,h=t.direction.x*p*t.factor,m=t.direction.y*f*t.factor;for(let[,e]of l){if(!u(e))continue;let t={x:e.internals.positionAbsolute.x+h,y:e.internals.positionAbsolute.y+m};r&&(t=nD(t,o));let{position:a,positionAbsolute:s}=ny({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:d,onError:i});e.position=a,e.internals.positionAbsolute=s,c.set(e.id,e)}s(c)},[])}let oB=(0,I.createContext)(null),oV=oB.Provider;oB.Consumer;let oU=()=>(0,I.useContext)(oB),oK=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),oW=(0,I.memo)(oS(function({type:e="source",position:t=N.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:a=!0,id:i,onConnect:s,children:l,className:d,onMouseDown:c,onTouchStart:u,...p},f){let h=i||null,m="target"===e,g=rJ(),x=oU(),{connectOnClick:v,noPanClassName:y,rfId:w}=rZ(oK,rW),{connectingFrom:S,connectingTo:C,clickConnecting:j,isPossibleEndHandle:E,connectionInProcess:k,clickConnectionInProcess:_,valid:I}=rZ(t=>{let{connectionClickStartHandle:n,connectionMode:r,connection:o}=t,{fromHandle:a,toHandle:i,isValid:s}=o,l=i?.nodeId===x&&i?.id===h&&i?.type===e;return{connectingFrom:a?.nodeId===x&&a?.id===h&&a?.type===e,connectingTo:l,clickConnecting:n?.nodeId===x&&n?.id===h&&n?.type===e,isPossibleEndHandle:r===b.Strict?a?.type!==e:x!==a?.nodeId||h!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!n,valid:l&&s}},rW);x||g.getState().onError?.("010","Handle: No node id found. Make sure to only use a Handle inside a custom Node.");let P=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),o={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(n6(o,e))}n?.(o),s?.(o)},M=e=>{if(!x)return;let t="clientX"in e.nativeEvent;if(o&&(t&&0===e.button||!t)){let t=g.getState();rj(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:m,handleId:h,nodeId:x,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:P,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?c?.(e):u?.(e)};return(0,T.jsx)("div",{"data-handleid":h,"data-nodeid":x,"data-handlepos":t,"data-id":`${w}-${x}-${h}-${e}`,className:R(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,d,{source:!m,target:m,connectable:r,connectablestart:o,connectableend:a,clickconnecting:j,connectingfrom:S,connectingto:C,valid:I,connectionindicator:r&&(!k||E)&&(k||_?a:o)}]),onMouseDown:M,onTouchStart:M,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:i,connectionMode:s,isValidConnection:l,lib:d,rfId:c,nodeLookup:u,connection:p}=g.getState();if(!x||!i&&!o)return;if(!i){r?.(t.nativeEvent,{nodeId:x,handleId:h,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:x,type:e,id:h}});return}let f=nY(t.target),m=n||l,{connection:v,isValid:y}=rC(t.nativeEvent,{handle:{nodeId:x,id:h,type:e},connectionMode:s,fromNodeId:i.nodeId,fromHandleId:i.id||null,fromType:i.type,isValidConnection:m,flowId:c,doc:f,lib:d,nodeLookup:u});y&&v&&P(v);let b=structuredClone(p);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:f,...p,children:l})})),oX={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},oG={input:function({data:e,isConnectable:t,sourcePosition:n=N.Bottom}){return(0,T.jsxs)(T.Fragment,{children:[e?.label,(0,T.jsx)(oW,{type:"source",position:n,isConnectable:t})]})},default:function({data:e,isConnectable:t,targetPosition:n=N.Top,sourcePosition:r=N.Bottom}){return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(oW,{type:"target",position:n,isConnectable:t}),e?.label,(0,T.jsx)(oW,{type:"source",position:r,isConnectable:t})]})},output:function({data:e,isConnectable:t,targetPosition:n=N.Top}){return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(oW,{type:"target",position:n,isConnectable:t}),e?.label]})},group:function(){return null}},oY=e=>{let{width:t,height:n,x:r,y:o}=ng(e.nodeLookup,{filter:e=>!!e.selected});return{width:nA(t)?t:null,height:nA(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function oq({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=rJ(),{width:o,height:a,transformString:i,userSelectionActive:s}=rZ(oY,rW),l=oF(),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{n||d.current?.focus({preventScroll:!0})},[n]);let c=!s&&null!==o&&null!==a;if(oH({nodeRef:d,disabled:!c}),!c)return null;let u=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,T.jsx)("div",{className:R(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:(0,T.jsx)("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(oX,e.key)&&(e.preventDefault(),l({direction:oX[e.key],factor:e.shiftKey?4:1}))},style:{width:o,height:a}})})}let oZ="u">typeof window?window:void 0,oJ=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oQ({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:s,deleteKeyCode:l,selectionKeyCode:d,selectionOnDrag:c,selectionMode:u,onSelectionStart:p,onSelectionEnd:f,multiSelectionKeyCode:h,panActivationKeyCode:m,zoomActivationKeyCode:g,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:w,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:j,defaultViewport:N,translateExtent:E,minZoom:k,maxZoom:_,preventScrolling:R,onSelectionContextMenu:P,noWheelClassName:M,noPanClassName:A,disableKeyboardA11y:O,onViewportChange:D,isControlledViewport:L}){let{nodesSelectionActive:z,userSelectionActive:$}=rZ(oJ,rW),H=of(d,{target:oZ}),F=of(m,{target:oZ}),B=F||j,V=F||b,U=c&&!0!==B,K=H||$||U;return!function({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=rJ(),{deleteElements:r}=o_(),o=of(e,{actInsideInputWithModifier:!1}),a=of(t,{target:oI});(0,I.useEffect)(()=>{if(o){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(oT),edges:e.filter(oT)}),n.setState({nodesSelectionActive:!1})}},[o]),(0,I.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}({deleteKeyCode:l,multiSelectionKeyCode:h}),(0,T.jsx)(oM,{onPaneContextMenu:a,elementsSelectable:x,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:V,panOnScrollSpeed:w,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!H&&B,defaultViewport:N,translateExtent:E,minZoom:k,maxZoom:_,zoomActivationKeyCode:g,preventScrolling:R,noWheelClassName:M,noPanClassName:A,onViewportChange:D,isControlledViewport:L,paneClickDistance:s,selectionOnDrag:U,children:(0,T.jsxs)(oz,{onSelectionStart:p,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:B,isSelecting:!!K,selectionMode:u,selectionKeyPressed:H,paneClickDistance:s,selectionOnDrag:U,children:[e,z&&(0,T.jsx)(oq,{onSelectionContextMenu:P,noPanClassName:A,disableKeyboardA11y:O})]})})}oQ.displayName="FlowRenderer";let o0=(0,I.memo)(oQ),o1=e=>e.updateNodeInternals;var o2=(0,I.memo)(function({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:a,onDoubleClick:i,nodesDraggable:s,elementsSelectable:l,nodesConnectable:d,nodesFocusable:c,resizeObserver:u,noDragClassName:p,noPanClassName:f,disableKeyboardA11y:h,rfId:m,nodeTypes:g,nodeClickDistance:x,onError:v}){let y,{node:b,internals:w,isParent:S}=rZ(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},rW),C=b.type||"default",j=g?.[C]||oG[C];void 0===j&&(v?.("003",(y=C,`Node type "${y}" not found. Using fallback type "default".`)),C="default",j=g?.default||oG.default);let N=!!(b.draggable||s&&void 0===b.draggable),E=!!(b.selectable||l&&void 0===b.selectable),k=!!(b.connectable||d&&void 0===b.connectable),_=!!(b.focusable||c&&void 0===b.focusable),P=rJ(),M=nU(b),A=function({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let o=rJ(),a=(0,I.useRef)(null),i=(0,I.useRef)(null),s=(0,I.useRef)(e.sourcePosition),l=(0,I.useRef)(e.targetPosition),d=(0,I.useRef)(t),c=n&&!!e.internals.handleBounds;return(0,I.useEffect)(()=>{!a.current||e.hidden||c&&i.current===a.current||(i.current&&r?.unobserve(i.current),r?.observe(a.current),i.current=a.current)},[c,e.hidden]),(0,I.useEffect)(()=>()=>{i.current&&(r?.unobserve(i.current),i.current=null)},[]),(0,I.useEffect)(()=>{if(a.current){let n=d.current!==t,r=s.current!==e.sourcePosition,i=l.current!==e.targetPosition;(n||r||i)&&(d.current=t,s.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}({node:b,nodeType:C,hasDimensions:M,resizeObserver:u}),O=oH({nodeRef:A,disabled:b.hidden||!N,noDragClassName:p,handleSelector:b.dragHandle,nodeId:e,isSelectable:E,nodeClickDistance:x}),D=oF();if(b.hidden)return null;let L=nV(b),z=void 0===b.internals.handleBounds?{width:b.width??b.initialWidth??b.style?.width,height:b.height??b.initialHeight??b.style?.height}:{width:b.width??b.style?.width,height:b.height??b.style?.height},$=E||N||t||n||r||o,H=n?e=>n(e,{...w.userNode}):void 0,F=r?e=>r(e,{...w.userNode}):void 0,B=o?e=>o(e,{...w.userNode}):void 0,V=a?e=>a(e,{...w.userNode}):void 0,U=i?e=>i(e,{...w.userNode}):void 0;return(0,T.jsx)("div",{className:R(["react-flow__node",`react-flow__node-${C}`,{[f]:N},b.className,{selected:b.selected,selectable:E,parent:S,draggable:N,dragging:O}]),ref:A,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:M?"visible":"hidden",...b.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:F,onMouseLeave:B,onContextMenu:V,onClick:n=>{let{selectNodesOnDrag:r,nodeDragThreshold:o}=P.getState();E&&(!r||!N||o>0)&&o$({id:e,store:P,nodeRef:A}),t&&t(n,{...w.userNode})},onDoubleClick:U,onKeyDown:_?t=>{if(!nZ(t.nativeEvent)&&!h){if(nl.includes(t.key)&&E)o$({id:e,store:P,unselect:"Escape"===t.key,nodeRef:A});else if(N&&b.selected&&Object.prototype.hasOwnProperty.call(oX,t.key)){t.preventDefault();let{ariaLabelConfig:e}=P.getState();P.setState({ariaLiveMessage:e["node.a11yDescription.ariaLiveMessage"]({direction:t.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),D({direction:oX[t.key],factor:t.shiftKey?4:1})}}}:void 0,tabIndex:_?0:void 0,onFocus:_?()=>{if(h||!A.current?.matches(":focus-visible"))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:o,setCenter:a}=P.getState();!o||nx(new Map([[e,b]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(b.position.x+L.width/2,b.position.y+L.height/2,{zoom:t[2]})}:void 0,role:b.ariaRole??(_?"group":void 0),"aria-roledescription":"node","aria-describedby":h?void 0:`${r1}-${m}`,"aria-label":b.ariaLabel,...b.domAttributes,children:(0,T.jsx)(oV,{value:e,children:(0,T.jsx)(j,{id:e,data:b.data,type:C,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:b.selected??!1,selectable:E,draggable:N,deletable:b.deletable??!0,isConnectable:k,sourcePosition:b.sourcePosition,targetPosition:b.targetPosition,dragging:O,dragHandle:b.dragHandle,zIndex:w.z,parentId:b.parentId,...L})})})});let o5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function o3(e){var t;let{nodesDraggable:n,nodesConnectable:r,nodesFocusable:o,elementsSelectable:a,onError:i}=rZ(o5,rW),s=(t=e.onlyRenderVisibleElements,rZ((0,I.useCallback)(e=>t?nx(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(e=>e.id):Array.from(e.nodeLookup.keys()),[t]),rW)),l=function(){let e=rZ(o1),[t]=(0,I.useState)(()=>"u"<typeof ResizeObserver?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,I.useEffect)(()=>()=>{t?.disconnect()},[t]),t}();return(0,T.jsx)("div",{className:"react-flow__nodes",style:oR,children:s.map(t=>(0,T.jsx)(o2,{id:t,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:n,nodesConnectable:r,nodesFocusable:o,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:i},t))})}o3.displayName="NodeRenderer";let o4=(0,I.memo)(o3),o6={[j.Arrow]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,T.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},[j.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,T.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})}},o8=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:s="auto-start-reverse"})=>{let l,d=(l=rJ(),(0,I.useMemo)(()=>{let e;return Object.prototype.hasOwnProperty.call(o6,t)?o6[t]:(l.getState().onError?.("009",(e=t,`Marker type "${e}" doesn't exist.`)),null)},[t]));return d?(0,T.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:s,refX:"0",refY:"0",children:(0,T.jsx)(d,{color:n,strokeWidth:i})}):null},o9=({defaultColor:e,rfId:t})=>{let n=rZ(e=>e.edges),r=rZ(e=>e.defaultEdgeOptions),o=(0,I.useMemo)(()=>(function(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){let a=new Set;return e.reduce((e,i)=>([i.markerStart||r,i.markerEnd||o].forEach(r=>{if(r&&"object"==typeof r){let o=ri(r,t);a.has(o)||(e.push({id:o,color:r.color||n,...r}),a.add(o))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))})(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return o.length?(0,T.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,T.jsx)("defs",{children:o.map(e=>(0,T.jsx)(o8,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};o9.displayName="MarkerDefinitions";var o7=(0,I.memo)(o9);function ae({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:s=2,children:l,className:d,...c}){let[u,p]=(0,I.useState)({x:1,y:0,width:0,height:0}),f=R(["react-flow__edge-textwrapper",d]),h=(0,I.useRef)(null);return((0,I.useEffect)(()=>{if(h.current){let e=h.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n)?(0,T.jsxs)("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:f,visibility:u.width?"visible":"hidden",...c,children:[o&&(0,T.jsx)("rect",{width:u.width+2*i[0],x:-i[0],y:-i[1],height:u.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),(0,T.jsx)("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:h,style:r,children:n}),l]}):null}ae.displayName="EdgeText";let at=(0,I.memo)(ae);function an({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:l,interactionWidth:d=20,...c}){return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("path",{...c,d:e,fill:"none",className:R(["react-flow__edge-path",c.className])}),d?(0,T.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&nA(t)&&nA(n)?(0,T.jsx)(at,{x:t,y:n,label:r,labelStyle:o,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:l}):null]})}function ar({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===N.Left||e===N.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function ao({sourceX:e,sourceY:t,sourcePosition:n=N.Bottom,targetX:r,targetY:o,targetPosition:a=N.Top}){let[i,s]=ar({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,d]=ar({pos:a,x1:r,y1:o,x2:e,y2:t}),[c,u,p,f]=n0({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:s,targetControlX:l,targetControlY:d});return[`M${e},${t} C${i},${s} ${l},${d} ${r},${o}`,c,u,p,f]}function aa(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,sourcePosition:i,targetPosition:s,label:l,labelStyle:d,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:x})=>{let[v,y,b]=ao({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:a,targetPosition:s}),w=e.isInternal?void 0:t;return(0,T.jsx)(an,{id:w,path:v,labelX:y,labelY:b,label:l,labelStyle:d,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:x})})}let ai=aa({isInternal:!1}),as=aa({isInternal:!0});function al(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:p,sourcePosition:f=N.Bottom,targetPosition:h=N.Top,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:v})=>{let[y,b,w]=rt({sourceX:n,sourceY:r,sourcePosition:f,targetX:o,targetY:a,targetPosition:h,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),S=e.isInternal?void 0:t;return(0,T.jsx)(an,{id:S,path:y,labelX:b,labelY:w,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:g,interactionWidth:v})})}ai.displayName="SimpleBezierEdge",as.displayName="SimpleBezierEdgeInternal";let ad=al({isInternal:!1}),ac=al({isInternal:!0});function au(e){return(0,I.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,T.jsx)(ad,{...n,id:r,pathOptions:(0,I.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}ad.displayName="SmoothStepEdge",ac.displayName="SmoothStepEdgeInternal";let ap=au({isInternal:!1}),af=au({isInternal:!0});function ah(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:p,markerEnd:f,markerStart:h,interactionWidth:m})=>{let[g,x,v]=n8({sourceX:n,sourceY:r,targetX:o,targetY:a}),y=e.isInternal?void 0:t;return(0,T.jsx)(an,{id:y,path:g,labelX:x,labelY:v,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:c,labelBgBorderRadius:u,style:p,markerEnd:f,markerStart:h,interactionWidth:m})})}ap.displayName="StepEdge",af.displayName="StepEdgeInternal";let am=ah({isInternal:!1}),ag=ah({isInternal:!0});function ax(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,sourcePosition:i=N.Bottom,targetPosition:s=N.Top,label:l,labelStyle:d,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,pathOptions:x,interactionWidth:v})=>{let[y,b,w]=n5({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:a,targetPosition:s,curvature:x?.curvature}),S=e.isInternal?void 0:t;return(0,T.jsx)(an,{id:S,path:y,labelX:b,labelY:w,label:l,labelStyle:d,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:g,interactionWidth:v})})}am.displayName="StraightEdge",ag.displayName="StraightEdgeInternal";let av=ax({isInternal:!1}),ay=ax({isInternal:!0});av.displayName="BezierEdge",ay.displayName="BezierEdgeInternal";let ab={default:ay,straight:ag,step:af,smoothstep:ac,simplebezier:as},aw={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},aS="react-flow__edgeupdater";function aC({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:a,onMouseOut:i,type:s}){return(0,T.jsx)("circle",{onMouseDown:o,onMouseEnter:a,onMouseOut:i,className:R([aS,`${aS}-${s}`]),cx:e===N.Left?t-r:e===N.Right?t+r:t,cy:e===N.Top?n-r:e===N.Bottom?n+r:n,r:r,stroke:"transparent",fill:"transparent"})}function aj({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,onReconnect:d,onReconnectStart:c,onReconnectEnd:u,setReconnecting:p,setUpdateHover:f}){let h=rJ(),m=(e,t)=>{if(0!==e.button)return;let{autoPanOnConnect:r,domNode:o,connectionMode:a,connectionRadius:i,lib:s,onConnectStart:l,cancelConnection:f,nodeLookup:m,rfId:g,panBy:x,updateConnection:v}=h.getState(),y="target"===t.type;rj(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:i,domNode:o,handleId:t.id,nodeId:t.nodeId,nodeLookup:m,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:f,panBy:x,isValidConnection:(...e)=>h.getState().isValidConnection?.(...e)??!0,onConnect:e=>d?.(n,e),onConnectStart:(r,o)=>{p(!0),c?.(e,n,t.type),l?.(r,o)},onConnectEnd:(...e)=>h.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{p(!1),u?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>h.getState().transform,getFromHandle:()=>h.getState().connection.fromHandle,dragThreshold:h.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=()=>f(!0),x=()=>f(!1);return(0,T.jsxs)(T.Fragment,{children:[(!0===e||"source"===e)&&(0,T.jsx)(aC,{position:s,centerX:r,centerY:o,radius:t,onMouseDown:e=>m(e,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),onMouseEnter:g,onMouseOut:x,type:"source"}),(!0===e||"target"===e)&&(0,T.jsx)(aC,{position:l,centerX:a,centerY:i,radius:t,onMouseDown:e=>m(e,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),onMouseEnter:g,onMouseOut:x,type:"target"})]})}var aN=(0,I.memo)(function({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:a,onContextMenu:i,onMouseEnter:s,onMouseMove:l,onMouseLeave:d,reconnectRadius:c,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,rfId:h,edgeTypes:m,noPanClassName:g,onError:x,disableKeyboardA11y:v}){let y,w=rZ(t=>t.edgeLookup.get(e)),S=rZ(e=>e.defaultEdgeOptions),C=(w=S?{...S,...w}:w).type||"default",j=m?.[C]||ab[C];void 0===j&&(x?.("011",(y=C,`Edge type "${y}" not found. Using fallback type "default".`)),C="default",j=m?.default||ab.default);let E=!!(w.focusable||t&&void 0===w.focusable),k=void 0!==u&&(w.reconnectable||n&&void 0===w.reconnectable),_=!!(w.selectable||r&&void 0===w.selectable),P=(0,I.useRef)(null),[M,A]=(0,I.useState)(!1),[O,D]=(0,I.useState)(!1),L=rJ(),{zIndex:z,sourceX:$,sourceY:H,targetX:F,targetY:B,sourcePosition:V,targetPosition:U}=rZ((0,I.useCallback)(t=>{let n=t.nodeLookup.get(w.source),r=t.nodeLookup.get(w.target);if(!n||!r)return{zIndex:w.zIndex,...aw};let o=function(e){let{sourceNode:t,targetNode:n}=e;if(!rn(t)||!rn(n))return null;let r=t.internals.handleBounds||rr(t.handles),o=n.internals.handleBounds||rr(n.handles),a=ra(r?.source??[],e.sourceHandle),i=ra(e.connectionMode===b.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",((e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${"source"===e?n:r}", edge id: ${t}.`)(!a?"source":"target",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||N.Bottom,l=i?.position||N.Top,d=ro(t,a,s),c=ro(n,i,l);return{sourceX:d.x,sourceY:d.y,targetX:c.x,targetY:c.y,sourcePosition:s,targetPosition:l}}({id:e,sourceNode:n,targetNode:r,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:t.connectionMode,onError:x});return{zIndex:function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:a="basic"}){if("manual"===a)return r;let i=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return(o&&n?r+1e3:r)+i}({selected:w.selected,zIndex:w.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...o||aw}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),rW),K=(0,I.useMemo)(()=>w.markerStart?`url('#${ri(w.markerStart,h)}')`:void 0,[w.markerStart,h]),W=(0,I.useMemo)(()=>w.markerEnd?`url('#${ri(w.markerEnd,h)}')`:void 0,[w.markerEnd,h]);if(w.hidden||null===$||null===H||null===F||null===B)return null;let X=a?e=>{a(e,{...w})}:void 0,G=i?e=>{i(e,{...w})}:void 0,Y=s?e=>{s(e,{...w})}:void 0,q=l?e=>{l(e,{...w})}:void 0,Z=d?e=>{d(e,{...w})}:void 0;return(0,T.jsx)("svg",{style:{zIndex:z},children:(0,T.jsxs)("g",{className:R(["react-flow__edge",`react-flow__edge-${C}`,w.className,g,{selected:w.selected,animated:w.animated,inactive:!_&&!o,updating:M,selectable:_}]),onClick:t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=L.getState();_&&(L.setState({nodesSelectionActive:!1}),w.selected&&a?(r({nodes:[],edges:[w]}),P.current?.blur()):n([e])),o&&o(t,w)},onDoubleClick:X,onContextMenu:G,onMouseEnter:Y,onMouseMove:q,onMouseLeave:Z,onKeyDown:E?t=>{if(!v&&nl.includes(t.key)&&_){let{unselectNodesAndEdges:n,addSelectedEdges:r}=L.getState();"Escape"===t.key?(P.current?.blur(),n({edges:[w]})):r([e])}}:void 0,tabIndex:E?0:void 0,role:w.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":null===w.ariaLabel?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":E?`${r2}-${h}`:void 0,ref:P,...w.domAttributes,children:[!O&&(0,T.jsx)(j,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:_,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:$,sourceY:H,targetX:F,targetY:B,sourcePosition:V,targetPosition:U,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:K,markerEnd:W,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),k&&(0,T.jsx)(aj,{edge:w,isReconnectable:k,reconnectRadius:c,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,sourceX:$,sourceY:H,targetX:F,targetY:B,sourcePosition:V,targetPosition:U,setUpdateHover:A,setReconnecting:D})]})})});let aE=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ak({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:c,reconnectRadius:u,onEdgeDoubleClick:p,onReconnectStart:f,onReconnectEnd:h,disableKeyboardA11y:m}){let{edgesFocusable:g,edgesReconnectable:x,elementsSelectable:v,onError:y}=rZ(aE,rW),b=rZ((0,I.useCallback)(e=>{if(!t)return e.edges.map(e=>e.id);let n=[];if(e.width&&e.height)for(let t of e.edges){let r=e.nodeLookup.get(t.source),o=e.nodeLookup.get(t.target);r&&o&&function({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){let a=nE(nI(e),nI(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),nP({x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]},n_(a))>0}({sourceNode:r,targetNode:o,width:e.width,height:e.height,transform:e.transform})&&n.push(t.id)}return n},[t]),rW);return(0,T.jsxs)("div",{className:"react-flow__edges",children:[(0,T.jsx)(o7,{defaultColor:e,rfId:n}),b.map(e=>(0,T.jsx)(aN,{id:e,edgesFocusable:g,edgesReconnectable:x,elementsSelectable:v,noPanClassName:o,onReconnect:a,onContextMenu:i,onMouseEnter:s,onMouseMove:l,onMouseLeave:d,onClick:c,reconnectRadius:u,onDoubleClick:p,onReconnectStart:f,onReconnectEnd:h,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:m},e))]})}ak.displayName="EdgeRenderer";let a_=(0,I.memo)(ak),aT=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function aI({children:e}){let t=rZ(aT);return(0,T.jsx)("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}let aR=e=>e.panZoom?.syncViewport;function aP(e){return e.connection.inProgress?{...e.connection,to:nL(e.connection.to,e.transform)}:{...e.connection}}let aM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function aA({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:o,width:a,height:i,isValid:s,inProgress:l}=rZ(aM,rW);return a&&o&&l?(0,T.jsx)("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:(0,T.jsx)("g",{className:R(["react-flow__connection",np(s)]),children:(0,T.jsx)(aO,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}let aO=({style:e,type:t=C.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:o,from:a,fromNode:i,fromHandle:s,fromPosition:l,to:d,toNode:c,toHandle:u,toPosition:p,pointer:f}=rZ(aP,rW);if(!o)return;if(n)return(0,T.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:s,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:l,toPosition:p,connectionStatus:np(r),toNode:c,toHandle:u,pointer:f});let h="",m={sourceX:a.x,sourceY:a.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case C.Bezier:[h]=n5(m);break;case C.SimpleBezier:[h]=ao(m);break;case C.Step:[h]=rt({...m,borderRadius:0});break;case C.SmoothStep:[h]=rt(m);break;default:[h]=n8(m)}return(0,T.jsx)("path",{d:h,fill:"none",className:"react-flow__connection-path",style:e})};aO.displayName="ConnectionLine";let aD={};function aL(e=aD){(0,I.useRef)(e),rJ(),(0,I.useEffect)(()=>{},[e])}function az({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:c,onSelectionContextMenu:u,onSelectionStart:p,onSelectionEnd:f,connectionLineType:h,connectionLineStyle:m,connectionLineComponent:g,connectionLineContainerStyle:x,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:w,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:j,onlyRenderVisibleElements:N,elementsSelectable:E,defaultViewport:k,translateExtent:_,minZoom:R,maxZoom:P,preventScrolling:M,defaultMarkerColor:A,zoomOnScroll:O,zoomOnPinch:D,panOnScroll:L,panOnScrollSpeed:z,panOnScrollMode:$,zoomOnDoubleClick:H,panOnDrag:F,onPaneClick:B,onPaneMouseEnter:V,onPaneMouseMove:U,onPaneMouseLeave:K,onPaneScroll:W,onPaneContextMenu:X,paneClickDistance:G,nodeClickDistance:Y,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:J,onEdgeMouseLeave:Q,reconnectRadius:ee,onReconnect:et,onReconnectStart:en,onReconnectEnd:er,noDragClassName:eo,noWheelClassName:ea,noPanClassName:ei,disableKeyboardA11y:es,nodeExtent:el,rfId:ed,viewport:ec,onViewportChange:eu}){let ep,ef,eh,em;return aL(e),aL(t),rJ(),(0,I.useRef)(!1),(0,I.useEffect)(()=>{},[]),ep=o_(),ef=(0,I.useRef)(!1),(0,I.useEffect)(()=>{!ef.current&&ep.viewportInitialized&&n&&(setTimeout(()=>n(ep),1),ef.current=!0)},[n,ep.viewportInitialized]),eh=rZ(aR),em=rJ(),(0,I.useEffect)(()=>{ec&&(eh?.(ec),em.setState({transform:[ec.x,ec.y,ec.zoom]}))},[ec,eh]),(0,T.jsx)(o0,{onPaneClick:B,onPaneMouseEnter:V,onPaneMouseMove:U,onPaneMouseLeave:K,onPaneContextMenu:X,onPaneScroll:W,paneClickDistance:G,deleteKeyCode:j,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:p,onSelectionEnd:f,multiSelectionKeyCode:w,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:O,zoomOnPinch:D,zoomOnDoubleClick:H,panOnScroll:L,panOnScrollSpeed:z,panOnScrollMode:$,panOnDrag:F,defaultViewport:k,translateExtent:_,minZoom:R,maxZoom:P,onSelectionContextMenu:u,preventScrolling:M,noDragClassName:eo,noWheelClassName:ea,noPanClassName:ei,disableKeyboardA11y:es,onViewportChange:eu,isControlledViewport:!!ec,children:(0,T.jsxs)(aI,{children:[(0,T.jsx)(a_,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:et,onReconnectStart:en,onReconnectEnd:er,onlyRenderVisibleElements:N,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:J,onEdgeMouseLeave:Q,reconnectRadius:ee,defaultMarkerColor:A,noPanClassName:ei,disableKeyboardA11y:es,rfId:ed}),(0,T.jsx)(aA,{style:m,type:h,component:g,containerStyle:x}),(0,T.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,T.jsx)(o4,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:c,nodeClickDistance:Y,onlyRenderVisibleElements:N,noPanClassName:ei,noDragClassName:eo,disableKeyboardA11y:es,nodeExtent:el,rfId:ed}),(0,T.jsx)("div",{className:"react-flow__viewport-portal"})]})})}az.displayName="GraphView";let a$=(0,I.memo)(az),aH=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:l=.5,maxZoom:d=2,nodeOrigin:c,nodeExtent:u,zIndexMode:p="basic"}={})=>{let f=new Map,h=new Map,m=new Map,g=new Map,x=r??t??[],v=n??e??[],y=c??[0,0],w=u??ns;rx(m,g,x);let S=ru(v,f,h,{nodeOrigin:y,nodeExtent:w,zIndexMode:p}),C=[0,0,1];if(i&&o&&a){let{x:e,y:t,zoom:n}=nH(ng(f,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),o,a,l,d,s?.padding??.1);C=[e,t,n]}return{rfId:"1",width:o??0,height:a??0,transform:C,nodes:v,nodesInitialized:S,nodeLookup:f,parentLookup:h,edges:x,edgeLookup:g,connectionLookup:m,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==n,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:l,maxZoom:d,translateExtent:ns,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:b.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:s,fitViewResolver:null,connection:{...nc},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:nO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:nd,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}};function aF({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:a,initialMinZoom:i,initialMaxZoom:s,initialFitViewOptions:l,fitView:d,nodeOrigin:c,nodeExtent:u,zIndexMode:p,children:f}){let[h]=(0,I.useState)(()=>(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:l,maxZoom:d,nodeOrigin:c,nodeExtent:u,zIndexMode:p})=>{let f,h;return f=(f,h)=>{async function m(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:o,height:a,minZoom:i,maxZoom:s}=h();t&&(await nv({nodes:e,width:o,height:a,panZoom:t,minZoom:i,maxZoom:s},n),r?.resolve(!0),f({fitViewResolver:null}))}return{...aH({nodes:e,edges:t,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:l,maxZoom:d,nodeOrigin:c,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:o,fitViewQueued:a,zIndexMode:i}=h(),s=ru(e,t,n,{nodeOrigin:r,nodeExtent:u,elevateNodesOnSelect:o,checkEquality:!0,zIndexMode:i});a&&s?(m(),f({nodes:e,nodesInitialized:s,fitViewQueued:!1,fitViewOptions:void 0})):f({nodes:e,nodesInitialized:s})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=h();rx(t,n,e),f({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=h();t(e),f({hasDefaultNodes:!0})}if(t){let{setEdges:e}=h();e(t),f({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:o,nodeOrigin:a,nodeExtent:i,debug:s,fitViewQueued:l,zIndexMode:d}=h(),{changes:c,updatedInternals:u}=function(e,t,n,r,o,a,i){let s=r?.querySelector(".xyflow__viewport"),l=!1;if(!s)return{changes:[],updatedInternals:l};let d=[],c=window.getComputedStyle(s),{m22:u}=new window.DOMMatrixReadOnly(c.transform),p=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),l=!0;continue}let s=nG(r.nodeElement),c=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(c||!e.internals.handleBounds||r.force)){let f=r.nodeElement.getBoundingClientRect(),h=nB(e.extent)?e.extent:a,{positionAbsolute:m}=e.internals;e.parentId&&"parent"===e.extent?m=nC(m,s,t.get(e.parentId)):h&&(m=nS(m,h,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:m,handleBounds:{source:nQ("source",r.nodeElement,f,u,e.id),target:nQ("target",r.nodeElement,f,u,e.id)}}};t.set(e.id,g),e.parentId&&rp(g,t,n,{nodeOrigin:o,zIndexMode:i}),l=!0,c&&(d.push({id:e.id,type:"dimensions",dimensions:s}),e.expandParent&&e.parentId&&p.push({id:e.id,parentId:e.parentId,rect:nT(g,o)}))}}if(p.length>0){let e=rh(p,t,n,o);d.push(...e)}return{changes:d,updatedInternals:l}}(e,n,r,o,a,i,d);u&&(!function(e,t,n){let r=rd(rs,n);for(let n of e.values())if(n.parentId)rp(n,e,t,r);else{let e=nS(nm(n,r.nodeOrigin),nB(n.extent)?n.extent:r.nodeExtent,nV(n));n.internals.positionAbsolute=e}}(n,r,{nodeOrigin:a,nodeExtent:i,zIndexMode:d}),l?(m(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),c?.length>0&&(s&&console.log("React Flow: trigger node changes",c),t?.(c)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:o,triggerNodeChanges:a,connection:i,updateConnection:s,onNodesChangeMiddlewareMap:l}=h();for(let[a,l]of e){let e=o.get(a),d=!!(e?.expandParent&&e?.parentId&&l?.position),c={id:a,type:"position",position:d?{x:Math.max(0,l.position.x),y:Math.max(0,l.position.y)}:l.position,dragging:t};if(e&&i.inProgress&&i.fromNode.id===e.id){let t=ro(e,i.fromHandle,N.Left,!0);s({...i,from:t})}d&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...l.internals.positionAbsolute,width:l.measured.width??0,height:l.measured.height??0}}),r.push(c)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=h(),a=rh(n,o,e,t);r.push(...a)}for(let e of l.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:o,debug:a}=h();e?.length&&(o&&n(og(e,r)),a&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:o,debug:a}=h();e?.length&&(o&&n(og(e,r)),a&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:o,triggerEdgeChanges:a}=h();t?o(e.map(e=>ox(e,!0))):(o(ov(r,new Set([...e]),!0)),a(ov(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:o,triggerEdgeChanges:a}=h();t?a(e.map(e=>ox(e,!0))):(a(ov(n,new Set([...e]))),o(ov(r,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:o,triggerNodeChanges:a,triggerEdgeChanges:i}=h(),s=[];for(let t of e||r){if(!t.selected)continue;let e=o.get(t.id);e&&(e.selected=!1),s.push(ox(t.id,!1))}let l=[];for(let e of t||n)e.selected&&l.push(ox(e.id,!1));a(s),i(l)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=h();t?.setScaleExtent([e,n]),f({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=h();t?.setScaleExtent([n,e]),f({maxZoom:e})},setTranslateExtent:e=>{h().panZoom?.setTranslateExtent(e),f({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:o}=h();if(!o)return;let a=t.reduce((e,t)=>t.selected?[...e,ox(t.id,!1)]:e,[]),i=e.reduce((e,t)=>t.selected?[...e,ox(t.id,!1)]:e,[]);n(a),r(i)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:o,elevateNodesOnSelect:a,nodeExtent:i,zIndexMode:s}=h();(e[0][0]!==i[0][0]||e[0][1]!==i[0][1]||e[1][0]!==i[1][0]||e[1][1]!==i[1][1])&&(ru(t,n,r,{nodeOrigin:o,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),f({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:o,translateExtent:a}=h();return rm({delta:e,panZoom:o,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:o,maxZoom:a,panZoom:i}=h();if(!i)return Promise.resolve(!1);let s=void 0!==n?.zoom?n.zoom:a;return await i.setViewport({x:r/2-e*s,y:o/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...nc}})},updateConnection:e=>{f({connection:e})},reset:()=>f({...aH()})}},h=Object.is,f?rK(f,h):rK})({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:d,minZoom:i,maxZoom:s,fitViewOptions:l,nodeOrigin:c,nodeExtent:u,zIndexMode:p}));return(0,T.jsx)(rY,{value:h,children:(0,T.jsx)(oE,{children:f})})}function aB({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:a,height:i,fitView:s,fitViewOptions:l,minZoom:d,maxZoom:c,nodeOrigin:u,nodeExtent:p,zIndexMode:f}){return(0,I.useContext)(rG)?(0,T.jsx)(T.Fragment,{children:e}):(0,T.jsx)(aF,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:a,initialHeight:i,fitView:s,initialFitViewOptions:l,initialMinZoom:d,initialMaxZoom:c,nodeOrigin:u,nodeExtent:p,zIndexMode:f,children:e})}let aV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var aU=oS(function({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:a,edgeTypes:i,onNodeClick:s,onEdgeClick:l,onInit:d,onMove:c,onMoveStart:u,onMoveEnd:p,onConnect:f,onConnectStart:h,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:x,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:N,onNodeDragStart:E,onNodeDrag:k,onNodeDragStop:_,onNodesDelete:P,onEdgesDelete:M,onDelete:A,onSelectionChange:O,onSelectionDragStart:D,onSelectionDrag:L,onSelectionDragStop:z,onSelectionContextMenu:$,onSelectionStart:H,onSelectionEnd:F,onBeforeDelete:B,connectionMode:V,connectionLineType:U=C.Bezier,connectionLineStyle:K,connectionLineComponent:W,connectionLineContainerStyle:X,deleteKeyCode:G="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:q=!1,selectionMode:Z=S.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:Q=nF()?"Meta":"Control",zoomActivationKeyCode:ee=nF()?"Meta":"Control",snapToGrid:et,snapGrid:en,onlyRenderVisibleElements:er=!1,selectNodesOnDrag:eo,nodesDraggable:ea,autoPanOnNodeFocus:ei,nodesConnectable:es,nodesFocusable:el,nodeOrigin:ed=oa,edgesFocusable:ec,edgesReconnectable:eu,elementsSelectable:ep=!0,defaultViewport:ef=oi,minZoom:eh=.5,maxZoom:em=2,translateExtent:eg=ns,preventScrolling:ex=!0,nodeExtent:ev,defaultMarkerColor:ey="#b1b1b7",zoomOnScroll:eb=!0,zoomOnPinch:ew=!0,panOnScroll:eS=!1,panOnScrollSpeed:eC=.5,panOnScrollMode:ej=w.Free,zoomOnDoubleClick:eN=!0,panOnDrag:eE=!0,onPaneClick:ek,onPaneMouseEnter:e_,onPaneMouseMove:eT,onPaneMouseLeave:eI,onPaneScroll:eR,onPaneContextMenu:eP,paneClickDistance:eM=1,nodeClickDistance:eA=0,children:eO,onReconnect:eD,onReconnectStart:eL,onReconnectEnd:ez,onEdgeContextMenu:e$,onEdgeDoubleClick:eH,onEdgeMouseEnter:eF,onEdgeMouseMove:eB,onEdgeMouseLeave:eV,reconnectRadius:eU=10,onNodesChange:eK,onEdgesChange:eW,noDragClassName:eX="nodrag",noWheelClassName:eG="nowheel",noPanClassName:eY="nopan",fitView:eq,fitViewOptions:eZ,connectOnClick:eJ,attributionPosition:eQ,proOptions:e0,defaultEdgeOptions:e1,elevateNodesOnSelect:e2=!0,elevateEdgesOnSelect:e5=!1,disableKeyboardA11y:e3=!1,autoPanOnConnect:e4,autoPanOnNodeDrag:e6,autoPanSpeed:e8,connectionRadius:e9,isValidConnection:e7,onError:te,style:tt,id:tn,nodeDragThreshold:tr,connectionDragThreshold:to,viewport:ta,onViewportChange:ti,width:ts,height:tl,colorMode:td="light",debug:tc,onScroll:tu,ariaLabelConfig:tp,zIndexMode:tf="basic",...th},tm){let tg=tn||"1",tx=function(e){let[t,n]=(0,I.useState)("system"===e?null:e);return(0,I.useEffect)(()=>{if("system"!==e)return void n(e);let t=ou(),r=()=>n(t?.matches?"dark":"light");return r(),t?.addEventListener("change",r),()=>{t?.removeEventListener("change",r)}},[e]),null!==t?t:ou()?.matches?"dark":"light"}(td),tv=(0,I.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),tu?.(e)},[tu]);return(0,T.jsx)("div",{"data-testid":"rf__wrapper",...th,onScroll:tv,style:{...tt,...aV},ref:tm,className:R(["react-flow",o,tx]),id:tn,role:"application",children:(0,T.jsxs)(aB,{nodes:e,edges:t,width:ts,height:tl,fitView:eq,fitViewOptions:eZ,minZoom:eh,maxZoom:em,nodeOrigin:ed,nodeExtent:ev,zIndexMode:tf,children:[(0,T.jsx)(a$,{onInit:d,onNodeClick:s,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:N,nodeTypes:a,edgeTypes:i,connectionLineType:U,connectionLineStyle:K,connectionLineComponent:W,connectionLineContainerStyle:X,selectionKeyCode:Y,selectionOnDrag:q,selectionMode:Z,deleteKeyCode:G,multiSelectionKeyCode:Q,panActivationKeyCode:J,zoomActivationKeyCode:ee,onlyRenderVisibleElements:er,defaultViewport:ef,translateExtent:eg,minZoom:eh,maxZoom:em,preventScrolling:ex,zoomOnScroll:eb,zoomOnPinch:ew,zoomOnDoubleClick:eN,panOnScroll:eS,panOnScrollSpeed:eC,panOnScrollMode:ej,panOnDrag:eE,onPaneClick:ek,onPaneMouseEnter:e_,onPaneMouseMove:eT,onPaneMouseLeave:eI,onPaneScroll:eR,onPaneContextMenu:eP,paneClickDistance:eM,nodeClickDistance:eA,onSelectionContextMenu:$,onSelectionStart:H,onSelectionEnd:F,onReconnect:eD,onReconnectStart:eL,onReconnectEnd:ez,onEdgeContextMenu:e$,onEdgeDoubleClick:eH,onEdgeMouseEnter:eF,onEdgeMouseMove:eB,onEdgeMouseLeave:eV,reconnectRadius:eU,defaultMarkerColor:ey,noDragClassName:eX,noWheelClassName:eG,noPanClassName:eY,rfId:tg,disableKeyboardA11y:e3,nodeExtent:ev,viewport:ta,onViewportChange:ti}),(0,T.jsx)(oc,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:h,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:x,nodesDraggable:ea,autoPanOnNodeFocus:ei,nodesConnectable:es,nodesFocusable:el,edgesFocusable:ec,edgesReconnectable:eu,elementsSelectable:ep,elevateNodesOnSelect:e2,elevateEdgesOnSelect:e5,minZoom:eh,maxZoom:em,nodeExtent:ev,onNodesChange:eK,onEdgesChange:eW,snapToGrid:et,snapGrid:en,connectionMode:V,translateExtent:eg,connectOnClick:eJ,defaultEdgeOptions:e1,fitView:eq,fitViewOptions:eZ,onNodesDelete:P,onEdgesDelete:M,onDelete:A,onNodeDragStart:E,onNodeDrag:k,onNodeDragStop:_,onSelectionDrag:L,onSelectionDragStart:D,onSelectionDragStop:z,onMove:c,onMoveStart:u,onMoveEnd:p,noPanClassName:eY,nodeOrigin:ed,rfId:tg,autoPanOnConnect:e4,autoPanOnNodeDrag:e6,autoPanSpeed:e8,onError:te,connectionRadius:e9,isValidConnection:e7,selectNodesOnDrag:eo,nodeDragThreshold:tr,connectionDragThreshold:to,onBeforeDelete:B,debug:tc,ariaLabelConfig:tp,zIndexMode:tf}),(0,T.jsx)(oo,{onSelectionChange:O}),eO,(0,T.jsx)(r9,{proOptions:e0,position:eQ}),(0,T.jsx)(r6,{rfId:tg,disableKeyboardA11y:e3})]})})});function aK({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,T.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:R(["react-flow__background-pattern",n,r])})}function aW({radius:e,className:t}){return(0,T.jsx)("circle",{cx:e,cy:e,r:e,className:R(["react-flow__background-pattern","dots",t])})}(p=k||(k={})).Lines="lines",p.Dots="dots",p.Cross="cross";let aX={[k.Dots]:1,[k.Lines]:1,[k.Cross]:6},aG=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function aY({id:e,variant:t=k.Dots,gap:n=20,size:r,lineWidth:o=1,offset:a=0,color:i,bgColor:s,style:l,className:d,patternClassName:c}){let u=(0,I.useRef)(null),{transform:p,patternId:f}=rZ(aG,rW),h=r||aX[t],m=t===k.Dots,g=t===k.Cross,x=Array.isArray(n)?n:[n,n],v=[x[0]*p[2]||1,x[1]*p[2]||1],y=h*p[2],b=Array.isArray(a)?a:[a,a],w=g?[y,y]:v,S=[b[0]*p[2]||1+w[0]/2,b[1]*p[2]||1+w[1]/2],C=`${f}${e||""}`;return(0,T.jsxs)("svg",{className:R(["react-flow__background",d]),style:{...l,...oR,"--xy-background-color-props":s,"--xy-background-pattern-color-props":i},ref:u,"data-testid":"rf__background",children:[(0,T.jsx)("pattern",{id:C,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:m?(0,T.jsx)(aW,{radius:y/2,className:c}):(0,T.jsx)(aK,{dimensions:w,lineWidth:o,variant:t,className:c})}),(0,T.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}aY.displayName="Background";let aq=(0,I.memo)(aY);function aZ(){return(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,T.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function aJ(){return(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,T.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function aQ(){return(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,T.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function a0(){return(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,T.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function a1(){return(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,T.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function a2({children:e,className:t,...n}){return(0,T.jsx)("button",{type:"button",className:R(["react-flow__controls-button",t]),...n,children:e})}let a5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function a3({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:a,onZoomOut:i,onFitView:s,onInteractiveChange:l,className:d,children:c,position:u="bottom-left",orientation:p="vertical","aria-label":f}){let h=rJ(),{isInteractive:m,minZoomReached:g,maxZoomReached:x,ariaLabelConfig:v}=rZ(a5,rW),{zoomIn:y,zoomOut:b,fitView:w}=o_();return(0,T.jsxs)(r8,{className:R(["react-flow__controls","horizontal"===p?"horizontal":"vertical",d]),position:u,style:e,"data-testid":"rf__controls","aria-label":f??v["controls.ariaLabel"],children:[t&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(a2,{onClick:()=>{y(),a?.()},className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:x,children:(0,T.jsx)(aZ,{})}),(0,T.jsx)(a2,{onClick:()=>{b(),i?.()},className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:g,children:(0,T.jsx)(aJ,{})})]}),n&&(0,T.jsx)(a2,{className:"react-flow__controls-fitview",onClick:()=>{w(o),s?.()},title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:(0,T.jsx)(aQ,{})}),r&&(0,T.jsx)(a2,{className:"react-flow__controls-interactive",onClick:()=>{h.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),l?.(!m)},title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:m?(0,T.jsx)(a1,{}):(0,T.jsx)(a0,{})}),c]})}a3.displayName="Controls";let a4=(0,I.memo)(a3),a6=(0,I.memo)(function({id:e,x:t,y:n,width:r,height:o,style:a,color:i,strokeColor:s,strokeWidth:l,className:d,borderRadius:c,shapeRendering:u,selected:p,onClick:f}){let{background:h,backgroundColor:m}=a||{};return(0,T.jsx)("rect",{className:R(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:c,ry:c,width:r,height:o,style:{fill:i||h||m,stroke:s,strokeWidth:l},shapeRendering:u,onClick:f?t=>f(t,e):void 0})}),a8=e=>e.nodes.map(e=>e.id),a9=e=>e instanceof Function?e:()=>e,a7=(0,I.memo)(function({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:s,onClick:l}){let{node:d,x:c,y:u,width:p,height:f}=rZ(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:o,y:a}=n.internals.positionAbsolute,{width:i,height:s}=nV(r);return{node:r,x:o,y:a,width:i,height:s}},rW);return d&&!d.hidden&&nU(d)?(0,T.jsx)(s,{x:c,y:u,width:p,height:f,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:o,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:l,id:d.id}):null});var ie=(0,I.memo)(function({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:a=a6,onClick:i}){let s=rZ(a8,rW),l=a9(t),d=a9(e),c=a9(n),u="u"<typeof window||window.chrome?"crispEdges":"geometricPrecision";return(0,T.jsx)(T.Fragment,{children:s.map(e=>(0,T.jsx)(a7,{id:e,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:c,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:a,onClick:i,shapeRendering:u},e))})});let it=e=>!e.hidden,ir=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?nR(ng(e.nodeLookup,{filter:it}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}};function io({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:s,bgColor:l,maskColor:d,maskStrokeColor:c,maskStrokeWidth:u,position:p="bottom-right",onClick:f,onNodeClick:h,pannable:m=!1,zoomable:g=!1,ariaLabel:x,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let w=rJ(),S=(0,I.useRef)(null),{boundingRect:C,viewBB:j,rfId:N,panZoom:E,translateExtent:k,flowWidth:_,flowHeight:P,ariaLabelConfig:M}=rZ(ir,rW),A=e?.width??200,O=e?.height??150,D=Math.max(C.width/A,C.height/O),L=D*A,z=D*O,$=b*D,H=C.x-(L-C.width)/2-$,F=C.y-(z-C.height)/2-$,B=L+2*$,V=z+2*$,U=`react-flow__minimap-desc-${N}`,K=(0,I.useRef)(0),W=(0,I.useRef)();K.current=D,(0,I.useEffect)(()=>{if(S.current&&E)return W.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let o=eC(e);return{update:function({translateExtent:e,width:a,height:i,zoomStep:s=1,pannable:l=!0,zoomable:d=!0,inversePan:c=!1}){let u=[0,0],p=na().on("start",e=>{("mousedown"===e.sourceEvent.type||"touchstart"===e.sourceEvent.type)&&(u=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on("zoom",l?o=>{let s=n();if("mousemove"!==o.sourceEvent.type&&"touchmove"!==o.sourceEvent.type||!t)return;let l=[o.sourceEvent.clientX??o.sourceEvent.touches[0].clientX,o.sourceEvent.clientY??o.sourceEvent.touches[0].clientY],d=[l[0]-u[0],l[1]-u[1]];u=l;let p=r()*Math.max(s[2],Math.log(s[2]))*(c?-1:1),f={x:s[0]-d[0]*p,y:s[1]-d[1]*p};t.setViewportConstrained({x:f.x,y:f.y,zoom:s[2]},[[0,0],[a,i]],e)}:null).on("zoom.wheel",d?e=>{if("wheel"!==e.sourceEvent.type||!t)return;let r=n(),o=e.sourceEvent.ctrlKey&&nF()?10:1,a=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*s,i=r[2]*Math.pow(2,a*o);t.scaleTo(i)}:null);o.call(p,{})},destroy:function(){o.on("zoom",null)},pointer:ej}}({domNode:S.current,panZoom:E,getTransform:()=>w.getState().transform,getViewScale:()=>K.current}),()=>{W.current?.destroy()}},[E]),(0,I.useEffect)(()=>{W.current?.update({translateExtent:k,width:_,height:P,inversePan:v,pannable:m,zoomStep:y,zoomable:g})},[m,g,v,y,k,_,P]);let X=f?e=>{let[t,n]=W.current?.pointer(e)||[0,0];f(e,{x:t,y:n})}:void 0,G=h?(0,I.useCallback)((e,t)=>{h(e,w.getState().nodeLookup.get(t).internals.userNode)},[]):void 0,Y=x??M["minimap.ariaLabel"];return(0,T.jsx)(r8,{position:p,style:{...e,"--xy-minimap-background-color-props":"string"==typeof l?l:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof c?c:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof u?u*D:void 0,"--xy-minimap-node-background-color-props":"string"==typeof r?r:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof n?n:void 0,"--xy-minimap-node-stroke-width-props":"number"==typeof i?i:void 0},className:R(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,T.jsxs)("svg",{width:A,height:O,viewBox:`${H} ${F} ${B} ${V}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":U,ref:S,onClick:X,children:[Y&&(0,T.jsx)("title",{id:U,children:Y}),(0,T.jsx)(ie,{onClick:G,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:s}),(0,T.jsx)("path",{className:"react-flow__minimap-mask",d:`M${H-$},${F-$}h${B+2*$}v${V+2*$}h${-B-2*$}z
2
- M${j.x},${j.y}h${j.width}v${j.height}h${-j.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}io.displayName="MiniMap";let ia=(0,I.memo)(io),ii={[E.Line]:"right",[E.Handle]:"bottom-right"};(0,I.memo)(function({nodeId:e,position:t,variant:n=E.Handle,className:r,style:o,children:a,color:i,minWidth:s=10,minHeight:l=10,maxWidth:d=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:f=!0,shouldResize:h,onResizeStart:m,onResize:g,onResizeEnd:x}){let v,y=oU(),b="string"==typeof e?e:y,w=rJ(),S=(0,I.useRef)(null),C=n===E.Handle,j=rZ((0,I.useCallback)((v=C&&f,e=>v?`${Math.max(1/e.transform[2],1)}`:void 0),[C,f]),rW),N=(0,I.useRef)(null),k=t??ii[n];(0,I.useEffect)(()=>{if(S.current&&b)return N.current||(N.current=function({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){let a=eC(e),i={controlDirection:rP("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:s,keepAspectRatio:l,resizeDirection:d,onResizeStart:c,onResize:u,onResizeEnd:p,shouldResize:f}){let h,m,g,x,v={...rD},y={...rL};i={boundaries:s,resizeDirection:d,keepAspectRatio:l,controlDirection:rP(e)};let b=null,w=[],S=!1,C=eL().on("start",e=>{let{nodeLookup:r,transform:o,snapGrid:a,snapToGrid:i,nodeOrigin:s,paneDomNode:l}=n();if(!(h=r.get(t)))return;b=l?.getBoundingClientRect()??null;let{xSnapped:d,ySnapped:u}=nX(e.sourceEvent,{transform:o,snapGrid:a,snapToGrid:i,containerBounds:b});if(y={...v={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},pointerX:d,pointerY:u,aspectRatio:v.width/v.height},m=void 0,h.parentId&&("parent"===h.extent||h.expandParent)){var p;g=(m=r.get(h.parentId))&&"parent"===h.extent?[[0,0],[(p=m).measured.width,p.measured.height]]:void 0}for(let[e,n]of(w=[],x=void 0,r))if(n.parentId===t&&(w.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let r=t.position.x+e.position.x,o=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,s=n[0]*a,l=n[1]*i;return[[r-s,o-l],[r+a-s,o+i-l]]}(n,h,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}c?.(e,{...v})}).on("drag",e=>{let{transform:t,snapGrid:o,snapToGrid:a,nodeOrigin:s}=n(),l=nX(e.sourceEvent,{transform:t,snapGrid:o,snapToGrid:a,containerBounds:b}),d=[];if(!h)return;let{x:c,y:p,width:C,height:j}=v,N={},E=h.origin??s,{width:k,height:_,x:T,y:I}=function(e,t,n,r,o,a,i,s){var l,d,c,u;let{affectsX:p,affectsY:f}=t,{isHorizontal:h,isVertical:m}=t,g=h&&m,{xSnapped:x,ySnapped:v}=n,{minWidth:y,maxWidth:b,minHeight:w,maxHeight:S}=r,{x:C,y:j,width:N,height:E,aspectRatio:k}=e,_=Math.floor(h?x-e.pointerX:0),T=Math.floor(m?v-e.pointerY:0),I=N+(p?-_:_),R=E+(f?-T:T),P=-a[0]*N,M=-a[1]*E,A=rO(I,y,b),O=rO(R,w,S);if(i){let e=0,t=0;p&&_<0?e=rM(C+_+P,i[0][0]):!p&&_>0&&(e=rA(C+I+P,i[1][0])),f&&T<0?t=rM(j+T+M,i[0][1]):!f&&T>0&&(t=rA(j+R+M,i[1][1])),A=Math.max(A,e),O=Math.max(O,t)}if(s){let e=0,t=0;p&&_>0?e=rA(C+_,s[0][0]):!p&&_<0&&(e=rM(C+I,s[1][0])),f&&T>0?t=rA(j+T,s[0][1]):!f&&T<0&&(t=rM(j+R,s[1][1])),A=Math.max(A,e),O=Math.max(O,t)}if(o){if(h){(A=Math.max(A,rO(I/k,w,S)*k),i)&&(A=Math.max(A,(p||f)&&(!p||f||!g)?rM(j+M+(p?_:-_)/k,i[0][1])*k:rA(j+M+I/k,i[1][1])*k));s&&(A=Math.max(A,(p||f)&&(!p||f||!g)?rA(j+(p?_:-_)/k,s[0][1])*k:rM(j+I/k,s[1][1])*k))}if(m){(O=Math.max(O,rO(R*k,y,b)/k),i)&&(O=Math.max(O,(p||f)&&(!f||p||!g)?rM(C+(f?T:-T)*k+P,i[0][0])/k:rA(C+R*k+P,i[1][0])/k));s&&(O=Math.max(O,(p||f)&&(!f||p||!g)?rA(C+(f?T:-T)*k,s[0][0])/k:rM(C+R*k,s[1][0])/k))}}T+=T<0?O:-O,_+=_<0?A:-A,o&&(g?I>R*k?T=((l=p,d=f,l?!d:d)?-_:_)/k:_=((c=p,u=f,c?!u:u)?-T:T)*k:h?(T=_/k,f=p):(_=T*k,p=f));let D=p?C+_:C,L=f?j+T:j;return{width:N+(p?-_:_),height:E+(f?-T:T),x:a[0]*_*(p?-1:1)+D,y:a[1]*T*(f?-1:1)+L}}(y,i.controlDirection,l,i.boundaries,i.keepAspectRatio,E,g,x),R=k!==C,P=_!==j,M=T!==c&&R,A=I!==p&&P;if(!M&&!A&&!R&&!P)return;if((M||A||1===E[0]||1===E[1])&&(N.x=M?T:v.x,N.y=A?I:v.y,v.x=N.x,v.y=N.y,w.length>0)){let e=T-c,t=I-p;for(let n of w)n.position={x:n.position.x-e+E[0]*(k-C),y:n.position.y-t+E[1]*(_-j)},d.push(n)}if((R||P)&&(N.width=R&&(!i.resizeDirection||"horizontal"===i.resizeDirection)?k:v.width,N.height=P&&(!i.resizeDirection||"vertical"===i.resizeDirection)?_:v.height,v.width=N.width,v.height=N.height),m&&h.expandParent){let e=E[0]*(N.width??0);N.x&&N.x<e&&(v.x=e,y.x=y.x-(N.x-e));let t=E[1]*(N.height??0);N.y&&N.y<t&&(v.y=t,y.y=y.y-(N.y-t))}let O=function({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:a}){let i=e-t,s=n-r,l=[i>0?1:i<0?-1:0,s>0?1:s<0?-1:0];return i&&o&&(l[0]=-1*l[0]),s&&a&&(l[1]=-1*l[1]),l}({width:v.width,prevWidth:C,height:v.height,prevHeight:j,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),D={...v,direction:O};!1!==f?.(e,D)&&(S=!0,u?.(e,D),r(N,d))}).on("end",e=>{S&&(p?.(e,{...v}),o?.({...v}),S=!1)});a.call(C)},destroy:function(){a.on(".drag",null)}}}({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:o,domNode:a}=w.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:o,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:o,nodeOrigin:a}=w.getState(),i=[],s={x:e.x,y:e.y},l=r.get(b);if(l&&l.expandParent&&l.parentId){let t=l.origin??a,n=e.width??l.measured.width??0,d=e.height??l.measured.height??0,c=rh([{id:l.id,parentId:l.parentId,rect:{width:n,height:d,...nK({x:e.x??l.position.x,y:e.y??l.position.y},{width:n,height:d},l.parentId,r,t)}}],r,o,a);i.push(...c),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*d,e.y):void 0}if(void 0!==s.x&&void 0!==s.y){let e={id:b,type:"position",position:{...s}};i.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:b,type:"dimensions",resizing:!0,setAttributes:!p||("horizontal"===p?"width":"height"),dimensions:{width:e.width,height:e.height}};i.push(t)}for(let e of t){let t={...e,type:"position"};i.push(t)}n(i)},onEnd:({width:e,height:t})=>{w.getState().triggerNodeChanges([{id:b,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),N.current.update({controlPosition:k,boundaries:{minWidth:s,minHeight:l,maxWidth:d,maxHeight:c},keepAspectRatio:u,resizeDirection:p,onResizeStart:m,onResize:g,onResizeEnd:x,shouldResize:h}),()=>{N.current?.destroy()}},[k,s,l,d,c,u,m,g,x,h]);let _=k.split("-");return(0,T.jsx)("div",{className:R(["react-flow__resize-control","nodrag",..._,n,r]),ref:S,style:{...o,scale:j,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})});let is=e=>{let t,n=new Set,r=(e,r)=>{let o="function"==typeof e?e(t):e;if(!Object.is(o,t)){let e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>i,subscribe:e=>(n.add(e),()=>n.delete(e))},i=t=e(r,o,a);return a},il=e=>{let t=e?is(e):is,n=e=>(function(e,t=e=>e){let n=I.default.useSyncExternalStore(e.subscribe,I.default.useCallback(()=>t(e.getState()),[e,t]),I.default.useCallback(()=>t(e.getInitialState()),[e,t]));return I.default.useDebugValue(n),n})(t,e);return Object.assign(n,t),n},id=e=>e?il(e):il;var ic=e.i(68773);class iu{definitions=new Map;register(e){this.definitions.set(e.nodeType,e)}registerAll(e){for(let t of e)this.register(t)}get(e){return this.definitions.get(e)}getAll(){return[...this.definitions.values()]}getByCategory(e){return this.getAll().filter(t=>t.category===e)}getRegisteredTypes(){return[...this.definitions.keys()]}has(e){return this.definitions.has(e)}unregister(e){return this.definitions.delete(e)}clear(){this.definitions.clear()}getDefaultPorts(e){let t=this.definitions.get(e);return t?.defaultPorts??{inputs:[],outputs:[]}}getDefaultParams(e){let t=this.definitions.get(e);return t?.defaultParams??{}}getDefaultLabel(e){let t=this.definitions.get(e);return t?.label??"Unknown"}getCategoryForType(e){let t=this.definitions.get(e);return t?.category??ic.NodeCategory.ACTION}getGroupedDefinitions(){let e={[ic.NodeCategory.TRIGGER]:{icon:"⚡",color:"text-emerald-400",name:"Triggers"},[ic.NodeCategory.ACTION]:{icon:"🔧",color:"text-blue-400",name:"Actions"},[ic.NodeCategory.LOGIC]:{icon:"🔀",color:"text-amber-400",name:"Logic Control"},[ic.NodeCategory.VARIABLE]:{icon:"📦",color:"text-purple-400",name:"Variables"},[ic.NodeCategory.OUTPUT]:{icon:"📤",color:"text-rose-400",name:"Output"}},t={};for(let n of this.getAll().sort((e,t)=>(e.order??100)-(t.order??100))){let r=e[n.category],o=n.group??r?.name??n.category;t[o]||(t[o]={icon:r?.icon??"📦",color:r?.color??"text-gray-400",templates:[]}),t[o].templates.push({nodeType:n.nodeType,label:n.label,icon:n.icon,category:n.category})}return t}}let ip=new iu,ih=[{nodeType:ic.TriggerType.HTTP_WEBHOOK,category:ic.NodeCategory.TRIGGER,label:"HTTP Webhook",icon:"🌐",description:"Listen for HTTP requests",order:1,defaultPorts:{inputs:[],outputs:[{id:"request",label:"Request",dataType:"object"},{id:"body",label:"Body",dataType:"object"},{id:"query",label:"Query",dataType:"object"}]},defaultParams:{method:"POST",routePath:"/api/endpoint",parseBody:!0}},{nodeType:ic.TriggerType.CRON_JOB,category:ic.NodeCategory.TRIGGER,label:"Cron Job",icon:"⏰",description:"Scheduled cron trigger",order:2,defaultPorts:{inputs:[],outputs:[{id:"output",label:"Output",dataType:"any"}]},defaultParams:{schedule:"0 * * * *",functionName:"cronHandler"}},{nodeType:ic.TriggerType.MANUAL,category:ic.NodeCategory.TRIGGER,label:"Manual Trigger",icon:"👤",description:"Manual trigger",order:3,defaultPorts:{inputs:[],outputs:[{id:"output",label:"Output",dataType:"any"}]},defaultParams:{functionName:"handler",args:[]}},{nodeType:ic.ActionType.FETCH_API,category:ic.NodeCategory.ACTION,label:"Fetch API",icon:"📡",description:"Call external HTTP API",order:10,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"response",label:"Response",dataType:"object"},{id:"data",label:"Data",dataType:"any"}]},defaultParams:{url:"https://api.example.com",method:"GET",parseJson:!0}},{nodeType:ic.ActionType.SQL_QUERY,category:ic.NodeCategory.ACTION,label:"SQL Query",icon:"🗄️",description:"Execute SQL query",order:11,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"result",label:"Result",dataType:"array"}]},defaultParams:{orm:"drizzle",query:"SELECT * FROM users",params:[]}},{nodeType:ic.ActionType.REDIS_CACHE,category:ic.NodeCategory.ACTION,label:"Redis Cache",icon:"💾",description:"Access Redis cache",order:12,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"value",label:"Value",dataType:"any"}]},defaultParams:{operation:"get",key:"cache_key"}},{nodeType:ic.ActionType.CUSTOM_CODE,category:ic.NodeCategory.ACTION,label:"Custom Code",icon:"💻",description:"Custom TypeScript code",order:13,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"result",label:"Result",dataType:"any"}]},defaultParams:{code:"// your code here",returnVariable:"result"}},{nodeType:ic.ActionType.CALL_SUBFLOW,category:ic.NodeCategory.ACTION,label:"Call Subflow",icon:"🔗",description:"Call subflow",order:14,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"result",label:"Result",dataType:"any"}]},defaultParams:{flowPath:"./sub-flow",functionName:"subHandler",inputMapping:{}}},{nodeType:ic.LogicType.IF_ELSE,category:ic.NodeCategory.LOGIC,label:"If / Else",icon:"🔀",description:"Conditional branch",order:20,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!0}],outputs:[{id:"true",label:"True",dataType:"any"},{id:"false",label:"False",dataType:"any"}]},defaultParams:{condition:"data !== null"}},{nodeType:ic.LogicType.FOR_LOOP,category:ic.NodeCategory.LOGIC,label:"For Loop",icon:"🔁",description:"Iterate array",order:21,defaultPorts:{inputs:[{id:"iterable",label:"Iterable",dataType:"array",required:!0}],outputs:[{id:"item",label:"Item",dataType:"any"},{id:"result",label:"Result",dataType:"array"}]},defaultParams:{iterableExpression:"items",itemVariable:"item"}},{nodeType:ic.LogicType.TRY_CATCH,category:ic.NodeCategory.LOGIC,label:"Try / Catch",icon:"🛡️",description:"Error handling wrapper",order:22,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!0}],outputs:[{id:"success",label:"Success",dataType:"any"},{id:"error",label:"Error",dataType:"object"}]},defaultParams:{errorVariable:"error"}},{nodeType:ic.LogicType.PROMISE_ALL,category:ic.NodeCategory.LOGIC,label:"Promise.all",icon:"⚡",description:"Execute multiple async tasks in parallel",order:23,defaultPorts:{inputs:[{id:"task1",label:"Task 1",dataType:"any",required:!0},{id:"task2",label:"Task 2",dataType:"any",required:!0}],outputs:[{id:"results",label:"Results",dataType:"array"}]},defaultParams:{}},{nodeType:ic.VariableType.DECLARE,category:ic.NodeCategory.VARIABLE,label:"Declare Variable",icon:"📦",description:"Declare variable",order:30,defaultPorts:{inputs:[],outputs:[{id:"value",label:"Value",dataType:"any"}]},defaultParams:{name:"myVar",dataType:"string",isConst:!0,initialValue:"''"}},{nodeType:ic.VariableType.TRANSFORM,category:ic.NodeCategory.VARIABLE,label:"Transform",icon:"🔄",description:"Transform data",order:31,defaultPorts:{inputs:[{id:"input",label:"Input",dataType:"any",required:!0}],outputs:[{id:"output",label:"Output",dataType:"any"}]},defaultParams:{expression:"input.map(x => x)"}},{nodeType:ic.OutputType.RETURN_RESPONSE,category:ic.NodeCategory.OUTPUT,label:"Return Response",icon:"📤",description:"Return HTTP response",order:40,defaultPorts:{inputs:[{id:"data",label:"Data",dataType:"any",required:!0}],outputs:[]},defaultParams:{statusCode:200,bodyExpression:"{{$input}}"}}];function im(e){return ip.getDefaultPorts(e)}function ig(e){return ip.getDefaultParams(e)}function ix(e){return ip.getDefaultLabel(e)}ip.registerAll(ih);let iv=0;function iy(e,t){return{nodes:e.map(e=>({...e,data:structuredClone(e.data)})),edges:t.map(e=>({...e}))}}let ib=function(e=50){return(t,n)=>({undoStack:[],redoStack:[],pushSnapshot:r=>{let o=[...n().undoStack,r];o.length>e&&o.shift(),t({undoStack:o,redoStack:[]})},undo:e=>{let{undoStack:r}=n();if(0===r.length)return null;let o=r[r.length-1];return t({undoStack:r.slice(0,-1),redoStack:[...n().redoStack,e]}),o},redo:e=>{let{redoStack:r}=n();if(0===r.length)return null;let o=r[r.length-1];return t({redoStack:r.slice(0,-1),undoStack:[...n().undoStack,e]}),o},canUndo:()=>n().undoStack.length>0,canRedo:()=>n().redoStack.length>0,clearHistory:()=>{t({undoStack:[],redoStack:[]})}})}(50),iw=id((...e)=>{let[t,n]=e;return{...ib(...e),nodes:[],edges:[],selectedNodeId:null,flowCreatedAt:null,flowHistory:[],pushHistory:e=>{let{nodes:r,edges:o,flowHistory:a}=n();if(0===r.length&&0===o.length)return;let i=[...a,{id:`hist_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:e,timestamp:new Date().toISOString(),nodeCount:r.length,edgeCount:o.length,snapshot:iy(r,o)}];i.length>30&&i.shift(),t({flowHistory:i})},restoreFromHistory:e=>{let r=n().flowHistory.find(t=>t.id===e);if(!r)return;let{nodes:o,edges:a}=n();o.length>0&&n().pushHistory("Before restore"),n().pushSnapshot(iy(o,a)),t({nodes:r.snapshot.nodes.map(e=>({...e,data:{...e.data}})),edges:r.snapshot.edges.map(e=>({...e}))})},clearFlowHistory:()=>{t({flowHistory:[]})},snapshot:()=>{n().pushSnapshot(iy(n().nodes,n().edges))},undoFlow:()=>{let e=n().undo(iy(n().nodes,n().edges));e&&t({nodes:e.nodes,edges:e.edges})},redoFlow:()=>{let e=n().redo(iy(n().nodes,n().edges));e&&t({nodes:e.nodes,edges:e.edges})},onNodesChange:e=>{e.some(e=>"remove"===e.type)&&n().pushSnapshot(iy(n().nodes,n().edges)),t({nodes:og(e,n().nodes)})},onEdgesChange:e=>{e.some(e=>"remove"===e.type)&&n().pushSnapshot(iy(n().nodes,n().edges)),t({edges:og(e,n().edges)})},onConnect:e=>{n().snapshot(),t({edges:n6(e,n().edges)})},addFlowNode:(e,r,o)=>{n().snapshot();let a=`node_${++iv}_${Date.now()}`,i=ip.getCategoryForType(e),{inputs:s,outputs:l}=im(e),d=ig(e),c=ix(e);return t({nodes:[...n().nodes,{id:a,type:"flowNode",position:o,data:{nodeType:e,category:i,label:c,params:d,inputs:s,outputs:l}}],flowCreatedAt:n().flowCreatedAt??new Date().toISOString()}),a},updateNodeParams:(e,r)=>{t({nodes:n().nodes.map(t=>t.id===e?{...t,data:{...t.data,params:{...t.data.params,...r}}}:t)})},updateNodeLabel:(e,r)=>{t({nodes:n().nodes.map(t=>t.id===e?{...t,data:{...t.data,label:r}}:t)})},selectNode:e=>{t({selectedNodeId:e})},removeNode:e=>{n().snapshot(),t({nodes:n().nodes.filter(t=>t.id!==e),edges:n().edges.filter(t=>t.source!==e&&t.target!==e),selectedNodeId:n().selectedNodeId===e?null:n().selectedNodeId})},removeSelectedNodes:()=>{let e=n().nodes.filter(e=>e.selected).map(e=>e.id),r=n().edges.filter(e=>e.selected).map(e=>e.id);if(0===e.length&&0===r.length)return;n().snapshot();let o=new Set(e),a=new Set(r);t({nodes:n().nodes.filter(e=>!o.has(e.id)),edges:n().edges.filter(e=>!o.has(e.source)&&!o.has(e.target)&&!a.has(e.id)),selectedNodeId:o.has(n().selectedNodeId??"")?null:n().selectedNodeId})},removeSelectedEdges:()=>{let e=n().edges.filter(e=>e.selected);if(0===e.length)return;n().snapshot();let r=new Set(e.map(e=>e.id));t({edges:n().edges.filter(e=>!r.has(e.id))})},getSelectedNodeIds:()=>n().nodes.filter(e=>e.selected).map(e=>e.id),exportIR:()=>{let{nodes:e,edges:t}=n(),r=e.map(e=>({id:e.id,nodeType:e.data.nodeType,category:e.data.category,label:e.data.label,params:e.data.params,inputs:e.data.inputs,outputs:e.data.outputs})),o=t.map(e=>({id:e.id,sourceNodeId:e.source,sourcePortId:e.sourceHandle??"output",targetNodeId:e.target,targetPortId:e.targetHandle??"input"}));return{version:"1.0.0",meta:{name:"Untitled Flow",description:"",createdAt:n().flowCreatedAt??new Date().toISOString(),updatedAt:new Date().toISOString()},nodes:r,edges:o}},reset:()=>{n().nodes.length>0&&n().pushHistory("Before reset"),iv=0,n().clearHistory(),t({nodes:[],edges:[],selectedNodeId:null,flowCreatedAt:null})},loadIR:e=>{let r=n().nodes,o=n().edges,a=e.meta?.name??"Untitled";r.length>0&&n().pushHistory(`Before loading "${a}"`),n().pushSnapshot(iy(r,o)),iv=e.nodes.reduce((e,t)=>{let n=t.id.match(/^node_(\d+)/);return n?Math.max(e,Number(n[1])):e},e.nodes.length),t({nodes:e.nodes.map((e,t)=>{let n=im(e.nodeType);return{id:e.id,type:"flowNode",position:{x:100+t%3*300,y:100+200*Math.floor(t/3)},data:{nodeType:e.nodeType,category:e.category,label:e.label??ix(e.nodeType),params:e.params??ig(e.nodeType),inputs:e.inputs??n.inputs,outputs:e.outputs??n.outputs}}}),edges:e.edges.map(e=>({id:e.id,source:e.sourceNodeId,sourceHandle:e.sourcePortId,target:e.targetNodeId,targetHandle:e.targetPortId,type:"smoothstep"})),selectedNodeId:null,flowCreatedAt:e.meta?.createdAt??new Date().toISOString()})}}}),iS={[ic.NodeCategory.TRIGGER]:{bar:"#22c55e",color:"#22c55e"},[ic.NodeCategory.ACTION]:{bar:"#3b82f6",color:"#3b82f6"},[ic.NodeCategory.LOGIC]:{bar:"#eab308",color:"#eab308"},[ic.NodeCategory.VARIABLE]:{bar:"#a855f7",color:"#a855f7"},[ic.NodeCategory.OUTPUT]:{bar:"#f43f5e",color:"#f43f5e"}},iC={[ic.NodeCategory.TRIGGER]:"TRIGGER",[ic.NodeCategory.ACTION]:"ACTION",[ic.NodeCategory.LOGIC]:"LOGIC",[ic.NodeCategory.VARIABLE]:"VARIABLE",[ic.NodeCategory.OUTPUT]:"OUTPUT"},ij=(0,I.memo)(function({data:e,selected:t}){let n=iS[e.category]??iS[ic.NodeCategory.ACTION],r=iC[e.category]??"NODE",o=e.inputs??[],a=e.outputs??[],i=Math.max(o.length,a.length,0);return(0,T.jsxs)("div",{className:"flex group",style:{minWidth:220,maxWidth:300},children:[(0,T.jsx)("div",{className:"w-[3px] rounded-l-md shrink-0",style:{background:n.bar}}),(0,T.jsxs)("div",{className:["flex-1 rounded-r-md border border-l-0 bg-[oklch(0.17_0_0)] border-[oklch(0.25_0_0)]",t?"ring-1 ring-white/20 border-[oklch(0.35_0_0)]":"","transition-[border-color,box-shadow] duration-150"].join(" "),children:[(0,T.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 pt-2.5 pb-1",children:[(0,T.jsx)("span",{className:"text-[13px] font-medium text-[oklch(0.93_0_0)] leading-tight truncate",children:e.label}),(0,T.jsx)("span",{className:"text-[9px] tracking-wider font-semibold shrink-0 px-1.5 py-0.5 rounded",style:{color:n.color,background:`color-mix(in oklch, ${n.color} 12%, transparent)`},children:r})]}),(0,T.jsx)("div",{className:"px-3 pb-1.5",children:(0,T.jsx)("span",{className:"font-mono text-[11px] text-[oklch(0.5_0_0)]",children:e.nodeType})}),i>0&&(0,T.jsx)("div",{className:"border-t border-[oklch(0.22_0_0)] px-3 py-1.5 flex flex-col gap-0.5",children:Array.from({length:i},(e,t)=>(0,T.jsxs)("div",{className:"flex items-center justify-between text-[10px] text-[oklch(0.55_0_0)]",children:[(0,T.jsx)("span",{children:o[t]?.label??""}),(0,T.jsx)("span",{children:a[t]?.label??""})]},t))})]}),o.map((e,t)=>{let r=i>0?`calc(56px + ${16*t}px + 8px)`:`${28+18*t}px`;return(0,T.jsx)(oW,{type:"target",position:N.Left,id:e.id,style:{top:r,left:-1,width:8,height:8,borderRadius:2,background:n.color,border:"none"},title:`${e.label} (${e.dataType})`},`in-${e.id}`)}),a.map((e,t)=>{let r=i>0?`calc(56px + ${16*t}px + 8px)`:`${28+18*t}px`;return(0,T.jsx)(oW,{type:"source",position:N.Right,id:e.id,style:{top:r,right:-1,width:8,height:8,borderRadius:2,background:n.color,border:"none"},title:`${e.label} (${e.dataType})`},`out-${e.id}`)})]})});var iN=e.i(7284);let iE=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,ik=iN.clsx,i_=(e,t)=>n=>{var r;if((null==t?void 0:t.variants)==null)return ik(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(e=>{let t=null==n?void 0:n[e],r=null==a?void 0:a[e];if(null===t)return null;let i=iE(t)||iE(r);return o[e][i]}),s=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{});return ik(e,i,null==t||null==(r=t.compoundVariants)?void 0:r.reduce((e,t)=>{let{class:n,className:r,...o}=t;return Object.entries(o).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...a,...s}[t]):({...a,...s})[t]===n})?[...e,n,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)};var iT=e.i(60310),iT=iT,iI=e.i(75157);let iR=i_("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function iP({className:e,variant:t="default",size:n="default",asChild:r=!1,...o}){let a=r?iT.Root:"button";return(0,T.jsx)(a,{"data-slot":"button","data-variant":t,"data-size":n,className:(0,iI.cn)(iR({variant:t,size:n,className:e})),...o})}var iM=e.i(38169),iA=e.i(49874),iO=e.i(62497),iD=e.i(29779),iL=e.i(39325),iz=I.createContext(void 0);function i$(e){let t=I.useContext(iz);return e||t||"ltr"}var iH=e.i(50694);function iF(e,[t,n]){return Math.min(n,Math.max(t,e))}var iB=e.i(91967),iV="ScrollArea",[iU,iK]=(0,iO.createContextScope)(iV),[iW,iX]=iU(iV),iG=I.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...i}=e,[s,l]=I.useState(null),[d,c]=I.useState(null),[u,p]=I.useState(null),[f,h]=I.useState(null),[m,g]=I.useState(null),[x,v]=I.useState(0),[y,b]=I.useState(0),[w,S]=I.useState(!1),[C,j]=I.useState(!1),N=(0,iD.useComposedRefs)(t,e=>l(e)),E=i$(o);return(0,T.jsx)(iW,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:d,onViewportChange:c,content:u,onContentChange:p,scrollbarX:f,onScrollbarXChange:h,scrollbarXEnabled:w,onScrollbarXEnabledChange:S,scrollbarY:m,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:j,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,T.jsx)(iM.Primitive.div,{dir:E,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});iG.displayName=iV;var iY="ScrollAreaViewport",iq=I.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:o,...a}=e,i=iX(iY,n),s=I.useRef(null),l=(0,iD.useComposedRefs)(t,s,i.onViewportChange);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),(0,T.jsx)(iM.Primitive.div,{"data-radix-scroll-area-viewport":"",...a,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,T.jsx)("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});iq.displayName=iY;var iZ="ScrollAreaScrollbar",iJ=I.forwardRef((e,t)=>{let{forceMount:n,...r}=e,o=iX(iZ,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,s="horizontal"===e.orientation;return I.useEffect(()=>(s?a(!0):i(!0),()=>{s?a(!1):i(!1)}),[s,a,i]),"hover"===o.type?(0,T.jsx)(iQ,{...r,ref:t,forceMount:n}):"scroll"===o.type?(0,T.jsx)(i0,{...r,ref:t,forceMount:n}):"auto"===o.type?(0,T.jsx)(i1,{...r,ref:t,forceMount:n}):"always"===o.type?(0,T.jsx)(i2,{...r,ref:t}):null});iJ.displayName=iZ;var iQ=I.forwardRef((e,t)=>{let{forceMount:n,...r}=e,o=iX(iZ,e.__scopeScrollArea),[a,i]=I.useState(!1);return I.useEffect(()=>{let e=o.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),i(!0)},r=()=>{t=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}},[o.scrollArea,o.scrollHideDelay]),(0,T.jsx)(iA.Presence,{present:n||a,children:(0,T.jsx)(i1,{"data-state":a?"visible":"hidden",...r,ref:t})})}),i0=I.forwardRef((e,t)=>{var n;let{forceMount:r,...o}=e,a=iX(iZ,e.__scopeScrollArea),i="horizontal"===e.orientation,s=sc(()=>d("SCROLL_END"),100),[l,d]=(n={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},I.useReducer((e,t)=>n[e][t]??e,"hidden"));return I.useEffect(()=>{if("idle"===l){let e=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[l,a.scrollHideDelay,d]),I.useEffect(()=>{let e=a.viewport,t=i?"scrollLeft":"scrollTop";if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(d("SCROLL"),s()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[a.viewport,i,d,s]),(0,T.jsx)(iA.Presence,{present:r||"hidden"!==l,children:(0,T.jsx)(i2,{"data-state":"hidden"===l?"hidden":"visible",...o,ref:t,onPointerEnter:(0,iB.composeEventHandlers)(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:(0,iB.composeEventHandlers)(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),i1=I.forwardRef((e,t)=>{let n=iX(iZ,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,i]=I.useState(!1),s="horizontal"===e.orientation,l=sc(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;i(s?e:t)}},10);return su(n.viewport,l),su(n.content,l),(0,T.jsx)(iA.Presence,{present:r||a,children:(0,T.jsx)(i2,{"data-state":a?"visible":"hidden",...o,ref:t})})}),i2=I.forwardRef((e,t)=>{let{orientation:n="vertical",...r}=e,o=iX(iZ,e.__scopeScrollArea),a=I.useRef(null),i=I.useRef(0),[s,l]=I.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=sa(s.viewport,s.content),c={...r,sizes:s,onSizesChange:l,hasThumb:!!(d>0&&d<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function u(e,t){return function(e,t,n,r="ltr"){let o=si(n),a=t||o/2,i=n.scrollbar.paddingStart+a,s=n.scrollbar.size-n.scrollbar.paddingEnd-(o-a),l=n.content-n.viewport;return sl([i,s],"ltr"===r?[0,l]:[-1*l,0])(e)}(e,i.current,s,t)}return"horizontal"===n?(0,T.jsx)(i5,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){let e=ss(o.viewport.scrollLeft,s,o.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=u(e,o.dir))}}):"vertical"===n?(0,T.jsx)(i3,{...c,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){let e=ss(o.viewport.scrollTop,s);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=u(e))}}):null}),i5=I.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...o}=e,a=iX(iZ,e.__scopeScrollArea),[i,s]=I.useState(),l=I.useRef(null),d=(0,iD.useComposedRefs)(t,l,a.onScrollbarXChange);return I.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),(0,T.jsx)(i8,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":si(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){var r,o;let i=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(i),r=i,o=n,r>0&&r<o&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:so(i.paddingLeft),paddingEnd:so(i.paddingRight)}})}})}),i3=I.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...o}=e,a=iX(iZ,e.__scopeScrollArea),[i,s]=I.useState(),l=I.useRef(null),d=(0,iD.useComposedRefs)(t,l,a.onScrollbarYChange);return I.useEffect(()=>{l.current&&s(getComputedStyle(l.current))},[l]),(0,T.jsx)(i8,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":si(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){var r,o;let i=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(i),r=i,o=n,r>0&&r<o&&t.preventDefault()}},onResize:()=>{l.current&&a.viewport&&i&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:so(i.paddingTop),paddingEnd:so(i.paddingBottom)}})}})}),[i4,i6]=iU(iZ),i8=I.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:s,onThumbPositionChange:l,onDragScroll:d,onWheelScroll:c,onResize:u,...p}=e,f=iX(iZ,n),[h,m]=I.useState(null),g=(0,iD.useComposedRefs)(t,e=>m(e)),x=I.useRef(null),v=I.useRef(""),y=f.viewport,b=r.content-r.viewport,w=(0,iL.useCallbackRef)(c),S=(0,iL.useCallbackRef)(l),C=sc(u,10);function j(e){x.current&&d({x:e.clientX-x.current.left,y:e.clientY-x.current.top})}return I.useEffect(()=>{let e=e=>{let t=e.target;h?.contains(t)&&w(e,b)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[y,h,b,w]),I.useEffect(S,[r,S]),su(h,C),su(f.content,C),(0,T.jsx)(i4,{scope:n,scrollbar:h,hasThumb:o,onThumbChange:(0,iL.useCallbackRef)(a),onThumbPointerUp:(0,iL.useCallbackRef)(i),onThumbPositionChange:S,onThumbPointerDown:(0,iL.useCallbackRef)(s),children:(0,T.jsx)(iM.Primitive.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:(0,iB.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),x.current=h.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(e))}),onPointerMove:(0,iB.composeEventHandlers)(e.onPointerMove,j),onPointerUp:(0,iB.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,f.viewport&&(f.viewport.style.scrollBehavior=""),x.current=null})})})}),i9="ScrollAreaThumb",i7=I.forwardRef((e,t)=>{let{forceMount:n,...r}=e,o=i6(i9,e.__scopeScrollArea);return(0,T.jsx)(iA.Presence,{present:n||o.hasThumb,children:(0,T.jsx)(se,{ref:t,...r})})}),se=I.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...o}=e,a=iX(i9,n),i=i6(i9,n),{onThumbPositionChange:s}=i,l=(0,iD.useComposedRefs)(t,e=>i.onThumbChange(e)),d=I.useRef(void 0),c=sc(()=>{d.current&&(d.current(),d.current=void 0)},100);return I.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{c(),d.current||(d.current=sd(e,s),s())};return s(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[a.viewport,c,s]),(0,T.jsx)(iM.Primitive.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:(0,iB.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;i.onThumbPointerDown({x:n,y:r})}),onPointerUp:(0,iB.composeEventHandlers)(e.onPointerUp,i.onThumbPointerUp)})});i7.displayName=i9;var st="ScrollAreaCorner",sn=I.forwardRef((e,t)=>{let n=iX(st,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?(0,T.jsx)(sr,{...e,ref:t}):null});sn.displayName=st;var sr=I.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,o=iX(st,n),[a,i]=I.useState(0),[s,l]=I.useState(0),d=!!(a&&s);return su(o.scrollbarX,()=>{let e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),l(e)}),su(o.scrollbarY,()=>{let e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),i(e)}),d?(0,T.jsx)(iM.Primitive.div,{...r,ref:t,style:{width:a,height:s,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null});function so(e){return e?parseInt(e,10):0}function sa(e,t){let n=e/t;return isNaN(n)?0:n}function si(e){let t=sa(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-n)*t,18)}function ss(e,t,n="ltr"){let r=si(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,s=iF(e,"ltr"===n?[0,i]:[-1*i,0]);return sl([0,i],[0,a-r])(s)}function sl(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}var sd=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return!function o(){let a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,s=n.top!==a.top;(i||s)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function sc(e,t){let n=(0,iL.useCallbackRef)(e),r=I.useRef(0);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),I.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function su(e,t){let n=(0,iL.useCallbackRef)(t);(0,iH.useLayoutEffect)(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}e.s(["Corner",()=>sn,"Root",()=>iG,"ScrollArea",()=>iG,"ScrollAreaCorner",()=>sn,"ScrollAreaScrollbar",()=>iJ,"ScrollAreaThumb",()=>i7,"ScrollAreaViewport",()=>iq,"Scrollbar",()=>iJ,"Thumb",()=>i7,"Viewport",()=>iq,"createScrollAreaScope",()=>iK],40045);var sp=e.i(40045),sp=sp;function sf({className:e,children:t,...n}){return(0,T.jsxs)(sp.Root,{"data-slot":"scroll-area",className:(0,iI.cn)("relative",e),...n,children:[(0,T.jsx)(sp.Viewport,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,T.jsx)(sh,{}),(0,T.jsx)(sp.Corner,{})]})}function sh({className:e,orientation:t="vertical",...n}){return(0,T.jsx)(sp.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,iI.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,T.jsx)(sp.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var sm="horizontal",sg=["horizontal","vertical"],sx=I.forwardRef((e,t)=>{var n;let{decorative:r,orientation:o=sm,...a}=e,i=(n=o,sg.includes(n))?o:sm;return(0,T.jsx)(iM.Primitive.div,{"data-orientation":i,...r?{role:"none"}:{"aria-orientation":"vertical"===i?i:void 0,role:"separator"},...a,ref:t})});sx.displayName="Separator",e.s(["Root",()=>sx,"Separator",()=>sx],7102);var sv=e.i(7102),sv=sv;function sy({className:e,orientation:t="horizontal",decorative:n=!0,...r}){return(0,T.jsx)(sv.Root,{"data-slot":"separator",decorative:n,orientation:t,className:(0,iI.cn)("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...r})}var sb=e.i(46798),sw=e.i(16671),sS=e.i(11207),sC="Collapsible",[sj,sN]=(0,iO.createContextScope)(sC),[sE,sk]=sj(sC),s_=I.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:a,onOpenChange:i,...s}=e,[l,d]=(0,sw.useControllableState)({prop:r,defaultProp:o??!1,onChange:i,caller:sC});return(0,T.jsx)(sE,{scope:n,disabled:a,contentId:(0,sS.useId)(),open:l,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),children:(0,T.jsx)(iM.Primitive.div,{"data-state":sA(l),"data-disabled":a?"":void 0,...s,ref:t})})});s_.displayName=sC;var sT="CollapsibleTrigger",sI=I.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,o=sk(sT,n);return(0,T.jsx)(iM.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:(0,iB.composeEventHandlers)(e.onClick,o.onOpenToggle)})});sI.displayName=sT;var sR="CollapsibleContent",sP=I.forwardRef((e,t)=>{let{forceMount:n,...r}=e,o=sk(sR,e.__scopeCollapsible);return(0,T.jsx)(iA.Presence,{present:n||o.open,children:({present:e})=>(0,T.jsx)(sM,{...r,ref:t,present:e})})});sP.displayName=sR;var sM=I.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:o,...a}=e,i=sk(sR,n),[s,l]=I.useState(r),d=I.useRef(null),c=(0,iD.useComposedRefs)(t,d),u=I.useRef(0),p=u.current,f=I.useRef(0),h=f.current,m=i.open||s,g=I.useRef(m),x=I.useRef(void 0);return I.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,iH.useLayoutEffect)(()=>{let e=d.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,f.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),l(r)}},[i.open,r]),(0,T.jsx)(iM.Primitive.div,{"data-state":sA(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!m,...a,ref:c,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:m&&o})});function sA(e){return e?"open":"closed"}e.s(["Collapsible",()=>s_,"CollapsibleContent",()=>sP,"CollapsibleTrigger",()=>sI,"Content",()=>sP,"Root",()=>s_,"Trigger",()=>sI,"createCollapsibleScope",()=>sN],69593);var sO=e.i(69593),sO=sO;function sD({...e}){return(0,T.jsx)(sO.Root,{"data-slot":"collapsible",...e})}function sL({...e}){return(0,T.jsx)(sO.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function sz({...e}){return(0,T.jsx)(sO.CollapsibleContent,{"data-slot":"collapsible-content",...e})}function s$(){let e=iw(e=>e.addFlowNode),[t,n]=(0,I.useState)(!1),r=(0,I.useMemo)(()=>ip.getGroupedDefinitions(),[]);return(0,T.jsxs)("div",{className:`bg-card border-r border-border flex flex-col shrink-0 transition-all duration-300 ease-in-out overflow-hidden ${t?"w-12":"w-56"}`,children:[(0,T.jsxs)("div",{className:`flex flex-col items-center py-3 gap-2 transition-opacity duration-200 ${t?"opacity-100":"opacity-0 hidden"}`,children:[(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"icon",className:"w-8 h-8 text-lg",onClick:()=>n(!1),children:"»"})}),(0,T.jsx)(sb.TooltipContent,{side:"right",children:"Expand Node Library"})]}),(0,T.jsx)(sy,{className:"w-6"}),Object.entries(r).map(([e,t])=>(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)("span",{className:"text-sm cursor-default",children:t.icon})}),(0,T.jsx)(sb.TooltipContent,{side:"right",children:e})]},e))]}),(0,T.jsxs)("div",{className:`flex flex-col flex-1 min-w-0 transition-opacity duration-200 ${t?"opacity-0 hidden":"opacity-100"}`,children:[(0,T.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border",children:[(0,T.jsx)("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wider whitespace-nowrap",children:"Node Library"}),(0,T.jsx)(iP,{variant:"ghost",size:"icon",className:"w-6 h-6 text-muted-foreground hover:text-foreground",onClick:()=>n(!0),children:"«"})]}),(0,T.jsx)(sf,{className:"flex-1",children:(0,T.jsx)("div",{className:"p-2 flex flex-col gap-1",children:Object.entries(r).map(([t,n])=>(0,T.jsxs)(sD,{defaultOpen:!0,children:[(0,T.jsxs)(sL,{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs font-semibold text-muted-foreground hover:text-foreground w-full rounded-md hover:bg-accent transition-colors cursor-pointer",children:[(0,T.jsx)("span",{children:n.icon}),(0,T.jsx)("span",{className:n.color,children:t})]}),(0,T.jsx)(sz,{children:(0,T.jsx)("div",{className:"flex flex-col gap-0.5 py-0.5 pl-2",children:n.templates.map(t=>(0,T.jsxs)("button",{onClick:()=>{let n,r;return n=200+300*Math.random(),r=100+400*Math.random(),void e(t.nodeType,t.category,{x:n,y:r})},className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer text-left group",children:[(0,T.jsx)("span",{className:"text-sm group-hover:scale-110 transition-transform",children:t.icon}),(0,T.jsx)("span",{children:t.label})]},t.nodeType))})})]},t))})})]})]})}let sH=(t=new Map,{register(e){t.set(e.nodeType,e)},registerAll(e){for(let n of e)t.set(n.nodeType,n)},get:e=>t.get(e),has:e=>t.has(e),getAll:()=>new Map(t),clear(){t.clear()}}),sF={entries:[],interfaceCode:"",hasTypes:!1};function sB(e){let t=iw(e=>e.nodes),n=iw(e=>e.edges);return(0,I.useMemo)(()=>{if(!e||0===t.length)return sF;let r=function(e,t){let n=new Map;for(let e of t){let t=n.get(e.target)??[];t.push(e.source),n.set(e.target,t)}let r=new Set,o=[e];for(;o.length>0;){let e=o.shift();for(let t of n.get(e)??[])r.has(t)||(r.add(t),o.push(t))}return r}(e,n),o=t.filter(e=>r.has(e.id));if(0===o.length)return sF;let a=o.map(e=>({id:e.id,nodeType:e.data.nodeType,category:e.data.category,label:e.data.label,params:e.data.params,inputs:e.data.inputs,outputs:e.data.outputs})),i=new Set(a.map(e=>e.id)),s=n.filter(e=>i.has(e.source)&&i.has(e.target)).map(e=>({id:e.id,sourceNodeId:e.source,sourcePortId:e.sourceHandle??"output",targetNodeId:e.target,targetPortId:e.targetHandle??"input"})),l={version:ic.CURRENT_IR_VERSION,meta:{name:"_partial",createdAt:"",updatedAt:""},nodes:a,edges:s};try{let{interfaceCode:e,nodeTypes:t}=function(e,t){let n=new Map;for(let t of e.nodes){let e=function(e,t){var n;let r=t?.get(e.nodeType)??(n=e.nodeType,sH.get(n));return r?.getOutputType?r.getOutputType(e):e.outputs&&e.outputs.length>0?function(e){switch(e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":return"unknown[]";case"void":return"void";case"Response":return"Response";default:return"unknown"}}(e.outputs[0].dataType):"unknown"}(t,void 0);n.set(t.id,e)}let r=e.nodes.map(e=>{let t=n.get(e.id)||"unknown",r=e.id;return` '${r}'?: ${t};`}).join("\n");return{interfaceCode:`interface FlowState {
3
- ${r}
4
- }`,nodeTypes:n}}(l),n=a.map(e=>({nodeId:e.id,label:e.label,nodeType:e.nodeType,tsType:t.get(e.id)??"unknown"}));return{entries:n,interfaceCode:e,hasTypes:n.length>0}}catch{return sF}},[e,t,n])}function sV({className:e,type:t,...n}){return(0,T.jsx)("input",{type:t,"data-slot":"input",className:(0,iI.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}var sU=I.forwardRef((e,t)=>(0,T.jsx)(iM.Primitive.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));sU.displayName="Label",e.s(["Label",()=>sU,"Root",()=>sU],42600);var sK=e.i(42600),sK=sK;function sW({className:e,...t}){return(0,T.jsx)(sK.Root,{"data-slot":"label",className:(0,iI.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function sX({className:e,...t}){return(0,T.jsx)("textarea",{"data-slot":"textarea",className:(0,iI.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var iT=iT;let sG=i_("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function sY({className:e,variant:t="default",asChild:n=!1,...r}){let o=n?iT.Root:"span";return(0,T.jsx)(o,{"data-slot":"badge","data-variant":t,className:(0,iI.cn)(sG({variant:t}),e),...r})}let sq=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),sZ=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var sJ={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let sQ=(0,I.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...s},l)=>(0,I.createElement)("svg",{ref:l,...sJ,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:sq("lucide",o),...!a&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(s)&&{"aria-hidden":"true"},...s},[...i.map(([e,t])=>(0,I.createElement)(e,t)),...Array.isArray(a)?a:[a]])),s0=(e,t)=>{let n=(0,I.forwardRef)(({className:n,...r},o)=>(0,I.createElement)(sQ,{ref:o,iconNode:t,className:sq(`lucide-${sZ(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r}));return n.displayName=sZ(e),n},s1=s0("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),s2=s0("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),s5=s0("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var s3=iT;function s4(e){let t=e+"CollectionProvider",[n,r]=(0,iO.createContextScope)(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=e=>{let{scope:t,children:n}=e,r=I.default.useRef(null),a=I.default.useRef(new Map).current;return(0,T.jsx)(o,{scope:t,itemMap:a,collectionRef:r,children:n})};i.displayName=t;let s=e+"CollectionSlot",l=(0,s3.createSlot)(s),d=I.default.forwardRef((e,t)=>{let{scope:n,children:r}=e,o=a(s,n),i=(0,iD.useComposedRefs)(t,o.collectionRef);return(0,T.jsx)(l,{ref:i,children:r})});d.displayName=s;let c=e+"CollectionItemSlot",u="data-radix-collection-item",p=(0,s3.createSlot)(c),f=I.default.forwardRef((e,t)=>{let{scope:n,children:r,...o}=e,i=I.default.useRef(null),s=(0,iD.useComposedRefs)(t,i),l=a(c,n);return I.default.useEffect(()=>(l.itemMap.set(i,{ref:i,...o}),()=>void l.itemMap.delete(i))),(0,T.jsx)(p,{...{[u]:""},ref:s,children:r})});return f.displayName=c,[{Provider:i,Slot:d,ItemSlot:f},function(t){let n=a(e+"CollectionConsumer",t);return I.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},r]}var s6=new WeakMap;function s8(e,t){var n,r;let o,a,i;if("at"in Array.prototype)return Array.prototype.at.call(e,t);let s=(n=e,r=t,o=n.length,(i=(a=s9(r))>=0?a:o+a)<0||i>=o?-1:i);return -1===s?void 0:e[s]}function s9(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],s6.set(this,!0)}set(e,t){return s6.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r,o=this.has(t),a=this.#e.length,i=s9(e),s=i>=0?i:a+i,l=s<0||s>=a?-1:s;if(l===this.size||o&&l===this.size-1||-1===l)return this.set(t,n),this;let d=this.size+ +!o;i<0&&s++;let c=[...this.#e],u=!1;for(let e=s;e<d;e++)if(s===e){let a=c[e];c[e]===t&&(a=c[e+1]),o&&this.delete(t),r=this.get(a),this.set(t,n)}else{u||c[e-1]!==t||(u=!0);let n=c[u?e:e-1],o=r;r=this.get(n),this.delete(n),this.set(n,o)}return this}with(t,n,r){let o=new e(this);return o.insert(t,n,r),o}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=s8(this.#e,e);if(void 0!==t)return this.get(t)}entryAt(e){let t=s8(this.#e,e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return s8(this.#e,e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return -1}filter(t,n){let r=[],o=0;for(let e of this)Reflect.apply(t,n,[e,o,this])&&r.push(e),o++;return new e(r)}map(t,n){let r=[],o=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,o,this])]),o++;return new e(r)}reduce(...e){let[t,n]=e,r=0,o=n??this.at(0);for(let n of this)o=0===r&&1===e.length?n:Reflect.apply(t,this,[o,n,r,this]),r++;return o}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let o=this.at(n);r=n===this.size-1&&1===e.length?o:Reflect.apply(t,this,[r,o,n,this])}return r}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,o=this.size-1;if(void 0===t)return r;t<0&&(t+=this.size),void 0!==n&&n>0&&(o=n-1);for(let e=t;e<=o;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}});var s7=e.i(5840),le=0;function lt(){I.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ln()),document.body.insertAdjacentElement("beforeend",e[1]??ln()),le++,()=>{1===le&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),le--}},[])}function ln(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var lr="focusScope.autoFocusOnMount",lo="focusScope.autoFocusOnUnmount",la={bubbles:!1,cancelable:!0},li=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[s,l]=I.useState(null),d=(0,iL.useCallbackRef)(o),c=(0,iL.useCallbackRef)(a),u=I.useRef(null),p=(0,iD.useComposedRefs)(t,e=>l(e)),f=I.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;I.useEffect(()=>{if(r){let e=function(e){if(f.paused||!s)return;let t=e.target;s.contains(t)?u.current=t:ld(u.current,{select:!0})},t=function(e){if(f.paused||!s)return;let t=e.relatedTarget;null!==t&&(s.contains(t)||ld(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&ld(s)});return s&&n.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[r,s,f.paused]),I.useEffect(()=>{if(s){lc.add(f);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(lr,la);s.addEventListener(lr,d),s.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(ld(r,{select:t}),document.activeElement!==n)return}(ls(s).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&ld(s))}return()=>{s.removeEventListener(lr,d),setTimeout(()=>{let t=new CustomEvent(lo,la);s.addEventListener(lo,c),s.dispatchEvent(t),t.defaultPrevented||ld(e??document.body,{select:!0}),s.removeEventListener(lo,c),lc.remove(f)},0)}}},[s,d,c,f]);let h=I.useCallback(e=>{if(!n&&!r||f.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,o=document.activeElement;if(t&&o){var a;let t,r=e.currentTarget,[i,s]=[ll(t=ls(a=r),a),ll(t.reverse(),a)];i&&s?e.shiftKey||o!==s?e.shiftKey&&o===i&&(e.preventDefault(),n&&ld(s,{select:!0})):(e.preventDefault(),n&&ld(i,{select:!0})):o===r&&e.preventDefault()}},[n,r,f.paused]);return(0,T.jsx)(iM.Primitive.div,{tabIndex:-1,...i,ref:p,onKeyDown:h})});function ls(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ll(e,t){for(let n of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function ld(e,{select:t=!1}={}){if(e&&e.focus){var n;let r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}li.displayName="FocusScope";var lc=(o=[],{add(e){let t=o[0];e!==t&&t?.pause(),(o=lu(o,e)).unshift(e)},remove(e){o=lu(o,e),o[0]?.resume()}});function lu(e,t){let n=[...e],r=n.indexOf(t);return -1!==r&&n.splice(r,1),n}var lp=e.i(60008),lf=e.i(54340),lh=iT,lm=e.i(50014),lg=new WeakMap,lx=new WeakMap,lv={},ly=0,lb=function(e){return e&&(e.host||lb(e.parentNode))},lw=function(e,t,n,r){var o=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=lb(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});lv[n]||(lv[n]=new WeakMap);var a=lv[n],i=[],s=new Set,l=new Set(o),d=function(e){!e||s.has(e)||(s.add(e),d(e.parentNode))};o.forEach(d);var c=function(e){!e||l.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))c(e);else try{var t=e.getAttribute(r),o=null!==t&&"false"!==t,l=(lg.get(e)||0)+1,d=(a.get(e)||0)+1;lg.set(e,l),a.set(e,d),i.push(e),1===l&&o&&lx.set(e,!0),1===d&&e.setAttribute(n,"true"),o||e.setAttribute(r,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),s.clear(),ly++,function(){i.forEach(function(e){var t=lg.get(e)-1,o=a.get(e)-1;lg.set(e,t),a.set(e,o),t||(lx.has(e)||e.removeAttribute(r),lx.delete(e)),o||e.removeAttribute(n)}),--ly||(lg=new WeakMap,lg=new WeakMap,lx=new WeakMap,lv={})}},lS=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=t||("u"<typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),lw(r,o,n,"aria-hidden")):function(){return null}},lC=function(){return(lC=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function lj(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)0>t.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}var lN=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),lE="width-before-scroll-bar";function lk(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var l_="u">typeof window?I.useLayoutEffect:I.useEffect,lT=new WeakMap,lI=(void 0===f&&(f={}),(void 0===h&&(h=function(e){return e}),m=[],g=!1,x={read:function(){if(g)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return m.length?m[m.length-1]:null},useMedium:function(e){var t=h(e,g);return m.push(t),function(){m=m.filter(function(e){return e!==t})}},assignSyncMedium:function(e){for(g=!0;m.length;){var t=m;m=[],t.forEach(e)}m={push:function(t){return e(t)},filter:function(){return m}}},assignMedium:function(e){g=!0;var t=[];if(m.length){var n=m;m=[],n.forEach(e),t=m}var r=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(r)};o(),m={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),m}}}}).options=lC({async:!0,ssr:!1},f),x),lR=function(){},lP=I.forwardRef(function(e,t){var n,r,o,a,i=I.useRef(null),s=I.useState({onScrollCapture:lR,onWheelCapture:lR,onTouchMoveCapture:lR}),l=s[0],d=s[1],c=e.forwardProps,u=e.children,p=e.className,f=e.removeScrollBar,h=e.enabled,m=e.shards,g=e.sideCar,x=e.noRelative,v=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,S=e.gapMode,C=lj(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=(n=[i,t],r=function(e){return n.forEach(function(t){return lk(t,e)})},(o=(0,I.useState)(function(){return{value:null,callback:r,facade:{get current(){return o.value},set current(value){var e=o.value;e!==value&&(o.value=value,o.callback(value,e))}}}})[0]).callback=r,a=o.facade,l_(function(){var e=lT.get(a);if(e){var t=new Set(e),r=new Set(n),o=a.current;t.forEach(function(e){r.has(e)||lk(e,null)}),r.forEach(function(e){t.has(e)||lk(e,o)})}lT.set(a,n)},[n]),a),N=lC(lC({},C),l);return I.createElement(I.Fragment,null,h&&I.createElement(g,{sideCar:lI,removeScrollBar:f,shards:m,noRelative:x,noIsolation:v,inert:y,setCallbacks:d,allowPinchZoom:!!b,lockRef:i,gapMode:S}),c?I.cloneElement(I.Children.only(u),lC(lC({},N),{ref:j})):I.createElement(void 0===w?"div":w,lC({},N,{className:p,ref:j}),u))});lP.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},lP.classNames={fullWidth:lE,zeroRight:lN};var lM=function(e){var t=e.sideCar,n=lj(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error("Sidecar medium not found");return I.createElement(r,lC({},n))};lM.isSideCarExport=!0;var lA=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=_||("u">typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var r,o;(r=t).styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n)),o=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(o)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lO=function(){var e=lA();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lD=function(){var e=lO();return function(t){return e(t.styles,t.dynamic),null}},lL={left:0,top:0,right:0,gap:0},lz=function(e){return parseInt(e||"",10)||0},l$=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[lz(n),lz(r),lz(o)]},lH=function(e){if(void 0===e&&(e="margin"),"u"<typeof window)return lL;var t=l$(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},lF=lD(),lB="data-scroll-locked",lV=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(s,"px ").concat(r,";\n }\n body[").concat(lB,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(i,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(s,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(s,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(lN," {\n right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(lE," {\n margin-right: ").concat(s,"px ").concat(r,";\n }\n \n .").concat(lN," .").concat(lN," {\n right: 0 ").concat(r,";\n }\n \n .").concat(lE," .").concat(lE," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(lB,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(s,"px;\n }\n")},lU=function(){var e=parseInt(document.body.getAttribute(lB)||"0",10);return isFinite(e)?e:0},lK=function(){I.useEffect(function(){return document.body.setAttribute(lB,(lU()+1).toString()),function(){var e=lU()-1;e<=0?document.body.removeAttribute(lB):document.body.setAttribute(lB,e.toString())}},[])},lW=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=void 0===r?"margin":r;lK();var a=I.useMemo(function(){return lH(o)},[o]);return I.createElement(lF,{styles:lV(a,!t,o,n?"":"!important")})},lX=!1;if("u">typeof window)try{var lG=Object.defineProperty({},"passive",{get:function(){return lX=!0,!0}});window.addEventListener("test",lG,lG),window.removeEventListener("test",lG,lG)}catch(e){lX=!1}var lY=!!lX&&{passive:!1},lq=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},lZ=function(e,t){var n=t.ownerDocument,r=t;do{if("u">typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),lJ(e,r)){var o=lQ(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body)return!1},lJ=function(e,t){return"v"===e?lq(t,"overflowY"):lq(t,"overflowX")},lQ=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},l0=function(e,t,n,r,o){var a,i=(a=window.getComputedStyle(t).direction,"h"===e&&"rtl"===a?-1:1),s=i*r,l=n.target,d=t.contains(l),c=!1,u=s>0,p=0,f=0;do{if(!l)break;var h=lQ(e,l),m=h[0],g=h[1]-h[2]-i*m;(m||g)&&lJ(e,l)&&(p+=g,f+=m);var x=l.parentNode;l=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!d&&l!==document.body||d&&(t.contains(l)||t===l))return u&&(o&&1>Math.abs(p)||!o&&s>p)?c=!0:!u&&(o&&1>Math.abs(f)||!o&&-s>f)&&(c=!0),c},l1=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},l2=function(e){return[e.deltaX,e.deltaY]},l5=function(e){return e&&"current"in e?e.current:e},l3=0,l4=[];let l6=(v=function(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),o=I.useState(l3++)[0],a=I.useState(lD)[0],i=I.useRef(e);I.useEffect(function(){i.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var t=(function(e,t,n){if(n||2==arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(l5),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=I.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!i.current.allowPinchZoom;var o,a=l1(e),s=n.current,l="deltaX"in e?e.deltaX:s[0]-a[0],d="deltaY"in e?e.deltaY:s[1]-a[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var p=window.getSelection(),f=p&&p.anchorNode;if(f&&(f===c||f.contains(c)))return!1;var h=lZ(u,c);if(!h)return!0;if(h?o=u:(o="v"===u?"h":"v",h=lZ(u,c)),!h)return!1;if(!r.current&&"changedTouches"in e&&(l||d)&&(r.current=o),!o)return!0;var m=r.current||o;return l0(m,t,e,"h"===m?l:d,!0)},[]),l=I.useCallback(function(e){if(l4.length&&l4[l4.length-1]===a){var n="deltaY"in e?l2(e):l1(e),r=t.current.filter(function(t){var r;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(r=t.delta,r[0]===n[0]&&r[1]===n[1])})[0];if(r&&r.should){e.cancelable&&e.preventDefault();return}if(!r){var o=(i.current.shards||[]).map(l5).filter(Boolean).filter(function(t){return t.contains(e.target)});(o.length>0?s(e,o[0]):!i.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=I.useCallback(function(e,n,r,o){var a={name:e,delta:n,target:r,should:o,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),c=I.useCallback(function(e){n.current=l1(e),r.current=void 0},[]),u=I.useCallback(function(t){d(t.type,l2(t),t.target,s(t,e.lockRef.current))},[]),p=I.useCallback(function(t){d(t.type,l1(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return l4.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:p}),document.addEventListener("wheel",l,lY),document.addEventListener("touchmove",l,lY),document.addEventListener("touchstart",c,lY),function(){l4=l4.filter(function(e){return e!==a}),document.removeEventListener("wheel",l,lY),document.removeEventListener("touchmove",l,lY),document.removeEventListener("touchstart",c,lY)}},[]);var f=e.removeScrollBar,h=e.inert;return I.createElement(I.Fragment,null,h?I.createElement(a,{styles:"\n .block-interactivity-".concat(o," {pointer-events: none;}\n .allow-interactivity-").concat(o," {pointer-events: all;}\n")}):null,f?I.createElement(lW,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},lI.useMedium(v),lM);var l8=I.forwardRef(function(e,t){return I.createElement(lP,lC({},e,{ref:t,sideCar:l6}))});l8.classNames=lP.classNames;var l9=[" ","Enter","ArrowUp","ArrowDown"],l7=[" ","Enter"],de="Select",[dt,dn,dr]=s4(de),[da,di]=(0,iO.createContextScope)(de,[dr,lp.createPopperScope]),ds=(0,lp.createPopperScope)(),[dl,dd]=da(de),[dc,du]=da(de),dp=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:s,onValueChange:l,dir:d,name:c,autoComplete:u,disabled:p,required:f,form:h}=e,m=ds(t),[g,x]=I.useState(null),[v,y]=I.useState(null),[b,w]=I.useState(!1),S=i$(d),[C,j]=(0,sw.useControllableState)({prop:r,defaultProp:o??!1,onChange:a,caller:de}),[N,E]=(0,sw.useControllableState)({prop:i,defaultProp:s,onChange:l,caller:de}),k=I.useRef(null),_=!g||h||!!g.closest("form"),[R,P]=I.useState(new Set),M=Array.from(R).map(e=>e.props.value).join(";");return(0,T.jsx)(lp.Root,{...m,children:(0,T.jsxs)(dl,{required:f,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:(0,sS.useId)(),value:N,onValueChange:E,open:C,onOpenChange:j,dir:S,triggerPointerDownPosRef:k,disabled:p,children:[(0,T.jsx)(dt.Provider,{scope:t,children:(0,T.jsx)(dc,{scope:e.__scopeSelect,onNativeOptionAdd:I.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:I.useCallback(e=>{P(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),_?(0,T.jsxs)(dQ,{"aria-hidden":!0,required:f,tabIndex:-1,name:c,autoComplete:u,value:N,onChange:e=>E(e.target.value),disabled:p,form:h,children:[void 0===N?(0,T.jsx)("option",{value:""}):null,Array.from(R)]},M):null]})})};dp.displayName=de;var df="SelectTrigger",dh=I.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...o}=e,a=ds(n),i=dd(df,n),s=i.disabled||r,l=(0,iD.useComposedRefs)(t,i.onTriggerChange),d=dn(n),c=I.useRef("touch"),[u,p,f]=d1(e=>{let t=d().filter(e=>!e.disabled),n=t.find(e=>e.value===i.value),r=d2(t,e,n);void 0!==r&&i.onValueChange(r.value)}),h=e=>{s||(i.onOpenChange(!0),f()),e&&(i.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,T.jsx)(lp.Anchor,{asChild:!0,...a,children:(0,T.jsx)(iM.Primitive.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:s,"data-disabled":s?"":void 0,"data-placeholder":d0(i.value)?"":void 0,...o,ref:l,onClick:(0,iB.composeEventHandlers)(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==c.current&&h(e)}),onPointerDown:(0,iB.composeEventHandlers)(o.onPointerDown,e=>{c.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(h(e),e.preventDefault())}),onKeyDown:(0,iB.composeEventHandlers)(o.onKeyDown,e=>{let t=""!==u.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),(!t||" "!==e.key)&&l9.includes(e.key)&&(h(),e.preventDefault())})})})});dh.displayName=df;var dm="SelectValue",dg=I.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...s}=e,l=dd(dm,n),{onValueNodeHasChildrenChange:d}=l,c=void 0!==a,u=(0,iD.useComposedRefs)(t,l.onValueNodeChange);return(0,iH.useLayoutEffect)(()=>{d(c)},[d,c]),(0,T.jsx)(iM.Primitive.span,{...s,ref:u,style:{pointerEvents:"none"},children:d0(l.value)?(0,T.jsx)(T.Fragment,{children:i}):a})});dg.displayName=dm;var dx=I.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...o}=e;return(0,T.jsx)(iM.Primitive.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});dx.displayName="SelectIcon";var dv=e=>(0,T.jsx)(lf.Portal,{asChild:!0,...e});dv.displayName="SelectPortal";var dy="SelectContent",db=I.forwardRef((e,t)=>{let n=dd(dy,e.__scopeSelect),[r,o]=I.useState();return((0,iH.useLayoutEffect)(()=>{o(new DocumentFragment)},[]),n.open)?(0,T.jsx)(dj,{...e,ref:t}):r?rX.createPortal((0,T.jsx)(dw,{scope:e.__scopeSelect,children:(0,T.jsx)(dt.Slot,{scope:e.__scopeSelect,children:(0,T.jsx)("div",{children:e.children})})}),r):null});db.displayName=dy;var[dw,dS]=da(dy),dC=(0,lh.createSlot)("SelectContent.RemoveScroll"),dj=I.forwardRef((e,t)=>{let{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:s,sideOffset:l,align:d,alignOffset:c,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:h,hideWhenDetached:m,avoidCollisions:g,...x}=e,v=dd(dy,n),[y,b]=I.useState(null),[w,S]=I.useState(null),C=(0,iD.useComposedRefs)(t,e=>b(e)),[j,N]=I.useState(null),[E,k]=I.useState(null),_=dn(n),[R,P]=I.useState(!1),M=I.useRef(!1);I.useEffect(()=>{if(y)return lS(y)},[y]),lt();let A=I.useCallback(e=>{let[t,...n]=_().map(e=>e.ref.current),[r]=n.slice(-1),o=document.activeElement;for(let n of e)if(n===o||(n?.scrollIntoView({block:"nearest"}),n===t&&w&&(w.scrollTop=0),n===r&&w&&(w.scrollTop=w.scrollHeight),n?.focus(),document.activeElement!==o))return},[_,w]),O=I.useCallback(()=>A([j,y]),[A,j,y]);I.useEffect(()=>{R&&O()},[R,O]);let{onOpenChange:D,triggerPointerDownPosRef:L}=v;I.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(L.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||D(!1),document.removeEventListener("pointermove",t),L.current=null};return null!==L.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[y,D,L]),I.useEffect(()=>{let e=()=>D(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[D]);let[z,$]=d1(e=>{let t=_().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=d2(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),H=I.useCallback((e,t,n)=>{let r=!M.current&&!n;(void 0!==v.value&&v.value===t||r)&&(N(e),r&&(M.current=!0))},[v.value]),F=I.useCallback(()=>y?.focus(),[y]),B=I.useCallback((e,t,n)=>{let r=!M.current&&!n;(void 0!==v.value&&v.value===t||r)&&k(e)},[v.value]),V="popper"===r?dE:dN,U=V===dE?{side:s,sideOffset:l,align:d,alignOffset:c,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:h,hideWhenDetached:m,avoidCollisions:g}:{};return(0,T.jsx)(dw,{scope:n,content:y,viewport:w,onViewportChange:S,itemRefCallback:H,selectedItem:j,onItemLeave:F,itemTextRefCallback:B,focusSelectedItem:O,selectedItemText:E,position:r,isPositioned:R,searchRef:z,children:(0,T.jsx)(l8,{as:dC,allowPinchZoom:!0,children:(0,T.jsx)(li,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:(0,iB.composeEventHandlers)(o,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,T.jsx)(s7.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,T.jsx)(V,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:e=>e.preventDefault(),...x,...U,onPlaced:()=>P(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:(0,iB.composeEventHandlers)(x.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||$(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=_().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>A(t)),e.preventDefault()}})})})})})})});dj.displayName="SelectContentImpl";var dN=I.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...o}=e,a=dd(dy,n),i=dS(dy,n),[s,l]=I.useState(null),[d,c]=I.useState(null),u=(0,iD.useComposedRefs)(t,e=>c(e)),p=dn(n),f=I.useRef(!1),h=I.useRef(!0),{viewport:m,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=I.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&d&&m&&g&&x){let e=a.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),o=x.getBoundingClientRect();if("rtl"!==a.dir){let r=o.left-t.left,a=n.left-r,i=e.left-a,l=e.width+i,d=Math.max(l,t.width),c=iF(a,[10,Math.max(10,window.innerWidth-10-d)]);s.style.minWidth=l+"px",s.style.left=c+"px"}else{let r=t.right-o.right,a=window.innerWidth-n.right-r,i=window.innerWidth-e.right-a,l=e.width+i,d=Math.max(l,t.width),c=iF(a,[10,Math.max(10,window.innerWidth-10-d)]);s.style.minWidth=l+"px",s.style.right=c+"px"}let i=p(),l=window.innerHeight-20,c=m.scrollHeight,u=window.getComputedStyle(d),h=parseInt(u.borderTopWidth,10),v=parseInt(u.paddingTop,10),y=parseInt(u.borderBottomWidth,10),b=h+v+c+parseInt(u.paddingBottom,10)+y,w=Math.min(5*g.offsetHeight,b),S=window.getComputedStyle(m),C=parseInt(S.paddingTop,10),j=parseInt(S.paddingBottom,10),N=e.top+e.height/2-10,E=g.offsetHeight/2,k=h+v+(g.offsetTop+E);if(k<=N){let e=i.length>0&&g===i[i.length-1].ref.current;s.style.bottom="0px";let t=Math.max(l-N,E+(e?j:0)+(d.clientHeight-m.offsetTop-m.offsetHeight)+y);s.style.height=k+t+"px"}else{let e=i.length>0&&g===i[0].ref.current;s.style.top="0px";let t=Math.max(N,h+m.offsetTop+(e?C:0)+E);s.style.height=t+(b-k)+"px",m.scrollTop=k-N+m.offsetTop}s.style.margin="10px 0",s.style.minHeight=w+"px",s.style.maxHeight=l+"px",r?.(),requestAnimationFrame(()=>f.current=!0)}},[p,a.trigger,a.valueNode,s,d,m,g,x,a.dir,r]);(0,iH.useLayoutEffect)(()=>y(),[y]);let[b,w]=I.useState();(0,iH.useLayoutEffect)(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=I.useCallback(e=>{e&&!0===h.current&&(y(),v?.(),h.current=!1)},[y,v]);return(0,T.jsx)(dk,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:f,onScrollButtonChange:S,children:(0,T.jsx)("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,T.jsx)(iM.Primitive.div,{...o,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});dN.displayName="SelectItemAlignedPosition";var dE=I.forwardRef((e,t)=>{let{__scopeSelect:n,align:r="start",collisionPadding:o=10,...a}=e,i=ds(n);return(0,T.jsx)(lp.Content,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});dE.displayName="SelectPopperPosition";var[dk,d_]=da(dy,{}),dT="SelectViewport",dI=I.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...o}=e,a=dS(dT,n),i=d_(dT,n),s=(0,iD.useComposedRefs)(t,a.onViewportChange),l=I.useRef(0);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,T.jsx)(dt.Slot,{scope:n,children:(0,T.jsx)(iM.Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:s,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:(0,iB.composeEventHandlers)(o.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=i;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-20,o=Math.max(parseFloat(n.style.minHeight),parseFloat(n.style.height));if(o<r){let a=o+e,i=Math.min(r,a),s=a-i;n.style.height=i+"px","0px"===n.style.bottom&&(t.scrollTop=s>0?s:0,n.style.justifyContent="flex-end")}}}l.current=t.scrollTop})})})]})});dI.displayName=dT;var dR="SelectGroup",[dP,dM]=da(dR),dA=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,o=(0,sS.useId)();return(0,T.jsx)(dP,{scope:n,id:o,children:(0,T.jsx)(iM.Primitive.div,{role:"group","aria-labelledby":o,...r,ref:t})})});dA.displayName=dR;var dO="SelectLabel",dD=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,o=dM(dO,n);return(0,T.jsx)(iM.Primitive.div,{id:o.id,...r,ref:t})});dD.displayName=dO;var dL="SelectItem",[dz,d$]=da(dL),dH=I.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,s=dd(dL,n),l=dS(dL,n),d=s.value===r,[c,u]=I.useState(a??""),[p,f]=I.useState(!1),h=(0,iD.useComposedRefs)(t,e=>l.itemRefCallback?.(e,r,o)),m=(0,sS.useId)(),g=I.useRef("touch"),x=()=>{o||(s.onValueChange(r),s.onOpenChange(!1))};if(""===r)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,T.jsx)(dz,{scope:n,value:r,disabled:o,textId:m,isSelected:d,onItemTextChange:I.useCallback(e=>{u(t=>t||(e?.textContent??"").trim())},[]),children:(0,T.jsx)(dt.ItemSlot,{scope:n,value:r,disabled:o,textValue:c,children:(0,T.jsx)(iM.Primitive.div,{role:"option","aria-labelledby":m,"data-highlighted":p?"":void 0,"aria-selected":d&&p,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:h,onFocus:(0,iB.composeEventHandlers)(i.onFocus,()=>f(!0)),onBlur:(0,iB.composeEventHandlers)(i.onBlur,()=>f(!1)),onClick:(0,iB.composeEventHandlers)(i.onClick,()=>{"mouse"!==g.current&&x()}),onPointerUp:(0,iB.composeEventHandlers)(i.onPointerUp,()=>{"mouse"===g.current&&x()}),onPointerDown:(0,iB.composeEventHandlers)(i.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:(0,iB.composeEventHandlers)(i.onPointerMove,e=>{g.current=e.pointerType,o?l.onItemLeave?.():"mouse"===g.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:(0,iB.composeEventHandlers)(i.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:(0,iB.composeEventHandlers)(i.onKeyDown,e=>{(l.searchRef?.current===""||" "!==e.key)&&(l7.includes(e.key)&&x()," "===e.key&&e.preventDefault())})})})})});dH.displayName=dL;var dF="SelectItemText",dB=I.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:o,...a}=e,i=dd(dF,n),s=dS(dF,n),l=d$(dF,n),d=du(dF,n),[c,u]=I.useState(null),p=(0,iD.useComposedRefs)(t,e=>u(e),l.onItemTextChange,e=>s.itemTextRefCallback?.(e,l.value,l.disabled)),f=c?.textContent,h=I.useMemo(()=>(0,T.jsx)("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:m,onNativeOptionRemove:g}=d;return(0,iH.useLayoutEffect)(()=>(m(h),()=>g(h)),[m,g,h]),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(iM.Primitive.span,{id:l.textId,...a,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?rX.createPortal(a.children,i.valueNode):null]})});dB.displayName=dF;var dV="SelectItemIndicator",dU=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return d$(dV,n).isSelected?(0,T.jsx)(iM.Primitive.span,{"aria-hidden":!0,...r,ref:t}):null});dU.displayName=dV;var dK="SelectScrollUpButton",dW=I.forwardRef((e,t)=>{let n=dS(dK,e.__scopeSelect),r=d_(dK,e.__scopeSelect),[o,a]=I.useState(!1),i=(0,iD.useComposedRefs)(t,r.onScrollButtonChange);return(0,iH.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?(0,T.jsx)(dY,{...e,ref:i,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});dW.displayName=dK;var dX="SelectScrollDownButton",dG=I.forwardRef((e,t)=>{let n=dS(dX,e.__scopeSelect),r=d_(dX,e.__scopeSelect),[o,a]=I.useState(!1),i=(0,iD.useComposedRefs)(t,r.onScrollButtonChange);return(0,iH.useLayoutEffect)(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),o?(0,T.jsx)(dY,{...e,ref:i,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});dG.displayName=dX;var dY=I.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...o}=e,a=dS("SelectScrollButton",n),i=I.useRef(null),s=dn(n),l=I.useCallback(()=>{null!==i.current&&(window.clearInterval(i.current),i.current=null)},[]);return I.useEffect(()=>()=>l(),[l]),(0,iH.useLayoutEffect)(()=>{let e=s().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[s]),(0,T.jsx)(iM.Primitive.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:(0,iB.composeEventHandlers)(o.onPointerDown,()=>{null===i.current&&(i.current=window.setInterval(r,50))}),onPointerMove:(0,iB.composeEventHandlers)(o.onPointerMove,()=>{a.onItemLeave?.(),null===i.current&&(i.current=window.setInterval(r,50))}),onPointerLeave:(0,iB.composeEventHandlers)(o.onPointerLeave,()=>{l()})})}),dq=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,T.jsx)(iM.Primitive.div,{"aria-hidden":!0,...r,ref:t})});dq.displayName="SelectSeparator";var dZ="SelectArrow",dJ=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,o=ds(n),a=dd(dZ,n),i=dS(dZ,n);return a.open&&"popper"===i.position?(0,T.jsx)(lp.Arrow,{...o,...r,ref:t}):null});dJ.displayName=dZ;var dQ=I.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let o,a=I.useRef(null),i=(0,iD.useComposedRefs)(r,a),s=(o=I.useRef({value:t,previous:t}),I.useMemo(()=>(o.current.value!==t&&(o.current.previous=o.current.value,o.current.value=t),o.current.previous),[t]));return I.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(s!==t&&n){let r=new Event("change",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[s,t]),(0,T.jsx)(iM.Primitive.select,{...n,style:{...lm.VISUALLY_HIDDEN_STYLES,...n.style},ref:i,defaultValue:t})});function d0(e){return""===e||void 0===e}function d1(e){let t=(0,iL.useCallbackRef)(e),n=I.useRef(""),r=I.useRef(0),o=I.useCallback(e=>{let o=n.current+e;t(o),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(o)},[t]),a=I.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function d2(e,t,n){var r,o;let a=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,s=(r=e,o=Math.max(i,0),r.map((e,t)=>r[(o+t)%r.length]));1===a.length&&(s=s.filter(e=>e!==n));let l=s.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return l!==n?l:void 0}dQ.displayName="SelectBubbleInput",e.s(["Arrow",()=>dJ,"Content",()=>db,"Group",()=>dA,"Icon",()=>dx,"Item",()=>dH,"ItemIndicator",()=>dU,"ItemText",()=>dB,"Label",()=>dD,"Portal",()=>dv,"Root",()=>dp,"ScrollDownButton",()=>dG,"ScrollUpButton",()=>dW,"Select",()=>dp,"SelectArrow",()=>dJ,"SelectContent",()=>db,"SelectGroup",()=>dA,"SelectIcon",()=>dx,"SelectItem",()=>dH,"SelectItemIndicator",()=>dU,"SelectItemText",()=>dB,"SelectLabel",()=>dD,"SelectPortal",()=>dv,"SelectScrollDownButton",()=>dG,"SelectScrollUpButton",()=>dW,"SelectSeparator",()=>dq,"SelectTrigger",()=>dh,"SelectValue",()=>dg,"SelectViewport",()=>dI,"Separator",()=>dq,"Trigger",()=>dh,"Value",()=>dg,"Viewport",()=>dI,"createSelectScope",()=>di],73331);var d5=e.i(73331),d5=d5;function d3({...e}){return(0,T.jsx)(d5.Root,{"data-slot":"select",...e})}function d4({...e}){return(0,T.jsx)(d5.Value,{"data-slot":"select-value",...e})}function d6({className:e,size:t="default",children:n,...r}){return(0,T.jsxs)(d5.Trigger,{"data-slot":"select-trigger","data-size":t,className:(0,iI.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,(0,T.jsx)(d5.Icon,{asChild:!0,children:(0,T.jsx)(s2,{className:"size-4 opacity-50"})})]})}function d8({className:e,children:t,position:n="item-aligned",align:r="center",...o}){return(0,T.jsx)(d5.Portal,{children:(0,T.jsxs)(d5.Content,{"data-slot":"select-content",className:(0,iI.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...o,children:[(0,T.jsx)(d7,{}),(0,T.jsx)(d5.Viewport,{className:(0,iI.cn)("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),(0,T.jsx)(ce,{})]})})}function d9({className:e,children:t,...n}){return(0,T.jsxs)(d5.Item,{"data-slot":"select-item",className:(0,iI.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[(0,T.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,T.jsx)(d5.ItemIndicator,{children:(0,T.jsx)(s1,{className:"size-4"})})}),(0,T.jsx)(d5.ItemText,{children:t})]})}function d7({className:e,...t}){return(0,T.jsx)(d5.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:(0,iI.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,T.jsx)(s5,{className:"size-4"})})}function ce({className:e,...t}){return(0,T.jsx)(d5.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:(0,iI.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,T.jsx)(s2,{className:"size-4"})})}let ct=[{label:"$trigger",insertText:"$trigger",description:"Trigger input data",kind:"keyword",sortOrder:0},{label:"$input",insertText:"$input",description:"Same as $trigger",kind:"keyword",sortOrder:1},{label:"flowState",insertText:"flowState",description:"Flow state object (upstream node outputs)",kind:"keyword",sortOrder:2}],cn=[{label:".map()",insertText:".map((item) => )",description:"Iterate and transform array",kind:"method",sortOrder:100},{label:".filter()",insertText:".filter((item) => )",description:"Filter array elements",kind:"method",sortOrder:101},{label:".find()",insertText:".find((item) => )",description:"Find the first matching element",kind:"method",sortOrder:102},{label:".length",insertText:".length",description:"Array or string length",kind:"method",sortOrder:103},{label:".toString()",insertText:".toString()",description:"Convert to string",kind:"method",sortOrder:104},{label:".includes()",insertText:".includes()",description:"Whether it contains the specified value",kind:"method",sortOrder:105},{label:".join()",insertText:".join(', ')",description:"Join array into string",kind:"method",sortOrder:106},{label:".slice()",insertText:".slice(0, )",description:"Get subset",kind:"method",sortOrder:107}],cr=[{label:"JSON.stringify()",insertText:"JSON.stringify()",description:"Serialize object to JSON string",kind:"snippet",sortOrder:200},{label:"JSON.parse()",insertText:"JSON.parse()",description:"Parse JSON string to object",kind:"snippet",sortOrder:201},{label:"Object.keys()",insertText:"Object.keys()",description:"Get all keys of an object",kind:"snippet",sortOrder:202},{label:"Object.values()",insertText:"Object.values()",description:"Get all values of an object",kind:"snippet",sortOrder:203},{label:"Object.entries()",insertText:"Object.entries()",description:"Get [key, value] pairs of an object",kind:"snippet",sortOrder:204},{label:"Date.now()",insertText:"Date.now()",description:"Current timestamp (milliseconds)",kind:"snippet",sortOrder:205},{label:"new Date().toISOString()",insertText:"new Date().toISOString()",description:"ISO date string",kind:"snippet",sortOrder:206},{label:"Math.round()",insertText:"Math.round()",description:"Round to nearest integer",kind:"snippet",sortOrder:207},{label:"Number()",insertText:"Number()",description:"Convert to number",kind:"snippet",sortOrder:208},{label:"String()",insertText:"String()",description:"Convert to string",kind:"snippet",sortOrder:209},{label:"Boolean()",insertText:"Boolean()",description:"Convert to boolean",kind:"snippet",sortOrder:210},{label:"Array.isArray()",insertText:"Array.isArray()",description:"Check if value is an array",kind:"snippet",sortOrder:211}];function co({nodeId:e,label:t,value:n,onChange:r,placeholder:o,error:a}){let i,s,l,{getFiltered:d}=(i=sB(e),s=(0,I.useMemo)(()=>{let e=[...ct];for(let t of i.entries)e.push({label:`flowState['${t.nodeId}']`,insertText:`flowState['${t.nodeId}']`,description:`${t.label} (${t.tsType})`,kind:"variable",sortOrder:10});return e.push(...cn),e.push(...cr),e.sort((e,t)=>e.sortOrder-t.sortOrder)},[i]),l=(0,I.useMemo)(()=>(e,t)=>{let n=t??e.length,r=e.slice(0,n),o=/[\w$.'[\]]*$/.exec(r),a=o?o[0].toLowerCase():"";return a?s.filter(e=>e.label.toLowerCase().includes(a)||e.insertText.toLowerCase().includes(a)):s},[s]),{suggestions:s,getFiltered:l,upstreamTypes:i}),[c,u]=(0,I.useState)(!1),[p,f]=(0,I.useState)(0),[h,m]=(0,I.useState)([]),[g,x]=(0,I.useState)({top:0,left:0}),v=(0,I.useRef)(null),y=(0,I.useRef)(null),b=(0,I.useCallback)((e,t)=>{let n=d(e,t);m(n),f(0),u(n.length>0)},[d]),w=(0,I.useCallback)(e=>{let t=e.target.value;r(t),b(t,e.target.selectionStart??void 0)},[r,b]),S=(0,I.useCallback)(e=>{let t=v.current;if(!t)return;let o=t.selectionStart,a=n.slice(0,o),i=/[\w$.'[\]]*$/.exec(a),s=i?o-i[0].length:o;r(n.slice(0,s)+e.insertText+n.slice(o)),u(!1),requestAnimationFrame(()=>{let n=s+e.insertText.length;t.setSelectionRange(n,n),t.focus()})},[n,r]),C=(0,I.useCallback)(e=>{if(c&&0!==h.length)switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>(e+1)%h.length);break;case"ArrowUp":e.preventDefault(),f(e=>e<=0?h.length-1:e-1);break;case"Enter":case"Tab":e.preventDefault(),S(h[p]);break;case"Escape":e.preventDefault(),u(!1)}},[c,h,p,S]);(0,I.useEffect)(()=>{c&&v.current&&x({top:v.current.getBoundingClientRect().height+2,left:0})},[c]),(0,I.useEffect)(()=>{if(!c)return;let e=e=>{y.current&&!y.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]);let j={variable:"𝑥",method:"ƒ",keyword:"$",snippet:"⟨⟩"};return(0,T.jsxs)("div",{className:"flex flex-col gap-1.5 relative",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:t}),(0,T.jsx)(sX,{ref:v,value:String(n),onChange:w,onKeyDown:C,onBlur:()=>{setTimeout(()=>u(!1),150)},onFocus:()=>b(String(n)),placeholder:o,className:`font-mono text-xs resize-y min-h-[60px] ${a?"border-red-500":""}`,autoComplete:"off",spellCheck:!1}),c&&h.length>0&&(0,T.jsx)("div",{ref:y,className:"absolute z-50 border border-border bg-popover rounded-md shadow-lg max-h-48 overflow-y-auto w-full",style:{top:g.top,left:g.left},children:h.slice(0,15).map((e,t)=>(0,T.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 cursor-pointer text-xs ${t===p?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:t=>{t.preventDefault(),S(e)},onMouseEnter:()=>f(t),children:[(0,T.jsx)("span",{className:"text-muted-foreground font-mono text-[10px] w-4 shrink-0 text-center",children:j[e.kind]}),(0,T.jsx)("span",{className:"font-mono text-xs truncate",children:e.label}),(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground ml-auto truncate max-w-[120px]",children:e.description})]},e.label))}),a&&(0,T.jsx)("p",{className:"text-[10px] text-red-400",children:a})]})}let ca={[ic.NodeCategory.TRIGGER]:"⚡",[ic.NodeCategory.ACTION]:"🔧",[ic.NodeCategory.LOGIC]:"🔀",[ic.NodeCategory.VARIABLE]:"📦",[ic.NodeCategory.OUTPUT]:"📤"};function ci({label:e,value:t,onChange:n,type:r="text",placeholder:o,error:a}){let i=`param-${e}`;return"textarea"===r?(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{htmlFor:i,className:"text-[10px] uppercase tracking-wider",children:e}),(0,T.jsx)(sX,{id:i,value:String(t),onChange:e=>n(e.target.value),placeholder:o,className:`font-mono text-xs resize-y min-h-[60px] ${a?"border-red-500":""}`}),a&&(0,T.jsx)("p",{className:"text-[10px] text-red-400",children:a})]}):"checkbox"===r?(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)("input",{id:i,type:"checkbox",checked:!!t,onChange:e=>n(String(e.target.checked)),className:"rounded border-border accent-primary"}),(0,T.jsx)(sW,{htmlFor:i,className:"text-[10px] uppercase tracking-wider cursor-pointer",children:e})]}):(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{htmlFor:i,className:"text-[10px] uppercase tracking-wider",children:e}),(0,T.jsx)(sV,{id:i,type:r,value:String(t),onChange:e=>n(e.target.value),placeholder:o,className:`font-mono text-xs h-8 ${a?"border-red-500":""}`}),a&&(0,T.jsx)("p",{className:"text-[10px] text-red-400",children:a})]})}function cs(){let e=iw(e=>e.selectedNodeId),t=iw(e=>e.selectNode),n=iw(e=>e.nodes),r=iw(e=>e.updateNodeParams),o=iw(e=>e.updateNodeLabel),a=iw(e=>e.removeNode),i=iw(e=>e.removeSelectedNodes),s=iw(e=>e.getSelectedNodeIds)(),l=s.length>1,d=n.find(t=>t.id===e),c=sB(e);if(!l&&!d)return null;let u=e=>(0,T.jsx)("div",{className:"absolute right-0 top-0 h-full w-[480px] max-w-[55vw] bg-card/95 backdrop-blur-sm border-l border-border flex flex-col shadow-2xl z-10 animate-in slide-in-from-right duration-200",children:e});if(l){let e=n.filter(e=>s.includes(e.id)),r=[...new Set(e.map(e=>e.data.category))];return u((0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)("span",{className:"text-base",children:"📋"}),(0,T.jsxs)("div",{children:[(0,T.jsx)("h3",{className:"text-sm font-semibold",children:"Multi-Select"}),(0,T.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:[s.length," nodes selected"]})]})]}),(0,T.jsxs)("div",{className:"flex items-center gap-1",children:[(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>i(),className:"text-destructive hover:text-destructive hover:bg-destructive/10 h-7 text-xs",children:"Delete All"}),(0,T.jsx)(iP,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>t(null),children:"✕"})]})]}),(0,T.jsx)(sf,{className:"flex-1",children:(0,T.jsxs)("div",{className:"p-4 flex flex-col gap-3",children:[(0,T.jsx)("div",{className:"flex flex-wrap gap-1",children:r.map(e=>(0,T.jsxs)(sY,{variant:"secondary",className:"text-[10px]",children:[ca[e]??"📦"," ",e]},e))}),(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)("span",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:"Selected Nodes"}),e.map(e=>{let t=e.data;return(0,T.jsxs)("div",{className:"flex items-center justify-between gap-1 py-1.5 px-3 rounded-md bg-accent/30",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,T.jsx)("span",{className:"text-sm",children:ca[t.category]??"📦"}),(0,T.jsxs)("div",{className:"min-w-0",children:[(0,T.jsx)("span",{className:"text-xs text-foreground truncate block",children:t.label}),(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:t.nodeType})]})]}),(0,T.jsx)(iP,{variant:"ghost",size:"icon",className:"w-6 h-6 text-destructive hover:text-destructive hover:bg-destructive/10 shrink-0",onClick:()=>a(e.id),children:"✕"})]},e.id)})]})]})})]}))}let p=d.data,f=ca[p.category]??"📦";return u((0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,T.jsx)("span",{className:"text-lg",children:f}),(0,T.jsxs)("div",{className:"min-w-0",children:[(0,T.jsx)("h3",{className:"text-sm font-semibold truncate",children:p.label}),(0,T.jsx)("p",{className:"text-[10px] text-muted-foreground font-mono",children:p.nodeType})]})]}),(0,T.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>a(d.id),className:"text-destructive hover:text-destructive hover:bg-destructive/10 h-7 text-xs",children:"Delete"}),(0,T.jsx)(iP,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>t(null),children:"✕"})]})]}),(0,T.jsx)(sf,{className:"flex-1",children:(0,T.jsxs)("div",{className:"p-4 flex flex-col gap-4",children:[(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Node Name"}),(0,T.jsx)(sV,{value:p.label,onChange:e=>o(d.id,e.target.value),className:"font-mono text-xs h-8"}),(0,T.jsx)("p",{className:"text-[10px] text-muted-foreground font-mono truncate",children:d.id})]}),(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,T.jsx)("span",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:"Parameters"}),function(e,t,n){let r=e.params;switch(e.nodeType){case ic.TriggerType.HTTP_WEBHOOK:{let e=String(r.routePath??""),n=e&&!e.startsWith("/")?"Path must start with /":void 0;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"HTTP Method"}),(0,T.jsxs)(d3,{value:String(r.method??"GET"),onValueChange:e=>t("method",e),children:[(0,T.jsx)(d6,{className:"font-mono text-xs h-8",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["GET","POST","PUT","PATCH","DELETE"].map(e=>(0,T.jsx)(d9,{value:e,className:"font-mono text-xs",children:e},e))})]})]}),(0,T.jsx)(ci,{label:"Route Path",value:e,onChange:e=>t("routePath",e),placeholder:"/api/endpoint",error:n}),(0,T.jsx)(ci,{label:"Parse Body",value:!!r.parseBody,onChange:e=>t("parseBody",e),type:"checkbox"})]})}case ic.ActionType.FETCH_API:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"URL",value:String(r.url??""),onChange:e=>t("url",e),placeholder:"https://api.example.com"}),(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Method"}),(0,T.jsxs)(d3,{value:String(r.method??"GET"),onValueChange:e=>t("method",e),children:[(0,T.jsx)(d6,{className:"font-mono text-xs h-8",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["GET","POST","PUT","PATCH","DELETE"].map(e=>(0,T.jsx)(d9,{value:e,className:"font-mono text-xs",children:e},e))})]})]}),(0,T.jsx)(ci,{label:"Body",value:String(r.body??""),onChange:e=>t("body",e),type:"textarea"}),(0,T.jsx)(ci,{label:"Parse JSON",value:!!r.parseJson,onChange:e=>t("parseJson",e),type:"checkbox"})]});case ic.ActionType.SQL_QUERY:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"ORM"}),(0,T.jsxs)(d3,{value:String(r.orm??"drizzle"),onValueChange:e=>t("orm",e),children:[(0,T.jsx)(d6,{className:"font-mono text-xs h-8",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["drizzle","prisma","raw"].map(e=>(0,T.jsx)(d9,{value:e,className:"font-mono text-xs",children:e},e))})]})]}),(0,T.jsx)(ci,{label:"Query",value:String(r.query??""),onChange:e=>t("query",e),type:"textarea"})]});case ic.ActionType.CUSTOM_CODE:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(co,{nodeId:n,label:"Code",value:String(r.code??""),onChange:e=>t("code",e)}),(0,T.jsx)(ci,{label:"Return Variable",value:String(r.returnVariable??""),onChange:e=>t("returnVariable",e)})]});case ic.ActionType.REDIS_CACHE:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Operation"}),(0,T.jsxs)(d3,{value:String(r.operation??"get"),onValueChange:e=>t("operation",e),children:[(0,T.jsx)(d6,{className:"font-mono text-xs h-8",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["get","set","del"].map(e=>(0,T.jsx)(d9,{value:e,className:"font-mono text-xs",children:e},e))})]})]}),(0,T.jsx)(ci,{label:"Key",value:String(r.key??""),onChange:e=>t("key",e)}),"set"===String(r.operation)&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Value",value:String(r.value??""),onChange:e=>t("value",e),type:"textarea"}),(0,T.jsx)(ci,{label:"TTL (seconds)",value:String(r.ttl??""),onChange:e=>t("ttl",e),type:"number"})]})]});case ic.ActionType.CALL_SUBFLOW:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Flow Path",value:String(r.flowPath??""),onChange:e=>t("flowPath",e)}),(0,T.jsx)(ci,{label:"Function Name",value:String(r.functionName??""),onChange:e=>t("functionName",e)}),(0,T.jsx)(ci,{label:"Input Mapping (JSON)",value:"object"==typeof r.inputMapping?JSON.stringify(r.inputMapping):String(r.inputMapping??"{}"),onChange:e=>t("inputMapping",e),type:"textarea"})]});case ic.LogicType.IF_ELSE:return(0,T.jsx)(co,{nodeId:n,label:"Condition",value:String(r.condition??""),onChange:e=>t("condition",e),placeholder:"flowState['nodeId'] > 0"});case ic.LogicType.FOR_LOOP:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Iterable Expression",value:String(r.iterableExpression??""),onChange:e=>t("iterableExpression",e)}),(0,T.jsx)(ci,{label:"Item Variable",value:String(r.itemVariable??""),onChange:e=>t("itemVariable",e)}),(0,T.jsx)(ci,{label:"Index Variable",value:String(r.indexVariable??""),onChange:e=>t("indexVariable",e)})]});case ic.LogicType.TRY_CATCH:return(0,T.jsx)(ci,{label:"Error Variable",value:String(r.errorVariable??""),onChange:e=>t("errorVariable",e)});case ic.TriggerType.CRON_JOB:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Cron Schedule",value:String(r.schedule??""),onChange:e=>t("schedule",e),placeholder:"0 * * * *"}),(0,T.jsx)(ci,{label:"Function Name",value:String(r.functionName??""),onChange:e=>t("functionName",e)})]});case ic.TriggerType.MANUAL:return(0,T.jsx)(T.Fragment,{children:(0,T.jsx)(ci,{label:"Function Name",value:String(r.functionName??""),onChange:e=>t("functionName",e)})});case ic.VariableType.DECLARE:return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Variable Name",value:String(r.name??""),onChange:e=>t("name",e)}),(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Data Type"}),(0,T.jsxs)(d3,{value:String(r.dataType??"string"),onValueChange:e=>t("dataType",e),children:[(0,T.jsx)(d6,{className:"font-mono text-xs h-8",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["string","number","boolean","object","array","any"].map(e=>(0,T.jsx)(d9,{value:e,className:"font-mono text-xs",children:e},e))})]})]}),(0,T.jsx)(ci,{label:"Initial Value",value:String(r.initialValue??""),onChange:e=>t("initialValue",e)}),(0,T.jsx)(ci,{label:"Is Const",value:!!r.isConst,onChange:e=>t("isConst",e),type:"checkbox"})]});case ic.VariableType.TRANSFORM:return(0,T.jsx)(co,{nodeId:n,label:"Expression",value:String(r.expression??""),onChange:e=>t("expression",e),placeholder:"flowState['fetch_1'].data"});case ic.OutputType.RETURN_RESPONSE:{let e=Number(r.statusCode??200);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(ci,{label:"Status Code",value:String(r.statusCode??200),onChange:e=>t("statusCode",e),type:"number",error:e<100||e>599?"Status code range: 100-599":void 0}),(0,T.jsx)(co,{nodeId:n,label:"Body Expression",value:String(r.bodyExpression??""),onChange:e=>t("bodyExpression",e),placeholder:"{ result: flowState['nodeId'] }"})]})}default:return(0,T.jsx)("pre",{className:"text-[10px] text-muted-foreground font-mono overflow-x-auto bg-secondary rounded-md p-2",children:JSON.stringify(r,null,2)})}}(p,(e,t)=>{let n=t;if("inputMapping"===e)try{n=JSON.parse(t)}catch{n=t}else if("true"===t)n=!0;else if("false"===t)n=!1;else if("statusCode"===e){let e=Number(t);n=isNaN(e)?t:e}else isNaN(Number(t))||""===t||"routePath"===e||"name"===e||"functionName"===e||"flowPath"===e||(n=Number(t));r(d.id,{[e]:n})},e)]}),(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,T.jsx)("span",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:"Ports"}),p.inputs.length>0&&(0,T.jsxs)("div",{className:"flex flex-wrap gap-1 items-center",children:[(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground mr-1",children:"In:"}),p.inputs.map(e=>(0,T.jsx)(sY,{variant:"secondary",className:"text-[10px]",children:e.label},e.id))]}),p.outputs.length>0&&(0,T.jsxs)("div",{className:"flex flex-wrap gap-1 items-center",children:[(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground mr-1",children:"Out:"}),p.outputs.map(e=>(0,T.jsx)(sY,{variant:"outline",className:"text-[10px] text-amber-400 border-amber-400/30",children:e.label},e.id))]})]}),c.hasTypes&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,T.jsx)("span",{className:"text-xs text-cyan-400 font-semibold uppercase tracking-wider",children:"flowState Available Fields"}),(0,T.jsxs)("div",{className:"space-y-1",children:[c.entries.map(e=>(0,T.jsxs)("div",{className:"flex items-center justify-between gap-1",children:[(0,T.jsxs)("code",{className:"text-[10px] text-foreground font-mono truncate",children:["flowState['",e.nodeId,"']"]}),(0,T.jsx)(sY,{variant:"outline",className:"text-[9px] text-cyan-400 border-cyan-500/30 shrink-0",children:e.tsType})]},e.nodeId)),(0,T.jsxs)("p",{className:"text-[9px] text-muted-foreground pt-1",children:["Output types from ",c.entries.length," upstream node(s)"]})]})]})]})]})})]}))}let cl=e=>t=>{try{let n=e(t);if(n instanceof Promise)return n;return{then:e=>cl(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>cl(t)(e)}}},cd=[{name:"Copilot API (Local)",baseUrl:"http://localhost:4141/v1",apiKey:"",model:"gpt-4o",supportsJsonMode:!0}],cc=id()((n=(e,t)=>({activeEndpointId:"0",endpoints:cd,setActiveEndpoint:t=>e({activeEndpointId:t}),addEndpoint:t=>e(e=>({endpoints:[...e.endpoints,t]})),updateEndpoint:(t,n)=>e(e=>({endpoints:e.endpoints.map((e,r)=>r===t?n:e)})),removeEndpoint:t=>e(e=>({endpoints:e.endpoints.filter((e,n)=>n!==t),activeEndpointId:e.activeEndpointId===String(t)?"0":e.activeEndpointId})),getActiveConfig:()=>{let{activeEndpointId:e,endpoints:n}=t();return"env"===e?null:n[parseInt(e,10)]??null}}),r={name:"flow2code-ai-settings"},(e,t,o)=>{let a,i={storage:function(e,t){let n;try{n=e()}catch(e){return}return{getItem:e=>{var t;let r=e=>null===e?null:JSON.parse(e,void 0),o=null!=(t=n.getItem(e))?t:null;return o instanceof Promise?o.then(r):r(o)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...r},s=!1,l=0,d=new Set,c=new Set,u=i.storage;if(!u)return n((...t)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),e(...t)},t,o);let p=()=>{let e=i.partialize({...t()});return u.setItem(i.name,{state:e,version:i.version})},f=o.setState;o.setState=(e,t)=>(f(e,t),p());let h=n((...t)=>(e(...t),p()),t,o);o.getInitialState=()=>h;let m=()=>{var n,r;if(!u)return;let o=++l;s=!1,d.forEach(e=>{var n;return e(null!=(n=t())?n:h)});let f=(null==(r=i.onRehydrateStorage)?void 0:r.call(i,null!=(n=t())?n:h))||void 0;return cl(u.getItem.bind(u))(i.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];else{if(i.migrate){let t=i.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(n=>{var r;if(o!==l)return;let[s,d]=n;if(e(a=i.merge(d,null!=(r=t())?r:h),!0),s)return p()}).then(()=>{o===l&&(null==f||f(a,void 0),a=t(),s=!0,c.forEach(e=>e(a)))}).catch(e=>{o===l&&(null==f||f(void 0,e))})};return o.persist={setOptions:e=>{i={...i,...e},e.storage&&(u=e.storage)},clearStorage:()=>{null==u||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>m(),hasHydrated:()=>s,onHydrate:e=>(d.add(e),()=>{d.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},i.skipHydration||m(),a||h}));var cu=e.i(44497),cp=e.i(94501),cf=e.i(45966);async function ch(e,t){try{let n,{url:r,headers:o,body:a,signal:i}=e,s={...a,stream:!0},l=new AbortController,d=setTimeout(()=>l.abort(Error("Connection timeout (60s)")),6e4),c=l.signal;i&&(c=AbortSignal.any([i,l.signal]));try{n=await fetch(r,{method:"POST",headers:o,body:JSON.stringify(s),signal:c})}finally{clearTimeout(d)}if(!n.ok){let e=await n.text();t.onError(Error(`AI API error (${n.status}): ${e}`));return}if(!n.body)return void t.onError(Error("Response has no readable stream (response.body is null)"));let u=n.body.getReader(),p=new TextDecoder("utf-8"),f="",h="";try{for(;;){let{done:e,value:n}=await u.read();if(e)break;let r=(f+=p.decode(n,{stream:!0})).split("\n");for(let e of(f=r.pop()??"",r)){let n=e.trim();if(!(!n||n.startsWith(":"))&&"data: [DONE]"!==n&&n.startsWith("data: ")){let e=n.slice(6);try{let n=JSON.parse(e),r=n.choices?.[0]?.delta?.content;r&&(h+=r,t.onToken(r))}catch{}}}}t.onComplete(h)}catch(e){"AbortError"===e.name?t.onComplete(h):t.onError(e instanceof Error?e:Error(String(e)))}}catch(e){"AbortError"===e.name?t.onComplete(""):t.onError(e instanceof Error?e:Error(String(e)))}}function cm(e){let t=0;for(let n of e)/[\u4e00-\u9fff\u3400-\u4dbf\uf900-\ufaff]/.test(n)?t+=.67:t+=.25;return Math.ceil(t)}async function cg(e,t={}){let n,{maxRetries:r=3,initialDelay:o=1e3,backoffMultiplier:a=2,signal:i,onRetry:s}=t,l=o;for(let t=0;t<=r;t++)try{if(i?.aborted)throw Error("Cancelled");return await e()}catch(e){if(n=e instanceof Error?e:Error(String(e)),t===r||"AbortError"===n.name||i?.aborted||n.message.includes("(4"))break;s?.(t+1,n),await new Promise(e=>setTimeout(e,l)),l*=a}throw n??Error("Max retries exhausted")}async function cx(t,n,r,o,a){let i,s,{FLOW_IR_SYSTEM_PROMPT:l}=await e.A(29641),d=function(e,t,n=8e3){let r=cm(e)+cm(t);return{withinBudget:r<=n,estimated:r,limit:n}}(l,n);if(!d.withinBudget)return`⚠️ Prompt may be too long (estimated ~${d.estimated} tokens, recommended ≤${d.limit})
5
- Please simplify your description and retry.`;let c=t.baseUrl.replace(/\/+$/,""),u={"Content-Type":"application/json"};t.apiKey&&(u.Authorization=`Bearer ${t.apiKey}`);let p={model:t.model,messages:[{role:"system",content:l},{role:"user",content:n}],temperature:.2};t.supportsJsonMode&&(p.response_format={type:"json_object"});try{i=await cg(async()=>new Promise((e,t)=>{let n="";ch({url:`${c}/chat/completions`,headers:u,body:p,signal:r.current?.signal},{onToken:e=>{n+=e,o(n)},onComplete:t=>e(t),onError:e=>t(e)})}),{maxRetries:2,initialDelay:1500,signal:r.current?.signal,onRetry:(e,t)=>{o(`⏳ Retrying (${e}/2): ${t.message}
6
- `)}})}catch{let e=await fetch(`${c}/chat/completions`,{method:"POST",headers:u,body:JSON.stringify(p),signal:r.current?.signal});if(!e.ok){let t=await e.text();return`❌ AI API error (${e.status}): ${t}`}let t=await e.json();i=t.choices?.[0]?.message?.content??""}if(!i)return"❌ AI returned empty content";let f=i,h=i.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);h&&(f=h[1]);try{s=JSON.parse(f)}catch{return`❌ JSON parsing failed:
7
- ${i}`}let m=s.nodes.find(e=>"trigger"===e.category);if(m){let e=m.outputs?.[0]?.id||"output",t=new Set(s.edges.map(e=>e.targetNodeId)),n=0;s.nodes.forEach(r=>{r.id!==m.id&&!t.has(r.id)&&r.inputs&&r.inputs.length>0&&(s.edges.push({id:`healed_e_${crypto.randomUUID().slice(0,8)}`,sourceNodeId:m.id,sourcePortId:"http_webhook"===m.nodeType?"request":e,targetNodeId:r.id,targetPortId:r.inputs[0].id}),n++)}),n>0&&console.warn(`[AutoHeal] Connected ${n} orphaned nodes to trigger.`)}let{validateFlowIR:g}=await e.A(30679),x=g(s);if(!x.valid)return`❌ IR validation failed:
8
- ${x.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}
9
-
10
- ${JSON.stringify(s,null,2)}`;a(s);let v=s.nodes??[],y=s.edges??[],b=[];v.some(e=>"trigger"===e.category)||b.push("⚠️ Missing trigger node"),v.some(e=>"return_response"===e.nodeType)||b.push("⚠️ Missing Return Response node"),v.length>15&&b.push("💡 Too many nodes, consider splitting into sub-flows"),0===y.length&&v.length>1&&b.push("⚠️ No connections between nodes");let w=b.length>0?`
11
-
12
- 📋 Auto review:
13
- ${b.join("\n")}`:"\n\n✅ Auto review passed",S=s.meta;return`✅ AI generated flow chart: "${S?.name??"Untitled"}"
14
- 📡 ${t.name} (${t.model})
15
- 📊 Token estimate: ~${d.estimated}
16
-
17
- ${v.length} nodes, ${y.length} edges${w}`}async function cv(t,n,r){let{getApiBase:o}=await e.A(98984),a=await fetch(`${o()}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t}),signal:n.current?.signal}),i=await a.json();return i.success&&i.ir?(r(i.ir),`✅ AI generated flow chart: "${i.ir.meta?.name??"Untitled"}"
18
-
19
- ${i.ir.nodes?.length??0} nodes, ${i.ir.edges?.length??0} edges`):`❌ AI generation failed:
20
- ${i.error??"Unknown error"}
21
-
22
- ${i.validationErrors?JSON.stringify(i.validationErrors,null,2):""}`}var cy="rovingFocusGroup.onEntryFocus",cb={bubbles:!1,cancelable:!0},cw="RovingFocusGroup",[cS,cC,cj]=s4(cw),[cN,cE]=(0,iO.createContextScope)(cw,[cj]),[ck,c_]=cN(cw),cT=I.forwardRef((e,t)=>(0,T.jsx)(cS.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(cS.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(cI,{...e,ref:t})})}));cT.displayName=cw;var cI=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:c=!1,...u}=e,p=I.useRef(null),f=(0,iD.useComposedRefs)(t,p),h=i$(a),[m,g]=(0,sw.useControllableState)({prop:i,defaultProp:s??null,onChange:l,caller:cw}),[x,v]=I.useState(!1),y=(0,iL.useCallbackRef)(d),b=cC(n),w=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(cy,y),()=>e.removeEventListener(cy,y)},[y]),(0,T.jsx)(ck,{scope:n,orientation:r,dir:h,loop:o,currentTabStopId:m,onItemFocus:I.useCallback(e=>g(e),[g]),onItemShiftTab:I.useCallback(()=>v(!0),[]),onFocusableItemAdd:I.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:I.useCallback(()=>C(e=>e-1),[]),children:(0,T.jsx)(iM.Primitive.div,{tabIndex:x||0===S?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...e.style},onMouseDown:(0,iB.composeEventHandlers)(e.onMouseDown,()=>{w.current=!0}),onFocus:(0,iB.composeEventHandlers)(e.onFocus,e=>{let t=!w.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(cy,cb);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);cA([e.find(e=>e.active),e.find(e=>e.id===m),...e].filter(Boolean).map(e=>e.ref.current),c)}}w.current=!1}),onBlur:(0,iB.composeEventHandlers)(e.onBlur,()=>v(!1))})})}),cR="RovingFocusGroupItem",cP=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...s}=e,l=(0,sS.useId)(),d=a||l,c=c_(cR,n),u=c.currentTabStopId===d,p=cC(n),{onFocusableItemAdd:f,onFocusableItemRemove:h,currentTabStopId:m}=c;return I.useEffect(()=>{if(r)return f(),()=>h()},[r,f,h]),(0,T.jsx)(cS.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:(0,T.jsx)(iM.Primitive.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:(0,iB.composeEventHandlers)(e.onMouseDown,e=>{r?c.onItemFocus(d):e.preventDefault()}),onFocus:(0,iB.composeEventHandlers)(e.onFocus,()=>c.onItemFocus(d)),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void c.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var r;let o=(r=e.key,"rtl"!==n?r:"ArrowLeft"===r?"ArrowRight":"ArrowRight"===r?"ArrowLeft":r);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(o))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(o)))return cM[o]}(e,c.orientation,c.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let o=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)o.reverse();else if("prev"===t||"next"===t){var n,r;"prev"===t&&o.reverse();let a=o.indexOf(e.currentTarget);o=c.loop?(n=o,r=a+1,n.map((e,t)=>n[(r+t)%n.length])):o.slice(a+1)}setTimeout(()=>cA(o))}}),children:"function"==typeof i?i({isCurrentTabStop:u,hasTabStop:null!=m}):i})})});cP.displayName=cR;var cM={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cA(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}var cO="Tabs",[cD,cL]=(0,iO.createContextScope)(cO,[cE]),cz=cE(),[c$,cH]=cD(cO),cF=I.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:s,activationMode:l="automatic",...d}=e,c=i$(s),[u,p]=(0,sw.useControllableState)({prop:r,onChange:o,defaultProp:a??"",caller:cO});return(0,T.jsx)(c$,{scope:n,baseId:(0,sS.useId)(),value:u,onValueChange:p,orientation:i,dir:c,activationMode:l,children:(0,T.jsx)(iM.Primitive.div,{dir:c,"data-orientation":i,...d,ref:t})})});cF.displayName=cO;var cB="TabsList",cV=I.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...o}=e,a=cH(cB,n),i=cz(n);return(0,T.jsx)(cT,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:(0,T.jsx)(iM.Primitive.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});cV.displayName=cB;var cU="TabsTrigger",cK=I.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=cH(cU,n),s=cz(n),l=cG(i.baseId,r),d=cY(i.baseId,r),c=r===i.value;return(0,T.jsx)(cP,{asChild:!0,...s,focusable:!o,active:c,children:(0,T.jsx)(iM.Primitive.button,{type:"button",role:"tab","aria-selected":c,"aria-controls":d,"data-state":c?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:(0,iB.composeEventHandlers)(e.onMouseDown,e=>{o||0!==e.button||!1!==e.ctrlKey?e.preventDefault():i.onValueChange(r)}),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&i.onValueChange(r)}),onFocus:(0,iB.composeEventHandlers)(e.onFocus,()=>{let e="manual"!==i.activationMode;c||o||!e||i.onValueChange(r)})})})});cK.displayName=cU;var cW="TabsContent",cX=I.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,s=cH(cW,n),l=cG(s.baseId,r),d=cY(s.baseId,r),c=r===s.value,u=I.useRef(c);return I.useEffect(()=>{let e=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,T.jsx)(iA.Presence,{present:o||c,children:({present:n})=>(0,T.jsx)(iM.Primitive.div,{"data-state":c?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!n,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:n&&a})})});function cG(e,t){return`${e}-trigger-${t}`}function cY(e,t){return`${e}-content-${t}`}cX.displayName=cW,e.s(["Content",()=>cX,"List",()=>cV,"Root",()=>cF,"Tabs",()=>cF,"TabsContent",()=>cX,"TabsList",()=>cV,"TabsTrigger",()=>cK,"Trigger",()=>cK,"createTabsScope",()=>cL],26869);var cq=e.i(26869),cq=cq;function cZ({className:e,orientation:t="horizontal",...n}){return(0,T.jsx)(cq.Root,{"data-slot":"tabs","data-orientation":t,orientation:t,className:(0,iI.cn)("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}let cJ=i_("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function cQ({className:e,variant:t="default",...n}){return(0,T.jsx)(cq.List,{"data-slot":"tabs-list","data-variant":t,className:(0,iI.cn)(cJ({variant:t}),e),...n})}function c0({className:e,...t}){return(0,T.jsx)(cq.Trigger,{"data-slot":"tabs-trigger",className:(0,iI.cn)("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function c1({className:e,...t}){return(0,T.jsx)(cq.Content,{"data-slot":"tabs-content",className:(0,iI.cn)("flex-1 outline-none",e),...t})}let c2=s0("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var c5=iT,c3="Dialog",[c4,c6]=(0,iO.createContextScope)(c3),[c8,c9]=c4(c3),c7=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,s=I.useRef(null),l=I.useRef(null),[d,c]=(0,sw.useControllableState)({prop:r,defaultProp:o??!1,onChange:a,caller:c3});return(0,T.jsx)(c8,{scope:t,triggerRef:s,contentRef:l,contentId:(0,sS.useId)(),titleId:(0,sS.useId)(),descriptionId:(0,sS.useId)(),open:d,onOpenChange:c,onOpenToggle:I.useCallback(()=>c(e=>!e),[c]),modal:i,children:n})};c7.displayName=c3;var ue="DialogTrigger",ut=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=c9(ue,n),a=(0,iD.useComposedRefs)(t,o.triggerRef);return(0,T.jsx)(iM.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":uw(o.open),...r,ref:a,onClick:(0,iB.composeEventHandlers)(e.onClick,o.onOpenToggle)})});ut.displayName=ue;var un="DialogPortal",[ur,uo]=c4(un,{forceMount:void 0}),ua=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=c9(un,t);return(0,T.jsx)(ur,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,T.jsx)(iA.Presence,{present:n||a.open,children:(0,T.jsx)(lf.Portal,{asChild:!0,container:o,children:e})}))})};ua.displayName=un;var ui="DialogOverlay",us=I.forwardRef((e,t)=>{let n=uo(ui,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=c9(ui,e.__scopeDialog);return a.modal?(0,T.jsx)(iA.Presence,{present:r||a.open,children:(0,T.jsx)(ud,{...o,ref:t})}):null});us.displayName=ui;var ul=(0,c5.createSlot)("DialogOverlay.RemoveScroll"),ud=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=c9(ui,n);return(0,T.jsx)(l8,{as:ul,allowPinchZoom:!0,shards:[o.contentRef],children:(0,T.jsx)(iM.Primitive.div,{"data-state":uw(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),uc="DialogContent",uu=I.forwardRef((e,t)=>{let n=uo(uc,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=c9(uc,e.__scopeDialog);return(0,T.jsx)(iA.Presence,{present:r||a.open,children:a.modal?(0,T.jsx)(up,{...o,ref:t}):(0,T.jsx)(uf,{...o,ref:t})})});uu.displayName=uc;var up=I.forwardRef((e,t)=>{let n=c9(uc,e.__scopeDialog),r=I.useRef(null),o=(0,iD.useComposedRefs)(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return lS(e)},[]),(0,T.jsx)(uh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,iB.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:(0,iB.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:(0,iB.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault())})}),uf=I.forwardRef((e,t)=>{let n=c9(uc,e.__scopeDialog),r=I.useRef(!1),o=I.useRef(!1);return(0,T.jsx)(uh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),uh=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,s=c9(uc,n),l=I.useRef(null),d=(0,iD.useComposedRefs)(t,l);return lt(),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(li,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:(0,T.jsx)(s7.DismissableLayer,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":uw(s.open),...i,ref:d,onDismiss:()=>s.onOpenChange(!1)})}),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(uN,{titleId:s.titleId}),(0,T.jsx)(uE,{contentRef:l,descriptionId:s.descriptionId})]})]})}),um="DialogTitle",ug=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=c9(um,n);return(0,T.jsx)(iM.Primitive.h2,{id:o.titleId,...r,ref:t})});ug.displayName=um;var ux="DialogDescription",uv=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=c9(ux,n);return(0,T.jsx)(iM.Primitive.p,{id:o.descriptionId,...r,ref:t})});uv.displayName=ux;var uy="DialogClose",ub=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=c9(uy,n);return(0,T.jsx)(iM.Primitive.button,{type:"button",...r,ref:t,onClick:(0,iB.composeEventHandlers)(e.onClick,()=>o.onOpenChange(!1))})});function uw(e){return e?"open":"closed"}ub.displayName=uy;var uS="DialogTitleWarning",[uC,uj]=(0,iO.createContext)(uS,{contentName:uc,titleName:um,docsSlug:"dialog"}),uN=({titleId:e})=>{let t=uj(uS),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
23
-
24
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
25
-
26
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return I.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},uE=({contentRef:e,descriptionId:t})=>{let n=uj("DialogDescriptionWarning"),r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return I.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null};e.s(["Close",()=>ub,"Content",()=>uu,"Description",()=>uv,"Dialog",()=>c7,"DialogClose",()=>ub,"DialogContent",()=>uu,"DialogDescription",()=>uv,"DialogOverlay",()=>us,"DialogPortal",()=>ua,"DialogTitle",()=>ug,"DialogTrigger",()=>ut,"Overlay",()=>us,"Portal",()=>ua,"Root",()=>c7,"Title",()=>ug,"Trigger",()=>ut,"WarningProvider",()=>uC,"createDialogScope",()=>c6],44162);var uk=e.i(44162),uk=uk;function u_({...e}){return(0,T.jsx)(uk.Root,{"data-slot":"dialog",...e})}function uT({...e}){return(0,T.jsx)(uk.Portal,{"data-slot":"dialog-portal",...e})}function uI({className:e,...t}){return(0,T.jsx)(uk.Overlay,{"data-slot":"dialog-overlay",className:(0,iI.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function uR({className:e,children:t,showCloseButton:n=!0,...r}){return(0,T.jsxs)(uT,{"data-slot":"dialog-portal",children:[(0,T.jsx)(uI,{}),(0,T.jsxs)(uk.Content,{"data-slot":"dialog-content",className:(0,iI.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...r,children:[t,n&&(0,T.jsxs)(uk.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,T.jsx)(c2,{}),(0,T.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function uP({className:e,...t}){return(0,T.jsx)("div",{"data-slot":"dialog-header",className:(0,iI.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function uM({className:e,showCloseButton:t=!1,children:n,...r}){return(0,T.jsxs)("div",{"data-slot":"dialog-footer",className:(0,iI.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&(0,T.jsx)(uk.Close,{asChild:!0,children:(0,T.jsx)(iP,{variant:"outline",children:"Close"})})]})}function uA({className:e,...t}){return(0,T.jsx)(uk.Title,{"data-slot":"dialog-title",className:(0,iI.cn)("text-lg leading-none font-semibold",e),...t})}function uO({className:e,...t}){return(0,T.jsx)(uk.Description,{"data-slot":"dialog-description",className:(0,iI.cn)("text-muted-foreground text-sm",e),...t})}function uD({initialMethod:e="GET",initialPath:t="/api/hello",onClose:n}){let[r,o]=(0,I.useState)(e),[a,i]=(0,I.useState)(`http://localhost:3003${t}`),[s,l]=(0,I.useState)('{\n "Content-Type": "application/json"\n}'),[d,c]=(0,I.useState)("{}"),[u,p]=(0,I.useState)(null),[f,h]=(0,I.useState)(!1),[m,g]=(0,I.useState)(null),x=(0,I.useCallback)(async()=>{h(!0),g(null),p(null);let e=performance.now();try{let t,n={};try{n=JSON.parse(s)}catch{g("Invalid Headers JSON format"),h(!1);return}let o={method:r,headers:n};["POST","PUT","PATCH"].includes(r)&&d.trim()&&(o.body=d);let i=await fetch(a,o),l=Math.round(performance.now()-e),c={};if(i.headers.forEach((e,t)=>{c[t]=e}),(i.headers.get("content-type")||"").includes("application/json")){let e=await i.json();t=JSON.stringify(e,null,2)}else t=await i.text();p({status:i.status,statusText:i.statusText,headers:c,body:t,duration:l})}catch(e){g(e instanceof Error?e.message:String(e))}finally{h(!1)}},[r,a,s,d]),v=u?u.status<300?"default":u.status<400?"secondary":"destructive":"secondary";return(0,T.jsx)(u_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,T.jsxs)(uR,{className:"sm:max-w-[820px] max-h-[85vh] flex flex-col gap-0 p-0",children:[(0,T.jsx)(uP,{className:"px-5 pt-5 pb-3",children:(0,T.jsx)(uA,{children:"🧪 API Test Sandbox"})}),(0,T.jsxs)("div",{className:"px-5 pb-4 space-y-3 border-b border-border",children:[(0,T.jsxs)("div",{className:"flex gap-2",children:[(0,T.jsxs)(d3,{value:r,onValueChange:o,children:[(0,T.jsx)(d6,{className:"w-[110px] font-mono text-sm",children:(0,T.jsx)(d4,{})}),(0,T.jsx)(d8,{children:["GET","POST","PUT","PATCH","DELETE"].map(e=>(0,T.jsx)(d9,{value:e,children:e},e))})]}),(0,T.jsx)(sV,{value:a,onChange:e=>i(e.target.value),placeholder:"http://localhost:3003/api/...",className:"flex-1 font-mono text-sm"}),(0,T.jsx)(iP,{onClick:x,disabled:f,size:"default",children:f?"⏳":"▶ Send"})]}),(0,T.jsxs)(cZ,{defaultValue:"body",className:"w-full",children:[(0,T.jsxs)(cQ,{className:"h-8",children:[(0,T.jsx)(c0,{value:"body",className:"text-xs",children:"Body"}),(0,T.jsx)(c0,{value:"headers",className:"text-xs",children:"Headers"})]}),(0,T.jsx)(c1,{value:"body",children:(0,T.jsx)(sX,{value:d,onChange:e=>c(e.target.value),placeholder:'{ "key": "value" }',rows:4,className:"font-mono text-xs resize-y"})}),(0,T.jsx)(c1,{value:"headers",children:(0,T.jsx)(sX,{value:s,onChange:e=>l(e.target.value),rows:4,className:"font-mono text-xs resize-y"})})]})]}),(0,T.jsxs)(sf,{className:"flex-1 px-5 py-4 max-h-[50vh]",children:[m&&(0,T.jsxs)("div",{className:"text-destructive text-xs font-mono bg-destructive/10 px-3 py-2 rounded-md mb-3",children:["❌ ",m]}),u&&(0,T.jsxs)("div",{className:"space-y-3",children:[(0,T.jsxs)("div",{className:"flex items-center gap-3",children:[(0,T.jsxs)(sY,{variant:v,className:"font-mono",children:[u.status," ",u.statusText]}),(0,T.jsxs)("span",{className:"text-muted-foreground text-xs",children:["⏱ ",u.duration,"ms"]}),(0,T.jsxs)("span",{className:"text-muted-foreground text-xs",children:["📦 ",new Blob([u.body]).size," bytes"]})]}),(0,T.jsx)("pre",{className:"bg-secondary text-emerald-400 text-xs font-mono rounded-lg p-3 overflow-auto max-h-[300px] whitespace-pre-wrap border border-border",children:u.body}),(0,T.jsxs)("details",{className:"text-xs",children:[(0,T.jsxs)("summary",{className:"text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:["Response Headers (",Object.keys(u.headers).length,")"]}),(0,T.jsx)("pre",{className:"bg-secondary text-muted-foreground font-mono rounded-lg p-2 mt-1 overflow-auto max-h-[150px] border border-border",children:JSON.stringify(u.headers,null,2)})]})]}),!u&&!m&&!f&&(0,T.jsx)("p",{className:"text-muted-foreground text-xs text-center py-8",children:"Click Send to make a request"})]})]})})}let uL={name:"",baseUrl:"",apiKey:"",model:"gpt-4o",supportsJsonMode:!0};function uz({open:e,onOpenChange:t}){let{activeEndpointId:n,endpoints:r,setActiveEndpoint:o,addEndpoint:a,updateEndpoint:i,removeEndpoint:s}=cc(),[l,d]=(0,I.useState)(null),[c,u]=(0,I.useState)(uL),[p,f]=(0,I.useState)(!1),h=async e=>{try{let t=e.baseUrl.replace(/\/+$/,""),n={"Content-Type":"application/json"};e.apiKey&&(n.Authorization=`Bearer ${e.apiKey}`);let r=await fetch(`${t}/models`,{headers:n});r.ok?alert("✅ Connection successful!"):alert(`❌ Connection failed: HTTP ${r.status}`)}catch(e){alert(`❌ Connection failed: ${e instanceof Error?e.message:String(e)}`)}};return(0,T.jsx)(u_,{open:e,onOpenChange:t,children:(0,T.jsxs)(uR,{className:"sm:max-w-[600px] max-h-[80vh] flex flex-col",children:[(0,T.jsxs)(uP,{children:[(0,T.jsx)(uA,{children:"⚙️ AI API Settings"}),(0,T.jsx)(uO,{children:"Configure AI endpoints to generate flow diagrams using natural language. Supports OpenAI, copilot-api reverse proxy, Gemini Web API, or any OpenAI-compatible API."})]}),(0,T.jsx)(sf,{className:"flex-1 max-h-[55vh]",children:(0,T.jsxs)("div",{className:"space-y-4 p-1",children:[(0,T.jsx)("button",{onClick:()=>o("env"),className:`w-full text-left px-4 py-3 rounded-lg border transition-all cursor-pointer ${"env"===n?"border-purple-500 bg-purple-500/10":"border-border hover:bg-accent"}`,children:(0,T.jsxs)("div",{className:"flex items-center justify-between",children:[(0,T.jsxs)("div",{children:[(0,T.jsx)("p",{className:"text-sm font-medium",children:"🔑 Environment Variable Mode"}),(0,T.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Uses OPENAI_API_KEY / OPENAI_BASE_URL / OPENAI_MODEL"})]}),"env"===n&&(0,T.jsx)(sY,{className:"bg-purple-600 text-white text-[10px]",children:"Active"})]})}),(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"space-y-2",children:[(0,T.jsxs)("div",{className:"flex items-center justify-between",children:[(0,T.jsx)("p",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:"Custom Endpoints"}),(0,T.jsx)(iP,{variant:"outline",size:"sm",onClick:()=>{u(uL),d(null),f(!0)},className:"h-7 text-xs",children:"+ Add Endpoint"})]}),r.map((e,t)=>(0,T.jsx)("div",{role:"button",tabIndex:0,onClick:()=>o(String(t)),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&o(String(t))},className:`w-full text-left px-4 py-3 rounded-lg border transition-all cursor-pointer ${n===String(t)?"border-purple-500 bg-purple-500/10":"border-border hover:bg-accent"}`,children:(0,T.jsxs)("div",{className:"flex items-center justify-between",children:[(0,T.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,T.jsx)(sY,{variant:"secondary",className:"text-[10px] font-mono shrink-0",children:e.model})]}),(0,T.jsx)("p",{className:"text-[10px] text-muted-foreground font-mono mt-0.5 truncate",children:e.baseUrl})]}),(0,T.jsxs)("div",{className:"flex items-center gap-1 ml-2 shrink-0",children:[n===String(t)&&(0,T.jsx)(sY,{className:"bg-purple-600 text-white text-[10px]",children:"Active"}),(0,T.jsx)(iP,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-xs",onClick:t=>{t.stopPropagation(),h(e)},children:"🔌"}),(0,T.jsx)(iP,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-xs",onClick:e=>{e.stopPropagation(),u({...r[t]}),d(t),f(!0)},children:"✏️"}),(0,T.jsx)(iP,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-xs text-destructive",onClick:e=>{e.stopPropagation(),s(t)},children:"🗑️"})]})]})},t)),0===r.length&&(0,T.jsx)("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No custom endpoints added yet"})]}),p&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"space-y-3 p-3 border border-border rounded-lg bg-secondary/30",children:[(0,T.jsx)("p",{className:"text-xs font-semibold",children:null!==l?"✏️ Edit Endpoint":"➕ Add Endpoint"}),(0,T.jsxs)("div",{className:"space-y-2",children:[(0,T.jsxs)("div",{children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Name"}),(0,T.jsx)(sV,{value:c.name,onChange:e=>u(t=>({...t,name:e.target.value})),placeholder:"My Copilot API",className:"font-mono text-xs h-8 mt-1"})]}),(0,T.jsxs)("div",{children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Base URL"}),(0,T.jsx)(sV,{value:c.baseUrl,onChange:e=>u(t=>({...t,baseUrl:e.target.value})),placeholder:"http://localhost:4141/v1",className:"font-mono text-xs h-8 mt-1"})]}),(0,T.jsxs)("div",{children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"API Key (optional)"}),(0,T.jsx)(sV,{type:"password",value:c.apiKey,onChange:e=>u(t=>({...t,apiKey:e.target.value})),placeholder:"sk-xxxx (can be left empty for reverse proxies)",className:"font-mono text-xs h-8 mt-1"})]}),(0,T.jsxs)("div",{children:[(0,T.jsx)(sW,{className:"text-[10px] uppercase tracking-wider",children:"Model"}),(0,T.jsx)(sV,{value:c.model,onChange:e=>u(t=>({...t,model:e.target.value})),placeholder:"gpt-4o",className:"font-mono text-xs h-8 mt-1"})]}),(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)("input",{type:"checkbox",id:"json-mode",checked:c.supportsJsonMode,onChange:e=>u(t=>({...t,supportsJsonMode:e.target.checked})),className:"rounded border-border accent-primary"}),(0,T.jsx)(sW,{htmlFor:"json-mode",className:"text-[10px] uppercase tracking-wider cursor-pointer",children:"Supports JSON Mode (response_format)"})]})]}),(0,T.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>{f(!1),d(null)},className:"h-7 text-xs",children:"Cancel"}),(0,T.jsx)(iP,{size:"sm",onClick:()=>{c.name.trim()&&c.baseUrl.trim()&&(null!==l?i(l,c):a(c),f(!1),u(uL),d(null))},disabled:!c.name.trim()||!c.baseUrl.trim(),className:"h-7 text-xs bg-purple-600 hover:bg-purple-500 text-white",children:"Save"})]})]})]}),(0,T.jsx)(sy,{}),(0,T.jsxs)("div",{className:"space-y-1.5 text-[10px] text-muted-foreground",children:[(0,T.jsx)("p",{className:"font-semibold uppercase tracking-wider",children:"Supported API Formats"}),(0,T.jsxs)("ul",{className:"space-y-0.5 list-disc list-inside",children:[(0,T.jsxs)("li",{children:[(0,T.jsx)("strong",{children:"OpenAI"})," — api.openai.com/v1"]}),(0,T.jsxs)("li",{children:[(0,T.jsx)("strong",{children:"copilot-api"})," — Reverse GitHub Copilot API (localhost:4141/v1)"]}),(0,T.jsxs)("li",{children:[(0,T.jsx)("strong",{children:"Gemini Web API"})," — Reverse Google Gemini"]}),(0,T.jsxs)("li",{children:[(0,T.jsx)("strong",{children:"Ollama"})," — localhost:11434/v1"]}),(0,T.jsx)("li",{children:"Any OpenAI-compatible /chat/completions endpoint"})]})]})]})}),(0,T.jsx)(uM,{children:(0,T.jsx)(iP,{variant:"outline",onClick:()=>t(!1),children:"Close"})})]})})}function u$({entry:e,onRestore:t}){var n;let r,o=e.label.toLowerCase().includes("ai")||e.label.includes("loading"),a=e.label.toLowerCase().includes("reset"),i=e.label.toLowerCase().includes("restore");return(0,T.jsxs)("div",{className:"group flex items-start gap-3 py-2.5 px-3 rounded-md hover:bg-accent/30 transition-colors",children:[(0,T.jsxs)("div",{className:"flex flex-col items-center pt-1",children:[(0,T.jsx)("span",{className:"text-sm",children:o?"✨":a?"🗑️":i?"⏪":"💾"}),(0,T.jsx)("div",{className:"w-px flex-1 bg-border mt-1"})]}),(0,T.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,T.jsx)("p",{className:"text-xs text-foreground leading-tight truncate",children:e.label}),(0,T.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"·"}),(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(n=e.timestamp,(r=Date.now()-new Date(n).getTime())<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`)})]}),(0,T.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[(0,T.jsxs)(sY,{variant:"secondary",className:"text-[9px] px-1.5 py-0",children:[e.nodeCount," nodes"]}),(0,T.jsxs)(sY,{variant:"secondary",className:"text-[9px] px-1.5 py-0",children:[e.edgeCount," edges"]})]})]}),(0,T.jsx)(iP,{variant:"outline",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity h-7 text-[10px] shrink-0",onClick:()=>t(e.id),children:"⏪ Restore"})]})}function uH(){let e=iw(e=>e.flowHistory),t=iw(e=>e.restoreFromHistory),n=iw(e=>e.clearFlowHistory),r=iw(e=>e.nodes),o=iw(e=>e.edges),a=[...e].reverse();return(0,T.jsxs)("div",{className:"flex flex-col h-full max-h-[60vh]",children:[(0,T.jsx)("div",{className:"px-4 py-3 bg-accent/20 rounded-md mb-3",children:(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)("span",{className:"text-sm",children:"📍"}),(0,T.jsxs)("div",{children:[(0,T.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Current State"}),(0,T.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:[r.length," nodes · ",o.length," edges"]})]})]})}),0===e.length?(0,T.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,T.jsxs)("div",{className:"text-center",children:[(0,T.jsx)("p",{className:"text-sm text-muted-foreground",children:"No history yet"}),(0,T.jsx)("p",{className:"text-[10px] text-muted-foreground mt-1",children:"History is automatically saved when you generate with AI, load files, or reset."})]})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,T.jsxs)("span",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider",children:["Timeline (",e.length,")"]}),(0,T.jsx)(iP,{variant:"ghost",size:"sm",className:"text-[10px] text-destructive hover:text-destructive h-6",onClick:n,children:"Clear All"})]}),(0,T.jsx)(sf,{className:"flex-1",children:(0,T.jsx)("div",{className:"flex flex-col gap-0.5",children:a.map(e=>(0,T.jsx)(u$,{entry:e,onRestore:t},e.id))})})]})]})}s0("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),s0("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var uF=iT,uB=["Enter"," "],uV=["ArrowUp","PageDown","End"],uU=["ArrowDown","PageUp","Home",...uV],uK={ltr:[...uB,"ArrowRight"],rtl:[...uB,"ArrowLeft"]},uW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uX="Menu",[uG,uY,uq]=s4(uX),[uZ,uJ]=(0,iO.createContextScope)(uX,[uq,lp.createPopperScope,cE]),uQ=(0,lp.createPopperScope)(),u0=cE(),[u1,u2]=uZ(uX),[u5,u3]=uZ(uX),u4=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,s=uQ(t),[l,d]=I.useState(null),c=I.useRef(!1),u=(0,iL.useCallbackRef)(a),p=i$(o);return I.useEffect(()=>{let e=()=>{c.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>c.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,T.jsx)(lp.Root,{...s,children:(0,T.jsx)(u1,{scope:t,open:n,onOpenChange:u,content:l,onContentChange:d,children:(0,T.jsx)(u5,{scope:t,onClose:I.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:c,dir:p,modal:i,children:r})})})};u4.displayName=uX;var u6=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,o=uQ(n);return(0,T.jsx)(lp.Anchor,{...o,...r,ref:t})});u6.displayName="MenuAnchor";var u8="MenuPortal",[u9,u7]=uZ(u8,{forceMount:void 0}),pe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=u2(u8,t);return(0,T.jsx)(u9,{scope:t,forceMount:n,children:(0,T.jsx)(iA.Presence,{present:n||a.open,children:(0,T.jsx)(lf.Portal,{asChild:!0,container:o,children:r})})})};pe.displayName=u8;var pt="MenuContent",[pn,pr]=uZ(pt),po=I.forwardRef((e,t)=>{let n=u7(pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=u2(pt,e.__scopeMenu),i=u3(pt,e.__scopeMenu);return(0,T.jsx)(uG.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(iA.Presence,{present:r||a.open,children:(0,T.jsx)(uG.Slot,{scope:e.__scopeMenu,children:i.modal?(0,T.jsx)(pa,{...o,ref:t}):(0,T.jsx)(pi,{...o,ref:t})})})})}),pa=I.forwardRef((e,t)=>{let n=u2(pt,e.__scopeMenu),r=I.useRef(null),o=(0,iD.useComposedRefs)(t,r);return I.useEffect(()=>{let e=r.current;if(e)return lS(e)},[]),(0,T.jsx)(pl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:(0,iB.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),pi=I.forwardRef((e,t)=>{let n=u2(pt,e.__scopeMenu);return(0,T.jsx)(pl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ps=(0,uF.createSlot)("MenuContent.ScrollLock"),pl=I.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,onDismiss:f,disableOutsideScroll:h,...m}=e,g=u2(pt,n),x=u3(pt,n),v=uQ(n),y=u0(n),b=uY(n),[w,S]=I.useState(null),C=I.useRef(null),j=(0,iD.useComposedRefs)(t,C,g.onContentChange),N=I.useRef(0),E=I.useRef(""),k=I.useRef(0),_=I.useRef(null),R=I.useRef("right"),P=I.useRef(0),M=h?l8:I.Fragment;I.useEffect(()=>()=>window.clearTimeout(N.current),[]),lt();let A=I.useCallback(e=>{var t,n;return R.current===_.current?.side&&(t=e,!!(n=_.current?.area)&&function(e,t){let{x:n,y:r}=e,o=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let i=t[e],s=t[a],l=i.x,d=i.y,c=s.x,u=s.y;d>r!=u>r&&n<(c-l)*(r-d)/(u-d)+l&&(o=!o)}return o}({x:t.clientX,y:t.clientY},n))},[]);return(0,T.jsx)(pn,{scope:n,searchRef:E,onItemEnter:I.useCallback(e=>{A(e)&&e.preventDefault()},[A]),onItemLeave:I.useCallback(e=>{A(e)||(C.current?.focus(),S(null))},[A]),onTriggerLeave:I.useCallback(e=>{A(e)&&e.preventDefault()},[A]),pointerGraceTimerRef:k,onPointerGraceIntentChange:I.useCallback(e=>{_.current=e},[]),children:(0,T.jsx)(M,{...h?{as:ps,allowPinchZoom:!0}:void 0,children:(0,T.jsx)(li,{asChild:!0,trapped:o,onMountAutoFocus:(0,iB.composeEventHandlers)(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:(0,T.jsx)(s7.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,onDismiss:f,children:(0,T.jsx)(cT,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:(0,iB.composeEventHandlers)(l,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,T.jsx)(lp.Content,{role:"menu","aria-orientation":"vertical","data-state":pD(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...m,ref:j,style:{outline:"none",...m.style},onKeyDown:(0,iB.composeEventHandlers)(m.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var o;let t,a,i,s,l,d;"Tab"===e.key&&e.preventDefault(),!n&&r&&(o=e.key,t=E.current+o,a=b().filter(e=>!e.disabled),i=document.activeElement,s=a.find(e=>e.ref.current===i)?.textValue,l=function(e,t,n){var r;let o=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,a=n?e.indexOf(n):-1,i=(r=Math.max(a,0),e.map((t,n)=>e[(r+n)%e.length]));1===o.length&&(i=i.filter(e=>e!==n));let s=i.find(e=>e.toLowerCase().startsWith(o.toLowerCase()));return s!==n?s:void 0}(a.map(e=>e.textValue),t,s),d=a.find(e=>e.textValue===l)?.ref.current,function e(t){E.current=t,window.clearTimeout(N.current),""!==t&&(N.current=window.setTimeout(()=>e(""),1e3))}(t),d&&setTimeout(()=>d.focus()))}let a=C.current;if(e.target!==a||!uU.includes(e.key))return;e.preventDefault();let i=b().filter(e=>!e.disabled).map(e=>e.ref.current);uV.includes(e.key)&&i.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(i)}),onBlur:(0,iB.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(N.current),E.current="")}),onPointerMove:(0,iB.composeEventHandlers)(e.onPointerMove,p$(e=>{let t=e.target,n=P.current!==e.clientX;e.currentTarget.contains(t)&&n&&(R.current=e.clientX>P.current?"right":"left",P.current=e.clientX)}))})})})})})})});po.displayName=pt;var pd=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(iM.Primitive.div,{role:"group",...r,ref:t})});pd.displayName="MenuGroup";var pc=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(iM.Primitive.div,{...r,ref:t})});pc.displayName="MenuLabel";var pu="MenuItem",pp="menu.itemSelect",pf=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...o}=e,a=I.useRef(null),i=u3(pu,e.__scopeMenu),s=pr(pu,e.__scopeMenu),l=(0,iD.useComposedRefs)(t,a),d=I.useRef(!1);return(0,T.jsx)(ph,{...o,ref:l,disabled:n,onClick:(0,iB.composeEventHandlers)(e.onClick,()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(pp,{bubbles:!0,cancelable:!0});e.addEventListener(pp,e=>r?.(e),{once:!0}),(0,iM.dispatchDiscreteCustomEvent)(e,t),t.defaultPrevented?d.current=!1:i.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),d.current=!0},onPointerUp:(0,iB.composeEventHandlers)(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==s.searchRef.current;n||t&&" "===e.key||uB.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});pf.displayName=pu;var ph=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=pr(pu,n),s=u0(n),l=I.useRef(null),d=(0,iD.useComposedRefs)(t,l),[c,u]=I.useState(!1),[p,f]=I.useState("");return I.useEffect(()=>{let e=l.current;e&&f((e.textContent??"").trim())},[a.children]),(0,T.jsx)(uG.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:(0,T.jsx)(cP,{asChild:!0,...s,focusable:!r,children:(0,T.jsx)(iM.Primitive.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:d,onPointerMove:(0,iB.composeEventHandlers)(e.onPointerMove,p$(e=>{r?i.onItemLeave(e):(i.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,iB.composeEventHandlers)(e.onPointerLeave,p$(e=>i.onItemLeave(e))),onFocus:(0,iB.composeEventHandlers)(e.onFocus,()=>u(!0)),onBlur:(0,iB.composeEventHandlers)(e.onBlur,()=>u(!1))})})})}),pm=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...o}=e;return(0,T.jsx)(pC,{scope:e.__scopeMenu,checked:n,children:(0,T.jsx)(pf,{role:"menuitemcheckbox","aria-checked":pL(n)?"mixed":n,...o,ref:t,"data-state":pz(n),onSelect:(0,iB.composeEventHandlers)(o.onSelect,()=>r?.(!!pL(n)||!n),{checkForDefaultPrevented:!1})})})});pm.displayName="MenuCheckboxItem";var pg="MenuRadioGroup",[px,pv]=uZ(pg,{value:void 0,onValueChange:()=>{}}),py=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...o}=e,a=(0,iL.useCallbackRef)(r);return(0,T.jsx)(px,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,T.jsx)(pd,{...o,ref:t})})});py.displayName=pg;var pb="MenuRadioItem",pw=I.forwardRef((e,t)=>{let{value:n,...r}=e,o=pv(pb,e.__scopeMenu),a=n===o.value;return(0,T.jsx)(pC,{scope:e.__scopeMenu,checked:a,children:(0,T.jsx)(pf,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":pz(a),onSelect:(0,iB.composeEventHandlers)(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});pw.displayName=pb;var pS="MenuItemIndicator",[pC,pj]=uZ(pS,{checked:!1}),pN=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...o}=e,a=pj(pS,n);return(0,T.jsx)(iA.Presence,{present:r||pL(a.checked)||!0===a.checked,children:(0,T.jsx)(iM.Primitive.span,{...o,ref:t,"data-state":pz(a.checked)})})});pN.displayName=pS;var pE=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(iM.Primitive.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});pE.displayName="MenuSeparator";var pk=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,o=uQ(n);return(0,T.jsx)(lp.Arrow,{...o,...r,ref:t})});pk.displayName="MenuArrow";var p_="MenuSub",[pT,pI]=uZ(p_),pR=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,a=u2(p_,t),i=uQ(t),[s,l]=I.useState(null),[d,c]=I.useState(null),u=(0,iL.useCallbackRef)(o);return I.useEffect(()=>(!1===a.open&&u(!1),()=>u(!1)),[a.open,u]),(0,T.jsx)(lp.Root,{...i,children:(0,T.jsx)(u1,{scope:t,open:r,onOpenChange:u,content:d,onContentChange:c,children:(0,T.jsx)(pT,{scope:t,contentId:(0,sS.useId)(),triggerId:(0,sS.useId)(),trigger:s,onTriggerChange:l,children:n})})})};pR.displayName=p_;var pP="MenuSubTrigger",pM=I.forwardRef((e,t)=>{let n=u2(pP,e.__scopeMenu),r=u3(pP,e.__scopeMenu),o=pI(pP,e.__scopeMenu),a=pr(pP,e.__scopeMenu),i=I.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,d={__scopeMenu:e.__scopeMenu},c=I.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return I.useEffect(()=>c,[c]),I.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]),(0,T.jsx)(u6,{asChild:!0,...d,children:(0,T.jsx)(ph,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pD(n.open),...e,ref:(0,iD.composeRefs)(t,o.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:(0,iB.composeEventHandlers)(e.onPointerMove,p$(t=>{a.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||i.current||(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100)))})),onPointerLeave:(0,iB.composeEventHandlers)(e.onPointerLeave,p$(e=>{c();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,o="right"===r,i=t[o?"left":"right"],l=t[o?"right":"left"];a.onPointerGraceIntentChange({area:[{x:e.clientX+(o?-5:5),y:e.clientY},{x:i,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:i,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,t=>{let o=""!==a.searchRef.current;e.disabled||o&&" "===t.key||uK[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});pM.displayName=pP;var pA="MenuSubContent",pO=I.forwardRef((e,t)=>{let n=u7(pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=u2(pt,e.__scopeMenu),i=u3(pt,e.__scopeMenu),s=pI(pA,e.__scopeMenu),l=I.useRef(null),d=(0,iD.useComposedRefs)(t,l);return(0,T.jsx)(uG.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(iA.Presence,{present:r||a.open,children:(0,T.jsx)(uG.Slot,{scope:e.__scopeMenu,children:(0,T.jsx)(pl,{id:s.contentId,"aria-labelledby":s.triggerId,...o,ref:d,align:"start",side:"rtl"===i.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{i.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,iB.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:(0,iB.composeEventHandlers)(e.onEscapeKeyDown,e=>{i.onClose(),e.preventDefault()}),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=uW[i.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});function pD(e){return e?"open":"closed"}function pL(e){return"indeterminate"===e}function pz(e){return pL(e)?"indeterminate":e?"checked":"unchecked"}function p$(e){return t=>"mouse"===t.pointerType?e(t):void 0}pO.displayName=pA;var pH="DropdownMenu",[pF,pB]=(0,iO.createContextScope)(pH,[uJ]),pV=uJ(),[pU,pK]=pF(pH),pW=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:s=!0}=e,l=pV(t),d=I.useRef(null),[c,u]=(0,sw.useControllableState)({prop:o,defaultProp:a??!1,onChange:i,caller:pH});return(0,T.jsx)(pU,{scope:t,triggerId:(0,sS.useId)(),triggerRef:d,contentId:(0,sS.useId)(),open:c,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:s,children:(0,T.jsx)(u4,{...l,open:c,onOpenChange:u,dir:r,modal:s,children:n})})};pW.displayName=pH;var pX="DropdownMenuTrigger",pG=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=pK(pX,n),i=pV(n);return(0,T.jsx)(u6,{asChild:!0,...i,children:(0,T.jsx)(iM.Primitive.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:(0,iD.composeRefs)(t,a.triggerRef),onPointerDown:(0,iB.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:(0,iB.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&a.onOpenToggle(),"ArrowDown"===e.key&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});pG.displayName=pX;var pY=e=>{let{__scopeDropdownMenu:t,...n}=e,r=pV(t);return(0,T.jsx)(pe,{...r,...n})};pY.displayName="DropdownMenuPortal";var pq="DropdownMenuContent",pZ=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pK(pq,n),a=pV(n),i=I.useRef(!1);return(0,T.jsx)(po,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:(0,iB.composeEventHandlers)(e.onCloseAutoFocus,e=>{i.current||o.triggerRef.current?.focus(),i.current=!1,e.preventDefault()}),onInteractOutside:(0,iB.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!o.modal||r)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});pZ.displayName=pq;var pJ=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pd,{...o,...r,ref:t})});pJ.displayName="DropdownMenuGroup";var pQ=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pc,{...o,...r,ref:t})});pQ.displayName="DropdownMenuLabel";var p0=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pf,{...o,...r,ref:t})});p0.displayName="DropdownMenuItem";var p1=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pm,{...o,...r,ref:t})});p1.displayName="DropdownMenuCheckboxItem";var p2=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(py,{...o,...r,ref:t})});p2.displayName="DropdownMenuRadioGroup";var p5=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pw,{...o,...r,ref:t})});p5.displayName="DropdownMenuRadioItem";var p3=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pN,{...o,...r,ref:t})});p3.displayName="DropdownMenuItemIndicator";var p4=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pE,{...o,...r,ref:t})});p4.displayName="DropdownMenuSeparator";var p6=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pk,{...o,...r,ref:t})});p6.displayName="DropdownMenuArrow";var p8=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:a}=e,i=pV(t),[s,l]=(0,sw.useControllableState)({prop:r,defaultProp:a??!1,onChange:o,caller:"DropdownMenuSub"});return(0,T.jsx)(pR,{...i,open:s,onOpenChange:l,children:n})},p9=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pM,{...o,...r,ref:t})});p9.displayName="DropdownMenuSubTrigger";var p7=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,o=pV(n);return(0,T.jsx)(pO,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});p7.displayName="DropdownMenuSubContent",e.s(["Arrow",()=>p6,"CheckboxItem",()=>p1,"Content",()=>pZ,"DropdownMenu",()=>pW,"DropdownMenuArrow",()=>p6,"DropdownMenuCheckboxItem",()=>p1,"DropdownMenuContent",()=>pZ,"DropdownMenuGroup",()=>pJ,"DropdownMenuItem",()=>p0,"DropdownMenuItemIndicator",()=>p3,"DropdownMenuLabel",()=>pQ,"DropdownMenuPortal",()=>pY,"DropdownMenuRadioGroup",()=>p2,"DropdownMenuRadioItem",()=>p5,"DropdownMenuSeparator",()=>p4,"DropdownMenuSub",()=>p8,"DropdownMenuSubContent",()=>p7,"DropdownMenuSubTrigger",()=>p9,"DropdownMenuTrigger",()=>pG,"Group",()=>pJ,"Item",()=>p0,"ItemIndicator",()=>p3,"Label",()=>pQ,"Portal",()=>pY,"RadioGroup",()=>p2,"RadioItem",()=>p5,"Root",()=>pW,"Separator",()=>p4,"Sub",()=>p8,"SubContent",()=>p7,"SubTrigger",()=>p9,"Trigger",()=>pG,"createDropdownMenuScope",()=>pB],81332);var fe=e.i(81332),fe=fe;function ft({...e}){return(0,T.jsx)(fe.Root,{"data-slot":"dropdown-menu",...e})}function fn({...e}){return(0,T.jsx)(fe.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function fr({className:e,sideOffset:t=4,...n}){return(0,T.jsx)(fe.Portal,{children:(0,T.jsx)(fe.Content,{"data-slot":"dropdown-menu-content",sideOffset:t,className:(0,iI.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function fo({className:e,inset:t,variant:n="default",...r}){return(0,T.jsx)(fe.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:(0,iI.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function fa({className:e,...t}){return(0,T.jsx)(fe.Separator,{"data-slot":"dropdown-menu-separator",className:(0,iI.cn)("bg-border -mx-1 my-1 h-px",e),...t})}function fi(){let t,n,r,o,a=iw(e=>e.exportIR),i=iw(e=>e.reset),s=iw(e=>e.nodes),[l,d]=(0,I.useState)(""),[c,u]=(0,I.useState)(!1),[p,f]=(0,I.useState)(!1),[h,m]=(0,I.useState)(!1),[g,x]=(0,I.useState)("GET"),[v,y]=(0,I.useState)("/api/hello"),[b,w]=(0,I.useState)(!1),[S,C]=(0,I.useState)(!1),j=(0,I.useRef)(null),N=cc(),E=(t=iw(e=>e.exportIR),n=(0,I.useCallback)(()=>{let e=JSON.stringify(t(),null,2);return navigator.clipboard?.writeText(e).catch(()=>{}),e},[t]),r=(0,I.useCallback)(()=>{let e=t(),n=(0,cp.validateFlowIR)(e);return n.valid?"✅ IR validation passed! No errors.":"❌ IR validation failed:\n"+n.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")},[t]),o=(0,I.useCallback)(()=>{let e=t();if(!(0,cp.validateFlowIR)(e).valid)return"❌ Please fix IR errors before analyzing the execution plan.";try{let t=function(e){let{nodes:t,edges:n}=e,{indegree:r,adjacency:o,reverseAdjacency:a}=function(e,t){let n=new Map,r=new Map,o=new Map;for(let t of e)n.set(t.id,0),r.set(t.id,new Set),o.set(t.id,new Set);for(let e of t)r.get(e.sourceNodeId).add(e.targetNodeId),o.get(e.targetNodeId).add(e.sourceNodeId),n.set(e.targetNodeId,(n.get(e.targetNodeId)??0)+1);return{indegree:n,adjacency:r,reverseAdjacency:o}}(t,n),i=new Map(r),s=[],l=[],d=[];for(let[e,t]of i)0===t&&d.push(e);let c=0;for(;d.length>0;){l.push({index:c,nodeIds:[...d],concurrent:d.length>1}),s.push(...d);let e=[];for(let t of d)for(let n of o.get(t)??[]){let t=(i.get(n)??1)-1;i.set(n,t),0===t&&e.push(n)}d=e,c++}let u=new Map,p=new Map;for(let e of t)u.set(e.id,a.get(e.id)??new Set),p.set(e.id,o.get(e.id)??new Set);if(s.length!==t.length)throw Error(`Topological sort failed: cycle detected in graph. Sorted ${s.length}/${t.length} nodes.`);return{steps:l,sortedNodeIds:s,dependencies:u,dependents:p}}(e),n=new Map(e.nodes.map(e=>[e.id,e])),r=["=== Execution Plan ==="];for(let e of t.steps){let t=e.nodeIds.map(e=>{let t=n.get(e);return t?`${t.label} (${e})`:e}).join(", "),o=e.concurrent?"⚡ CONCURRENT":"→ SEQUENTIAL";r.push(`Step ${e.index} [${o}]: ${t}`)}return r.join("\n")}catch(e){return`❌ Analysis failed: ${e instanceof Error?e.message:String(e)}`}},[t]),{handleCompile:(0,I.useCallback)(async()=>{let e=t();try{let t=await fetch(`${(0,cf.getApiBase)()}/api/compile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ir:e,write:!0})}),n=await t.json();if(n.success){let e=`✅ Compilation successful!
27
- 📁 ${n.filePath??"generated.ts"}
28
- `;return n.writtenTo&&(e+=`💾 Written to: ${n.writtenTo}
29
- `),n.dependencies?.missing?.length>0&&(e+=`
30
- ⚠️ Missing packages:
31
- `,e+=n.dependencies.missing.map(e=>` npm install ${e}`).join("\n"),e+="\n"),n.dependencies?.all?.length>0&&(e+=`
32
- 📦 Required packages: ${n.dependencies.all.join(", ")}
33
- `),n.sourceMap&&(e+=`
34
- 🗺️ Source Map: ${Object.keys(n.sourceMap.mappings??{}).length} nodes mapped
35
- `),e+=`
36
- ${n.code}`}return`❌ Compilation failed: ${n.error}`}catch(e){return`❌ Compilation request failed: ${e instanceof Error?e.message:String(e)}`}},[t]),handleValidate:r,handleAnalyze:o,handleExportIR:n,handleDownloadIR:(0,I.useCallback)(()=>{let e=t(),n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${e.meta.name.replace(/\s+/g,"-").toLowerCase()||"flow"}.flow.json`,o.click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)},[t])}),k=function(){let e=iw(e=>e.loadIR),t=cc(),[n,r]=(0,I.useState)(""),[o,a]=(0,I.useState)(!1),[i,s]=(0,I.useState)(""),[l,d]=(0,I.useState)(0),c=(0,I.useRef)(null),u=(0,I.useCallback)(e=>{d(cm(e))},[]),p=(0,I.useCallback)(()=>{c.current?.abort()},[]),f=(0,I.useCallback)(async()=>{if(!n.trim())return"";a(!0),s(""),c.current=new AbortController;try{let r=t.getActiveConfig();if(r)return await cx(r,n.trim(),c,s,e);return await cv(n.trim(),c,e)}catch(e){if("AbortError"===e.name)return"⏹️ AI generation cancelled";return`❌ AI request failed: ${e instanceof Error?e.message:String(e)}`}finally{a(!1),s(""),c.current=null}},[n,t,e]);return{aiPrompt:n,setAiPrompt:r,aiLoading:o,aiStreamContent:i,tokenEstimate:l,handleAIGenerate:f,handleCancelAI:p,updateTokenEstimate:u}}(),_=function(t){let n=iw(e=>e.loadIR),[r,o]=(0,I.useState)(!1),[a,i]=(0,I.useState)([]),s=(0,I.useCallback)(()=>new Promise(e=>{let r=document.createElement("input");r.type="file",r.accept=".json,.flow.json",r.onchange=async r=>{let o=r.target.files?.[0];if(!o)return void e(null);let a=await o.text();try{let r=JSON.parse(a),o=(0,cp.validateFlowIR)(r);if(!o.valid){let n="❌ Loaded IR validation failed:\n"+o.errors.map(e=>` [${e.code}] ${e.message}`).join("\n");t(n),e(n);return}n(r);let i=`✅ Flow diagram loaded: "${r.meta?.name??"Untitled"}"`;t(i),e(i)}catch{let n="❌ JSON parse failed. Please verify the file format.";t(n),e(n)}},r.click()}),[n,t]),l=(0,I.useCallback)(()=>{let n=document.createElement("input");n.type="file",n.accept=".json,.yaml,.yml",n.onchange=async n=>{let r=n.target.files?.[0];if(!r)return;let a=await r.text();try{let n;if(r.name.match(/\.ya?ml$/i)){let{parse:t}=await e.A(9830);n=t(a)}else n=JSON.parse(a);let s=await fetch(`${(0,cf.getApiBase)()}/api/import-openapi`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:n})}),l=await s.json();l.flows&&l.flows.length>0?(i(l.flows),o(!0)):t(`❌ OpenAPI import failed: ${l.errors?.join(", ")??"No endpoints found"}`)}catch{t("❌ Parse failed. Please verify the file is a valid OpenAPI 3.x JSON or YAML file.")}},n.click()},[t]),d=(0,I.useCallback)(e=>{let r=(0,cp.validateFlowIR)(e);if(!r.valid){let e=r.errors.map(e=>` [${e.code}] ${e.message}`).join("\n");t(`⚠️ OpenAPI IR has validation warnings:
37
- ${e}`)}n(r.migratedIR??e),o(!1);let a=`✅ Endpoint loaded: "${e.meta?.name??"Untitled"}"
38
- Total ${e.nodes?.length??0} nodes`;return t(a),a},[n,t]);return{showOpenAPIDialog:r,setShowOpenAPIDialog:o,openAPIFlows:a,handleLoadIRFromJSON:s,handleImportOpenAPI:l,handleSelectOpenAPIFlow:d,handleDecompileTS:(0,I.useCallback)(()=>{let r=document.createElement("input");r.type="file",r.accept=".ts,.tsx,.js,.jsx,.txt",r.onchange=async r=>{let o=r.target.files?.[0];if(!o)return;let a=await o.text();if(0===a.trim().length)return void t("❌ File is empty.");try{let{getApiBase:r}=await e.A(98984),i=await fetch(`${r()}/api/decompile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,fileName:o.name.endsWith(".txt")?o.name.replace(/\.txt$/,".ts"):o.name})}),s=await i.json();if(s.success&&s.ir){let e=(0,cp.validateFlowIR)(s.ir);if(!e.valid){let n=e.errors.map(e=>` [${e.code}] ${e.message}`).join("\n");t(`⚠️ Decompiled IR has validation warnings:
39
- ${n}`)}n(e.migratedIR??s.ir);let r=Math.round((s.confidence??0)*100),a=`✅ TypeScript → IR decompilation successful
40
- `;a+=`📊 Confidence score: ${r}%
41
- 📁 ${o.name}
42
-
43
- Total ${s.ir.nodes?.length??0} nodes, ${s.ir.edges?.length??0} edges`,s.errors?.length&&(a+=`
44
-
45
- ⚠️ Warnings:
46
- ${s.errors.join("\n")}`),r<50&&(a+=`
47
-
48
- 💡 Low confidence score — manual review of node configuration recommended`),t(a)}else t(`❌ Decompilation failed:
49
- ${s.errors?.join("\n")??s.error??"Unknown error"}`)}catch(e){t(`❌ Decompile error: ${e instanceof Error?e.message:String(e)}
50
-
51
- Make sure the dev server is running (npx flow2code dev or pnpm dev).`)}},r.click()},[n,t])}}((0,I.useCallback)(e=>{d(e),u(!0)},[])),R=async()=>{let e=await E.handleCompile();if(d(e),u(!0),e.startsWith("✅")){let e=a().nodes.find(e=>"trigger"===e.category);if(e?.params){let t=e.params;"string"==typeof t.method&&x(t.method),"string"==typeof t.routePath&&y(t.routePath)}}},P=async()=>{let e=await k.handleAIGenerate();e&&(d(e),u(!0),e.startsWith("✅")&&(f(!1),k.setAiPrompt("")))};return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("header",{className:"h-12 bg-card border-b border-border flex items-center px-4 gap-1.5 shrink-0",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2 mr-3",children:[(0,T.jsx)("img",{src:"/favicon-32x32.png",alt:"Flow2Code",className:"w-6 h-6"}),(0,T.jsx)("span",{className:"text-sm font-bold tracking-tight text-foreground",children:"Flow2Code"})]}),(0,T.jsx)(sy,{orientation:"vertical",className:"h-5 mx-1"}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:R,className:"text-primary hover:text-primary hover:bg-primary/10",children:"🚀 Compile"})}),(0,T.jsx)(sb.TooltipContent,{children:"Compile the flow diagram to TypeScript code"})]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>{d(E.handleValidate()),u(!0)},children:"✅ Validate"})}),(0,T.jsx)(sb.TooltipContent,{children:"Validate IR structural correctness"})]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>{d(E.handleAnalyze()),u(!0)},children:"📊 Analyze"})}),(0,T.jsx)(sb.TooltipContent,{children:"Analyze execution plan (topological sort + concurrency detection)"})]}),(0,T.jsx)(sy,{orientation:"vertical",className:"h-5 mx-1"}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>f(!0),className:"text-purple-400 hover:text-purple-300 hover:bg-purple-500/10",children:"✨ AI Generate"})}),(0,T.jsx)(sb.TooltipContent,{children:"Describe in natural language, AI auto-generates the flow diagram"})]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"text-purple-400 hover:text-purple-300 hover:bg-purple-500/10 px-1.5",children:"⚙️"})}),(0,T.jsx)(sb.TooltipContent,{children:"AI API endpoint settings"})]}),(0,T.jsx)(sy,{orientation:"vertical",className:"h-5 mx-1"}),(0,T.jsxs)(ft,{children:[(0,T.jsx)(fn,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",children:"📁 File"})}),(0,T.jsxs)(fr,{align:"start",children:[(0,T.jsxs)(fo,{onClick:()=>_.handleLoadIRFromJSON(),children:[(0,T.jsx)("span",{className:"mr-2",children:"📂"})," Load Flow JSON"]}),(0,T.jsxs)(fo,{onClick:E.handleDownloadIR,children:[(0,T.jsx)("span",{className:"mr-2",children:"💾"})," Download Flow JSON"]}),(0,T.jsxs)(fo,{onClick:()=>{d(E.handleExportIR()),u(!0)},children:[(0,T.jsx)("span",{className:"mr-2",children:"📋"})," Export IR to Clipboard"]}),(0,T.jsx)(fa,{}),(0,T.jsxs)(fo,{onClick:_.handleImportOpenAPI,children:[(0,T.jsx)("span",{className:"mr-2",children:"📄"})," Import OpenAPI Spec"]}),(0,T.jsxs)(fo,{onClick:_.handleDecompileTS,children:[(0,T.jsx)("span",{className:"mr-2",children:"🔄"})," Import TypeScript (Decompile)"]})]})]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>m(!0),className:"text-emerald-400 hover:text-emerald-300 hover:bg-emerald-500/10",children:"🧪 Test"})}),(0,T.jsx)(sb.TooltipContent,{children:"Open API test sandbox"})]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:()=>C(!0),children:"📜 History"})}),(0,T.jsx)(sb.TooltipContent,{children:"View flow history and restore previous states"})]}),(0,T.jsx)("div",{className:"flex-1"}),(0,T.jsxs)(sY,{variant:"secondary",className:"text-[10px] font-mono",children:[s.length," nodes"]}),(0,T.jsxs)(sb.Tooltip,{children:[(0,T.jsx)(sb.TooltipTrigger,{asChild:!0,children:(0,T.jsx)(iP,{variant:"ghost",size:"sm",onClick:i,className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:"🗑️ Reset"})}),(0,T.jsx)(sb.TooltipContent,{children:"Clear all nodes and edges"})]})]}),(0,T.jsx)(u_,{open:p,onOpenChange:f,children:(0,T.jsxs)(uR,{className:"sm:max-w-[600px] max-h-[85vh] flex flex-col overflow-hidden",children:[(0,T.jsxs)(uP,{children:[(0,T.jsx)(uA,{children:"✨ AI Generate Flow Diagram"}),(0,T.jsx)(uO,{children:"Describe the API endpoint or workflow you want to build, and AI will automatically generate the complete flow diagram."})]}),(0,T.jsxs)("div",{className:"flex flex-col gap-3 py-2 overflow-y-auto min-h-0",children:[(0,T.jsx)(sX,{ref:j,value:k.aiPrompt,onChange:e=>{k.setAiPrompt(e.target.value),k.updateTokenEstimate(e.target.value)},placeholder:"e.g.: Create a GET /api/users endpoint that queries the user list from the database and returns it...",className:"min-h-[120px] font-mono text-sm resize-y",onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&P()}}),k.aiLoading&&k.aiStreamContent&&(0,T.jsxs)("div",{className:"bg-secondary/50 rounded-md p-3 overflow-hidden",children:[(0,T.jsx)("div",{className:"text-[10px] text-muted-foreground mb-1 font-semibold",children:"📡 Live Stream"}),(0,T.jsxs)(sf,{className:"max-h-[200px] w-full",children:[(0,T.jsx)("pre",{className:"text-[10px] text-emerald-400 font-mono whitespace-pre-wrap break-words",children:k.aiStreamContent.length>500?`...${k.aiStreamContent.slice(-500)}`:k.aiStreamContent}),(0,T.jsx)(sh,{orientation:"vertical"}),(0,T.jsx)(sh,{orientation:"horizontal"})]})]}),(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,T.jsx)("span",{className:"text-[10px] text-muted-foreground uppercase font-semibold tracking-wider",children:"Examples"}),(0,T.jsx)("div",{className:"flex flex-wrap gap-1",children:cu.EXAMPLE_PROMPTS.map((e,t)=>(0,T.jsx)("button",{onClick:()=>{k.setAiPrompt(e),k.updateTokenEstimate(e)},className:"text-[10px] text-purple-400 hover:text-purple-300 bg-secondary hover:bg-secondary/80 px-2 py-1 rounded-md cursor-pointer truncate max-w-[280px] transition-colors",children:e},t))})]})]}),(0,T.jsxs)(uM,{className:"flex items-center justify-between",children:[(0,T.jsxs)("span",{className:"text-muted-foreground text-[10px]",children:["⌘+Enter to submit ·"," ",N.getActiveConfig()?`📡 ${N.getActiveConfig().name}`:"🔑 Environment variable mode",k.tokenEstimate>0&&` \xb7 ~${k.tokenEstimate} tokens`," · ",(0,T.jsx)("button",{onClick:()=>{w(!0)},className:"text-purple-400 hover:underline cursor-pointer",children:"Configure endpoint"})]}),(0,T.jsxs)("div",{className:"flex gap-2",children:[k.aiLoading&&(0,T.jsx)(iP,{onClick:k.handleCancelAI,variant:"outline",size:"sm",className:"text-destructive border-destructive/50 hover:bg-destructive/10",children:"⏹ Cancel"}),(0,T.jsx)(iP,{onClick:P,disabled:k.aiLoading||!k.aiPrompt.trim(),className:"bg-purple-600 hover:bg-purple-500 text-white",children:k.aiLoading?"⏳ Generating...":"✨ Generate"})]})]})]})}),(0,T.jsx)(u_,{open:c,onOpenChange:u,children:(0,T.jsxs)(uR,{className:"sm:max-w-[720px] max-h-[80vh] flex flex-col overflow-hidden",children:[(0,T.jsxs)(uP,{children:[(0,T.jsx)(uA,{children:"Output"}),(0,T.jsx)(uO,{children:"Output from compilation, validation, or AI generation"})]}),(0,T.jsxs)(sf,{className:"flex-1 max-h-[60vh] w-full",children:[(0,T.jsx)("pre",{className:"p-4 text-xs text-emerald-400 font-mono whitespace-pre-wrap break-words leading-relaxed",children:l}),(0,T.jsx)(sh,{orientation:"vertical"}),(0,T.jsx)(sh,{orientation:"horizontal"})]})]})}),h&&(0,T.jsx)(uD,{initialMethod:g,initialPath:v,onClose:()=>m(!1)}),(0,T.jsx)(u_,{open:_.showOpenAPIDialog,onOpenChange:_.setShowOpenAPIDialog,children:(0,T.jsxs)(uR,{className:"sm:max-w-[700px] max-h-[80vh] flex flex-col",children:[(0,T.jsxs)(uP,{children:[(0,T.jsx)(uA,{children:"📄 Select Endpoint to Import"}),(0,T.jsxs)(uO,{children:["Found ",_.openAPIFlows.length," endpoints in the OpenAPI spec. Select one to import:"]})]}),(0,T.jsx)(sf,{className:"flex-1 max-h-[60vh]",children:(0,T.jsx)("div",{className:"flex flex-col gap-0.5 p-1",children:_.openAPIFlows.map((e,t)=>(0,T.jsxs)("button",{onClick:()=>_.handleSelectOpenAPIFlow(e),className:"w-full text-left px-3 py-2.5 hover:bg-accent rounded-md transition-colors cursor-pointer flex items-center gap-3 group",children:[(0,T.jsx)(sY,{variant:"outline",className:"min-w-[60px] justify-center text-[10px] font-bold",children:e.meta?.name?.split(" ")[0]??"?"}),(0,T.jsx)("span",{className:"text-sm text-foreground flex-1 truncate group-hover:text-primary transition-colors",children:e.meta?.name??`Endpoint ${t+1}`}),(0,T.jsxs)("span",{className:"text-muted-foreground text-[10px]",children:[e.nodes?.length??0," nodes"]})]},t))})})]})}),(0,T.jsx)(uz,{open:b,onOpenChange:w}),(0,T.jsx)(u_,{open:S,onOpenChange:C,children:(0,T.jsxs)(uR,{className:"sm:max-w-[520px] max-h-[80vh] flex flex-col overflow-hidden",children:[(0,T.jsxs)(uP,{children:[(0,T.jsx)(uA,{children:"📜 Flow History"}),(0,T.jsx)(uO,{children:"Browse and restore previous flow states. History is automatically saved on AI generation, file load, and reset."})]}),(0,T.jsx)(uH,{})]})})]})}let fs={version:"1.0.0",meta:{name:"User List API",description:"GET /api/users — Auth check → Fetch users → Return JSON",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},nodes:[{id:"trigger_1",nodeType:ic.TriggerType.HTTP_WEBHOOK,category:ic.NodeCategory.TRIGGER,label:"GET /api/users",params:{method:"GET",routePath:"/api/users",parseBody:!1},inputs:[],outputs:[{id:"request",label:"Request",dataType:"object"}]},{id:"transform_1",nodeType:ic.VariableType.TRANSFORM,category:ic.NodeCategory.VARIABLE,label:"Get Auth Token",params:{expression:"req.headers.get('authorization')"},inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"result",label:"Result",dataType:"any"}]},{id:"if_1",nodeType:ic.LogicType.IF_ELSE,category:ic.NodeCategory.LOGIC,label:"Has Token?",params:{condition:"token !== undefined && token !== ''"},inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"true",label:"Yes",dataType:"any"},{id:"false",label:"No",dataType:"any"}]},{id:"fetch_1",nodeType:ic.ActionType.FETCH_API,category:ic.NodeCategory.ACTION,label:"Fetch Users",params:{url:"https://jsonplaceholder.typicode.com/users",method:"GET",parseJson:!0},inputs:[{id:"input",label:"Input",dataType:"any",required:!1}],outputs:[{id:"data",label:"Data",dataType:"any"}]},{id:"response_1",nodeType:ic.OutputType.RETURN_RESPONSE,category:ic.NodeCategory.OUTPUT,label:"200 OK",params:{statusCode:200,bodyExpression:"flowState['fetch_1']"},inputs:[{id:"data",label:"Data",dataType:"any",required:!0}],outputs:[]},{id:"response_2",nodeType:ic.OutputType.RETURN_RESPONSE,category:ic.NodeCategory.OUTPUT,label:"401 Unauthorized",params:{statusCode:401,bodyExpression:"{ error: 'Missing auth token' }"},inputs:[{id:"data",label:"Data",dataType:"any",required:!0}],outputs:[]}],edges:[{id:"e1",sourceNodeId:"trigger_1",sourcePortId:"request",targetNodeId:"transform_1",targetPortId:"input"},{id:"e2",sourceNodeId:"transform_1",sourcePortId:"result",targetNodeId:"if_1",targetPortId:"input"},{id:"e3",sourceNodeId:"if_1",sourcePortId:"true",targetNodeId:"fetch_1",targetPortId:"input"},{id:"e4",sourceNodeId:"fetch_1",sourcePortId:"data",targetNodeId:"response_1",targetPortId:"data"},{id:"e5",sourceNodeId:"if_1",sourcePortId:"false",targetNodeId:"response_2",targetPortId:"data"}]};function fl({onDismiss:e}){let t=iw(e=>e.loadIR);return(0,T.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none",children:(0,T.jsx)("div",{className:"pointer-events-auto max-w-lg w-full mx-4",children:(0,T.jsxs)("div",{className:"bg-[oklch(0.15_0_0)] border border-[oklch(0.25_0_0)] rounded-xl overflow-hidden",children:[(0,T.jsxs)("div",{className:"px-8 pt-8 pb-4",children:[(0,T.jsxs)("div",{className:"flex items-center gap-3 mb-1",children:[(0,T.jsx)("span",{className:"text-2xl font-bold text-[oklch(0.95_0_0)] tracking-tight",children:"Flow2Code"}),(0,T.jsx)("span",{className:"text-[10px] font-mono bg-[oklch(0.22_0_0)] text-[oklch(0.6_0_0)] px-2 py-0.5 rounded",children:"v0.1.4"})]}),(0,T.jsxs)("p",{className:"text-sm text-[oklch(0.55_0_0)] leading-relaxed mt-2",children:["Build API handlers visually, compile to native TypeScript.",(0,T.jsx)("br",{}),"Drag nodes from the left panel, connect ports, then hit Compile."]})]}),(0,T.jsx)("div",{className:"px-8 pb-4",children:(0,T.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[(0,T.jsx)(fd,{icon:"1",text:"Drag a Trigger node to start"}),(0,T.jsx)(fd,{icon:"2",text:"Add Actions for your logic"}),(0,T.jsx)(fd,{icon:"3",text:"Connect ports with edges"}),(0,T.jsx)(fd,{icon:"4",text:"Click Compile to generate TS"})]})}),(0,T.jsx)("div",{className:"px-8 pb-5",children:(0,T.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-[oklch(0.45_0_0)]",children:[(0,T.jsxs)("span",{children:[(0,T.jsx)(fc,{children:"Ctrl+Z"})," Undo"]}),(0,T.jsxs)("span",{children:[(0,T.jsx)(fc,{children:"Ctrl+Shift+Z"})," Redo"]}),(0,T.jsxs)("span",{children:[(0,T.jsx)(fc,{children:"Delete"})," Remove selected"]}),(0,T.jsxs)("span",{children:[(0,T.jsx)(fc,{children:"Click edge"})," Select → Delete"]})]})}),(0,T.jsxs)("div",{className:"border-t border-[oklch(0.22_0_0)] px-8 py-4 flex items-center gap-3",children:[(0,T.jsx)(iP,{onClick:()=>{t(fs),e()},className:"bg-[oklch(0.65_0.2_260)] hover:bg-[oklch(0.6_0.2_260)] text-white text-sm h-9 px-4",children:"Load example flow"}),(0,T.jsx)(iP,{variant:"ghost",onClick:e,className:"text-sm text-[oklch(0.55_0_0)] hover:text-[oklch(0.8_0_0)] h-9 px-4",children:"Start from scratch"})]})]})})})}function fd({icon:e,text:t}){return(0,T.jsxs)("div",{className:"flex items-center gap-2 text-[oklch(0.6_0_0)]",children:[(0,T.jsx)("span",{className:"w-4 h-4 rounded bg-[oklch(0.22_0_0)] text-[oklch(0.5_0_0)] flex items-center justify-center text-[10px] font-mono shrink-0",children:e}),(0,T.jsx)("span",{children:t})]})}function fc({children:e}){return(0,T.jsx)("kbd",{className:"inline-block px-1 py-0.5 rounded bg-[oklch(0.2_0_0)] border border-[oklch(0.28_0_0)] text-[oklch(0.6_0_0)] font-mono text-[9px] mx-0.5",children:e})}var fu=I;class fp extends fu.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[FlowErrorBoundary]",e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?(0,T.jsx)("div",{className:"flex-1 flex items-center justify-center bg-background/50",children:(0,T.jsxs)("div",{className:"max-w-sm text-center space-y-3 p-6",children:[(0,T.jsxs)("h3",{className:"text-lg font-semibold text-red-400",children:["⚠️ ",this.props.fallbackMessage??"Canvas rendering error"]}),(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:this.state.error?.message??"Unknown error"}),(0,T.jsx)(iP,{variant:"outline",size:"sm",onClick:this.handleReset,children:"Retry"})]})}):this.props.children}}var ff=I;class fh extends ff.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary${this.props.name?`: ${this.props.name}`:""}]`,e,t.componentStack)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,T.jsxs)("div",{className:"flex flex-col items-center justify-center p-6 bg-destructive/5 border border-destructive/20 rounded-lg text-center gap-3",children:[(0,T.jsxs)("p",{className:"text-sm font-semibold text-destructive",children:["⚠️ ",this.props.name??"Component"," encountered an error"]}),(0,T.jsx)("p",{className:"text-xs text-muted-foreground max-w-xs truncate",children:this.state.error?.message}),(0,T.jsx)("button",{onClick:this.handleReset,className:"px-3 py-1.5 text-xs bg-secondary hover:bg-secondary/80 rounded-md transition-colors",children:"Retry"})]}):this.props.children}}let fm={flowNode:ij};function fg(){let e,t,n=iw(e=>e.nodes),r=iw(e=>e.edges),o=iw(e=>e.onNodesChange),a=iw(e=>e.onEdgesChange),i=iw(e=>e.onConnect),s=iw(e=>e.selectNode),l=iw(e=>e.removeNode),d=iw(e=>e.removeSelectedNodes),c=iw(e=>e.removeSelectedEdges),u=iw(e=>e.selectedNodeId),p=iw(e=>e.undoFlow),f=iw(e=>e.redoFlow),[h,m]=(0,I.useState)(!0),g=0===n.length;e=iw(e=>e.selectNode),t=iw(e=>e.nodes),(0,I.useEffect)(()=>{let n=new URLSearchParams(window.location.search).get("highlight");if(n&&t.find(e=>e.id===n)){e(n);let t=new URL(window.location.href);t.searchParams.delete("highlight"),window.history.replaceState({},"",t.toString())}},[t,e]),(0,I.useEffect)(()=>{let e=e=>{let t=e.target?.tagName;if("INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&!e.target?.isContentEditable){if("Delete"===e.key||"Backspace"===e.key){let t=iw.getState(),n=t.getSelectedNodeIds(),r=t.edges.filter(e=>e.selected).map(e=>e.id);n.length>0||r.length>0?(e.preventDefault(),e.stopPropagation(),d()):u&&(e.preventDefault(),e.stopPropagation(),l(u))}(e.ctrlKey||e.metaKey)&&"z"===e.key&&!e.shiftKey&&(e.preventDefault(),e.stopPropagation(),p()),((e.ctrlKey||e.metaKey)&&"z"===e.key&&e.shiftKey||(e.ctrlKey||e.metaKey)&&"y"===e.key)&&(e.preventDefault(),e.stopPropagation(),f())}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[u,l,d,c,p,f]);let x=(0,I.useCallback)((e,t)=>{s(t.id)},[s]),v=(0,I.useCallback)(()=>{s(null)},[s]);return(0,T.jsxs)("div",{className:"flex flex-col h-screen w-screen bg-background",children:[(0,T.jsx)(fh,{name:"Toolbar",children:(0,T.jsx)(fi,{})}),(0,T.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,T.jsx)(fh,{name:"NodeLibrary",children:(0,T.jsx)(s$,{})}),(0,T.jsx)(fp,{children:(0,T.jsxs)("div",{className:"flex-1 min-w-0 relative",children:[(0,T.jsxs)(aU,{nodes:n,edges:r,onNodesChange:o,onEdgesChange:a,onConnect:i,onNodeClick:x,onPaneClick:v,nodeTypes:fm,fitView:!0,snapToGrid:!0,snapGrid:[16,16],panOnDrag:[1],selectionOnDrag:!0,selectionMode:S.Partial,edgesFocusable:!0,edgesReconnectable:!0,defaultEdgeOptions:{type:"smoothstep",animated:!1,interactionWidth:20,focusable:!0,style:{stroke:"oklch(0.45 0 0)",strokeWidth:1.5}},style:{background:"transparent"},children:[(0,T.jsx)(a4,{position:"bottom-left",className:"bg-card! border-border! shadow-lg! [&>button]:bg-card! [&>button]:border-border! [&>button]:text-foreground! [&>button:hover]:bg-accent!",style:{marginLeft:"1rem",marginBottom:"1rem"}}),(0,T.jsx)(ia,{position:"bottom-right",className:"bg-card! border! border-border! rounded-lg! shadow-lg!",style:{marginRight:"1rem",marginBottom:"1rem"},maskColor:"rgba(0, 0, 0, 0.6)",nodeColor:e=>{let t=e.data;switch(t?.category){case"trigger":return"#10b981";case"action":return"#3b82f6";case"logic":return"#f59e0b";case"variable":return"#8b5cf6";case"output":return"#f43f5e";default:return"#6b7280"}}}),(0,T.jsx)(aq,{variant:k.Dots,gap:20,size:1,color:"oklch(0.3 0 0)"})]}),(0,T.jsx)(fh,{name:"ConfigPanel",children:(0,T.jsx)(cs,{})}),g&&h&&(0,T.jsx)(fl,{onDismiss:()=>m(!1)})]})})]})]})}function fx(){return(0,T.jsx)(fg,{})}e.s(["default",()=>fx],52683)}]);