jetic-cli 0.2.5 → 0.2.6

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.
@@ -388,7 +388,7 @@ Error generating stack: `+a.message+`
388
388
  * This source code is licensed under the MIT license found in the
389
389
  * LICENSE file in the root directory of this source tree.
390
390
  */var vx;function N2(){if(vx)return fd;vx=1;var n=Yr(),r=j2();function i(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}var o=typeof Object.is=="function"?Object.is:i,u=r.useSyncExternalStore,f=n.useRef,h=n.useEffect,g=n.useMemo,x=n.useDebugValue;return fd.useSyncExternalStoreWithSelector=function(m,p,b,v,N){var T=f(null);if(T.current===null){var _={hasValue:!1,value:null};T.current=_}else _=T.current;T=g(function(){function A(W){if(!V){if(V=!0,L=W,W=v(W),N!==void 0&&_.hasValue){var X=_.value;if(N(X,W))return C=X}return C=W}if(X=C,o(L,W))return X;var ie=v(W);return N!==void 0&&N(X,ie)?(L=W,X):(L=W,C=ie)}var V=!1,L,C,D=b===void 0?null:b;return[function(){return A(p())},D===null?void 0:function(){return A(D())}]},[p,b,v,N]);var M=u(m,T[0],T[1]);return h(function(){_.hasValue=!0,_.value=M},[M]),x(M),M},fd}var jx;function w2(){return jx||(jx=1,dd.exports=N2()),dd.exports}var S2=w2();const E2=E0(S2),k2={},Nx=n=>{let r;const i=new Set,o=(p,b)=>{const v=typeof p=="function"?p(r):p;if(!Object.is(v,r)){const N=r;r=b??(typeof v!="object"||v===null)?v:Object.assign({},r,v),i.forEach(T=>T(r,N))}},u=()=>r,x={setState:o,getState:u,getInitialState:()=>m,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(k2?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},m=r=n(o,u,x);return x},_2=n=>n?Nx(n):Nx,{useDebugValue:C2}=le,{useSyncExternalStoreWithSelector:T2}=E2,M2=n=>n;function U0(n,r=M2,i){const o=T2(n.subscribe,n.getState,n.getServerState||n.getInitialState,r,i);return C2(o),o}const wx=(n,r)=>{const i=_2(n),o=(u,f=r)=>U0(i,u,f);return Object.assign(o,i),o},A2=(n,r)=>n?wx(n,r):wx;function Ct(n,r){if(Object.is(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;if(n instanceof Map&&r instanceof Map){if(n.size!==r.size)return!1;for(const[o,u]of n)if(!Object.is(u,r.get(o)))return!1;return!0}if(n instanceof Set&&r instanceof Set){if(n.size!==r.size)return!1;for(const o of n)if(!r.has(o))return!1;return!0}const i=Object.keys(n);if(i.length!==Object.keys(r).length)return!1;for(const o of i)if(!Object.prototype.hasOwnProperty.call(r,o)||!Object.is(n[o],r[o]))return!1;return!0}var R2={value:()=>{}};function Go(){for(var n=0,r=arguments.length,i={},o;n<r;++n){if(!(o=arguments[n]+"")||o in i||/[\s.]/.test(o))throw new Error("illegal type: "+o);i[o]=[]}return new Co(i)}function Co(n){this._=n}function z2(n,r){return n.trim().split(/^|\s+/).map(function(i){var o="",u=i.indexOf(".");if(u>=0&&(o=i.slice(u+1),i=i.slice(0,u)),i&&!r.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}Co.prototype=Go.prototype={constructor:Co,on:function(n,r){var i=this._,o=z2(n+"",i),u,f=-1,h=o.length;if(arguments.length<2){for(;++f<h;)if((u=(n=o[f]).type)&&(u=O2(i[u],n.name)))return u;return}if(r!=null&&typeof r!="function")throw new Error("invalid callback: "+r);for(;++f<h;)if(u=(n=o[f]).type)i[u]=Sx(i[u],n.name,r);else if(r==null)for(u in i)i[u]=Sx(i[u],n.name,null);return this},copy:function(){var n={},r=this._;for(var i in r)n[i]=r[i].slice();return new Co(n)},call:function(n,r){if((u=arguments.length-2)>0)for(var i=new Array(u),o=0,u,f;o<u;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(f=this._[n],o=0,u=f.length;o<u;++o)f[o].value.apply(r,i)},apply:function(n,r,i){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var o=this._[n],u=0,f=o.length;u<f;++u)o[u].value.apply(r,i)}};function O2(n,r){for(var i=0,o=n.length,u;i<o;++i)if((u=n[i]).name===r)return u.value}function Sx(n,r,i){for(var o=0,u=n.length;o<u;++o)if(n[o].name===r){n[o]=R2,n=n.slice(0,o).concat(n.slice(o+1));break}return i!=null&&n.push({name:r,value:i}),n}var Ad="http://www.w3.org/1999/xhtml";const Ex={svg:"http://www.w3.org/2000/svg",xhtml:Ad,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Xo(n){var r=n+="",i=r.indexOf(":");return i>=0&&(r=n.slice(0,i))!=="xmlns"&&(n=n.slice(i+1)),Ex.hasOwnProperty(r)?{space:Ex[r],local:n}:n}function D2(n){return function(){var r=this.ownerDocument,i=this.namespaceURI;return i===Ad&&r.documentElement.namespaceURI===Ad?r.createElement(n):r.createElementNS(i,n)}}function H2(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function B0(n){var r=Xo(n);return(r.local?H2:D2)(r)}function $2(){}function ef(n){return n==null?$2:function(){return this.querySelector(n)}}function U2(n){typeof n!="function"&&(n=ef(n));for(var r=this._groups,i=r.length,o=new Array(i),u=0;u<i;++u)for(var f=r[u],h=f.length,g=o[u]=new Array(h),x,m,p=0;p<h;++p)(x=f[p])&&(m=n.call(x,x.__data__,p,f))&&("__data__"in x&&(m.__data__=x.__data__),g[p]=m);return new rn(o,this._parents)}function B2(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function q2(){return[]}function q0(n){return n==null?q2:function(){return this.querySelectorAll(n)}}function L2(n){return function(){return B2(n.apply(this,arguments))}}function Y2(n){typeof n=="function"?n=L2(n):n=q0(n);for(var r=this._groups,i=r.length,o=[],u=[],f=0;f<i;++f)for(var h=r[f],g=h.length,x,m=0;m<g;++m)(x=h[m])&&(o.push(n.call(x,x.__data__,m,h)),u.push(x));return new rn(o,u)}function L0(n){return function(){return this.matches(n)}}function Y0(n){return function(r){return r.matches(n)}}var V2=Array.prototype.find;function G2(n){return function(){return V2.call(this.children,n)}}function X2(){return this.firstElementChild}function Z2(n){return this.select(n==null?X2:G2(typeof n=="function"?n:Y0(n)))}var W2=Array.prototype.filter;function Q2(){return Array.from(this.children)}function K2(n){return function(){return W2.call(this.children,n)}}function J2(n){return this.selectAll(n==null?Q2:K2(typeof n=="function"?n:Y0(n)))}function I2(n){typeof n!="function"&&(n=L0(n));for(var r=this._groups,i=r.length,o=new Array(i),u=0;u<i;++u)for(var f=r[u],h=f.length,g=o[u]=[],x,m=0;m<h;++m)(x=f[m])&&n.call(x,x.__data__,m,f)&&g.push(x);return new rn(o,this._parents)}function V0(n){return new Array(n.length)}function F2(){return new rn(this._enter||this._groups.map(V0),this._parents)}function Oo(n,r){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=r}Oo.prototype={constructor:Oo,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,r){return this._parent.insertBefore(n,r)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function P2(n){return function(){return n}}function ej(n,r,i,o,u,f){for(var h=0,g,x=r.length,m=f.length;h<m;++h)(g=r[h])?(g.__data__=f[h],o[h]=g):i[h]=new Oo(n,f[h]);for(;h<x;++h)(g=r[h])&&(u[h]=g)}function tj(n,r,i,o,u,f,h){var g,x,m=new Map,p=r.length,b=f.length,v=new Array(p),N;for(g=0;g<p;++g)(x=r[g])&&(v[g]=N=h.call(x,x.__data__,g,r)+"",m.has(N)?u[g]=x:m.set(N,x));for(g=0;g<b;++g)N=h.call(n,f[g],g,f)+"",(x=m.get(N))?(o[g]=x,x.__data__=f[g],m.delete(N)):i[g]=new Oo(n,f[g]);for(g=0;g<p;++g)(x=r[g])&&m.get(v[g])===x&&(u[g]=x)}function nj(n){return n.__data__}function aj(n,r){if(!arguments.length)return Array.from(this,nj);var i=r?tj:ej,o=this._parents,u=this._groups;typeof n!="function"&&(n=P2(n));for(var f=u.length,h=new Array(f),g=new Array(f),x=new Array(f),m=0;m<f;++m){var p=o[m],b=u[m],v=b.length,N=sj(n.call(p,p&&p.__data__,m,o)),T=N.length,_=g[m]=new Array(T),M=h[m]=new Array(T),A=x[m]=new Array(v);i(p,b,_,M,A,N,r);for(var V=0,L=0,C,D;V<T;++V)if(C=_[V]){for(V>=L&&(L=V+1);!(D=M[L])&&++L<T;);C._next=D||null}}return h=new rn(h,o),h._enter=g,h._exit=x,h}function sj(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function lj(){return new rn(this._exit||this._groups.map(V0),this._parents)}function rj(n,r,i){var o=this.enter(),u=this,f=this.exit();return typeof n=="function"?(o=n(o),o&&(o=o.selection())):o=o.append(n+""),r!=null&&(u=r(u),u&&(u=u.selection())),i==null?f.remove():i(f),o&&u?o.merge(u).order():u}function ij(n){for(var r=n.selection?n.selection():n,i=this._groups,o=r._groups,u=i.length,f=o.length,h=Math.min(u,f),g=new Array(u),x=0;x<h;++x)for(var m=i[x],p=o[x],b=m.length,v=g[x]=new Array(b),N,T=0;T<b;++T)(N=m[T]||p[T])&&(v[T]=N);for(;x<u;++x)g[x]=i[x];return new rn(g,this._parents)}function oj(){for(var n=this._groups,r=-1,i=n.length;++r<i;)for(var o=n[r],u=o.length-1,f=o[u],h;--u>=0;)(h=o[u])&&(f&&h.compareDocumentPosition(f)^4&&f.parentNode.insertBefore(h,f),f=h);return this}function cj(n){n||(n=uj);function r(b,v){return b&&v?n(b.__data__,v.__data__):!b-!v}for(var i=this._groups,o=i.length,u=new Array(o),f=0;f<o;++f){for(var h=i[f],g=h.length,x=u[f]=new Array(g),m,p=0;p<g;++p)(m=h[p])&&(x[p]=m);x.sort(r)}return new rn(u,this._parents).order()}function uj(n,r){return n<r?-1:n>r?1:n>=r?0:NaN}function dj(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function fj(){return Array.from(this)}function hj(){for(var n=this._groups,r=0,i=n.length;r<i;++r)for(var o=n[r],u=0,f=o.length;u<f;++u){var h=o[u];if(h)return h}return null}function mj(){let n=0;for(const r of this)++n;return n}function pj(){return!this.node()}function xj(n){for(var r=this._groups,i=0,o=r.length;i<o;++i)for(var u=r[i],f=0,h=u.length,g;f<h;++f)(g=u[f])&&n.call(g,g.__data__,f,u);return this}function gj(n){return function(){this.removeAttribute(n)}}function yj(n){return function(){this.removeAttributeNS(n.space,n.local)}}function bj(n,r){return function(){this.setAttribute(n,r)}}function vj(n,r){return function(){this.setAttributeNS(n.space,n.local,r)}}function jj(n,r){return function(){var i=r.apply(this,arguments);i==null?this.removeAttribute(n):this.setAttribute(n,i)}}function Nj(n,r){return function(){var i=r.apply(this,arguments);i==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,i)}}function wj(n,r){var i=Xo(n);if(arguments.length<2){var o=this.node();return i.local?o.getAttributeNS(i.space,i.local):o.getAttribute(i)}return this.each((r==null?i.local?yj:gj:typeof r=="function"?i.local?Nj:jj:i.local?vj:bj)(i,r))}function G0(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function Sj(n){return function(){this.style.removeProperty(n)}}function Ej(n,r,i){return function(){this.style.setProperty(n,r,i)}}function kj(n,r,i){return function(){var o=r.apply(this,arguments);o==null?this.style.removeProperty(n):this.style.setProperty(n,o,i)}}function _j(n,r,i){return arguments.length>1?this.each((r==null?Sj:typeof r=="function"?kj:Ej)(n,r,i??"")):pl(this.node(),n)}function pl(n,r){return n.style.getPropertyValue(r)||G0(n).getComputedStyle(n,null).getPropertyValue(r)}function Cj(n){return function(){delete this[n]}}function Tj(n,r){return function(){this[n]=r}}function Mj(n,r){return function(){var i=r.apply(this,arguments);i==null?delete this[n]:this[n]=i}}function Aj(n,r){return arguments.length>1?this.each((r==null?Cj:typeof r=="function"?Mj:Tj)(n,r)):this.node()[n]}function X0(n){return n.trim().split(/^|\s+/)}function tf(n){return n.classList||new Z0(n)}function Z0(n){this._node=n,this._names=X0(n.getAttribute("class")||"")}Z0.prototype={add:function(n){var r=this._names.indexOf(n);r<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var r=this._names.indexOf(n);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function W0(n,r){for(var i=tf(n),o=-1,u=r.length;++o<u;)i.add(r[o])}function Q0(n,r){for(var i=tf(n),o=-1,u=r.length;++o<u;)i.remove(r[o])}function Rj(n){return function(){W0(this,n)}}function zj(n){return function(){Q0(this,n)}}function Oj(n,r){return function(){(r.apply(this,arguments)?W0:Q0)(this,n)}}function Dj(n,r){var i=X0(n+"");if(arguments.length<2){for(var o=tf(this.node()),u=-1,f=i.length;++u<f;)if(!o.contains(i[u]))return!1;return!0}return this.each((typeof r=="function"?Oj:r?Rj:zj)(i,r))}function Hj(){this.textContent=""}function $j(n){return function(){this.textContent=n}}function Uj(n){return function(){var r=n.apply(this,arguments);this.textContent=r??""}}function Bj(n){return arguments.length?this.each(n==null?Hj:(typeof n=="function"?Uj:$j)(n)):this.node().textContent}function qj(){this.innerHTML=""}function Lj(n){return function(){this.innerHTML=n}}function Yj(n){return function(){var r=n.apply(this,arguments);this.innerHTML=r??""}}function Vj(n){return arguments.length?this.each(n==null?qj:(typeof n=="function"?Yj:Lj)(n)):this.node().innerHTML}function Gj(){this.nextSibling&&this.parentNode.appendChild(this)}function Xj(){return this.each(Gj)}function Zj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wj(){return this.each(Zj)}function Qj(n){var r=typeof n=="function"?n:B0(n);return this.select(function(){return this.appendChild(r.apply(this,arguments))})}function Kj(){return null}function Jj(n,r){var i=typeof n=="function"?n:B0(n),o=r==null?Kj:typeof r=="function"?r:ef(r);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function Ij(){var n=this.parentNode;n&&n.removeChild(this)}function Fj(){return this.each(Ij)}function Pj(){var n=this.cloneNode(!1),r=this.parentNode;return r?r.insertBefore(n,this.nextSibling):n}function eN(){var n=this.cloneNode(!0),r=this.parentNode;return r?r.insertBefore(n,this.nextSibling):n}function tN(n){return this.select(n?eN:Pj)}function nN(n){return arguments.length?this.property("__data__",n):this.node().__data__}function aN(n){return function(r){n.call(this,r,this.__data__)}}function sN(n){return n.trim().split(/^|\s+/).map(function(r){var i="",o=r.indexOf(".");return o>=0&&(i=r.slice(o+1),r=r.slice(0,o)),{type:r,name:i}})}function lN(n){return function(){var r=this.__on;if(r){for(var i=0,o=-1,u=r.length,f;i<u;++i)f=r[i],(!n.type||f.type===n.type)&&f.name===n.name?this.removeEventListener(f.type,f.listener,f.options):r[++o]=f;++o?r.length=o:delete this.__on}}}function rN(n,r,i){return function(){var o=this.__on,u,f=aN(r);if(o){for(var h=0,g=o.length;h<g;++h)if((u=o[h]).type===n.type&&u.name===n.name){this.removeEventListener(u.type,u.listener,u.options),this.addEventListener(u.type,u.listener=f,u.options=i),u.value=r;return}}this.addEventListener(n.type,f,i),u={type:n.type,name:n.name,value:r,listener:f,options:i},o?o.push(u):this.__on=[u]}}function iN(n,r,i){var o=sN(n+""),u,f=o.length,h;if(arguments.length<2){var g=this.node().__on;if(g){for(var x=0,m=g.length,p;x<m;++x)for(u=0,p=g[x];u<f;++u)if((h=o[u]).type===p.type&&h.name===p.name)return p.value}return}for(g=r?rN:lN,u=0;u<f;++u)this.each(g(o[u],r,i));return this}function K0(n,r,i){var o=G0(n),u=o.CustomEvent;typeof u=="function"?u=new u(r,i):(u=o.document.createEvent("Event"),i?(u.initEvent(r,i.bubbles,i.cancelable),u.detail=i.detail):u.initEvent(r,!1,!1)),n.dispatchEvent(u)}function oN(n,r){return function(){return K0(this,n,r)}}function cN(n,r){return function(){return K0(this,n,r.apply(this,arguments))}}function uN(n,r){return this.each((typeof r=="function"?cN:oN)(n,r))}function*dN(){for(var n=this._groups,r=0,i=n.length;r<i;++r)for(var o=n[r],u=0,f=o.length,h;u<f;++u)(h=o[u])&&(yield h)}var J0=[null];function rn(n,r){this._groups=n,this._parents=r}function Xr(){return new rn([[document.documentElement]],J0)}function fN(){return this}rn.prototype=Xr.prototype={constructor:rn,select:U2,selectAll:Y2,selectChild:Z2,selectChildren:J2,filter:I2,data:aj,enter:F2,exit:lj,join:rj,merge:ij,selection:fN,order:oj,sort:cj,call:dj,nodes:fj,node:hj,size:mj,empty:pj,each:xj,attr:wj,style:_j,property:Aj,classed:Dj,text:Bj,html:Vj,raise:Xj,lower:Wj,append:Qj,insert:Jj,remove:Fj,clone:tN,datum:nN,on:iN,dispatch:uN,[Symbol.iterator]:dN};function gn(n){return typeof n=="string"?new rn([[document.querySelector(n)]],[document.documentElement]):new rn([[n]],J0)}function hN(n){let r;for(;r=n.sourceEvent;)n=r;return n}function Sn(n,r){if(n=hN(n),r===void 0&&(r=n.currentTarget),r){var i=r.ownerSVGElement||r;if(i.createSVGPoint){var o=i.createSVGPoint();return o.x=n.clientX,o.y=n.clientY,o=o.matrixTransform(r.getScreenCTM().inverse()),[o.x,o.y]}if(r.getBoundingClientRect){var u=r.getBoundingClientRect();return[n.clientX-u.left-r.clientLeft,n.clientY-u.top-r.clientTop]}}return[n.pageX,n.pageY]}const mN={passive:!1},Or={capture:!0,passive:!1};function pd(n){n.stopImmediatePropagation()}function fl(n){n.preventDefault(),n.stopImmediatePropagation()}function I0(n){var r=n.document.documentElement,i=gn(n).on("dragstart.drag",fl,Or);"onselectstart"in r?i.on("selectstart.drag",fl,Or):(r.__noselect=r.style.MozUserSelect,r.style.MozUserSelect="none")}function F0(n,r){var i=n.document.documentElement,o=gn(n).on("dragstart.drag",null);r&&(o.on("click.drag",fl,Or),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in i?o.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const po=n=>()=>n;function Rd(n,{sourceEvent:r,subject:i,target:o,identifier:u,active:f,x:h,y:g,dx:x,dy:m,dispatch:p}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:u,enumerable:!0,configurable:!0},active:{value:f,enumerable:!0,configurable:!0},x:{value:h,enumerable:!0,configurable:!0},y:{value:g,enumerable:!0,configurable:!0},dx:{value:x,enumerable:!0,configurable:!0},dy:{value:m,enumerable:!0,configurable:!0},_:{value:p}})}Rd.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function pN(n){return!n.ctrlKey&&!n.button}function xN(){return this.parentNode}function gN(n,r){return r??{x:n.x,y:n.y}}function yN(){return navigator.maxTouchPoints||"ontouchstart"in this}function bN(){var n=pN,r=xN,i=gN,o=yN,u={},f=Go("start","drag","end"),h=0,g,x,m,p,b=0;function v(C){C.on("mousedown.drag",N).filter(o).on("touchstart.drag",M).on("touchmove.drag",A,mN).on("touchend.drag touchcancel.drag",V).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function N(C,D){if(!(p||!n.call(this,C,D))){var W=L(this,r.call(this,C,D),C,D,"mouse");W&&(gn(C.view).on("mousemove.drag",T,Or).on("mouseup.drag",_,Or),I0(C.view),pd(C),m=!1,g=C.clientX,x=C.clientY,W("start",C))}}function T(C){if(fl(C),!m){var D=C.clientX-g,W=C.clientY-x;m=D*D+W*W>b}u.mouse("drag",C)}function _(C){gn(C.view).on("mousemove.drag mouseup.drag",null),F0(C.view,m),fl(C),u.mouse("end",C)}function M(C,D){if(n.call(this,C,D)){var W=C.changedTouches,X=r.call(this,C,D),ie=W.length,I,K;for(I=0;I<ie;++I)(K=L(this,X,C,D,W[I].identifier,W[I]))&&(pd(C),K("start",C,W[I]))}}function A(C){var D=C.changedTouches,W=D.length,X,ie;for(X=0;X<W;++X)(ie=u[D[X].identifier])&&(fl(C),ie("drag",C,D[X]))}function V(C){var D=C.changedTouches,W=D.length,X,ie;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),X=0;X<W;++X)(ie=u[D[X].identifier])&&(pd(C),ie("end",C,D[X]))}function L(C,D,W,X,ie,I){var K=f.copy(),ne=Sn(I||W,D),ee,se,S;if((S=i.call(C,new Rd("beforestart",{sourceEvent:W,target:v,identifier:ie,active:h,x:ne[0],y:ne[1],dx:0,dy:0,dispatch:K}),X))!=null)return ee=S.x-ne[0]||0,se=S.y-ne[1]||0,function U(k,H,O){var z=ne,E;switch(k){case"start":u[ie]=U,E=h++;break;case"end":delete u[ie],--h;case"drag":ne=Sn(O||H,D),E=h;break}K.call(k,C,new Rd(k,{sourceEvent:H,subject:S,target:v,identifier:ie,active:E,x:ne[0]+ee,y:ne[1]+se,dx:ne[0]-z[0],dy:ne[1]-z[1],dispatch:K}),X)}}return v.filter=function(C){return arguments.length?(n=typeof C=="function"?C:po(!!C),v):n},v.container=function(C){return arguments.length?(r=typeof C=="function"?C:po(C),v):r},v.subject=function(C){return arguments.length?(i=typeof C=="function"?C:po(C),v):i},v.touchable=function(C){return arguments.length?(o=typeof C=="function"?C:po(!!C),v):o},v.on=function(){var C=f.on.apply(f,arguments);return C===f?v:C},v.clickDistance=function(C){return arguments.length?(b=(C=+C)*C,v):Math.sqrt(b)},v}function nf(n,r,i){n.prototype=r.prototype=i,i.constructor=n}function P0(n,r){var i=Object.create(n.prototype);for(var o in r)i[o]=r[o];return i}function Zr(){}var Dr=.7,Do=1/Dr,hl="\\s*([+-]?\\d+)\\s*",Hr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",zn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vN=/^#([0-9a-f]{3,8})$/,jN=new RegExp(`^rgb\\(${hl},${hl},${hl}\\)$`),NN=new RegExp(`^rgb\\(${zn},${zn},${zn}\\)$`),wN=new RegExp(`^rgba\\(${hl},${hl},${hl},${Hr}\\)$`),SN=new RegExp(`^rgba\\(${zn},${zn},${zn},${Hr}\\)$`),EN=new RegExp(`^hsl\\(${Hr},${zn},${zn}\\)$`),kN=new RegExp(`^hsla\\(${Hr},${zn},${zn},${Hr}\\)$`),kx={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};nf(Zr,$r,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:_x,formatHex:_x,formatHex8:_N,formatHsl:CN,formatRgb:Cx,toString:Cx});function _x(){return this.rgb().formatHex()}function _N(){return this.rgb().formatHex8()}function CN(){return eg(this).formatHsl()}function Cx(){return this.rgb().formatRgb()}function $r(n){var r,i;return n=(n+"").trim().toLowerCase(),(r=vN.exec(n))?(i=r[1].length,r=parseInt(r[1],16),i===6?Tx(r):i===3?new Kt(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):i===8?xo(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):i===4?xo(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=jN.exec(n))?new Kt(r[1],r[2],r[3],1):(r=NN.exec(n))?new Kt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=wN.exec(n))?xo(r[1],r[2],r[3],r[4]):(r=SN.exec(n))?xo(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=EN.exec(n))?Rx(r[1],r[2]/100,r[3]/100,1):(r=kN.exec(n))?Rx(r[1],r[2]/100,r[3]/100,r[4]):kx.hasOwnProperty(n)?Tx(kx[n]):n==="transparent"?new Kt(NaN,NaN,NaN,0):null}function Tx(n){return new Kt(n>>16&255,n>>8&255,n&255,1)}function xo(n,r,i,o){return o<=0&&(n=r=i=NaN),new Kt(n,r,i,o)}function TN(n){return n instanceof Zr||(n=$r(n)),n?(n=n.rgb(),new Kt(n.r,n.g,n.b,n.opacity)):new Kt}function zd(n,r,i,o){return arguments.length===1?TN(n):new Kt(n,r,i,o??1)}function Kt(n,r,i,o){this.r=+n,this.g=+r,this.b=+i,this.opacity=+o}nf(Kt,zd,P0(Zr,{brighter(n){return n=n==null?Do:Math.pow(Do,n),new Kt(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Dr:Math.pow(Dr,n),new Kt(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new Kt(ds(this.r),ds(this.g),ds(this.b),Ho(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:Mx,formatHex:Mx,formatHex8:MN,formatRgb:Ax,toString:Ax}));function Mx(){return`#${cs(this.r)}${cs(this.g)}${cs(this.b)}`}function MN(){return`#${cs(this.r)}${cs(this.g)}${cs(this.b)}${cs((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ax(){const n=Ho(this.opacity);return`${n===1?"rgb(":"rgba("}${ds(this.r)}, ${ds(this.g)}, ${ds(this.b)}${n===1?")":`, ${n})`}`}function Ho(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function ds(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function cs(n){return n=ds(n),(n<16?"0":"")+n.toString(16)}function Rx(n,r,i,o){return o<=0?n=r=i=NaN:i<=0||i>=1?n=r=NaN:r<=0&&(n=NaN),new En(n,r,i,o)}function eg(n){if(n instanceof En)return new En(n.h,n.s,n.l,n.opacity);if(n instanceof Zr||(n=$r(n)),!n)return new En;if(n instanceof En)return n;n=n.rgb();var r=n.r/255,i=n.g/255,o=n.b/255,u=Math.min(r,i,o),f=Math.max(r,i,o),h=NaN,g=f-u,x=(f+u)/2;return g?(r===f?h=(i-o)/g+(i<o)*6:i===f?h=(o-r)/g+2:h=(r-i)/g+4,g/=x<.5?f+u:2-f-u,h*=60):g=x>0&&x<1?0:h,new En(h,g,x,n.opacity)}function AN(n,r,i,o){return arguments.length===1?eg(n):new En(n,r,i,o??1)}function En(n,r,i,o){this.h=+n,this.s=+r,this.l=+i,this.opacity=+o}nf(En,AN,P0(Zr,{brighter(n){return n=n==null?Do:Math.pow(Do,n),new En(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Dr:Math.pow(Dr,n),new En(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,r=isNaN(n)||isNaN(this.s)?0:this.s,i=this.l,o=i+(i<.5?i:1-i)*r,u=2*i-o;return new Kt(xd(n>=240?n-240:n+120,u,o),xd(n,u,o),xd(n<120?n+240:n-120,u,o),this.opacity)},clamp(){return new En(zx(this.h),go(this.s),go(this.l),Ho(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Ho(this.opacity);return`${n===1?"hsl(":"hsla("}${zx(this.h)}, ${go(this.s)*100}%, ${go(this.l)*100}%${n===1?")":`, ${n})`}`}}));function zx(n){return n=(n||0)%360,n<0?n+360:n}function go(n){return Math.max(0,Math.min(1,n||0))}function xd(n,r,i){return(n<60?r+(i-r)*n/60:n<180?i:n<240?r+(i-r)*(240-n)/60:r)*255}const tg=n=>()=>n;function RN(n,r){return function(i){return n+i*r}}function zN(n,r,i){return n=Math.pow(n,i),r=Math.pow(r,i)-n,i=1/i,function(o){return Math.pow(n+o*r,i)}}function ON(n){return(n=+n)==1?ng:function(r,i){return i-r?zN(r,i,n):tg(isNaN(r)?i:r)}}function ng(n,r){var i=r-n;return i?RN(n,i):tg(isNaN(n)?r:n)}const Ox=(function n(r){var i=ON(r);function o(u,f){var h=i((u=zd(u)).r,(f=zd(f)).r),g=i(u.g,f.g),x=i(u.b,f.b),m=ng(u.opacity,f.opacity);return function(p){return u.r=h(p),u.g=g(p),u.b=x(p),u.opacity=m(p),u+""}}return o.gamma=n,o})(1);function Da(n,r){return n=+n,r=+r,function(i){return n*(1-i)+r*i}}var Od=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gd=new RegExp(Od.source,"g");function DN(n){return function(){return n}}function HN(n){return function(r){return n(r)+""}}function $N(n,r){var i=Od.lastIndex=gd.lastIndex=0,o,u,f,h=-1,g=[],x=[];for(n=n+"",r=r+"";(o=Od.exec(n))&&(u=gd.exec(r));)(f=u.index)>i&&(f=r.slice(i,f),g[h]?g[h]+=f:g[++h]=f),(o=o[0])===(u=u[0])?g[h]?g[h]+=u:g[++h]=u:(g[++h]=null,x.push({i:h,x:Da(o,u)})),i=gd.lastIndex;return i<r.length&&(f=r.slice(i),g[h]?g[h]+=f:g[++h]=f),g.length<2?x[0]?HN(x[0].x):DN(r):(r=x.length,function(m){for(var p=0,b;p<r;++p)g[(b=x[p]).i]=b.x(m);return g.join("")})}var Dx=180/Math.PI,Dd={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ag(n,r,i,o,u,f){var h,g,x;return(h=Math.sqrt(n*n+r*r))&&(n/=h,r/=h),(x=n*i+r*o)&&(i-=n*x,o-=r*x),(g=Math.sqrt(i*i+o*o))&&(i/=g,o/=g,x/=g),n*o<r*i&&(n=-n,r=-r,x=-x,h=-h),{translateX:u,translateY:f,rotate:Math.atan2(r,n)*Dx,skewX:Math.atan(x)*Dx,scaleX:h,scaleY:g}}var yo;function UN(n){const r=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return r.isIdentity?Dd:ag(r.a,r.b,r.c,r.d,r.e,r.f)}function BN(n){return n==null||(yo||(yo=document.createElementNS("http://www.w3.org/2000/svg","g")),yo.setAttribute("transform",n),!(n=yo.transform.baseVal.consolidate()))?Dd:(n=n.matrix,ag(n.a,n.b,n.c,n.d,n.e,n.f))}function sg(n,r,i,o){function u(m){return m.length?m.pop()+" ":""}function f(m,p,b,v,N,T){if(m!==b||p!==v){var _=N.push("translate(",null,r,null,i);T.push({i:_-4,x:Da(m,b)},{i:_-2,x:Da(p,v)})}else(b||v)&&N.push("translate("+b+r+v+i)}function h(m,p,b,v){m!==p?(m-p>180?p+=360:p-m>180&&(m+=360),v.push({i:b.push(u(b)+"rotate(",null,o)-2,x:Da(m,p)})):p&&b.push(u(b)+"rotate("+p+o)}function g(m,p,b,v){m!==p?v.push({i:b.push(u(b)+"skewX(",null,o)-2,x:Da(m,p)}):p&&b.push(u(b)+"skewX("+p+o)}function x(m,p,b,v,N,T){if(m!==b||p!==v){var _=N.push(u(N)+"scale(",null,",",null,")");T.push({i:_-4,x:Da(m,b)},{i:_-2,x:Da(p,v)})}else(b!==1||v!==1)&&N.push(u(N)+"scale("+b+","+v+")")}return function(m,p){var b=[],v=[];return m=n(m),p=n(p),f(m.translateX,m.translateY,p.translateX,p.translateY,b,v),h(m.rotate,p.rotate,b,v),g(m.skewX,p.skewX,b,v),x(m.scaleX,m.scaleY,p.scaleX,p.scaleY,b,v),m=p=null,function(N){for(var T=-1,_=v.length,M;++T<_;)b[(M=v[T]).i]=M.x(N);return b.join("")}}}var qN=sg(UN,"px, ","px)","deg)"),LN=sg(BN,", ",")",")"),YN=1e-12;function Hx(n){return((n=Math.exp(n))+1/n)/2}function VN(n){return((n=Math.exp(n))-1/n)/2}function GN(n){return((n=Math.exp(2*n))-1)/(n+1)}const XN=(function n(r,i,o){function u(f,h){var g=f[0],x=f[1],m=f[2],p=h[0],b=h[1],v=h[2],N=p-g,T=b-x,_=N*N+T*T,M,A;if(_<YN)A=Math.log(v/m)/r,M=function(X){return[g+X*N,x+X*T,m*Math.exp(r*X*A)]};else{var V=Math.sqrt(_),L=(v*v-m*m+o*_)/(2*m*i*V),C=(v*v-m*m-o*_)/(2*v*i*V),D=Math.log(Math.sqrt(L*L+1)-L),W=Math.log(Math.sqrt(C*C+1)-C);A=(W-D)/r,M=function(X){var ie=X*A,I=Hx(D),K=m/(i*V)*(I*GN(r*ie+D)-VN(D));return[g+K*N,x+K*T,m*I/Hx(r*ie+D)]}}return M.duration=A*1e3*r/Math.SQRT2,M}return u.rho=function(f){var h=Math.max(.001,+f),g=h*h,x=g*g;return n(h,g,x)},u})(Math.SQRT2,2,4);var xl=0,Cr=0,Nr=0,lg=1e3,$o,Tr,Uo=0,ms=0,Zo=0,Ur=typeof performance=="object"&&performance.now?performance:Date,rg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function af(){return ms||(rg(ZN),ms=Ur.now()+Zo)}function ZN(){ms=0}function Bo(){this._call=this._time=this._next=null}Bo.prototype=ig.prototype={constructor:Bo,restart:function(n,r,i){if(typeof n!="function")throw new TypeError("callback is not a function");i=(i==null?af():+i)+(r==null?0:+r),!this._next&&Tr!==this&&(Tr?Tr._next=this:$o=this,Tr=this),this._call=n,this._time=i,Hd()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hd())}};function ig(n,r,i){var o=new Bo;return o.restart(n,r,i),o}function WN(){af(),++xl;for(var n=$o,r;n;)(r=ms-n._time)>=0&&n._call.call(void 0,r),n=n._next;--xl}function $x(){ms=(Uo=Ur.now())+Zo,xl=Cr=0;try{WN()}finally{xl=0,KN(),ms=0}}function QN(){var n=Ur.now(),r=n-Uo;r>lg&&(Zo-=r,Uo=n)}function KN(){for(var n,r=$o,i,o=1/0;r;)r._call?(o>r._time&&(o=r._time),n=r,r=r._next):(i=r._next,r._next=null,r=n?n._next=i:$o=i);Tr=n,Hd(o)}function Hd(n){if(!xl){Cr&&(Cr=clearTimeout(Cr));var r=n-ms;r>24?(n<1/0&&(Cr=setTimeout($x,n-Ur.now()-Zo)),Nr&&(Nr=clearInterval(Nr))):(Nr||(Uo=Ur.now(),Nr=setInterval(QN,lg)),xl=1,rg($x))}}function Ux(n,r,i){var o=new Bo;return r=r==null?0:+r,o.restart(u=>{o.stop(),n(u+r)},r,i),o}var JN=Go("start","end","cancel","interrupt"),IN=[],og=0,Bx=1,$d=2,To=3,qx=4,Ud=5,Mo=6;function Wo(n,r,i,o,u,f){var h=n.__transition;if(!h)n.__transition={};else if(i in h)return;FN(n,i,{name:r,index:o,group:u,on:JN,tween:IN,time:f.time,delay:f.delay,duration:f.duration,ease:f.ease,timer:null,state:og})}function sf(n,r){var i=kn(n,r);if(i.state>og)throw new Error("too late; already scheduled");return i}function On(n,r){var i=kn(n,r);if(i.state>To)throw new Error("too late; already running");return i}function kn(n,r){var i=n.__transition;if(!i||!(i=i[r]))throw new Error("transition not found");return i}function FN(n,r,i){var o=n.__transition,u;o[r]=i,i.timer=ig(f,0,i.time);function f(m){i.state=Bx,i.timer.restart(h,i.delay,i.time),i.delay<=m&&h(m-i.delay)}function h(m){var p,b,v,N;if(i.state!==Bx)return x();for(p in o)if(N=o[p],N.name===i.name){if(N.state===To)return Ux(h);N.state===qx?(N.state=Mo,N.timer.stop(),N.on.call("interrupt",n,n.__data__,N.index,N.group),delete o[p]):+p<r&&(N.state=Mo,N.timer.stop(),N.on.call("cancel",n,n.__data__,N.index,N.group),delete o[p])}if(Ux(function(){i.state===To&&(i.state=qx,i.timer.restart(g,i.delay,i.time),g(m))}),i.state=$d,i.on.call("start",n,n.__data__,i.index,i.group),i.state===$d){for(i.state=To,u=new Array(v=i.tween.length),p=0,b=-1;p<v;++p)(N=i.tween[p].value.call(n,n.__data__,i.index,i.group))&&(u[++b]=N);u.length=b+1}}function g(m){for(var p=m<i.duration?i.ease.call(null,m/i.duration):(i.timer.restart(x),i.state=Ud,1),b=-1,v=u.length;++b<v;)u[b].call(n,p);i.state===Ud&&(i.on.call("end",n,n.__data__,i.index,i.group),x())}function x(){i.state=Mo,i.timer.stop(),delete o[r];for(var m in o)return;delete n.__transition}}function Ao(n,r){var i=n.__transition,o,u,f=!0,h;if(i){r=r==null?null:r+"";for(h in i){if((o=i[h]).name!==r){f=!1;continue}u=o.state>$d&&o.state<Ud,o.state=Mo,o.timer.stop(),o.on.call(u?"interrupt":"cancel",n,n.__data__,o.index,o.group),delete i[h]}f&&delete n.__transition}}function PN(n){return this.each(function(){Ao(this,n)})}function e5(n,r){var i,o;return function(){var u=On(this,n),f=u.tween;if(f!==i){o=i=f;for(var h=0,g=o.length;h<g;++h)if(o[h].name===r){o=o.slice(),o.splice(h,1);break}}u.tween=o}}function t5(n,r,i){var o,u;if(typeof i!="function")throw new Error;return function(){var f=On(this,n),h=f.tween;if(h!==o){u=(o=h).slice();for(var g={name:r,value:i},x=0,m=u.length;x<m;++x)if(u[x].name===r){u[x]=g;break}x===m&&u.push(g)}f.tween=u}}function n5(n,r){var i=this._id;if(n+="",arguments.length<2){for(var o=kn(this.node(),i).tween,u=0,f=o.length,h;u<f;++u)if((h=o[u]).name===n)return h.value;return null}return this.each((r==null?e5:t5)(i,n,r))}function lf(n,r,i){var o=n._id;return n.each(function(){var u=On(this,o);(u.value||(u.value={}))[r]=i.apply(this,arguments)}),function(u){return kn(u,o).value[r]}}function cg(n,r){var i;return(typeof r=="number"?Da:r instanceof $r?Ox:(i=$r(r))?(r=i,Ox):$N)(n,r)}function a5(n){return function(){this.removeAttribute(n)}}function s5(n){return function(){this.removeAttributeNS(n.space,n.local)}}function l5(n,r,i){var o,u=i+"",f;return function(){var h=this.getAttribute(n);return h===u?null:h===o?f:f=r(o=h,i)}}function r5(n,r,i){var o,u=i+"",f;return function(){var h=this.getAttributeNS(n.space,n.local);return h===u?null:h===o?f:f=r(o=h,i)}}function i5(n,r,i){var o,u,f;return function(){var h,g=i(this),x;return g==null?void this.removeAttribute(n):(h=this.getAttribute(n),x=g+"",h===x?null:h===o&&x===u?f:(u=x,f=r(o=h,g)))}}function o5(n,r,i){var o,u,f;return function(){var h,g=i(this),x;return g==null?void this.removeAttributeNS(n.space,n.local):(h=this.getAttributeNS(n.space,n.local),x=g+"",h===x?null:h===o&&x===u?f:(u=x,f=r(o=h,g)))}}function c5(n,r){var i=Xo(n),o=i==="transform"?LN:cg;return this.attrTween(n,typeof r=="function"?(i.local?o5:i5)(i,o,lf(this,"attr."+n,r)):r==null?(i.local?s5:a5)(i):(i.local?r5:l5)(i,o,r))}function u5(n,r){return function(i){this.setAttribute(n,r.call(this,i))}}function d5(n,r){return function(i){this.setAttributeNS(n.space,n.local,r.call(this,i))}}function f5(n,r){var i,o;function u(){var f=r.apply(this,arguments);return f!==o&&(i=(o=f)&&d5(n,f)),i}return u._value=r,u}function h5(n,r){var i,o;function u(){var f=r.apply(this,arguments);return f!==o&&(i=(o=f)&&u5(n,f)),i}return u._value=r,u}function m5(n,r){var i="attr."+n;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(r==null)return this.tween(i,null);if(typeof r!="function")throw new Error;var o=Xo(n);return this.tween(i,(o.local?f5:h5)(o,r))}function p5(n,r){return function(){sf(this,n).delay=+r.apply(this,arguments)}}function x5(n,r){return r=+r,function(){sf(this,n).delay=r}}function g5(n){var r=this._id;return arguments.length?this.each((typeof n=="function"?p5:x5)(r,n)):kn(this.node(),r).delay}function y5(n,r){return function(){On(this,n).duration=+r.apply(this,arguments)}}function b5(n,r){return r=+r,function(){On(this,n).duration=r}}function v5(n){var r=this._id;return arguments.length?this.each((typeof n=="function"?y5:b5)(r,n)):kn(this.node(),r).duration}function j5(n,r){if(typeof r!="function")throw new Error;return function(){On(this,n).ease=r}}function N5(n){var r=this._id;return arguments.length?this.each(j5(r,n)):kn(this.node(),r).ease}function w5(n,r){return function(){var i=r.apply(this,arguments);if(typeof i!="function")throw new Error;On(this,n).ease=i}}function S5(n){if(typeof n!="function")throw new Error;return this.each(w5(this._id,n))}function E5(n){typeof n!="function"&&(n=L0(n));for(var r=this._groups,i=r.length,o=new Array(i),u=0;u<i;++u)for(var f=r[u],h=f.length,g=o[u]=[],x,m=0;m<h;++m)(x=f[m])&&n.call(x,x.__data__,m,f)&&g.push(x);return new aa(o,this._parents,this._name,this._id)}function k5(n){if(n._id!==this._id)throw new Error;for(var r=this._groups,i=n._groups,o=r.length,u=i.length,f=Math.min(o,u),h=new Array(o),g=0;g<f;++g)for(var x=r[g],m=i[g],p=x.length,b=h[g]=new Array(p),v,N=0;N<p;++N)(v=x[N]||m[N])&&(b[N]=v);for(;g<o;++g)h[g]=r[g];return new aa(h,this._parents,this._name,this._id)}function _5(n){return(n+"").trim().split(/^|\s+/).every(function(r){var i=r.indexOf(".");return i>=0&&(r=r.slice(0,i)),!r||r==="start"})}function C5(n,r,i){var o,u,f=_5(r)?sf:On;return function(){var h=f(this,n),g=h.on;g!==o&&(u=(o=g).copy()).on(r,i),h.on=u}}function T5(n,r){var i=this._id;return arguments.length<2?kn(this.node(),i).on.on(n):this.each(C5(i,n,r))}function M5(n){return function(){var r=this.parentNode;for(var i in this.__transition)if(+i!==n)return;r&&r.removeChild(this)}}function A5(){return this.on("end.remove",M5(this._id))}function R5(n){var r=this._name,i=this._id;typeof n!="function"&&(n=ef(n));for(var o=this._groups,u=o.length,f=new Array(u),h=0;h<u;++h)for(var g=o[h],x=g.length,m=f[h]=new Array(x),p,b,v=0;v<x;++v)(p=g[v])&&(b=n.call(p,p.__data__,v,g))&&("__data__"in p&&(b.__data__=p.__data__),m[v]=b,Wo(m[v],r,i,v,m,kn(p,i)));return new aa(f,this._parents,r,i)}function z5(n){var r=this._name,i=this._id;typeof n!="function"&&(n=q0(n));for(var o=this._groups,u=o.length,f=[],h=[],g=0;g<u;++g)for(var x=o[g],m=x.length,p,b=0;b<m;++b)if(p=x[b]){for(var v=n.call(p,p.__data__,b,x),N,T=kn(p,i),_=0,M=v.length;_<M;++_)(N=v[_])&&Wo(N,r,i,_,v,T);f.push(v),h.push(p)}return new aa(f,h,r,i)}var O5=Xr.prototype.constructor;function D5(){return new O5(this._groups,this._parents)}function H5(n,r){var i,o,u;return function(){var f=pl(this,n),h=(this.style.removeProperty(n),pl(this,n));return f===h?null:f===i&&h===o?u:u=r(i=f,o=h)}}function ug(n){return function(){this.style.removeProperty(n)}}function $5(n,r,i){var o,u=i+"",f;return function(){var h=pl(this,n);return h===u?null:h===o?f:f=r(o=h,i)}}function U5(n,r,i){var o,u,f;return function(){var h=pl(this,n),g=i(this),x=g+"";return g==null&&(x=g=(this.style.removeProperty(n),pl(this,n))),h===x?null:h===o&&x===u?f:(u=x,f=r(o=h,g))}}function B5(n,r){var i,o,u,f="style."+r,h="end."+f,g;return function(){var x=On(this,n),m=x.on,p=x.value[f]==null?g||(g=ug(r)):void 0;(m!==i||u!==p)&&(o=(i=m).copy()).on(h,u=p),x.on=o}}function q5(n,r,i){var o=(n+="")=="transform"?qN:cg;return r==null?this.styleTween(n,H5(n,o)).on("end.style."+n,ug(n)):typeof r=="function"?this.styleTween(n,U5(n,o,lf(this,"style."+n,r))).each(B5(this._id,n)):this.styleTween(n,$5(n,o,r),i).on("end.style."+n,null)}function L5(n,r,i){return function(o){this.style.setProperty(n,r.call(this,o),i)}}function Y5(n,r,i){var o,u;function f(){var h=r.apply(this,arguments);return h!==u&&(o=(u=h)&&L5(n,h,i)),o}return f._value=r,f}function V5(n,r,i){var o="style."+(n+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(r==null)return this.tween(o,null);if(typeof r!="function")throw new Error;return this.tween(o,Y5(n,r,i??""))}function G5(n){return function(){this.textContent=n}}function X5(n){return function(){var r=n(this);this.textContent=r??""}}function Z5(n){return this.tween("text",typeof n=="function"?X5(lf(this,"text",n)):G5(n==null?"":n+""))}function W5(n){return function(r){this.textContent=n.call(this,r)}}function Q5(n){var r,i;function o(){var u=n.apply(this,arguments);return u!==i&&(r=(i=u)&&W5(u)),r}return o._value=n,o}function K5(n){var r="text";if(arguments.length<1)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;return this.tween(r,Q5(n))}function J5(){for(var n=this._name,r=this._id,i=dg(),o=this._groups,u=o.length,f=0;f<u;++f)for(var h=o[f],g=h.length,x,m=0;m<g;++m)if(x=h[m]){var p=kn(x,r);Wo(x,n,i,m,h,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new aa(o,this._parents,n,i)}function I5(){var n,r,i=this,o=i._id,u=i.size();return new Promise(function(f,h){var g={value:h},x={value:function(){--u===0&&f()}};i.each(function(){var m=On(this,o),p=m.on;p!==n&&(r=(n=p).copy(),r._.cancel.push(g),r._.interrupt.push(g),r._.end.push(x)),m.on=r}),u===0&&f()})}var F5=0;function aa(n,r,i,o){this._groups=n,this._parents=r,this._name=i,this._id=o}function dg(){return++F5}var Fn=Xr.prototype;aa.prototype={constructor:aa,select:R5,selectAll:z5,selectChild:Fn.selectChild,selectChildren:Fn.selectChildren,filter:E5,merge:k5,selection:D5,transition:J5,call:Fn.call,nodes:Fn.nodes,node:Fn.node,size:Fn.size,empty:Fn.empty,each:Fn.each,on:T5,attr:c5,attrTween:m5,style:q5,styleTween:V5,text:Z5,textTween:K5,remove:A5,tween:n5,delay:g5,duration:v5,ease:N5,easeVarying:S5,end:I5,[Symbol.iterator]:Fn[Symbol.iterator]};function P5(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var ew={time:null,delay:0,duration:250,ease:P5};function tw(n,r){for(var i;!(i=n.__transition)||!(i=i[r]);)if(!(n=n.parentNode))throw new Error(`transition ${r} not found`);return i}function nw(n){var r,i;n instanceof aa?(r=n._id,n=n._name):(r=dg(),(i=ew).time=af(),n=n==null?null:n+"");for(var o=this._groups,u=o.length,f=0;f<u;++f)for(var h=o[f],g=h.length,x,m=0;m<g;++m)(x=h[m])&&Wo(x,n,r,m,h,i||tw(x,r));return new aa(o,this._parents,n,r)}Xr.prototype.interrupt=PN;Xr.prototype.transition=nw;const bo=n=>()=>n;function aw(n,{sourceEvent:r,target:i,transform:o,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:u}})}function Pn(n,r,i){this.k=n,this.x=r,this.y=i}Pn.prototype={constructor:Pn,scale:function(n){return n===1?this:new Pn(this.k*n,this.x,this.y)},translate:function(n,r){return n===0&r===0?this:new Pn(this.k,this.x+this.k*n,this.y+this.k*r)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ta=new Pn(1,0,0);Pn.prototype;function yd(n){n.stopImmediatePropagation()}function wr(n){n.preventDefault(),n.stopImmediatePropagation()}function sw(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function lw(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function Lx(){return this.__zoom||ta}function rw(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function iw(){return navigator.maxTouchPoints||"ontouchstart"in this}function ow(n,r,i){var o=n.invertX(r[0][0])-i[0][0],u=n.invertX(r[1][0])-i[1][0],f=n.invertY(r[0][1])-i[0][1],h=n.invertY(r[1][1])-i[1][1];return n.translate(u>o?(o+u)/2:Math.min(0,o)||Math.max(0,u),h>f?(f+h)/2:Math.min(0,f)||Math.max(0,h))}function fg(){var n=sw,r=lw,i=ow,o=rw,u=iw,f=[0,1/0],h=[[-1/0,-1/0],[1/0,1/0]],g=250,x=XN,m=Go("start","zoom","end"),p,b,v,N=500,T=150,_=0,M=10;function A(S){S.property("__zoom",Lx).on("wheel.zoom",ie,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",K).filter(u).on("touchstart.zoom",ne).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",se).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(S,U,k,H){var O=S.selection?S.selection():S;O.property("__zoom",Lx),S!==O?D(S,U,k,H):O.interrupt().each(function(){W(this,arguments).event(H).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},A.scaleBy=function(S,U,k,H){A.scaleTo(S,function(){var O=this.__zoom.k,z=typeof U=="function"?U.apply(this,arguments):U;return O*z},k,H)},A.scaleTo=function(S,U,k,H){A.transform(S,function(){var O=r.apply(this,arguments),z=this.__zoom,E=k==null?C(O):typeof k=="function"?k.apply(this,arguments):k,$=z.invert(E),Z=typeof U=="function"?U.apply(this,arguments):U;return i(L(V(z,Z),E,$),O,h)},k,H)},A.translateBy=function(S,U,k,H){A.transform(S,function(){return i(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof k=="function"?k.apply(this,arguments):k),r.apply(this,arguments),h)},null,H)},A.translateTo=function(S,U,k,H,O){A.transform(S,function(){var z=r.apply(this,arguments),E=this.__zoom,$=H==null?C(z):typeof H=="function"?H.apply(this,arguments):H;return i(ta.translate($[0],$[1]).scale(E.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof k=="function"?-k.apply(this,arguments):-k),z,h)},H,O)};function V(S,U){return U=Math.max(f[0],Math.min(f[1],U)),U===S.k?S:new Pn(U,S.x,S.y)}function L(S,U,k){var H=U[0]-k[0]*S.k,O=U[1]-k[1]*S.k;return H===S.x&&O===S.y?S:new Pn(S.k,H,O)}function C(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function D(S,U,k,H){S.on("start.zoom",function(){W(this,arguments).event(H).start()}).on("interrupt.zoom end.zoom",function(){W(this,arguments).event(H).end()}).tween("zoom",function(){var O=this,z=arguments,E=W(O,z).event(H),$=r.apply(O,z),Z=k==null?C($):typeof k=="function"?k.apply(O,z):k,ae=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),oe=O.__zoom,he=typeof U=="function"?U.apply(O,z):U,me=x(oe.invert(Z).concat(ae/oe.k),he.invert(Z).concat(ae/he.k));return function(Se){if(Se===1)Se=he;else{var ve=me(Se),Ae=ae/ve[2];Se=new Pn(Ae,Z[0]-ve[0]*Ae,Z[1]-ve[1]*Ae)}E.zoom(null,Se)}})}function W(S,U,k){return!k&&S.__zooming||new X(S,U)}function X(S,U){this.that=S,this.args=U,this.active=0,this.sourceEvent=null,this.extent=r.apply(S,U),this.taps=0}X.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,U){return this.mouse&&S!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&S!=="touch"&&(this.touch1[1]=U.invert(this.touch1[0])),this.that.__zoom=U,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(S){var U=gn(this.that).datum();m.call(S,this.that,new aw(S,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:m}),U)}};function ie(S,...U){if(!n.apply(this,arguments))return;var k=W(this,U).event(S),H=this.__zoom,O=Math.max(f[0],Math.min(f[1],H.k*Math.pow(2,o.apply(this,arguments)))),z=Sn(S);if(k.wheel)(k.mouse[0][0]!==z[0]||k.mouse[0][1]!==z[1])&&(k.mouse[1]=H.invert(k.mouse[0]=z)),clearTimeout(k.wheel);else{if(H.k===O)return;k.mouse=[z,H.invert(z)],Ao(this),k.start()}wr(S),k.wheel=setTimeout(E,T),k.zoom("mouse",i(L(V(H,O),k.mouse[0],k.mouse[1]),k.extent,h));function E(){k.wheel=null,k.end()}}function I(S,...U){if(v||!n.apply(this,arguments))return;var k=S.currentTarget,H=W(this,U,!0).event(S),O=gn(S.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",ae,!0),z=Sn(S,k),E=S.clientX,$=S.clientY;I0(S.view),yd(S),H.mouse=[z,this.__zoom.invert(z)],Ao(this),H.start();function Z(oe){if(wr(oe),!H.moved){var he=oe.clientX-E,me=oe.clientY-$;H.moved=he*he+me*me>_}H.event(oe).zoom("mouse",i(L(H.that.__zoom,H.mouse[0]=Sn(oe,k),H.mouse[1]),H.extent,h))}function ae(oe){O.on("mousemove.zoom mouseup.zoom",null),F0(oe.view,H.moved),wr(oe),H.event(oe).end()}}function K(S,...U){if(n.apply(this,arguments)){var k=this.__zoom,H=Sn(S.changedTouches?S.changedTouches[0]:S,this),O=k.invert(H),z=k.k*(S.shiftKey?.5:2),E=i(L(V(k,z),H,O),r.apply(this,U),h);wr(S),g>0?gn(this).transition().duration(g).call(D,E,H,S):gn(this).call(A.transform,E,H,S)}}function ne(S,...U){if(n.apply(this,arguments)){var k=S.touches,H=k.length,O=W(this,U,S.changedTouches.length===H).event(S),z,E,$,Z;for(yd(S),E=0;E<H;++E)$=k[E],Z=Sn($,this),Z=[Z,this.__zoom.invert(Z),$.identifier],O.touch0?!O.touch1&&O.touch0[2]!==Z[2]&&(O.touch1=Z,O.taps=0):(O.touch0=Z,z=!0,O.taps=1+!!p);p&&(p=clearTimeout(p)),z&&(O.taps<2&&(b=Z[0],p=setTimeout(function(){p=null},N)),Ao(this),O.start())}}function ee(S,...U){if(this.__zooming){var k=W(this,U).event(S),H=S.changedTouches,O=H.length,z,E,$,Z;for(wr(S),z=0;z<O;++z)E=H[z],$=Sn(E,this),k.touch0&&k.touch0[2]===E.identifier?k.touch0[0]=$:k.touch1&&k.touch1[2]===E.identifier&&(k.touch1[0]=$);if(E=k.that.__zoom,k.touch1){var ae=k.touch0[0],oe=k.touch0[1],he=k.touch1[0],me=k.touch1[1],Se=(Se=he[0]-ae[0])*Se+(Se=he[1]-ae[1])*Se,ve=(ve=me[0]-oe[0])*ve+(ve=me[1]-oe[1])*ve;E=V(E,Math.sqrt(Se/ve)),$=[(ae[0]+he[0])/2,(ae[1]+he[1])/2],Z=[(oe[0]+me[0])/2,(oe[1]+me[1])/2]}else if(k.touch0)$=k.touch0[0],Z=k.touch0[1];else return;k.zoom("touch",i(L(E,$,Z),k.extent,h))}}function se(S,...U){if(this.__zooming){var k=W(this,U).event(S),H=S.changedTouches,O=H.length,z,E;for(yd(S),v&&clearTimeout(v),v=setTimeout(function(){v=null},N),z=0;z<O;++z)E=H[z],k.touch0&&k.touch0[2]===E.identifier?delete k.touch0:k.touch1&&k.touch1[2]===E.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(E=Sn(E,this),Math.hypot(b[0]-E[0],b[1]-E[1])<M)){var $=gn(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return A.wheelDelta=function(S){return arguments.length?(o=typeof S=="function"?S:bo(+S),A):o},A.filter=function(S){return arguments.length?(n=typeof S=="function"?S:bo(!!S),A):n},A.touchable=function(S){return arguments.length?(u=typeof S=="function"?S:bo(!!S),A):u},A.extent=function(S){return arguments.length?(r=typeof S=="function"?S:bo([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),A):r},A.scaleExtent=function(S){return arguments.length?(f[0]=+S[0],f[1]=+S[1],A):[f[0],f[1]]},A.translateExtent=function(S){return arguments.length?(h[0][0]=+S[0][0],h[1][0]=+S[1][0],h[0][1]=+S[0][1],h[1][1]=+S[1][1],A):[[h[0][0],h[0][1]],[h[1][0],h[1][1]]]},A.constrain=function(S){return arguments.length?(i=S,A):i},A.duration=function(S){return arguments.length?(g=+S,A):g},A.interpolate=function(S){return arguments.length?(x=S,A):x},A.on=function(){var S=m.on.apply(m,arguments);return S===m?A:S},A.clickDistance=function(S){return arguments.length?(_=(S=+S)*S,A):Math.sqrt(_)},A.tapDistance=function(S){return arguments.length?(M=+S,A):M},A}k0();const Qo=j.createContext(null),cw=Qo.Provider,sa={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:n=>`Node type "${n}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:n=>`The old edge with id=${n} does not exist.`,error009:n=>`Marker type "${n}" doesn't exist.`,error008:(n,r)=>`Couldn't create edge for ${n?"target":"source"} handle id: "${n?r.targetHandle:r.sourceHandle}", edge id: ${r.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:n=>`Edge type "${n}" not found. Using fallback type "default".`,error012:n=>`Node with id "${n}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},hg=sa.error001();function tt(n,r){const i=j.useContext(Qo);if(i===null)throw new Error(hg);return U0(i,n,r)}const Nt=()=>{const n=j.useContext(Qo);if(n===null)throw new Error(hg);return j.useMemo(()=>({getState:n.getState,setState:n.setState,subscribe:n.subscribe,destroy:n.destroy}),[n])},uw=n=>n.userSelectionActive?"none":"all";function rf({position:n,children:r,className:i,style:o,...u}){const f=tt(uw),h=`${n}`.split("-");return le.createElement("div",{className:$t(["react-flow__panel",i,...h]),style:{...o,pointerEvents:f},...u},r)}function dw({proOptions:n,position:r="bottom-right"}){return n?.hideAttribution?null:le.createElement(rf,{position:r,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},le.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const fw=({x:n,y:r,label:i,labelStyle:o={},labelShowBg:u=!0,labelBgStyle:f={},labelBgPadding:h=[2,4],labelBgBorderRadius:g=2,children:x,className:m,...p})=>{const b=j.useRef(null),[v,N]=j.useState({x:0,y:0,width:0,height:0}),T=$t(["react-flow__edge-textwrapper",m]);return j.useEffect(()=>{if(b.current){const _=b.current.getBBox();N({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:le.createElement("g",{transform:`translate(${n-v.width/2} ${r-v.height/2})`,className:T,visibility:v.width?"visible":"hidden",...p},u&&le.createElement("rect",{width:v.width+2*h[0],x:-h[0],y:-h[1],height:v.height+2*h[1],className:"react-flow__edge-textbg",style:f,rx:g,ry:g}),le.createElement("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:b,style:o},i),x)};var hw=j.memo(fw);const of=n=>({width:n.offsetWidth,height:n.offsetHeight}),gl=(n,r=0,i=1)=>Math.min(Math.max(n,r),i),cf=(n={x:0,y:0},r)=>({x:gl(n.x,r[0][0],r[1][0]),y:gl(n.y,r[0][1],r[1][1])}),Yx=(n,r,i)=>n<r?gl(Math.abs(n-r),1,50)/50:n>i?-gl(Math.abs(n-i),1,50)/50:0,mg=(n,r)=>{const i=Yx(n.x,35,r.width-35)*20,o=Yx(n.y,35,r.height-35)*20;return[i,o]},pg=n=>n.getRootNode?.()||window?.document,xg=(n,r)=>({x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),x2:Math.max(n.x2,r.x2),y2:Math.max(n.y2,r.y2)}),Br=({x:n,y:r,width:i,height:o})=>({x:n,y:r,x2:n+i,y2:r+o}),gg=({x:n,y:r,x2:i,y2:o})=>({x:n,y:r,width:i-n,height:o-r}),Vx=n=>({...n.positionAbsolute||{x:0,y:0},width:n.width||0,height:n.height||0}),mw=(n,r)=>gg(xg(Br(n),Br(r))),Bd=(n,r)=>{const i=Math.max(0,Math.min(n.x+n.width,r.x+r.width)-Math.max(n.x,r.x)),o=Math.max(0,Math.min(n.y+n.height,r.y+r.height)-Math.max(n.y,r.y));return Math.ceil(i*o)},pw=n=>yn(n.width)&&yn(n.height)&&yn(n.x)&&yn(n.y),yn=n=>!isNaN(n)&&isFinite(n),ct=Symbol.for("internals"),yg=["Enter"," ","Escape"],xw=(n,r)=>{},gw=n=>"nativeEvent"in n;function qd(n){const i=(gw(n)?n.nativeEvent:n).composedPath?.()?.[0]||n.target;return["INPUT","SELECT","TEXTAREA"].includes(i?.nodeName)||i?.hasAttribute("contenteditable")||!!i?.closest(".nokey")}const bg=n=>"clientX"in n,Ua=(n,r)=>{const i=bg(n),o=i?n.clientX:n.touches?.[0].clientX,u=i?n.clientY:n.touches?.[0].clientY;return{x:o-(r?.left??0),y:u-(r?.top??0)}},qo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,Wr=({id:n,path:r,labelX:i,labelY:o,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m,style:p,markerEnd:b,markerStart:v,interactionWidth:N=20})=>le.createElement(le.Fragment,null,le.createElement("path",{id:n,style:p,d:r,fill:"none",className:"react-flow__edge-path",markerEnd:b,markerStart:v}),N&&le.createElement("path",{d:r,fill:"none",strokeOpacity:0,strokeWidth:N,className:"react-flow__edge-interaction"}),u&&yn(i)&&yn(o)?le.createElement(hw,{x:i,y:o,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m}):null);Wr.displayName="BaseEdge";function Sr(n,r,i){return i===void 0?i:o=>{const u=r().edges.find(f=>f.id===n);u&&i(o,{...u})}}function vg({sourceX:n,sourceY:r,targetX:i,targetY:o}){const u=Math.abs(i-n)/2,f=i<n?i+u:i-u,h=Math.abs(o-r)/2,g=o<r?o+h:o-h;return[f,g,u,h]}function jg({sourceX:n,sourceY:r,targetX:i,targetY:o,sourceControlX:u,sourceControlY:f,targetControlX:h,targetControlY:g}){const x=n*.125+u*.375+h*.375+i*.125,m=r*.125+f*.375+g*.375+o*.125,p=Math.abs(x-n),b=Math.abs(m-r);return[x,m,p,b]}var ps;(function(n){n.Strict="strict",n.Loose="loose"})(ps||(ps={}));var us;(function(n){n.Free="free",n.Vertical="vertical",n.Horizontal="horizontal"})(us||(us={}));var qr;(function(n){n.Partial="partial",n.Full="full"})(qr||(qr={}));var $a;(function(n){n.Bezier="default",n.Straight="straight",n.Step="step",n.SmoothStep="smoothstep",n.SimpleBezier="simplebezier"})($a||($a={}));var Ba;(function(n){n.Arrow="arrow",n.ArrowClosed="arrowclosed"})(Ba||(Ba={}));var xe;(function(n){n.Left="left",n.Top="top",n.Right="right",n.Bottom="bottom"})(xe||(xe={}));function Gx({pos:n,x1:r,y1:i,x2:o,y2:u}){return n===xe.Left||n===xe.Right?[.5*(r+o),i]:[r,.5*(i+u)]}function Ng({sourceX:n,sourceY:r,sourcePosition:i=xe.Bottom,targetX:o,targetY:u,targetPosition:f=xe.Top}){const[h,g]=Gx({pos:i,x1:n,y1:r,x2:o,y2:u}),[x,m]=Gx({pos:f,x1:o,y1:u,x2:n,y2:r}),[p,b,v,N]=jg({sourceX:n,sourceY:r,targetX:o,targetY:u,sourceControlX:h,sourceControlY:g,targetControlX:x,targetControlY:m});return[`M${n},${r} C${h},${g} ${x},${m} ${o},${u}`,p,b,v,N]}const uf=j.memo(({sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:u=xe.Bottom,targetPosition:f=xe.Top,label:h,labelStyle:g,labelShowBg:x,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:b,style:v,markerEnd:N,markerStart:T,interactionWidth:_})=>{const[M,A,V]=Ng({sourceX:n,sourceY:r,sourcePosition:u,targetX:i,targetY:o,targetPosition:f});return le.createElement(Wr,{path:M,labelX:A,labelY:V,label:h,labelStyle:g,labelShowBg:x,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:b,style:v,markerEnd:N,markerStart:T,interactionWidth:_})});uf.displayName="SimpleBezierEdge";const Xx={[xe.Left]:{x:-1,y:0},[xe.Right]:{x:1,y:0},[xe.Top]:{x:0,y:-1},[xe.Bottom]:{x:0,y:1}},yw=({source:n,sourcePosition:r=xe.Bottom,target:i})=>r===xe.Left||r===xe.Right?n.x<i.x?{x:1,y:0}:{x:-1,y:0}:n.y<i.y?{x:0,y:1}:{x:0,y:-1},Zx=(n,r)=>Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2));function bw({source:n,sourcePosition:r=xe.Bottom,target:i,targetPosition:o=xe.Top,center:u,offset:f}){const h=Xx[r],g=Xx[o],x={x:n.x+h.x*f,y:n.y+h.y*f},m={x:i.x+g.x*f,y:i.y+g.y*f},p=yw({source:x,sourcePosition:r,target:m}),b=p.x!==0?"x":"y",v=p[b];let N=[],T,_;const M={x:0,y:0},A={x:0,y:0},[V,L,C,D]=vg({sourceX:n.x,sourceY:n.y,targetX:i.x,targetY:i.y});if(h[b]*g[b]===-1){T=u.x??V,_=u.y??L;const X=[{x:T,y:x.y},{x:T,y:m.y}],ie=[{x:x.x,y:_},{x:m.x,y:_}];h[b]===v?N=b==="x"?X:ie:N=b==="x"?ie:X}else{const X=[{x:x.x,y:m.y}],ie=[{x:m.x,y:x.y}];if(b==="x"?N=h.x===v?ie:X:N=h.y===v?X:ie,r===o){const se=Math.abs(n[b]-i[b]);if(se<=f){const S=Math.min(f-1,f-se);h[b]===v?M[b]=(x[b]>n[b]?-1:1)*S:A[b]=(m[b]>i[b]?-1:1)*S}}if(r!==o){const se=b==="x"?"y":"x",S=h[b]===g[se],U=x[se]>m[se],k=x[se]<m[se];(h[b]===1&&(!S&&U||S&&k)||h[b]!==1&&(!S&&k||S&&U))&&(N=b==="x"?X:ie)}const I={x:x.x+M.x,y:x.y+M.y},K={x:m.x+A.x,y:m.y+A.y},ne=Math.max(Math.abs(I.x-N[0].x),Math.abs(K.x-N[0].x)),ee=Math.max(Math.abs(I.y-N[0].y),Math.abs(K.y-N[0].y));ne>=ee?(T=(I.x+K.x)/2,_=N[0].y):(T=N[0].x,_=(I.y+K.y)/2)}return[[n,{x:x.x+M.x,y:x.y+M.y},...N,{x:m.x+A.x,y:m.y+A.y},i],T,_,C,D]}function vw(n,r,i,o){const u=Math.min(Zx(n,r)/2,Zx(r,i)/2,o),{x:f,y:h}=r;if(n.x===f&&f===i.x||n.y===h&&h===i.y)return`L${f} ${h}`;if(n.y===h){const m=n.x<i.x?-1:1,p=n.y<i.y?1:-1;return`L ${f+u*m},${h}Q ${f},${h} ${f},${h+u*p}`}const g=n.x<i.x?1:-1,x=n.y<i.y?-1:1;return`L ${f},${h+u*x}Q ${f},${h} ${f+u*g},${h}`}function Ld({sourceX:n,sourceY:r,sourcePosition:i=xe.Bottom,targetX:o,targetY:u,targetPosition:f=xe.Top,borderRadius:h=5,centerX:g,centerY:x,offset:m=20}){const[p,b,v,N,T]=bw({source:{x:n,y:r},sourcePosition:i,target:{x:o,y:u},targetPosition:f,center:{x:g,y:x},offset:m});return[p.reduce((M,A,V)=>{let L="";return V>0&&V<p.length-1?L=vw(p[V-1],A,p[V+1],h):L=`${V===0?"M":"L"}${A.x} ${A.y}`,M+=L,M},""),b,v,N,T]}const Ko=j.memo(({sourceX:n,sourceY:r,targetX:i,targetY:o,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m,style:p,sourcePosition:b=xe.Bottom,targetPosition:v=xe.Top,markerEnd:N,markerStart:T,pathOptions:_,interactionWidth:M})=>{const[A,V,L]=Ld({sourceX:n,sourceY:r,sourcePosition:b,targetX:i,targetY:o,targetPosition:v,borderRadius:_?.borderRadius,offset:_?.offset});return le.createElement(Wr,{path:A,labelX:V,labelY:L,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m,style:p,markerEnd:N,markerStart:T,interactionWidth:M})});Ko.displayName="SmoothStepEdge";const df=j.memo(n=>le.createElement(Ko,{...n,pathOptions:j.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])}));df.displayName="StepEdge";function jw({sourceX:n,sourceY:r,targetX:i,targetY:o}){const[u,f,h,g]=vg({sourceX:n,sourceY:r,targetX:i,targetY:o});return[`M ${n},${r}L ${i},${o}`,u,f,h,g]}const ff=j.memo(({sourceX:n,sourceY:r,targetX:i,targetY:o,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m,style:p,markerEnd:b,markerStart:v,interactionWidth:N})=>{const[T,_,M]=jw({sourceX:n,sourceY:r,targetX:i,targetY:o});return le.createElement(Wr,{path:T,labelX:_,labelY:M,label:u,labelStyle:f,labelShowBg:h,labelBgStyle:g,labelBgPadding:x,labelBgBorderRadius:m,style:p,markerEnd:b,markerStart:v,interactionWidth:N})});ff.displayName="StraightEdge";function vo(n,r){return n>=0?.5*n:r*25*Math.sqrt(-n)}function Wx({pos:n,x1:r,y1:i,x2:o,y2:u,c:f}){switch(n){case xe.Left:return[r-vo(r-o,f),i];case xe.Right:return[r+vo(o-r,f),i];case xe.Top:return[r,i-vo(i-u,f)];case xe.Bottom:return[r,i+vo(u-i,f)]}}function wg({sourceX:n,sourceY:r,sourcePosition:i=xe.Bottom,targetX:o,targetY:u,targetPosition:f=xe.Top,curvature:h=.25}){const[g,x]=Wx({pos:i,x1:n,y1:r,x2:o,y2:u,c:h}),[m,p]=Wx({pos:f,x1:o,y1:u,x2:n,y2:r,c:h}),[b,v,N,T]=jg({sourceX:n,sourceY:r,targetX:o,targetY:u,sourceControlX:g,sourceControlY:x,targetControlX:m,targetControlY:p});return[`M${n},${r} C${g},${x} ${m},${p} ${o},${u}`,b,v,N,T]}const Lo=j.memo(({sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:u=xe.Bottom,targetPosition:f=xe.Top,label:h,labelStyle:g,labelShowBg:x,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:b,style:v,markerEnd:N,markerStart:T,pathOptions:_,interactionWidth:M})=>{const[A,V,L]=wg({sourceX:n,sourceY:r,sourcePosition:u,targetX:i,targetY:o,targetPosition:f,curvature:_?.curvature});return le.createElement(Wr,{path:A,labelX:V,labelY:L,label:h,labelStyle:g,labelShowBg:x,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:b,style:v,markerEnd:N,markerStart:T,interactionWidth:M})});Lo.displayName="BezierEdge";const hf=j.createContext(null),Nw=hf.Provider;hf.Consumer;const ww=()=>j.useContext(hf),Sw=n=>"id"in n&&"source"in n&&"target"in n,Ew=({source:n,sourceHandle:r,target:i,targetHandle:o})=>`reactflow__edge-${n}${r||""}-${i}${o||""}`,Yd=(n,r)=>typeof n>"u"?"":typeof n=="string"?n:`${r?`${r}__`:""}${Object.keys(n).sort().map(o=>`${o}=${n[o]}`).join("&")}`,kw=(n,r)=>r.some(i=>i.source===n.source&&i.target===n.target&&(i.sourceHandle===n.sourceHandle||!i.sourceHandle&&!n.sourceHandle)&&(i.targetHandle===n.targetHandle||!i.targetHandle&&!n.targetHandle)),_w=(n,r)=>{if(!n.source||!n.target)return r;let i;return Sw(n)?i={...n}:i={...n,id:Ew(n)},kw(i,r)?r:r.concat(i)},Vd=({x:n,y:r},[i,o,u],f,[h,g])=>{const x={x:(n-i)/u,y:(r-o)/u};return f?{x:h*Math.round(x.x/h),y:g*Math.round(x.y/g)}:x},Sg=({x:n,y:r},[i,o,u])=>({x:n*u+i,y:r*u+o}),fs=(n,r=[0,0])=>{if(!n)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const i=(n.width??0)*r[0],o=(n.height??0)*r[1],u={x:n.position.x-i,y:n.position.y-o};return{...u,positionAbsolute:n.positionAbsolute?{x:n.positionAbsolute.x-i,y:n.positionAbsolute.y-o}:u}},Jo=(n,r=[0,0])=>{if(n.length===0)return{x:0,y:0,width:0,height:0};const i=n.reduce((o,u)=>{const{x:f,y:h}=fs(u,r).positionAbsolute;return xg(o,Br({x:f,y:h,width:u.width||0,height:u.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return gg(i)},Eg=(n,r,[i,o,u]=[0,0,1],f=!1,h=!1,g=[0,0])=>{const x={x:(r.x-i)/u,y:(r.y-o)/u,width:r.width/u,height:r.height/u},m=[];return n.forEach(p=>{const{width:b,height:v,selectable:N=!0,hidden:T=!1}=p;if(h&&!N||T)return!1;const{positionAbsolute:_}=fs(p,g),M={x:_.x,y:_.y,width:b||0,height:v||0},A=Bd(x,M),V=typeof b>"u"||typeof v>"u"||b===null||v===null,L=f&&A>0,C=(b||0)*(v||0);(V||L||A>=C||p.dragging)&&m.push(p)}),m},kg=(n,r)=>{const i=n.map(o=>o.id);return r.filter(o=>i.includes(o.source)||i.includes(o.target))},_g=(n,r,i,o,u,f=.1)=>{const h=r/(n.width*(1+f)),g=i/(n.height*(1+f)),x=Math.min(h,g),m=gl(x,o,u),p=n.x+n.width/2,b=n.y+n.height/2,v=r/2-p*m,N=i/2-b*m;return{x:v,y:N,zoom:m}},os=(n,r=0)=>n.transition().duration(r);function Qx(n,r,i,o){return(r[i]||[]).reduce((u,f)=>(`${n.id}-${f.id}-${i}`!==o&&u.push({id:f.id||null,type:i,nodeId:n.id,x:(n.positionAbsolute?.x??0)+f.x+f.width/2,y:(n.positionAbsolute?.y??0)+f.y+f.height/2}),u),[])}function Cw(n,r,i,o,u,f){const{x:h,y:g}=Ua(n),m=r.elementsFromPoint(h,g).find(T=>T.classList.contains("react-flow__handle"));if(m){const T=m.getAttribute("data-nodeid");if(T){const _=mf(void 0,m),M=m.getAttribute("data-handleid"),A=f({nodeId:T,id:M,type:_});if(A){const V=u.find(L=>L.nodeId===T&&L.type===_&&L.id===M);return{handle:{id:M,type:_,nodeId:T,x:V?.x||i.x,y:V?.y||i.y},validHandleResult:A}}}}let p=[],b=1/0;if(u.forEach(T=>{const _=Math.sqrt((T.x-i.x)**2+(T.y-i.y)**2);if(_<=o){const M=f(T);_<=b&&(_<b?p=[{handle:T,validHandleResult:M}]:_===b&&p.push({handle:T,validHandleResult:M}),b=_)}}),!p.length)return{handle:null,validHandleResult:Cg()};if(p.length===1)return p[0];const v=p.some(({validHandleResult:T})=>T.isValid),N=p.some(({handle:T})=>T.type==="target");return p.find(({handle:T,validHandleResult:_})=>N?T.type==="target":v?_.isValid:!0)||p[0]}const Tw={source:null,target:null,sourceHandle:null,targetHandle:null},Cg=()=>({handleDomNode:null,isValid:!1,connection:Tw,endHandle:null});function Tg(n,r,i,o,u,f,h){const g=u==="target",x=h.querySelector(`.react-flow__handle[data-id="${n?.nodeId}-${n?.id}-${n?.type}"]`),m={...Cg(),handleDomNode:x};if(x){const p=mf(void 0,x),b=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),T=x.classList.contains("connectableend"),_={source:g?b:i,sourceHandle:g?v:o,target:g?i:b,targetHandle:g?o:v};m.connection=_,N&&T&&(r===ps.Strict?g&&p==="source"||!g&&p==="target":b!==i||v!==o)&&(m.endHandle={nodeId:b,handleId:v,type:p},m.isValid=f(_))}return m}function Mw({nodes:n,nodeId:r,handleId:i,handleType:o}){return n.reduce((u,f)=>{if(f[ct]){const{handleBounds:h}=f[ct];let g=[],x=[];h&&(g=Qx(f,h,"source",`${r}-${i}-${o}`),x=Qx(f,h,"target",`${r}-${i}-${o}`)),u.push(...g,...x)}return u},[])}function mf(n,r){return n||(r?.classList.contains("target")?"target":r?.classList.contains("source")?"source":null)}function bd(n){n?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Aw(n,r){let i=null;return r?i="valid":n&&!r&&(i="invalid"),i}function Mg({event:n,handleId:r,nodeId:i,onConnect:o,isTarget:u,getState:f,setState:h,isValidConnection:g,edgeUpdaterType:x,onReconnectEnd:m}){const p=pg(n.target),{connectionMode:b,domNode:v,autoPanOnConnect:N,connectionRadius:T,onConnectStart:_,panBy:M,getNodes:A,cancelConnection:V}=f();let L=0,C;const{x:D,y:W}=Ua(n),X=p?.elementFromPoint(D,W),ie=mf(x,X),I=v?.getBoundingClientRect();if(!I||!ie)return;let K,ne=Ua(n,I),ee=!1,se=null,S=!1,U=null;const k=Mw({nodes:A(),nodeId:i,handleId:r,handleType:ie}),H=()=>{if(!N)return;const[E,$]=mg(ne,I);M({x:E,y:$}),L=requestAnimationFrame(H)};h({connectionPosition:ne,connectionStatus:null,connectionNodeId:i,connectionHandleId:r,connectionHandleType:ie,connectionStartHandle:{nodeId:i,handleId:r,type:ie},connectionEndHandle:null}),_?.(n,{nodeId:i,handleId:r,handleType:ie});function O(E){const{transform:$}=f();ne=Ua(E,I);const{handle:Z,validHandleResult:ae}=Cw(E,p,Vd(ne,$,!1,[1,1]),T,k,oe=>Tg(oe,b,i,r,u?"target":"source",g,p));if(C=Z,ee||(H(),ee=!0),U=ae.handleDomNode,se=ae.connection,S=ae.isValid,h({connectionPosition:C&&S?Sg({x:C.x,y:C.y},$):ne,connectionStatus:Aw(!!C,S),connectionEndHandle:ae.endHandle}),!C&&!S&&!U)return bd(K);se.source!==se.target&&U&&(bd(K),K=U,U.classList.add("connecting","react-flow__handle-connecting"),U.classList.toggle("valid",S),U.classList.toggle("react-flow__handle-valid",S))}function z(E){(C||U)&&se&&S&&o?.(se),f().onConnectEnd?.(E),x&&m?.(E),bd(K),V(),cancelAnimationFrame(L),ee=!1,S=!1,se=null,U=null,p.removeEventListener("mousemove",O),p.removeEventListener("mouseup",z),p.removeEventListener("touchmove",O),p.removeEventListener("touchend",z)}p.addEventListener("mousemove",O),p.addEventListener("mouseup",z),p.addEventListener("touchmove",O),p.addEventListener("touchend",z)}const Kx=()=>!0,Rw=n=>({connectionStartHandle:n.connectionStartHandle,connectOnClick:n.connectOnClick,noPanClassName:n.noPanClassName}),zw=(n,r,i)=>o=>{const{connectionStartHandle:u,connectionEndHandle:f,connectionClickStartHandle:h}=o;return{connecting:u?.nodeId===n&&u?.handleId===r&&u?.type===i||f?.nodeId===n&&f?.handleId===r&&f?.type===i,clickConnecting:h?.nodeId===n&&h?.handleId===r&&h?.type===i}},Ag=j.forwardRef(({type:n="source",position:r=xe.Top,isValidConnection:i,isConnectable:o=!0,isConnectableStart:u=!0,isConnectableEnd:f=!0,id:h,onConnect:g,children:x,className:m,onMouseDown:p,onTouchStart:b,...v},N)=>{const T=h||null,_=n==="target",M=Nt(),A=ww(),{connectOnClick:V,noPanClassName:L}=tt(Rw,Ct),{connecting:C,clickConnecting:D}=tt(zw(A,T,n),Ct);A||M.getState().onError?.("010",sa.error010());const W=I=>{const{defaultEdgeOptions:K,onConnect:ne,hasDefaultEdges:ee}=M.getState(),se={...K,...I};if(ee){const{edges:S,setEdges:U}=M.getState();U(_w(se,S))}ne?.(se),g?.(se)},X=I=>{if(!A)return;const K=bg(I);u&&(K&&I.button===0||!K)&&Mg({event:I,handleId:T,nodeId:A,onConnect:W,isTarget:_,getState:M.getState,setState:M.setState,isValidConnection:i||M.getState().isValidConnection||Kx}),K?p?.(I):b?.(I)},ie=I=>{const{onClickConnectStart:K,onClickConnectEnd:ne,connectionClickStartHandle:ee,connectionMode:se,isValidConnection:S}=M.getState();if(!A||!ee&&!u)return;if(!ee){K?.(I,{nodeId:A,handleId:T,handleType:n}),M.setState({connectionClickStartHandle:{nodeId:A,type:n,handleId:T}});return}const U=pg(I.target),k=i||S||Kx,{connection:H,isValid:O}=Tg({nodeId:A,id:T,type:n},se,ee.nodeId,ee.handleId||null,ee.type,k,U);O&&W(H),ne?.(I),M.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":T,"data-nodeid":A,"data-handlepos":r,"data-id":`${A}-${T}-${n}`,className:$t(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",L,m,{source:!_,target:_,connectable:o,connectablestart:u,connectableend:f,connecting:D,connectionindicator:o&&(u&&!C||f&&C)}]),onMouseDown:X,onTouchStart:X,onClick:V?ie:void 0,ref:N,...v},x)});Ag.displayName="Handle";var jt=j.memo(Ag);const Rg=({data:n,isConnectable:r,targetPosition:i=xe.Top,sourcePosition:o=xe.Bottom})=>le.createElement(le.Fragment,null,le.createElement(jt,{type:"target",position:i,isConnectable:r}),n?.label,le.createElement(jt,{type:"source",position:o,isConnectable:r}));Rg.displayName="DefaultNode";var Gd=j.memo(Rg);const zg=({data:n,isConnectable:r,sourcePosition:i=xe.Bottom})=>le.createElement(le.Fragment,null,n?.label,le.createElement(jt,{type:"source",position:i,isConnectable:r}));zg.displayName="InputNode";var Og=j.memo(zg);const Dg=({data:n,isConnectable:r,targetPosition:i=xe.Top})=>le.createElement(le.Fragment,null,le.createElement(jt,{type:"target",position:i,isConnectable:r}),n?.label);Dg.displayName="OutputNode";var Hg=j.memo(Dg);const pf=()=>null;pf.displayName="GroupNode";const Ow=n=>({selectedNodes:n.getNodes().filter(r=>r.selected),selectedEdges:n.edges.filter(r=>r.selected).map(r=>({...r}))}),jo=n=>n.id;function Dw(n,r){return Ct(n.selectedNodes.map(jo),r.selectedNodes.map(jo))&&Ct(n.selectedEdges.map(jo),r.selectedEdges.map(jo))}const $g=j.memo(({onSelectionChange:n})=>{const r=Nt(),{selectedNodes:i,selectedEdges:o}=tt(Ow,Dw);return j.useEffect(()=>{const u={nodes:i,edges:o};n?.(u),r.getState().onSelectionChange.forEach(f=>f(u))},[i,o,n]),null});$g.displayName="SelectionListener";const Hw=n=>!!n.onSelectionChange;function $w({onSelectionChange:n}){const r=tt(Hw);return n||r?le.createElement($g,{onSelectionChange:n}):null}const Uw=n=>({setNodes:n.setNodes,setEdges:n.setEdges,setDefaultNodesAndEdges:n.setDefaultNodesAndEdges,setMinZoom:n.setMinZoom,setMaxZoom:n.setMaxZoom,setTranslateExtent:n.setTranslateExtent,setNodeExtent:n.setNodeExtent,reset:n.reset});function tl(n,r){j.useEffect(()=>{typeof n<"u"&&r(n)},[n])}function Ue(n,r,i){j.useEffect(()=>{typeof r<"u"&&i({[n]:r})},[r])}const Bw=({nodes:n,edges:r,defaultNodes:i,defaultEdges:o,onConnect:u,onConnectStart:f,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:x,nodesDraggable:m,nodesConnectable:p,nodesFocusable:b,edgesFocusable:v,edgesUpdatable:N,elevateNodesOnSelect:T,minZoom:_,maxZoom:M,nodeExtent:A,onNodesChange:V,onEdgesChange:L,elementsSelectable:C,connectionMode:D,snapGrid:W,snapToGrid:X,translateExtent:ie,connectOnClick:I,defaultEdgeOptions:K,fitView:ne,fitViewOptions:ee,onNodesDelete:se,onEdgesDelete:S,onNodeDrag:U,onNodeDragStart:k,onNodeDragStop:H,onSelectionDrag:O,onSelectionDragStart:z,onSelectionDragStop:E,noPanClassName:$,nodeOrigin:Z,rfId:ae,autoPanOnConnect:oe,autoPanOnNodeDrag:he,onError:me,connectionRadius:Se,isValidConnection:ve,nodeDragThreshold:Ae})=>{const{setNodes:Re,setEdges:We,setDefaultNodesAndEdges:Te,setMinZoom:be,setMaxZoom:q,setTranslateExtent:Y,setNodeExtent:ue,reset:re}=tt(Uw,Ct),P=Nt();return j.useEffect(()=>{const Ee=o?.map(ge=>({...ge,...K}));return Te(i,Ee),()=>{re()}},[]),Ue("defaultEdgeOptions",K,P.setState),Ue("connectionMode",D,P.setState),Ue("onConnect",u,P.setState),Ue("onConnectStart",f,P.setState),Ue("onConnectEnd",h,P.setState),Ue("onClickConnectStart",g,P.setState),Ue("onClickConnectEnd",x,P.setState),Ue("nodesDraggable",m,P.setState),Ue("nodesConnectable",p,P.setState),Ue("nodesFocusable",b,P.setState),Ue("edgesFocusable",v,P.setState),Ue("edgesUpdatable",N,P.setState),Ue("elementsSelectable",C,P.setState),Ue("elevateNodesOnSelect",T,P.setState),Ue("snapToGrid",X,P.setState),Ue("snapGrid",W,P.setState),Ue("onNodesChange",V,P.setState),Ue("onEdgesChange",L,P.setState),Ue("connectOnClick",I,P.setState),Ue("fitViewOnInit",ne,P.setState),Ue("fitViewOnInitOptions",ee,P.setState),Ue("onNodesDelete",se,P.setState),Ue("onEdgesDelete",S,P.setState),Ue("onNodeDrag",U,P.setState),Ue("onNodeDragStart",k,P.setState),Ue("onNodeDragStop",H,P.setState),Ue("onSelectionDrag",O,P.setState),Ue("onSelectionDragStart",z,P.setState),Ue("onSelectionDragStop",E,P.setState),Ue("noPanClassName",$,P.setState),Ue("nodeOrigin",Z,P.setState),Ue("rfId",ae,P.setState),Ue("autoPanOnConnect",oe,P.setState),Ue("autoPanOnNodeDrag",he,P.setState),Ue("onError",me,P.setState),Ue("connectionRadius",Se,P.setState),Ue("isValidConnection",ve,P.setState),Ue("nodeDragThreshold",Ae,P.setState),tl(n,Re),tl(r,We),tl(_,be),tl(M,q),tl(ie,Y),tl(A,ue),null},Jx={display:"none"},qw={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ug="react-flow__node-desc",Bg="react-flow__edge-desc",Lw="react-flow__aria-live",Yw=n=>n.ariaLiveMessage;function Vw({rfId:n}){const r=tt(Yw);return le.createElement("div",{id:`${Lw}-${n}`,"aria-live":"assertive","aria-atomic":"true",style:qw},r)}function Gw({rfId:n,disableKeyboardA11y:r}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${Ug}-${n}`,style:Jx},"Press enter or space to select a node.",!r&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),le.createElement("div",{id:`${Bg}-${n}`,style:Jx},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!r&&le.createElement(Vw,{rfId:n}))}var Lr=(n=null,r={actInsideInputWithModifier:!0})=>{const[i,o]=j.useState(!1),u=j.useRef(!1),f=j.useRef(new Set([])),[h,g]=j.useMemo(()=>{if(n!==null){const m=(Array.isArray(n)?n:[n]).filter(b=>typeof b=="string").map(b=>b.split("+")),p=m.reduce((b,v)=>b.concat(...v),[]);return[m,p]}return[[],[]]},[n]);return j.useEffect(()=>{const x=typeof document<"u"?document:null,m=r?.target||x;if(n!==null){const p=N=>{if(u.current=N.ctrlKey||N.metaKey||N.shiftKey,(!u.current||u.current&&!r.actInsideInputWithModifier)&&qd(N))return!1;const _=Fx(N.code,g);f.current.add(N[_]),Ix(h,f.current,!1)&&(N.preventDefault(),o(!0))},b=N=>{if((!u.current||u.current&&!r.actInsideInputWithModifier)&&qd(N))return!1;const _=Fx(N.code,g);Ix(h,f.current,!0)?(o(!1),f.current.clear()):f.current.delete(N[_]),N.key==="Meta"&&f.current.clear(),u.current=!1},v=()=>{f.current.clear(),o(!1)};return m?.addEventListener("keydown",p),m?.addEventListener("keyup",b),window.addEventListener("blur",v),()=>{m?.removeEventListener("keydown",p),m?.removeEventListener("keyup",b),window.removeEventListener("blur",v)}}},[n,o]),i};function Ix(n,r,i){return n.filter(o=>i||o.length===r.size).some(o=>o.every(u=>r.has(u)))}function Fx(n,r){return r.includes(n)?"code":"key"}function qg(n,r,i,o){const u=n.parentNode||n.parentId;if(!u)return i;const f=r.get(u),h=fs(f,o);return qg(f,r,{x:(i.x??0)+h.x,y:(i.y??0)+h.y,z:(f[ct]?.z??0)>(i.z??0)?f[ct]?.z??0:i.z??0},o)}function Lg(n,r,i){n.forEach(o=>{const u=o.parentNode||o.parentId;if(u&&!n.has(u))throw new Error(`Parent node ${u} not found`);if(u||i?.[o.id]){const{x:f,y:h,z:g}=qg(o,n,{...o.position,z:o[ct]?.z??0},r);o.positionAbsolute={x:f,y:h},o[ct].z=g,i?.[o.id]&&(o[ct].isParent=!0)}})}function vd(n,r,i,o){const u=new Map,f={},h=o?1e3:0;return n.forEach(g=>{const x=(yn(g.zIndex)?g.zIndex:0)+(g.selected?h:0),m=r.get(g.id),p={...g,positionAbsolute:{x:g.position.x,y:g.position.y}},b=g.parentNode||g.parentId;b&&(f[b]=!0);const v=m?.type&&m?.type!==g.type;Object.defineProperty(p,ct,{enumerable:!1,value:{handleBounds:v?void 0:m?.[ct]?.handleBounds,z:x}}),u.set(g.id,p)}),Lg(u,i,f),u}function Yg(n,r={}){const{getNodes:i,width:o,height:u,minZoom:f,maxZoom:h,d3Zoom:g,d3Selection:x,fitViewOnInitDone:m,fitViewOnInit:p,nodeOrigin:b}=n(),v=r.initial&&!m&&p;if(g&&x&&(v||!r.initial)){const T=i().filter(M=>{const A=r.includeHiddenNodes?M.width&&M.height:!M.hidden;return r.nodes?.length?A&&r.nodes.some(V=>V.id===M.id):A}),_=T.every(M=>M.width&&M.height);if(T.length>0&&_){const M=Jo(T,b),{x:A,y:V,zoom:L}=_g(M,o,u,r.minZoom??f,r.maxZoom??h,r.padding??.1),C=ta.translate(A,V).scale(L);return typeof r.duration=="number"&&r.duration>0?g.transform(os(x,r.duration),C):g.transform(x,C),!0}}return!1}function Xw(n,r){return n.forEach(i=>{const o=r.get(i.id);o&&r.set(o.id,{...o,[ct]:o[ct],selected:i.selected})}),new Map(r)}function Zw(n,r){return r.map(i=>{const o=n.find(u=>u.id===i.id);return o&&(i.selected=o.selected),i})}function No({changedNodes:n,changedEdges:r,get:i,set:o}){const{nodeInternals:u,edges:f,onNodesChange:h,onEdgesChange:g,hasDefaultNodes:x,hasDefaultEdges:m}=i();n?.length&&(x&&o({nodeInternals:Xw(n,u)}),h?.(n)),r?.length&&(m&&o({edges:Zw(r,f)}),g?.(r))}const nl=()=>{},Ww={zoomIn:nl,zoomOut:nl,zoomTo:nl,getZoom:()=>1,setViewport:nl,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:nl,fitBounds:nl,project:n=>n,screenToFlowPosition:n=>n,flowToScreenPosition:n=>n,viewportInitialized:!1},Qw=n=>({d3Zoom:n.d3Zoom,d3Selection:n.d3Selection}),Kw=()=>{const n=Nt(),{d3Zoom:r,d3Selection:i}=tt(Qw,Ct);return j.useMemo(()=>i&&r?{zoomIn:u=>r.scaleBy(os(i,u?.duration),1.2),zoomOut:u=>r.scaleBy(os(i,u?.duration),1/1.2),zoomTo:(u,f)=>r.scaleTo(os(i,f?.duration),u),getZoom:()=>n.getState().transform[2],setViewport:(u,f)=>{const[h,g,x]=n.getState().transform,m=ta.translate(u.x??h,u.y??g).scale(u.zoom??x);r.transform(os(i,f?.duration),m)},getViewport:()=>{const[u,f,h]=n.getState().transform;return{x:u,y:f,zoom:h}},fitView:u=>Yg(n.getState,u),setCenter:(u,f,h)=>{const{width:g,height:x,maxZoom:m}=n.getState(),p=typeof h?.zoom<"u"?h.zoom:m,b=g/2-u*p,v=x/2-f*p,N=ta.translate(b,v).scale(p);r.transform(os(i,h?.duration),N)},fitBounds:(u,f)=>{const{width:h,height:g,minZoom:x,maxZoom:m}=n.getState(),{x:p,y:b,zoom:v}=_g(u,h,g,x,m,f?.padding??.1),N=ta.translate(p,b).scale(v);r.transform(os(i,f?.duration),N)},project:u=>{const{transform:f,snapToGrid:h,snapGrid:g}=n.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Vd(u,f,h,g)},screenToFlowPosition:u=>{const{transform:f,snapToGrid:h,snapGrid:g,domNode:x}=n.getState();if(!x)return u;const{x:m,y:p}=x.getBoundingClientRect(),b={x:u.x-m,y:u.y-p};return Vd(b,f,h,g)},flowToScreenPosition:u=>{const{transform:f,domNode:h}=n.getState();if(!h)return u;const{x:g,y:x}=h.getBoundingClientRect(),m=Sg(u,f);return{x:m.x+g,y:m.y+x}},viewportInitialized:!0}:Ww,[r,i])};function xf(){const n=Kw(),r=Nt(),i=j.useCallback(()=>r.getState().getNodes().map(_=>({..._})),[]),o=j.useCallback(_=>r.getState().nodeInternals.get(_),[]),u=j.useCallback(()=>{const{edges:_=[]}=r.getState();return _.map(M=>({...M}))},[]),f=j.useCallback(_=>{const{edges:M=[]}=r.getState();return M.find(A=>A.id===_)},[]),h=j.useCallback(_=>{const{getNodes:M,setNodes:A,hasDefaultNodes:V,onNodesChange:L}=r.getState(),C=M(),D=typeof _=="function"?_(C):_;if(V)A(D);else if(L){const W=D.length===0?C.map(X=>({type:"remove",id:X.id})):D.map(X=>({item:X,type:"reset"}));L(W)}},[]),g=j.useCallback(_=>{const{edges:M=[],setEdges:A,hasDefaultEdges:V,onEdgesChange:L}=r.getState(),C=typeof _=="function"?_(M):_;if(V)A(C);else if(L){const D=C.length===0?M.map(W=>({type:"remove",id:W.id})):C.map(W=>({item:W,type:"reset"}));L(D)}},[]),x=j.useCallback(_=>{const M=Array.isArray(_)?_:[_],{getNodes:A,setNodes:V,hasDefaultNodes:L,onNodesChange:C}=r.getState();if(L){const W=[...A(),...M];V(W)}else if(C){const D=M.map(W=>({item:W,type:"add"}));C(D)}},[]),m=j.useCallback(_=>{const M=Array.isArray(_)?_:[_],{edges:A=[],setEdges:V,hasDefaultEdges:L,onEdgesChange:C}=r.getState();if(L)V([...A,...M]);else if(C){const D=M.map(W=>({item:W,type:"add"}));C(D)}},[]),p=j.useCallback(()=>{const{getNodes:_,edges:M=[],transform:A}=r.getState(),[V,L,C]=A;return{nodes:_().map(D=>({...D})),edges:M.map(D=>({...D})),viewport:{x:V,y:L,zoom:C}}},[]),b=j.useCallback(({nodes:_,edges:M})=>{const{nodeInternals:A,getNodes:V,edges:L,hasDefaultNodes:C,hasDefaultEdges:D,onNodesDelete:W,onEdgesDelete:X,onNodesChange:ie,onEdgesChange:I}=r.getState(),K=(_||[]).map(U=>U.id),ne=(M||[]).map(U=>U.id),ee=V().reduce((U,k)=>{const H=k.parentNode||k.parentId,O=!K.includes(k.id)&&H&&U.find(E=>E.id===H);return(typeof k.deletable=="boolean"?k.deletable:!0)&&(K.includes(k.id)||O)&&U.push(k),U},[]),se=L.filter(U=>typeof U.deletable=="boolean"?U.deletable:!0),S=se.filter(U=>ne.includes(U.id));if(ee||S){const U=kg(ee,se),k=[...S,...U],H=k.reduce((O,z)=>(O.includes(z.id)||O.push(z.id),O),[]);if((D||C)&&(D&&r.setState({edges:L.filter(O=>!H.includes(O.id))}),C&&(ee.forEach(O=>{A.delete(O.id)}),r.setState({nodeInternals:new Map(A)}))),H.length>0&&(X?.(k),I&&I(H.map(O=>({id:O,type:"remove"})))),ee.length>0&&(W?.(ee),ie)){const O=ee.map(z=>({id:z.id,type:"remove"}));ie(O)}}},[]),v=j.useCallback(_=>{const M=pw(_),A=M?null:r.getState().nodeInternals.get(_.id);return!M&&!A?[null,null,M]:[M?_:Vx(A),A,M]},[]),N=j.useCallback((_,M=!0,A)=>{const[V,L,C]=v(_);return V?(A||r.getState().getNodes()).filter(D=>{if(!C&&(D.id===L.id||!D.positionAbsolute))return!1;const W=Vx(D),X=Bd(W,V);return M&&X>0||X>=V.width*V.height}):[]},[]),T=j.useCallback((_,M,A=!0)=>{const[V]=v(_);if(!V)return!1;const L=Bd(V,M);return A&&L>0||L>=V.width*V.height},[]);return j.useMemo(()=>({...n,getNodes:i,getNode:o,getEdges:u,getEdge:f,setNodes:h,setEdges:g,addNodes:x,addEdges:m,toObject:p,deleteElements:b,getIntersectingNodes:N,isNodeIntersecting:T}),[n,i,o,u,f,h,g,x,m,p,b,N,T])}const Jw={actInsideInputWithModifier:!1};var Iw=({deleteKeyCode:n,multiSelectionKeyCode:r})=>{const i=Nt(),{deleteElements:o}=xf(),u=Lr(n,Jw),f=Lr(r);j.useEffect(()=>{if(u){const{edges:h,getNodes:g}=i.getState(),x=g().filter(p=>p.selected),m=h.filter(p=>p.selected);o({nodes:x,edges:m}),i.setState({nodesSelectionActive:!1})}},[u]),j.useEffect(()=>{i.setState({multiSelectionActive:f})},[f])};function Fw(n){const r=Nt();j.useEffect(()=>{let i;const o=()=>{if(!n.current)return;const u=of(n.current);(u.height===0||u.width===0)&&r.getState().onError?.("004",sa.error004()),r.setState({width:u.width||500,height:u.height||500})};return o(),window.addEventListener("resize",o),n.current&&(i=new ResizeObserver(()=>o()),i.observe(n.current)),()=>{window.removeEventListener("resize",o),i&&n.current&&i.unobserve(n.current)}},[])}const gf={position:"absolute",width:"100%",height:"100%",top:0,left:0},Pw=(n,r)=>n.x!==r.x||n.y!==r.y||n.zoom!==r.k,wo=n=>({x:n.x,y:n.y,zoom:n.k}),al=(n,r)=>n.target.closest(`.${r}`),Px=(n,r)=>r===2&&Array.isArray(n)&&n.includes(2),e0=n=>{const r=n.ctrlKey&&qo()?10:1;return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*r},eS=n=>({d3Zoom:n.d3Zoom,d3Selection:n.d3Selection,d3ZoomHandler:n.d3ZoomHandler,userSelectionActive:n.userSelectionActive}),tS=({onMove:n,onMoveStart:r,onMoveEnd:i,onPaneContextMenu:o,zoomOnScroll:u=!0,zoomOnPinch:f=!0,panOnScroll:h=!1,panOnScrollSpeed:g=.5,panOnScrollMode:x=us.Free,zoomOnDoubleClick:m=!0,elementsSelectable:p,panOnDrag:b=!0,defaultViewport:v,translateExtent:N,minZoom:T,maxZoom:_,zoomActivationKeyCode:M,preventScrolling:A=!0,children:V,noWheelClassName:L,noPanClassName:C})=>{const D=j.useRef(),W=Nt(),X=j.useRef(!1),ie=j.useRef(!1),I=j.useRef(null),K=j.useRef({x:0,y:0,zoom:0}),{d3Zoom:ne,d3Selection:ee,d3ZoomHandler:se,userSelectionActive:S}=tt(eS,Ct),U=Lr(M),k=j.useRef(0),H=j.useRef(!1),O=j.useRef();return Fw(I),j.useEffect(()=>{if(I.current){const z=I.current.getBoundingClientRect(),E=fg().scaleExtent([T,_]).translateExtent(N),$=gn(I.current).call(E),Z=ta.translate(v.x,v.y).scale(gl(v.zoom,T,_)),ae=[[0,0],[z.width,z.height]],oe=E.constrain()(Z,ae,N);E.transform($,oe),E.wheelDelta(e0),W.setState({d3Zoom:E,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[oe.x,oe.y,oe.k],domNode:I.current.closest(".react-flow")})}},[]),j.useEffect(()=>{ee&&ne&&(h&&!U&&!S?ee.on("wheel.zoom",z=>{if(al(z,L))return!1;z.preventDefault(),z.stopImmediatePropagation();const E=ee.property("__zoom").k||1;if(z.ctrlKey&&f){const ve=Sn(z),Ae=e0(z),Re=E*Math.pow(2,Ae);ne.scaleTo(ee,Re,ve,z);return}const $=z.deltaMode===1?20:1;let Z=x===us.Vertical?0:z.deltaX*$,ae=x===us.Horizontal?0:z.deltaY*$;!qo()&&z.shiftKey&&x!==us.Vertical&&(Z=z.deltaY*$,ae=0),ne.translateBy(ee,-(Z/E)*g,-(ae/E)*g,{internal:!0});const oe=wo(ee.property("__zoom")),{onViewportChangeStart:he,onViewportChange:me,onViewportChangeEnd:Se}=W.getState();clearTimeout(O.current),H.current||(H.current=!0,r?.(z,oe),he?.(oe)),H.current&&(n?.(z,oe),me?.(oe),O.current=setTimeout(()=>{i?.(z,oe),Se?.(oe),H.current=!1},150))},{passive:!1}):typeof se<"u"&&ee.on("wheel.zoom",function(z,E){if(!A&&z.type==="wheel"&&!z.ctrlKey||al(z,L))return null;z.preventDefault(),se.call(this,z,E)},{passive:!1}))},[S,h,x,ee,ne,se,U,f,A,L,r,n,i]),j.useEffect(()=>{ne&&ne.on("start",z=>{if(!z.sourceEvent||z.sourceEvent.internal)return null;k.current=z.sourceEvent?.button;const{onViewportChangeStart:E}=W.getState(),$=wo(z.transform);X.current=!0,K.current=$,z.sourceEvent?.type==="mousedown"&&W.setState({paneDragging:!0}),E?.($),r?.(z.sourceEvent,$)})},[ne,r]),j.useEffect(()=>{ne&&(S&&!X.current?ne.on("zoom",null):S||ne.on("zoom",z=>{const{onViewportChange:E}=W.getState();if(W.setState({transform:[z.transform.x,z.transform.y,z.transform.k]}),ie.current=!!(o&&Px(b,k.current??0)),(n||E)&&!z.sourceEvent?.internal){const $=wo(z.transform);E?.($),n?.(z.sourceEvent,$)}}))},[S,ne,n,b,o]),j.useEffect(()=>{ne&&ne.on("end",z=>{if(!z.sourceEvent||z.sourceEvent.internal)return null;const{onViewportChangeEnd:E}=W.getState();if(X.current=!1,W.setState({paneDragging:!1}),o&&Px(b,k.current??0)&&!ie.current&&o(z.sourceEvent),ie.current=!1,(i||E)&&Pw(K.current,z.transform)){const $=wo(z.transform);K.current=$,clearTimeout(D.current),D.current=setTimeout(()=>{E?.($),i?.(z.sourceEvent,$)},h?150:0)}})},[ne,h,b,i,o]),j.useEffect(()=>{ne&&ne.filter(z=>{const E=U||u,$=f&&z.ctrlKey;if((b===!0||Array.isArray(b)&&b.includes(1))&&z.button===1&&z.type==="mousedown"&&(al(z,"react-flow__node")||al(z,"react-flow__edge")))return!0;if(!b&&!E&&!h&&!m&&!f||S||!m&&z.type==="dblclick"||al(z,L)&&z.type==="wheel"||al(z,C)&&(z.type!=="wheel"||h&&z.type==="wheel"&&!U)||!f&&z.ctrlKey&&z.type==="wheel"||!E&&!h&&!$&&z.type==="wheel"||!b&&(z.type==="mousedown"||z.type==="touchstart")||Array.isArray(b)&&!b.includes(z.button)&&z.type==="mousedown")return!1;const Z=Array.isArray(b)&&b.includes(z.button)||!z.button||z.button<=1;return(!z.ctrlKey||z.type==="wheel")&&Z})},[S,ne,u,f,h,m,b,p,U]),le.createElement("div",{className:"react-flow__renderer",ref:I,style:gf},V)},nS=n=>({userSelectionActive:n.userSelectionActive,userSelectionRect:n.userSelectionRect});function aS(){const{userSelectionActive:n,userSelectionRect:r}=tt(nS,Ct);return n&&r?le.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}function t0(n,r){const i=r.parentNode||r.parentId,o=n.find(u=>u.id===i);if(o){const u=r.position.x+r.width-o.width,f=r.position.y+r.height-o.height;if(u>0||f>0||r.position.x<0||r.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,u>0&&(o.style.width+=u),f>0&&(o.style.height+=f),r.position.x<0){const h=Math.abs(r.position.x);o.position.x=o.position.x-h,o.style.width+=h,r.position.x=0}if(r.position.y<0){const h=Math.abs(r.position.y);o.position.y=o.position.y-h,o.style.height+=h,r.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function Vg(n,r){if(n.some(o=>o.type==="reset"))return n.filter(o=>o.type==="reset").map(o=>o.item);const i=n.filter(o=>o.type==="add").map(o=>o.item);return r.reduce((o,u)=>{const f=n.filter(g=>g.id===u.id);if(f.length===0)return o.push(u),o;const h={...u};for(const g of f)if(g)switch(g.type){case"select":{h.selected=g.selected;break}case"position":{typeof g.position<"u"&&(h.position=g.position),typeof g.positionAbsolute<"u"&&(h.positionAbsolute=g.positionAbsolute),typeof g.dragging<"u"&&(h.dragging=g.dragging),h.expandParent&&t0(o,h);break}case"dimensions":{typeof g.dimensions<"u"&&(h.width=g.dimensions.width,h.height=g.dimensions.height),typeof g.updateStyle<"u"&&(h.style={...h.style||{},...g.dimensions}),typeof g.resizing=="boolean"&&(h.resizing=g.resizing),h.expandParent&&t0(o,h);break}case"remove":return o}return o.push(h),o},i)}function Gg(n,r){return Vg(n,r)}function sS(n,r){return Vg(n,r)}const Ha=(n,r)=>({id:n,type:"select",selected:r});function cl(n,r){return n.reduce((i,o)=>{const u=r.includes(o.id);return!o.selected&&u?(o.selected=!0,i.push(Ha(o.id,!0))):o.selected&&!u&&(o.selected=!1,i.push(Ha(o.id,!1))),i},[])}const jd=(n,r)=>i=>{i.target===r.current&&n?.(i)},lS=n=>({userSelectionActive:n.userSelectionActive,elementsSelectable:n.elementsSelectable,dragging:n.paneDragging}),Xg=j.memo(({isSelecting:n,selectionMode:r=qr.Full,panOnDrag:i,onSelectionStart:o,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:h,onPaneScroll:g,onPaneMouseEnter:x,onPaneMouseMove:m,onPaneMouseLeave:p,children:b})=>{const v=j.useRef(null),N=Nt(),T=j.useRef(0),_=j.useRef(0),M=j.useRef(),{userSelectionActive:A,elementsSelectable:V,dragging:L}=tt(lS,Ct),C=()=>{N.setState({userSelectionActive:!1,userSelectionRect:null}),T.current=0,_.current=0},D=se=>{f?.(se),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},W=se=>{if(Array.isArray(i)&&i?.includes(2)){se.preventDefault();return}h?.(se)},X=g?se=>g(se):void 0,ie=se=>{const{resetSelectedElements:S,domNode:U}=N.getState();if(M.current=U?.getBoundingClientRect(),!V||!n||se.button!==0||se.target!==v.current||!M.current)return;const{x:k,y:H}=Ua(se,M.current);S(),N.setState({userSelectionRect:{width:0,height:0,startX:k,startY:H,x:k,y:H}}),o?.(se)},I=se=>{const{userSelectionRect:S,nodeInternals:U,edges:k,transform:H,onNodesChange:O,onEdgesChange:z,nodeOrigin:E,getNodes:$}=N.getState();if(!n||!M.current||!S)return;N.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Z=Ua(se,M.current),ae=S.startX??0,oe=S.startY??0,he={...S,x:Z.x<ae?Z.x:ae,y:Z.y<oe?Z.y:oe,width:Math.abs(Z.x-ae),height:Math.abs(Z.y-oe)},me=$(),Se=Eg(U,he,H,r===qr.Partial,!0,E),ve=kg(Se,k).map(Re=>Re.id),Ae=Se.map(Re=>Re.id);if(T.current!==Ae.length){T.current=Ae.length;const Re=cl(me,Ae);Re.length&&O?.(Re)}if(_.current!==ve.length){_.current=ve.length;const Re=cl(k,ve);Re.length&&z?.(Re)}N.setState({userSelectionRect:he})},K=se=>{if(se.button!==0)return;const{userSelectionRect:S}=N.getState();!A&&S&&se.target===v.current&&D?.(se),N.setState({nodesSelectionActive:T.current>0}),C(),u?.(se)},ne=se=>{A&&(N.setState({nodesSelectionActive:T.current>0}),u?.(se)),C()},ee=V&&(n||A);return le.createElement("div",{className:$t(["react-flow__pane",{dragging:L,selection:n}]),onClick:ee?void 0:jd(D,v),onContextMenu:jd(W,v),onWheel:jd(X,v),onMouseEnter:ee?void 0:x,onMouseDown:ee?ie:void 0,onMouseMove:ee?I:m,onMouseUp:ee?K:void 0,onMouseLeave:ee?ne:p,ref:v,style:gf},b,le.createElement(aS,null))});Xg.displayName="Pane";function Zg(n,r){const i=n.parentNode||n.parentId;if(!i)return!1;const o=r.get(i);return o?o.selected?!0:Zg(o,r):!1}function n0(n,r,i){let o=n;do{if(o?.matches(r))return!0;if(o===i.current)return!1;o=o.parentElement}while(o);return!1}function rS(n,r,i,o){return Array.from(n.values()).filter(u=>(u.selected||u.id===o)&&(!u.parentNode||u.parentId||!Zg(u,n))&&(u.draggable||r&&typeof u.draggable>"u")).map(u=>({id:u.id,position:u.position||{x:0,y:0},positionAbsolute:u.positionAbsolute||{x:0,y:0},distance:{x:i.x-(u.positionAbsolute?.x??0),y:i.y-(u.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:u.extent,parentNode:u.parentNode||u.parentId,parentId:u.parentNode||u.parentId,width:u.width,height:u.height,expandParent:u.expandParent}))}function iS(n,r){return!r||r==="parent"?r:[r[0],[r[1][0]-(n.width||0),r[1][1]-(n.height||0)]]}function Wg(n,r,i,o,u=[0,0],f){const h=iS(n,n.extent||o);let g=h;const x=n.parentNode||n.parentId;if(n.extent==="parent"&&!n.expandParent)if(x&&n.width&&n.height){const b=i.get(x),{x:v,y:N}=fs(b,u).positionAbsolute;g=b&&yn(v)&&yn(N)&&yn(b.width)&&yn(b.height)?[[v+n.width*u[0],N+n.height*u[1]],[v+b.width-n.width+n.width*u[0],N+b.height-n.height+n.height*u[1]]]:g}else f?.("005",sa.error005()),g=h;else if(n.extent&&x&&n.extent!=="parent"){const b=i.get(x),{x:v,y:N}=fs(b,u).positionAbsolute;g=[[n.extent[0][0]+v,n.extent[0][1]+N],[n.extent[1][0]+v,n.extent[1][1]+N]]}let m={x:0,y:0};if(x){const b=i.get(x);m=fs(b,u).positionAbsolute}const p=g&&g!=="parent"?cf(r,g):r;return{position:{x:p.x-m.x,y:p.y-m.y},positionAbsolute:p}}function Nd({nodeId:n,dragItems:r,nodeInternals:i}){const o=r.map(u=>({...i.get(u.id),position:u.position,positionAbsolute:u.positionAbsolute}));return[n?o.find(u=>u.id===n):o[0],o]}const a0=(n,r,i,o)=>{const u=r.querySelectorAll(n);if(!u||!u.length)return null;const f=Array.from(u),h=r.getBoundingClientRect(),g={x:h.width*o[0],y:h.height*o[1]};return f.map(x=>{const m=x.getBoundingClientRect();return{id:x.getAttribute("data-handleid"),position:x.getAttribute("data-handlepos"),x:(m.left-h.left-g.x)/i,y:(m.top-h.top-g.y)/i,...of(x)}})};function Er(n,r,i){return i===void 0?i:o=>{const u=r().nodeInternals.get(n);u&&i(o,{...u})}}function Xd({id:n,store:r,unselect:i=!1,nodeRef:o}){const{addSelectedNodes:u,unselectNodesAndEdges:f,multiSelectionActive:h,nodeInternals:g,onError:x}=r.getState(),m=g.get(n);if(!m){x?.("012",sa.error012(n));return}r.setState({nodesSelectionActive:!1}),m.selected?(i||m.selected&&h)&&(f({nodes:[m],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):u([n])}function oS(){const n=Nt();return j.useCallback(({sourceEvent:i})=>{const{transform:o,snapGrid:u,snapToGrid:f}=n.getState(),h=i.touches?i.touches[0].clientX:i.clientX,g=i.touches?i.touches[0].clientY:i.clientY,x={x:(h-o[0])/o[2],y:(g-o[1])/o[2]};return{xSnapped:f?u[0]*Math.round(x.x/u[0]):x.x,ySnapped:f?u[1]*Math.round(x.y/u[1]):x.y,...x}},[])}function wd(n){return(r,i,o)=>n?.(r,o)}function Qg({nodeRef:n,disabled:r=!1,noDragClassName:i,handleSelector:o,nodeId:u,isSelectable:f,selectNodesOnDrag:h}){const g=Nt(),[x,m]=j.useState(!1),p=j.useRef([]),b=j.useRef({x:null,y:null}),v=j.useRef(0),N=j.useRef(null),T=j.useRef({x:0,y:0}),_=j.useRef(null),M=j.useRef(!1),A=j.useRef(!1),V=j.useRef(!1),L=oS();return j.useEffect(()=>{if(n?.current){const C=gn(n.current),D=({x:ie,y:I})=>{const{nodeInternals:K,onNodeDrag:ne,onSelectionDrag:ee,updateNodePositions:se,nodeExtent:S,snapGrid:U,snapToGrid:k,nodeOrigin:H,onError:O}=g.getState();b.current={x:ie,y:I};let z=!1,E={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&S){const Z=Jo(p.current,H);E=Br(Z)}if(p.current=p.current.map(Z=>{const ae={x:ie-Z.distance.x,y:I-Z.distance.y};k&&(ae.x=U[0]*Math.round(ae.x/U[0]),ae.y=U[1]*Math.round(ae.y/U[1]));const oe=[[S[0][0],S[0][1]],[S[1][0],S[1][1]]];p.current.length>1&&S&&!Z.extent&&(oe[0][0]=Z.positionAbsolute.x-E.x+S[0][0],oe[1][0]=Z.positionAbsolute.x+(Z.width??0)-E.x2+S[1][0],oe[0][1]=Z.positionAbsolute.y-E.y+S[0][1],oe[1][1]=Z.positionAbsolute.y+(Z.height??0)-E.y2+S[1][1]);const he=Wg(Z,ae,K,oe,H,O);return z=z||Z.position.x!==he.position.x||Z.position.y!==he.position.y,Z.position=he.position,Z.positionAbsolute=he.positionAbsolute,Z}),!z)return;se(p.current,!0,!0),m(!0);const $=u?ne:wd(ee);if($&&_.current){const[Z,ae]=Nd({nodeId:u,dragItems:p.current,nodeInternals:K});$(_.current,Z,ae)}},W=()=>{if(!N.current)return;const[ie,I]=mg(T.current,N.current);if(ie!==0||I!==0){const{transform:K,panBy:ne}=g.getState();b.current.x=(b.current.x??0)-ie/K[2],b.current.y=(b.current.y??0)-I/K[2],ne({x:ie,y:I})&&D(b.current)}v.current=requestAnimationFrame(W)},X=ie=>{const{nodeInternals:I,multiSelectionActive:K,nodesDraggable:ne,unselectNodesAndEdges:ee,onNodeDragStart:se,onSelectionDragStart:S}=g.getState();A.current=!0;const U=u?se:wd(S);(!h||!f)&&!K&&u&&(I.get(u)?.selected||ee()),u&&f&&h&&Xd({id:u,store:g,nodeRef:n});const k=L(ie);if(b.current=k,p.current=rS(I,ne,k,u),U&&p.current){const[H,O]=Nd({nodeId:u,dragItems:p.current,nodeInternals:I});U(ie.sourceEvent,H,O)}};if(r)C.on(".drag",null);else{const ie=bN().on("start",I=>{const{domNode:K,nodeDragThreshold:ne}=g.getState();ne===0&&X(I),V.current=!1;const ee=L(I);b.current=ee,N.current=K?.getBoundingClientRect()||null,T.current=Ua(I.sourceEvent,N.current)}).on("drag",I=>{const K=L(I),{autoPanOnNodeDrag:ne,nodeDragThreshold:ee}=g.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(V.current=!0),!V.current){if(!M.current&&A.current&&ne&&(M.current=!0,W()),!A.current){const se=K.xSnapped-(b?.current?.x??0),S=K.ySnapped-(b?.current?.y??0);Math.sqrt(se*se+S*S)>ee&&X(I)}(b.current.x!==K.xSnapped||b.current.y!==K.ySnapped)&&p.current&&A.current&&(_.current=I.sourceEvent,T.current=Ua(I.sourceEvent,N.current),D(K))}}).on("end",I=>{if(!(!A.current||V.current)&&(m(!1),M.current=!1,A.current=!1,cancelAnimationFrame(v.current),p.current)){const{updateNodePositions:K,nodeInternals:ne,onNodeDragStop:ee,onSelectionDragStop:se}=g.getState(),S=u?ee:wd(se);if(K(p.current,!1,!1),S){const[U,k]=Nd({nodeId:u,dragItems:p.current,nodeInternals:ne});S(I.sourceEvent,U,k)}}}).filter(I=>{const K=I.target;return!I.button&&(!i||!n0(K,`.${i}`,n))&&(!o||n0(K,o,n))});return C.call(ie),()=>{C.on(".drag",null)}}}},[n,r,i,o,f,g,u,h,L]),x}function Kg(){const n=Nt();return j.useCallback(i=>{const{nodeInternals:o,nodeExtent:u,updateNodePositions:f,getNodes:h,snapToGrid:g,snapGrid:x,onError:m,nodesDraggable:p}=n.getState(),b=h().filter(V=>V.selected&&(V.draggable||p&&typeof V.draggable>"u")),v=g?x[0]:5,N=g?x[1]:5,T=i.isShiftPressed?4:1,_=i.x*v*T,M=i.y*N*T,A=b.map(V=>{if(V.positionAbsolute){const L={x:V.positionAbsolute.x+_,y:V.positionAbsolute.y+M};g&&(L.x=x[0]*Math.round(L.x/x[0]),L.y=x[1]*Math.round(L.y/x[1]));const{positionAbsolute:C,position:D}=Wg(V,L,o,u,void 0,m);V.position=D,V.positionAbsolute=C}return V});f(A,!0,!1)},[])}const ml={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var kr=n=>{const r=({id:i,type:o,data:u,xPos:f,yPos:h,xPosOrigin:g,yPosOrigin:x,selected:m,onClick:p,onMouseEnter:b,onMouseMove:v,onMouseLeave:N,onContextMenu:T,onDoubleClick:_,style:M,className:A,isDraggable:V,isSelectable:L,isConnectable:C,isFocusable:D,selectNodesOnDrag:W,sourcePosition:X,targetPosition:ie,hidden:I,resizeObserver:K,dragHandle:ne,zIndex:ee,isParent:se,noDragClassName:S,noPanClassName:U,initialized:k,disableKeyboardA11y:H,ariaLabel:O,rfId:z,hasHandleBounds:E})=>{const $=Nt(),Z=j.useRef(null),ae=j.useRef(null),oe=j.useRef(X),he=j.useRef(ie),me=j.useRef(o),Se=L||V||p||b||v||N,ve=Kg(),Ae=Er(i,$.getState,b),Re=Er(i,$.getState,v),We=Er(i,$.getState,N),Te=Er(i,$.getState,T),be=Er(i,$.getState,_),q=re=>{const{nodeDragThreshold:P}=$.getState();if(L&&(!W||!V||P>0)&&Xd({id:i,store:$,nodeRef:Z}),p){const Ee=$.getState().nodeInternals.get(i);Ee&&p(re,{...Ee})}},Y=re=>{if(!qd(re)&&!H)if(yg.includes(re.key)&&L){const P=re.key==="Escape";Xd({id:i,store:$,unselect:P,nodeRef:Z})}else V&&m&&Object.prototype.hasOwnProperty.call(ml,re.key)&&($.setState({ariaLiveMessage:`Moved selected node ${re.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~f}, y: ${~~h}`}),ve({x:ml[re.key].x,y:ml[re.key].y,isShiftPressed:re.shiftKey}))};j.useEffect(()=>()=>{ae.current&&(K?.unobserve(ae.current),ae.current=null)},[]),j.useEffect(()=>{if(Z.current&&!I){const re=Z.current;(!k||!E||ae.current!==re)&&(ae.current&&K?.unobserve(ae.current),K?.observe(re),ae.current=re)}},[I,k,E]),j.useEffect(()=>{const re=me.current!==o,P=oe.current!==X,Ee=he.current!==ie;Z.current&&(re||P||Ee)&&(re&&(me.current=o),P&&(oe.current=X),Ee&&(he.current=ie),$.getState().updateNodeDimensions([{id:i,nodeElement:Z.current,forceUpdate:!0}]))},[i,o,X,ie]);const ue=Qg({nodeRef:Z,disabled:I||!V,noDragClassName:S,handleSelector:ne,nodeId:i,isSelectable:L,selectNodesOnDrag:W});return I?null:le.createElement("div",{className:$t(["react-flow__node",`react-flow__node-${o}`,{[U]:V},A,{selected:m,selectable:L,parent:se,dragging:ue}]),ref:Z,style:{zIndex:ee,transform:`translate(${g}px,${x}px)`,pointerEvents:Se?"all":"none",visibility:k?"visible":"hidden",...M},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:Ae,onMouseMove:Re,onMouseLeave:We,onContextMenu:Te,onClick:q,onDoubleClick:be,onKeyDown:D?Y:void 0,tabIndex:D?0:void 0,role:D?"button":void 0,"aria-describedby":H?void 0:`${Ug}-${z}`,"aria-label":O},le.createElement(Nw,{value:i},le.createElement(n,{id:i,data:u,type:o,xPos:f,yPos:h,selected:m,isConnectable:C,sourcePosition:X,targetPosition:ie,dragging:ue,dragHandle:ne,zIndex:ee})))};return r.displayName="NodeWrapper",j.memo(r)};const cS=n=>{const r=n.getNodes().filter(i=>i.selected);return{...Jo(r,n.nodeOrigin),transformString:`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`,userSelectionActive:n.userSelectionActive}};function uS({onSelectionContextMenu:n,noPanClassName:r,disableKeyboardA11y:i}){const o=Nt(),{width:u,height:f,x:h,y:g,transformString:x,userSelectionActive:m}=tt(cS,Ct),p=Kg(),b=j.useRef(null);if(j.useEffect(()=>{i||b.current?.focus({preventScroll:!0})},[i]),Qg({nodeRef:b}),m||!u||!f)return null;const v=n?T=>{const _=o.getState().getNodes().filter(M=>M.selected);n(T,_)}:void 0,N=T=>{Object.prototype.hasOwnProperty.call(ml,T.key)&&p({x:ml[T.key].x,y:ml[T.key].y,isShiftPressed:T.shiftKey})};return le.createElement("div",{className:$t(["react-flow__nodesselection","react-flow__container",r]),style:{transform:x}},le.createElement("div",{ref:b,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:i?void 0:-1,onKeyDown:i?void 0:N,style:{width:u,height:f,top:g,left:h}}))}var dS=j.memo(uS);const fS=n=>n.nodesSelectionActive,Jg=({children:n,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:o,onPaneMouseLeave:u,onPaneContextMenu:f,onPaneScroll:h,deleteKeyCode:g,onMove:x,onMoveStart:m,onMoveEnd:p,selectionKeyCode:b,selectionOnDrag:v,selectionMode:N,onSelectionStart:T,onSelectionEnd:_,multiSelectionKeyCode:M,panActivationKeyCode:A,zoomActivationKeyCode:V,elementsSelectable:L,zoomOnScroll:C,zoomOnPinch:D,panOnScroll:W,panOnScrollSpeed:X,panOnScrollMode:ie,zoomOnDoubleClick:I,panOnDrag:K,defaultViewport:ne,translateExtent:ee,minZoom:se,maxZoom:S,preventScrolling:U,onSelectionContextMenu:k,noWheelClassName:H,noPanClassName:O,disableKeyboardA11y:z})=>{const E=tt(fS),$=Lr(b),Z=Lr(A),ae=Z||K,oe=Z||W,he=$||v&&ae!==!0;return Iw({deleteKeyCode:g,multiSelectionKeyCode:M}),le.createElement(tS,{onMove:x,onMoveStart:m,onMoveEnd:p,onPaneContextMenu:f,elementsSelectable:L,zoomOnScroll:C,zoomOnPinch:D,panOnScroll:oe,panOnScrollSpeed:X,panOnScrollMode:ie,zoomOnDoubleClick:I,panOnDrag:!$&&ae,defaultViewport:ne,translateExtent:ee,minZoom:se,maxZoom:S,zoomActivationKeyCode:V,preventScrolling:U,noWheelClassName:H,noPanClassName:O},le.createElement(Xg,{onSelectionStart:T,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:o,onPaneMouseLeave:u,onPaneContextMenu:f,onPaneScroll:h,panOnDrag:ae,isSelecting:!!he,selectionMode:N},n,E&&le.createElement(dS,{onSelectionContextMenu:k,noPanClassName:O,disableKeyboardA11y:z})))};Jg.displayName="FlowRenderer";var hS=j.memo(Jg);function mS(n){return tt(j.useCallback(i=>n?Eg(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[n]))}function pS(n){const r={input:kr(n.input||Og),default:kr(n.default||Gd),output:kr(n.output||Hg),group:kr(n.group||pf)},i={},o=Object.keys(n).filter(u=>!["input","default","output","group"].includes(u)).reduce((u,f)=>(u[f]=kr(n[f]||Gd),u),i);return{...r,...o}}const xS=({x:n,y:r,width:i,height:o,origin:u})=>!i||!o?{x:n,y:r}:u[0]<0||u[1]<0||u[0]>1||u[1]>1?{x:n,y:r}:{x:n-i*u[0],y:r-o*u[1]},gS=n=>({nodesDraggable:n.nodesDraggable,nodesConnectable:n.nodesConnectable,nodesFocusable:n.nodesFocusable,elementsSelectable:n.elementsSelectable,updateNodeDimensions:n.updateNodeDimensions,onError:n.onError}),Ig=n=>{const{nodesDraggable:r,nodesConnectable:i,nodesFocusable:o,elementsSelectable:u,updateNodeDimensions:f,onError:h}=tt(gS,Ct),g=mS(n.onlyRenderVisibleElements),x=j.useRef(),m=j.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const p=new ResizeObserver(b=>{const v=b.map(N=>({id:N.target.getAttribute("data-id"),nodeElement:N.target,forceUpdate:!0}));f(v)});return x.current=p,p},[]);return j.useEffect(()=>()=>{x?.current?.disconnect()},[]),le.createElement("div",{className:"react-flow__nodes",style:gf},g.map(p=>{let b=p.type||"default";n.nodeTypes[b]||(h?.("003",sa.error003(b)),b="default");const v=n.nodeTypes[b]||n.nodeTypes.default,N=!!(p.draggable||r&&typeof p.draggable>"u"),T=!!(p.selectable||u&&typeof p.selectable>"u"),_=!!(p.connectable||i&&typeof p.connectable>"u"),M=!!(p.focusable||o&&typeof p.focusable>"u"),A=n.nodeExtent?cf(p.positionAbsolute,n.nodeExtent):p.positionAbsolute,V=A?.x??0,L=A?.y??0,C=xS({x:V,y:L,width:p.width??0,height:p.height??0,origin:n.nodeOrigin});return le.createElement(v,{key:p.id,id:p.id,className:p.className,style:p.style,type:b,data:p.data,sourcePosition:p.sourcePosition||xe.Bottom,targetPosition:p.targetPosition||xe.Top,hidden:p.hidden,xPos:V,yPos:L,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:n.selectNodesOnDrag,onClick:n.onNodeClick,onMouseEnter:n.onNodeMouseEnter,onMouseMove:n.onNodeMouseMove,onMouseLeave:n.onNodeMouseLeave,onContextMenu:n.onNodeContextMenu,onDoubleClick:n.onNodeDoubleClick,selected:!!p.selected,isDraggable:N,isSelectable:T,isConnectable:_,isFocusable:M,resizeObserver:m,dragHandle:p.dragHandle,zIndex:p[ct]?.z??0,isParent:!!p[ct]?.isParent,noDragClassName:n.noDragClassName,noPanClassName:n.noPanClassName,initialized:!!p.width&&!!p.height,rfId:n.rfId,disableKeyboardA11y:n.disableKeyboardA11y,ariaLabel:p.ariaLabel,hasHandleBounds:!!p[ct]?.handleBounds})}))};Ig.displayName="NodeRenderer";var yS=j.memo(Ig);const bS=(n,r,i)=>i===xe.Left?n-r:i===xe.Right?n+r:n,vS=(n,r,i)=>i===xe.Top?n-r:i===xe.Bottom?n+r:n,s0="react-flow__edgeupdater",l0=({position:n,centerX:r,centerY:i,radius:o=10,onMouseDown:u,onMouseEnter:f,onMouseOut:h,type:g})=>le.createElement("circle",{onMouseDown:u,onMouseEnter:f,onMouseOut:h,className:$t([s0,`${s0}-${g}`]),cx:bS(r,o,n),cy:vS(i,o,n),r:o,stroke:"transparent",fill:"transparent"}),jS=()=>!0;var sl=n=>{const r=({id:i,className:o,type:u,data:f,onClick:h,onEdgeDoubleClick:g,selected:x,animated:m,label:p,labelStyle:b,labelShowBg:v,labelBgStyle:N,labelBgPadding:T,labelBgBorderRadius:_,style:M,source:A,target:V,sourceX:L,sourceY:C,targetX:D,targetY:W,sourcePosition:X,targetPosition:ie,elementsSelectable:I,hidden:K,sourceHandleId:ne,targetHandleId:ee,onContextMenu:se,onMouseEnter:S,onMouseMove:U,onMouseLeave:k,reconnectRadius:H,onReconnect:O,onReconnectStart:z,onReconnectEnd:E,markerEnd:$,markerStart:Z,rfId:ae,ariaLabel:oe,isFocusable:he,isReconnectable:me,pathOptions:Se,interactionWidth:ve,disableKeyboardA11y:Ae})=>{const Re=j.useRef(null),[We,Te]=j.useState(!1),[be,q]=j.useState(!1),Y=Nt(),ue=j.useMemo(()=>`url('#${Yd(Z,ae)}')`,[Z,ae]),re=j.useMemo(()=>`url('#${Yd($,ae)}')`,[$,ae]);if(K)return null;const P=Ve=>{const{edges:je,addSelectedEdges:Le,unselectNodesAndEdges:Ge,multiSelectionActive:At}=Y.getState(),Vt=je.find(Jt=>Jt.id===i);Vt&&(I&&(Y.setState({nodesSelectionActive:!1}),Vt.selected&&At?(Ge({nodes:[],edges:[Vt]}),Re.current?.blur()):Le([i])),h&&h(Ve,Vt))},Ee=Sr(i,Y.getState,g),ge=Sr(i,Y.getState,se),ke=Sr(i,Y.getState,S),Oe=Sr(i,Y.getState,U),ze=Sr(i,Y.getState,k),Tt=(Ve,je)=>{if(Ve.button!==0)return;const{edges:Le,isValidConnection:Ge}=Y.getState(),At=je?V:A,Vt=(je?ee:ne)||null,Jt=je?"target":"source",jl=Ge||jS,ys=je,la=Le.find(Dn=>Dn.id===i);q(!0),z?.(Ve,la,Jt);const Ya=Dn=>{q(!1),E?.(Dn,la,Jt)};Mg({event:Ve,handleId:Vt,nodeId:At,onConnect:Dn=>O?.(la,Dn),isTarget:ys,getState:Y.getState,setState:Y.setState,isValidConnection:jl,edgeUpdaterType:Jt,onReconnectEnd:Ya})},Mt=Ve=>Tt(Ve,!0),ft=Ve=>Tt(Ve,!1),nt=()=>Te(!0),pt=()=>Te(!1),at=!I&&!h,pe=Ve=>{if(!Ae&&yg.includes(Ve.key)&&I){const{unselectNodesAndEdges:je,addSelectedEdges:Le,edges:Ge}=Y.getState();Ve.key==="Escape"?(Re.current?.blur(),je({edges:[Ge.find(Vt=>Vt.id===i)]})):Le([i])}};return le.createElement("g",{className:$t(["react-flow__edge",`react-flow__edge-${u}`,o,{selected:x,animated:m,inactive:at,updating:We}]),onClick:P,onDoubleClick:Ee,onContextMenu:ge,onMouseEnter:ke,onMouseMove:Oe,onMouseLeave:ze,onKeyDown:he?pe:void 0,tabIndex:he?0:void 0,role:he?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":oe===null?void 0:oe||`Edge from ${A} to ${V}`,"aria-describedby":he?`${Bg}-${ae}`:void 0,ref:Re},!be&&le.createElement(n,{id:i,source:A,target:V,selected:x,animated:m,label:p,labelStyle:b,labelShowBg:v,labelBgStyle:N,labelBgPadding:T,labelBgBorderRadius:_,data:f,style:M,sourceX:L,sourceY:C,targetX:D,targetY:W,sourcePosition:X,targetPosition:ie,sourceHandleId:ne,targetHandleId:ee,markerStart:ue,markerEnd:re,pathOptions:Se,interactionWidth:ve}),me&&le.createElement(le.Fragment,null,(me==="source"||me===!0)&&le.createElement(l0,{position:X,centerX:L,centerY:C,radius:H,onMouseDown:Mt,onMouseEnter:nt,onMouseOut:pt,type:"source"}),(me==="target"||me===!0)&&le.createElement(l0,{position:ie,centerX:D,centerY:W,radius:H,onMouseDown:ft,onMouseEnter:nt,onMouseOut:pt,type:"target"})))};return r.displayName="EdgeWrapper",j.memo(r)};function NS(n){const r={default:sl(n.default||Lo),straight:sl(n.bezier||ff),step:sl(n.step||df),smoothstep:sl(n.step||Ko),simplebezier:sl(n.simplebezier||uf)},i={},o=Object.keys(n).filter(u=>!["default","bezier"].includes(u)).reduce((u,f)=>(u[f]=sl(n[f]||Lo),u),i);return{...r,...o}}function r0(n,r,i=null){const o=(i?.x||0)+r.x,u=(i?.y||0)+r.y,f=i?.width||r.width,h=i?.height||r.height;switch(n){case xe.Top:return{x:o+f/2,y:u};case xe.Right:return{x:o+f,y:u+h/2};case xe.Bottom:return{x:o+f/2,y:u+h};case xe.Left:return{x:o,y:u+h/2}}}function i0(n,r){return n?n.length===1||!r?n[0]:r&&n.find(i=>i.id===r)||null:null}const wS=(n,r,i,o,u,f)=>{const h=r0(i,n,r),g=r0(f,o,u);return{sourceX:h.x,sourceY:h.y,targetX:g.x,targetY:g.y}};function SS({sourcePos:n,targetPos:r,sourceWidth:i,sourceHeight:o,targetWidth:u,targetHeight:f,width:h,height:g,transform:x}){const m={x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),x2:Math.max(n.x+i,r.x+u),y2:Math.max(n.y+o,r.y+f)};m.x===m.x2&&(m.x2+=1),m.y===m.y2&&(m.y2+=1);const p=Br({x:(0-x[0])/x[2],y:(0-x[1])/x[2],width:h/x[2],height:g/x[2]}),b=Math.max(0,Math.min(p.x2,m.x2)-Math.max(p.x,m.x)),v=Math.max(0,Math.min(p.y2,m.y2)-Math.max(p.y,m.y));return Math.ceil(b*v)>0}function o0(n){const r=n?.[ct]?.handleBounds||null,i=r&&n?.width&&n?.height&&typeof n?.positionAbsolute?.x<"u"&&typeof n?.positionAbsolute?.y<"u";return[{x:n?.positionAbsolute?.x||0,y:n?.positionAbsolute?.y||0,width:n?.width||0,height:n?.height||0},r,!!i]}const ES=[{level:0,isMaxLevel:!0,edges:[]}];function kS(n,r,i=!1){let o=-1;const u=n.reduce((h,g)=>{const x=yn(g.zIndex);let m=x?g.zIndex:0;if(i){const p=r.get(g.target),b=r.get(g.source),v=g.selected||p?.selected||b?.selected,N=Math.max(b?.[ct]?.z||0,p?.[ct]?.z||0,1e3);m=(x?g.zIndex:0)+(v?N:0)}return h[m]?h[m].push(g):h[m]=[g],o=m>o?m:o,h},{}),f=Object.entries(u).map(([h,g])=>{const x=+h;return{edges:g,level:x,isMaxLevel:x===o}});return f.length===0?ES:f}function _S(n,r,i){const o=tt(j.useCallback(u=>n?u.edges.filter(f=>{const h=r.get(f.source),g=r.get(f.target);return h?.width&&h?.height&&g?.width&&g?.height&&SS({sourcePos:h.positionAbsolute||{x:0,y:0},targetPos:g.positionAbsolute||{x:0,y:0},sourceWidth:h.width,sourceHeight:h.height,targetWidth:g.width,targetHeight:g.height,width:u.width,height:u.height,transform:u.transform})}):u.edges,[n,r]));return kS(o,r,i)}const CS=({color:n="none",strokeWidth:r=1})=>le.createElement("polyline",{style:{stroke:n,strokeWidth:r},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),TS=({color:n="none",strokeWidth:r=1})=>le.createElement("polyline",{style:{stroke:n,fill:n,strokeWidth:r},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),c0={[Ba.Arrow]:CS,[Ba.ArrowClosed]:TS};function MS(n){const r=Nt();return j.useMemo(()=>Object.prototype.hasOwnProperty.call(c0,n)?c0[n]:(r.getState().onError?.("009",sa.error009(n)),null),[n])}const AS=({id:n,type:r,color:i,width:o=12.5,height:u=12.5,markerUnits:f="strokeWidth",strokeWidth:h,orient:g="auto-start-reverse"})=>{const x=MS(r);return x?le.createElement("marker",{className:"react-flow__arrowhead",id:n,markerWidth:`${o}`,markerHeight:`${u}`,viewBox:"-10 -10 20 20",markerUnits:f,orient:g,refX:"0",refY:"0"},le.createElement(x,{color:i,strokeWidth:h})):null},RS=({defaultColor:n,rfId:r})=>i=>{const o=[];return i.edges.reduce((u,f)=>([f.markerStart,f.markerEnd].forEach(h=>{if(h&&typeof h=="object"){const g=Yd(h,r);o.includes(g)||(u.push({id:g,color:h.color||n,...h}),o.push(g))}}),u),[]).sort((u,f)=>u.id.localeCompare(f.id))},Fg=({defaultColor:n,rfId:r})=>{const i=tt(j.useCallback(RS({defaultColor:n,rfId:r}),[n,r]),(o,u)=>!(o.length!==u.length||o.some((f,h)=>f.id!==u[h].id)));return le.createElement("defs",null,i.map(o=>le.createElement(AS,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};Fg.displayName="MarkerDefinitions";var zS=j.memo(Fg);const OS=n=>({nodesConnectable:n.nodesConnectable,edgesFocusable:n.edgesFocusable,edgesUpdatable:n.edgesUpdatable,elementsSelectable:n.elementsSelectable,width:n.width,height:n.height,connectionMode:n.connectionMode,nodeInternals:n.nodeInternals,onError:n.onError}),Pg=({defaultMarkerColor:n,onlyRenderVisibleElements:r,elevateEdgesOnSelect:i,rfId:o,edgeTypes:u,noPanClassName:f,onEdgeContextMenu:h,onEdgeMouseEnter:g,onEdgeMouseMove:x,onEdgeMouseLeave:m,onEdgeClick:p,onEdgeDoubleClick:b,onReconnect:v,onReconnectStart:N,onReconnectEnd:T,reconnectRadius:_,children:M,disableKeyboardA11y:A})=>{const{edgesFocusable:V,edgesUpdatable:L,elementsSelectable:C,width:D,height:W,connectionMode:X,nodeInternals:ie,onError:I}=tt(OS,Ct),K=_S(r,ie,i);return D?le.createElement(le.Fragment,null,K.map(({level:ne,edges:ee,isMaxLevel:se})=>le.createElement("svg",{key:ne,style:{zIndex:ne},width:D,height:W,className:"react-flow__edges react-flow__container"},se&&le.createElement(zS,{defaultColor:n,rfId:o}),le.createElement("g",null,ee.map(S=>{const[U,k,H]=o0(ie.get(S.source)),[O,z,E]=o0(ie.get(S.target));if(!H||!E)return null;let $=S.type||"default";u[$]||(I?.("011",sa.error011($)),$="default");const Z=u[$]||u.default,ae=X===ps.Strict?z.target:(z.target??[]).concat(z.source??[]),oe=i0(k.source,S.sourceHandle),he=i0(ae,S.targetHandle),me=oe?.position||xe.Bottom,Se=he?.position||xe.Top,ve=!!(S.focusable||V&&typeof S.focusable>"u"),Ae=S.reconnectable||S.updatable,Re=typeof v<"u"&&(Ae||L&&typeof Ae>"u");if(!oe||!he)return I?.("008",sa.error008(oe,S)),null;const{sourceX:We,sourceY:Te,targetX:be,targetY:q}=wS(U,oe,me,O,he,Se);return le.createElement(Z,{key:S.id,id:S.id,className:$t([S.className,f]),type:$,data:S.data,selected:!!S.selected,animated:!!S.animated,hidden:!!S.hidden,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,style:S.style,source:S.source,target:S.target,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerEnd:S.markerEnd,markerStart:S.markerStart,sourceX:We,sourceY:Te,targetX:be,targetY:q,sourcePosition:me,targetPosition:Se,elementsSelectable:C,onContextMenu:h,onMouseEnter:g,onMouseMove:x,onMouseLeave:m,onClick:p,onEdgeDoubleClick:b,onReconnect:v,onReconnectStart:N,onReconnectEnd:T,reconnectRadius:_,rfId:o,ariaLabel:S.ariaLabel,isFocusable:ve,isReconnectable:Re,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth,disableKeyboardA11y:A})})))),M):null};Pg.displayName="EdgeRenderer";var DS=j.memo(Pg);const HS=n=>`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;function $S({children:n}){const r=tt(HS);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:r}},n)}function US(n){const r=xf(),i=j.useRef(!1);j.useEffect(()=>{!i.current&&r.viewportInitialized&&n&&(setTimeout(()=>n(r),1),i.current=!0)},[n,r.viewportInitialized])}const BS={[xe.Left]:xe.Right,[xe.Right]:xe.Left,[xe.Top]:xe.Bottom,[xe.Bottom]:xe.Top},ey=({nodeId:n,handleType:r,style:i,type:o=$a.Bezier,CustomComponent:u,connectionStatus:f})=>{const{fromNode:h,handleId:g,toX:x,toY:m,connectionMode:p}=tt(j.useCallback(W=>({fromNode:W.nodeInternals.get(n),handleId:W.connectionHandleId,toX:(W.connectionPosition.x-W.transform[0])/W.transform[2],toY:(W.connectionPosition.y-W.transform[1])/W.transform[2],connectionMode:W.connectionMode}),[n]),Ct),b=h?.[ct]?.handleBounds;let v=b?.[r];if(p===ps.Loose&&(v=v||b?.[r==="source"?"target":"source"]),!h||!v)return null;const N=g?v.find(W=>W.id===g):v[0],T=N?N.x+N.width/2:(h.width??0)/2,_=N?N.y+N.height/2:h.height??0,M=(h.positionAbsolute?.x??0)+T,A=(h.positionAbsolute?.y??0)+_,V=N?.position,L=V?BS[V]:null;if(!V||!L)return null;if(u)return le.createElement(u,{connectionLineType:o,connectionLineStyle:i,fromNode:h,fromHandle:N,fromX:M,fromY:A,toX:x,toY:m,fromPosition:V,toPosition:L,connectionStatus:f});let C="";const D={sourceX:M,sourceY:A,sourcePosition:V,targetX:x,targetY:m,targetPosition:L};return o===$a.Bezier?[C]=wg(D):o===$a.Step?[C]=Ld({...D,borderRadius:0}):o===$a.SmoothStep?[C]=Ld(D):o===$a.SimpleBezier?[C]=Ng(D):C=`M${M},${A} ${x},${m}`,le.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};ey.displayName="ConnectionLine";const qS=n=>({nodeId:n.connectionNodeId,handleType:n.connectionHandleType,nodesConnectable:n.nodesConnectable,connectionStatus:n.connectionStatus,width:n.width,height:n.height});function LS({containerStyle:n,style:r,type:i,component:o}){const{nodeId:u,handleType:f,nodesConnectable:h,width:g,height:x,connectionStatus:m}=tt(qS,Ct);return!(u&&f&&g&&h)?null:le.createElement("svg",{style:n,width:g,height:x,className:"react-flow__edges react-flow__connectionline react-flow__container"},le.createElement("g",{className:$t(["react-flow__connection",m])},le.createElement(ey,{nodeId:u,handleType:f,style:r,type:i,CustomComponent:o,connectionStatus:m})))}function u0(n,r){return j.useRef(null),Nt(),j.useMemo(()=>r(n),[n])}const ty=({nodeTypes:n,edgeTypes:r,onMove:i,onMoveStart:o,onMoveEnd:u,onInit:f,onNodeClick:h,onEdgeClick:g,onNodeDoubleClick:x,onEdgeDoubleClick:m,onNodeMouseEnter:p,onNodeMouseMove:b,onNodeMouseLeave:v,onNodeContextMenu:N,onSelectionContextMenu:T,onSelectionStart:_,onSelectionEnd:M,connectionLineType:A,connectionLineStyle:V,connectionLineComponent:L,connectionLineContainerStyle:C,selectionKeyCode:D,selectionOnDrag:W,selectionMode:X,multiSelectionKeyCode:ie,panActivationKeyCode:I,zoomActivationKeyCode:K,deleteKeyCode:ne,onlyRenderVisibleElements:ee,elementsSelectable:se,selectNodesOnDrag:S,defaultViewport:U,translateExtent:k,minZoom:H,maxZoom:O,preventScrolling:z,defaultMarkerColor:E,zoomOnScroll:$,zoomOnPinch:Z,panOnScroll:ae,panOnScrollSpeed:oe,panOnScrollMode:he,zoomOnDoubleClick:me,panOnDrag:Se,onPaneClick:ve,onPaneMouseEnter:Ae,onPaneMouseMove:Re,onPaneMouseLeave:We,onPaneScroll:Te,onPaneContextMenu:be,onEdgeContextMenu:q,onEdgeMouseEnter:Y,onEdgeMouseMove:ue,onEdgeMouseLeave:re,onReconnect:P,onReconnectStart:Ee,onReconnectEnd:ge,reconnectRadius:ke,noDragClassName:Oe,noWheelClassName:ze,noPanClassName:Tt,elevateEdgesOnSelect:Mt,disableKeyboardA11y:ft,nodeOrigin:nt,nodeExtent:pt,rfId:at})=>{const pe=u0(n,pS),Ve=u0(r,NS);return US(f),le.createElement(hS,{onPaneClick:ve,onPaneMouseEnter:Ae,onPaneMouseMove:Re,onPaneMouseLeave:We,onPaneContextMenu:be,onPaneScroll:Te,deleteKeyCode:ne,selectionKeyCode:D,selectionOnDrag:W,selectionMode:X,onSelectionStart:_,onSelectionEnd:M,multiSelectionKeyCode:ie,panActivationKeyCode:I,zoomActivationKeyCode:K,elementsSelectable:se,onMove:i,onMoveStart:o,onMoveEnd:u,zoomOnScroll:$,zoomOnPinch:Z,zoomOnDoubleClick:me,panOnScroll:ae,panOnScrollSpeed:oe,panOnScrollMode:he,panOnDrag:Se,defaultViewport:U,translateExtent:k,minZoom:H,maxZoom:O,onSelectionContextMenu:T,preventScrolling:z,noDragClassName:Oe,noWheelClassName:ze,noPanClassName:Tt,disableKeyboardA11y:ft},le.createElement($S,null,le.createElement(DS,{edgeTypes:Ve,onEdgeClick:g,onEdgeDoubleClick:m,onlyRenderVisibleElements:ee,onEdgeContextMenu:q,onEdgeMouseEnter:Y,onEdgeMouseMove:ue,onEdgeMouseLeave:re,onReconnect:P,onReconnectStart:Ee,onReconnectEnd:ge,reconnectRadius:ke,defaultMarkerColor:E,noPanClassName:Tt,elevateEdgesOnSelect:!!Mt,disableKeyboardA11y:ft,rfId:at},le.createElement(LS,{style:V,type:A,component:L,containerStyle:C})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(yS,{nodeTypes:pe,onNodeClick:h,onNodeDoubleClick:x,onNodeMouseEnter:p,onNodeMouseMove:b,onNodeMouseLeave:v,onNodeContextMenu:N,selectNodesOnDrag:S,onlyRenderVisibleElements:ee,noPanClassName:Tt,noDragClassName:Oe,disableKeyboardA11y:ft,nodeOrigin:nt,nodeExtent:pt,rfId:at})))};ty.displayName="GraphView";var YS=j.memo(ty);const Zd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Oa={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Zd,nodeExtent:Zd,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ps.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:xw,isValidConnection:void 0},VS=()=>A2((n,r)=>({...Oa,setNodes:i=>{const{nodeInternals:o,nodeOrigin:u,elevateNodesOnSelect:f}=r();n({nodeInternals:vd(i,o,u,f)})},getNodes:()=>Array.from(r().nodeInternals.values()),setEdges:i=>{const{defaultEdgeOptions:o={}}=r();n({edges:i.map(u=>({...o,...u}))})},setDefaultNodesAndEdges:(i,o)=>{const u=typeof i<"u",f=typeof o<"u",h=u?vd(i,new Map,r().nodeOrigin,r().elevateNodesOnSelect):new Map;n({nodeInternals:h,edges:f?o:[],hasDefaultNodes:u,hasDefaultEdges:f})},updateNodeDimensions:i=>{const{onNodesChange:o,nodeInternals:u,fitViewOnInit:f,fitViewOnInitDone:h,fitViewOnInitOptions:g,domNode:x,nodeOrigin:m}=r(),p=x?.querySelector(".react-flow__viewport");if(!p)return;const b=window.getComputedStyle(p),{m22:v}=new window.DOMMatrixReadOnly(b.transform),N=i.reduce((_,M)=>{const A=u.get(M.id);if(A?.hidden)u.set(A.id,{...A,[ct]:{...A[ct],handleBounds:void 0}});else if(A){const V=of(M.nodeElement);!!(V.width&&V.height&&(A.width!==V.width||A.height!==V.height||M.forceUpdate))&&(u.set(A.id,{...A,[ct]:{...A[ct],handleBounds:{source:a0(".source",M.nodeElement,v,m),target:a0(".target",M.nodeElement,v,m)}},...V}),_.push({id:A.id,type:"dimensions",dimensions:V}))}return _},[]);Lg(u,m);const T=h||f&&!h&&Yg(r,{initial:!0,...g});n({nodeInternals:new Map(u),fitViewOnInitDone:T}),N?.length>0&&o?.(N)},updateNodePositions:(i,o=!0,u=!1)=>{const{triggerNodeChanges:f}=r(),h=i.map(g=>{const x={id:g.id,type:"position",dragging:u};return o&&(x.positionAbsolute=g.positionAbsolute,x.position=g.position),x});f(h)},triggerNodeChanges:i=>{const{onNodesChange:o,nodeInternals:u,hasDefaultNodes:f,nodeOrigin:h,getNodes:g,elevateNodesOnSelect:x}=r();if(i?.length){if(f){const m=Gg(i,g()),p=vd(m,u,h,x);n({nodeInternals:p})}o?.(i)}},addSelectedNodes:i=>{const{multiSelectionActive:o,edges:u,getNodes:f}=r();let h,g=null;o?h=i.map(x=>Ha(x,!0)):(h=cl(f(),i),g=cl(u,[])),No({changedNodes:h,changedEdges:g,get:r,set:n})},addSelectedEdges:i=>{const{multiSelectionActive:o,edges:u,getNodes:f}=r();let h,g=null;o?h=i.map(x=>Ha(x,!0)):(h=cl(u,i),g=cl(f(),[])),No({changedNodes:g,changedEdges:h,get:r,set:n})},unselectNodesAndEdges:({nodes:i,edges:o}={})=>{const{edges:u,getNodes:f}=r(),h=i||f(),g=o||u,x=h.map(p=>(p.selected=!1,Ha(p.id,!1))),m=g.map(p=>Ha(p.id,!1));No({changedNodes:x,changedEdges:m,get:r,set:n})},setMinZoom:i=>{const{d3Zoom:o,maxZoom:u}=r();o?.scaleExtent([i,u]),n({minZoom:i})},setMaxZoom:i=>{const{d3Zoom:o,minZoom:u}=r();o?.scaleExtent([u,i]),n({maxZoom:i})},setTranslateExtent:i=>{r().d3Zoom?.translateExtent(i),n({translateExtent:i})},resetSelectedElements:()=>{const{edges:i,getNodes:o}=r(),f=o().filter(g=>g.selected).map(g=>Ha(g.id,!1)),h=i.filter(g=>g.selected).map(g=>Ha(g.id,!1));No({changedNodes:f,changedEdges:h,get:r,set:n})},setNodeExtent:i=>{const{nodeInternals:o}=r();o.forEach(u=>{u.positionAbsolute=cf(u.position,i)}),n({nodeExtent:i,nodeInternals:new Map(o)})},panBy:i=>{const{transform:o,width:u,height:f,d3Zoom:h,d3Selection:g,translateExtent:x}=r();if(!h||!g||!i.x&&!i.y)return!1;const m=ta.translate(o[0]+i.x,o[1]+i.y).scale(o[2]),p=[[0,0],[u,f]],b=h?.constrain()(m,p,x);return h.transform(g,b),o[0]!==b.x||o[1]!==b.y||o[2]!==b.k},cancelConnection:()=>n({connectionNodeId:Oa.connectionNodeId,connectionHandleId:Oa.connectionHandleId,connectionHandleType:Oa.connectionHandleType,connectionStatus:Oa.connectionStatus,connectionStartHandle:Oa.connectionStartHandle,connectionEndHandle:Oa.connectionEndHandle}),reset:()=>n({...Oa})}),Object.is),ny=({children:n})=>{const r=j.useRef(null);return r.current||(r.current=VS()),le.createElement(cw,{value:r.current},n)};ny.displayName="ReactFlowProvider";const ay=({children:n})=>j.useContext(Qo)?le.createElement(le.Fragment,null,n):le.createElement(ny,null,n);ay.displayName="ReactFlowWrapper";const GS={input:Og,default:Gd,output:Hg,group:pf},XS={default:Lo,straight:ff,step:df,smoothstep:Ko,simplebezier:uf},ZS=[0,0],WS=[15,15],QS={x:0,y:0,zoom:1},KS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},yf=j.forwardRef(({nodes:n,edges:r,defaultNodes:i,defaultEdges:o,className:u,nodeTypes:f=GS,edgeTypes:h=XS,onNodeClick:g,onEdgeClick:x,onInit:m,onMove:p,onMoveStart:b,onMoveEnd:v,onConnect:N,onConnectStart:T,onConnectEnd:_,onClickConnectStart:M,onClickConnectEnd:A,onNodeMouseEnter:V,onNodeMouseMove:L,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:W,onNodeDragStart:X,onNodeDrag:ie,onNodeDragStop:I,onNodesDelete:K,onEdgesDelete:ne,onSelectionChange:ee,onSelectionDragStart:se,onSelectionDrag:S,onSelectionDragStop:U,onSelectionContextMenu:k,onSelectionStart:H,onSelectionEnd:O,connectionMode:z=ps.Strict,connectionLineType:E=$a.Bezier,connectionLineStyle:$,connectionLineComponent:Z,connectionLineContainerStyle:ae,deleteKeyCode:oe="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:me=!1,selectionMode:Se=qr.Full,panActivationKeyCode:ve="Space",multiSelectionKeyCode:Ae=qo()?"Meta":"Control",zoomActivationKeyCode:Re=qo()?"Meta":"Control",snapToGrid:We=!1,snapGrid:Te=WS,onlyRenderVisibleElements:be=!1,selectNodesOnDrag:q=!0,nodesDraggable:Y,nodesConnectable:ue,nodesFocusable:re,nodeOrigin:P=ZS,edgesFocusable:Ee,edgesUpdatable:ge,elementsSelectable:ke,defaultViewport:Oe=QS,minZoom:ze=.5,maxZoom:Tt=2,translateExtent:Mt=Zd,preventScrolling:ft=!0,nodeExtent:nt,defaultMarkerColor:pt="#b1b1b7",zoomOnScroll:at=!0,zoomOnPinch:pe=!0,panOnScroll:Ve=!1,panOnScrollSpeed:je=.5,panOnScrollMode:Le=us.Free,zoomOnDoubleClick:Ge=!0,panOnDrag:At=!0,onPaneClick:Vt,onPaneMouseEnter:Jt,onPaneMouseMove:jl,onPaneMouseLeave:ys,onPaneScroll:la,onPaneContextMenu:Ya,children:ra,onEdgeContextMenu:Dn,onEdgeDoubleClick:Qr,onEdgeMouseEnter:Kr,onEdgeMouseMove:Nl,onEdgeMouseLeave:wl,onEdgeUpdate:Jr,onEdgeUpdateStart:Io,onEdgeUpdateEnd:_n,onReconnect:wt,onReconnectStart:Ut,onReconnectEnd:ia,reconnectRadius:Sl=10,edgeUpdaterRadius:Fo=10,onNodesChange:Po,onEdgesChange:Ir,noDragClassName:Va="nodrag",noWheelClassName:El="nowheel",noPanClassName:Hn="nopan",fitView:oa=!1,fitViewOptions:Ga,connectOnClick:ca=!0,attributionPosition:xt,proOptions:Fr,defaultEdgeOptions:Pr,elevateNodesOnSelect:$n=!0,elevateEdgesOnSelect:ua=!1,disableKeyboardA11y:ei=!1,autoPanOnConnect:ti=!0,autoPanOnNodeDrag:ni=!0,connectionRadius:ec=20,isValidConnection:bs,onError:vs,style:bn,id:js,nodeDragThreshold:ai,...da},kl)=>{const Xa=js||"1";return le.createElement("div",{...da,style:{...bn,...KS},ref:kl,className:$t(["react-flow",u]),"data-testid":"rf__wrapper",id:js},le.createElement(ay,null,le.createElement(YS,{onInit:m,onMove:p,onMoveStart:b,onMoveEnd:v,onNodeClick:g,onEdgeClick:x,onNodeMouseEnter:V,onNodeMouseMove:L,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:W,nodeTypes:f,edgeTypes:h,connectionLineType:E,connectionLineStyle:$,connectionLineComponent:Z,connectionLineContainerStyle:ae,selectionKeyCode:he,selectionOnDrag:me,selectionMode:Se,deleteKeyCode:oe,multiSelectionKeyCode:Ae,panActivationKeyCode:ve,zoomActivationKeyCode:Re,onlyRenderVisibleElements:be,selectNodesOnDrag:q,defaultViewport:Oe,translateExtent:Mt,minZoom:ze,maxZoom:Tt,preventScrolling:ft,zoomOnScroll:at,zoomOnPinch:pe,zoomOnDoubleClick:Ge,panOnScroll:Ve,panOnScrollSpeed:je,panOnScrollMode:Le,panOnDrag:At,onPaneClick:Vt,onPaneMouseEnter:Jt,onPaneMouseMove:jl,onPaneMouseLeave:ys,onPaneScroll:la,onPaneContextMenu:Ya,onSelectionContextMenu:k,onSelectionStart:H,onSelectionEnd:O,onEdgeContextMenu:Dn,onEdgeDoubleClick:Qr,onEdgeMouseEnter:Kr,onEdgeMouseMove:Nl,onEdgeMouseLeave:wl,onReconnect:wt??Jr,onReconnectStart:Ut??Io,onReconnectEnd:ia??_n,reconnectRadius:Sl??Fo,defaultMarkerColor:pt,noDragClassName:Va,noWheelClassName:El,noPanClassName:Hn,elevateEdgesOnSelect:ua,rfId:Xa,disableKeyboardA11y:ei,nodeOrigin:P,nodeExtent:nt}),le.createElement(Bw,{nodes:n,edges:r,defaultNodes:i,defaultEdges:o,onConnect:N,onConnectStart:T,onConnectEnd:_,onClickConnectStart:M,onClickConnectEnd:A,nodesDraggable:Y,nodesConnectable:ue,nodesFocusable:re,edgesFocusable:Ee,edgesUpdatable:ge,elementsSelectable:ke,elevateNodesOnSelect:$n,minZoom:ze,maxZoom:Tt,nodeExtent:nt,onNodesChange:Po,onEdgesChange:Ir,snapToGrid:We,snapGrid:Te,connectionMode:z,translateExtent:Mt,connectOnClick:ca,defaultEdgeOptions:Pr,fitView:oa,fitViewOptions:Ga,onNodesDelete:K,onEdgesDelete:ne,onNodeDragStart:X,onNodeDrag:ie,onNodeDragStop:I,onSelectionDrag:S,onSelectionDragStart:se,onSelectionDragStop:U,noPanClassName:Hn,nodeOrigin:P,rfId:Xa,autoPanOnConnect:ti,autoPanOnNodeDrag:ni,onError:vs,connectionRadius:ec,isValidConnection:bs,nodeDragThreshold:ai}),le.createElement($w,{onSelectionChange:ee}),ra,le.createElement(dw,{proOptions:Fr,position:xt}),le.createElement(Gw,{rfId:Xa,disableKeyboardA11y:ei})))});yf.displayName="ReactFlow";function sy(n){return r=>{const[i,o]=j.useState(r),u=j.useCallback(f=>o(h=>n(f,h)),[]);return[i,o,u]}}const ly=sy(Gg),ry=sy(sS),iy=({id:n,x:r,y:i,width:o,height:u,style:f,color:h,strokeColor:g,strokeWidth:x,className:m,borderRadius:p,shapeRendering:b,onClick:v,selected:N})=>{const{background:T,backgroundColor:_}=f||{},M=h||T||_;return le.createElement("rect",{className:$t(["react-flow__minimap-node",{selected:N},m]),x:r,y:i,rx:p,ry:p,width:o,height:u,fill:M,stroke:g,strokeWidth:x,shapeRendering:b,onClick:v?A=>v(A,n):void 0})};iy.displayName="MiniMapNode";var JS=j.memo(iy);const IS=n=>n.nodeOrigin,FS=n=>n.getNodes().filter(r=>!r.hidden&&r.width&&r.height),Sd=n=>n instanceof Function?n:()=>n;function PS({nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:u=2,nodeComponent:f=JS,onClick:h}){const g=tt(FS,Ct),x=tt(IS),m=Sd(r),p=Sd(n),b=Sd(i),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,g.map(N=>{const{x:T,y:_}=fs(N,x).positionAbsolute;return le.createElement(f,{key:N.id,x:T,y:_,width:N.width,height:N.height,style:N.style,selected:N.selected,className:b(N),color:m(N),borderRadius:o,strokeColor:p(N),strokeWidth:u,shapeRendering:v,onClick:h,id:N.id})}))}var e3=j.memo(PS);const t3=200,n3=150,a3=n=>{const r=n.getNodes(),i={x:-n.transform[0]/n.transform[2],y:-n.transform[1]/n.transform[2],width:n.width/n.transform[2],height:n.height/n.transform[2]};return{viewBB:i,boundingRect:r.length>0?mw(Jo(r,n.nodeOrigin),i):i,rfId:n.rfId}},s3="react-flow__minimap-desc";function oy({style:n,className:r,nodeStrokeColor:i="transparent",nodeColor:o="#e2e2e2",nodeClassName:u="",nodeBorderRadius:f=5,nodeStrokeWidth:h=2,nodeComponent:g,maskColor:x="rgb(240, 240, 240, 0.6)",maskStrokeColor:m="none",maskStrokeWidth:p=1,position:b="bottom-right",onClick:v,onNodeClick:N,pannable:T=!1,zoomable:_=!1,ariaLabel:M="React Flow mini map",inversePan:A=!1,zoomStep:V=10,offsetScale:L=5}){const C=Nt(),D=j.useRef(null),{boundingRect:W,viewBB:X,rfId:ie}=tt(a3,Ct),I=n?.width??t3,K=n?.height??n3,ne=W.width/I,ee=W.height/K,se=Math.max(ne,ee),S=se*I,U=se*K,k=L*se,H=W.x-(S-W.width)/2-k,O=W.y-(U-W.height)/2-k,z=S+k*2,E=U+k*2,$=`${s3}-${ie}`,Z=j.useRef(0);Z.current=se,j.useEffect(()=>{if(D.current){const he=gn(D.current),me=Ae=>{const{transform:Re,d3Selection:We,d3Zoom:Te}=C.getState();if(Ae.sourceEvent.type!=="wheel"||!We||!Te)return;const be=-Ae.sourceEvent.deltaY*(Ae.sourceEvent.deltaMode===1?.05:Ae.sourceEvent.deltaMode?1:.002)*V,q=Re[2]*Math.pow(2,be);Te.scaleTo(We,q)},Se=Ae=>{const{transform:Re,d3Selection:We,d3Zoom:Te,translateExtent:be,width:q,height:Y}=C.getState();if(Ae.sourceEvent.type!=="mousemove"||!We||!Te)return;const ue=Z.current*Math.max(1,Re[2])*(A?-1:1),re={x:Re[0]-Ae.sourceEvent.movementX*ue,y:Re[1]-Ae.sourceEvent.movementY*ue},P=[[0,0],[q,Y]],Ee=ta.translate(re.x,re.y).scale(Re[2]),ge=Te.constrain()(Ee,P,be);Te.transform(We,ge)},ve=fg().on("zoom",T?Se:null).on("zoom.wheel",_?me:null);return he.call(ve),()=>{he.on("zoom",null)}}},[T,_,A,V]);const ae=v?he=>{const me=Sn(he);v(he,{x:me[0],y:me[1]})}:void 0,oe=N?(he,me)=>{const Se=C.getState().nodeInternals.get(me);N(he,Se)}:void 0;return le.createElement(rf,{position:b,style:n,className:$t(["react-flow__minimap",r]),"data-testid":"rf__minimap"},le.createElement("svg",{width:I,height:K,viewBox:`${H} ${O} ${z} ${E}`,role:"img","aria-labelledby":$,ref:D,onClick:ae},M&&le.createElement("title",{id:$},M),le.createElement(e3,{onClick:oe,nodeColor:o,nodeStrokeColor:i,nodeBorderRadius:f,nodeClassName:u,nodeStrokeWidth:h,nodeComponent:g}),le.createElement("path",{className:"react-flow__minimap-mask",d:`M${H-k},${O-k}h${z+k*2}v${E+k*2}h${-z-k*2}z
391
- M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fill:x,fillRule:"evenodd",stroke:m,strokeWidth:p,pointerEvents:"none"})))}oy.displayName="MiniMap";var l3=j.memo(oy);function r3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},le.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function i3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function o3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},le.createElement("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 c3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("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 u3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("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"}))}const Mr=({children:n,className:r,...i})=>le.createElement("button",{type:"button",className:$t(["react-flow__controls-button",r]),...i},n);Mr.displayName="ControlButton";const d3=n=>({isInteractive:n.nodesDraggable||n.nodesConnectable||n.elementsSelectable,minZoomReached:n.transform[2]<=n.minZoom,maxZoomReached:n.transform[2]>=n.maxZoom}),cy=({style:n,showZoom:r=!0,showFitView:i=!0,showInteractive:o=!0,fitViewOptions:u,onZoomIn:f,onZoomOut:h,onFitView:g,onInteractiveChange:x,className:m,children:p,position:b="bottom-left"})=>{const v=Nt(),[N,T]=j.useState(!1),{isInteractive:_,minZoomReached:M,maxZoomReached:A}=tt(d3,Ct),{zoomIn:V,zoomOut:L,fitView:C}=xf();if(j.useEffect(()=>{T(!0)},[]),!N)return null;const D=()=>{V(),f?.()},W=()=>{L(),h?.()},X=()=>{C(u),g?.()},ie=()=>{v.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),x?.(!_)};return le.createElement(rf,{className:$t(["react-flow__controls",m]),position:b,style:n,"data-testid":"rf__controls"},r&&le.createElement(le.Fragment,null,le.createElement(Mr,{onClick:D,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:A},le.createElement(r3,null)),le.createElement(Mr,{onClick:W,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:M},le.createElement(i3,null))),i&&le.createElement(Mr,{className:"react-flow__controls-fitview",onClick:X,title:"fit view","aria-label":"fit view"},le.createElement(o3,null)),o&&le.createElement(Mr,{className:"react-flow__controls-interactive",onClick:ie,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(u3,null):le.createElement(c3,null)),p)};cy.displayName="Controls";var uy=j.memo(cy),ln;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(ln||(ln={}));function f3({color:n,dimensions:r,lineWidth:i}){return le.createElement("path",{stroke:n,strokeWidth:i,d:`M${r[0]/2} 0 V${r[1]} M0 ${r[1]/2} H${r[0]}`})}function h3({color:n,radius:r}){return le.createElement("circle",{cx:r,cy:r,r,fill:n})}const m3={[ln.Dots]:"#91919a",[ln.Lines]:"#eee",[ln.Cross]:"#e2e2e2"},p3={[ln.Dots]:1,[ln.Lines]:1,[ln.Cross]:6},x3=n=>({transform:n.transform,patternId:`pattern-${n.rfId}`});function dy({id:n,variant:r=ln.Dots,gap:i=20,size:o,lineWidth:u=1,offset:f=2,color:h,style:g,className:x}){const m=j.useRef(null),{transform:p,patternId:b}=tt(x3,Ct),v=h||m3[r],N=o||p3[r],T=r===ln.Dots,_=r===ln.Cross,M=Array.isArray(i)?i:[i,i],A=[M[0]*p[2]||1,M[1]*p[2]||1],V=N*p[2],L=_?[V,V]:A,C=T?[V/f,V/f]:[L[0]/f,L[1]/f];return le.createElement("svg",{className:$t(["react-flow__background",x]),style:{...g,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:m,"data-testid":"rf__background"},le.createElement("pattern",{id:b+n,x:p[0]%A[0],y:p[1]%A[1],width:A[0],height:A[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},T?le.createElement(h3,{color:v,radius:V/f}):le.createElement(f3,{dimensions:L,color:v,lineWidth:u})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${b+n})`}))}dy.displayName="Background";var fy=j.memo(dy);const d0={GET:{bg:"bg-emerald-500/10",text:"text-emerald-400",dot:"#34d399"},POST:{bg:"bg-blue-500/10",text:"text-blue-400",dot:"#60a5fa"},PUT:{bg:"bg-amber-500/10",text:"text-amber-400",dot:"#fbbf24"},PATCH:{bg:"bg-orange-500/10",text:"text-orange-400",dot:"#fb923c"},DELETE:{bg:"bg-red-500/10",text:"text-red-400",dot:"#f87171"},HEAD:{bg:"theme-bg-overlay-md",text:"theme-text-muted",dot:"var(--text-muted)"},OPTIONS:{bg:"bg-purple-500/10",text:"text-purple-400",dot:"#c084fc"}};function bf(n){return d0[n.toUpperCase()]??d0.GET}const f0=["exists","not_exists","is_empty","is_not_empty"];function h0(n,r){return n.replace(/\{\{([^}]+)\}\}/g,(i,o)=>{const u=o.trim();if(u.includes(":")){const f=u.indexOf(":"),h=u.slice(0,f),g=u.slice(f+1);return r[`${h}:${g}`]??r[g]??""}return r[u]??""})}function g3(n,r){const i=h0(n.left,r),o=n.right!==void 0?h0(n.right,r):void 0;switch(n.operator){case"equals":return i===o;case"not_equals":return i!==o;case"greater_than":return Number(i)>Number(o);case"greater_than_or_equal":return Number(i)>=Number(o);case"less_than":return Number(i)<Number(o);case"less_than_or_equal":return Number(i)<=Number(o);case"exists":return i!==""&&i!==void 0;case"not_exists":return i===""||i===void 0;case"is_empty":return i===""||i===null;case"is_not_empty":return i!==""&&i!==null;case"contains":return o!==void 0&&i.includes(o);case"not_contains":return o!==void 0&&!i.includes(o);case"starts_with":return o!==void 0&&i.startsWith(o);case"ends_with":return o!==void 0&&i.endsWith(o);default:return!1}}function y3(n,r){const{rules:i}=n,o=i.all??i.any??[],u=!!i.all;if(o.length===0)return{passed:!0,reason:"No rules"};const f=o.map(m=>({rule:m,ok:g3(m,r)})),h=u?f.every(m=>m.ok):f.some(m=>m.ok),g=f.filter(m=>!m.ok),x=h?`All conditions met (${u?"AND":"OR"})`:`Failed: ${g.map(m=>`${m.rule.left} ${m.rule.operator}${m.rule.right!==void 0?" "+m.rule.right:""}`).join(", ")}`;return{passed:h,reason:x}}async function b3(n,r){const i=n.replace(/^workflows\//,"").replace(/\.json$/,"");await fetch(`/api/workflows/${encodeURIComponent(i)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({steps:r})})}function v3({method:n}){const r=bf(n);return s.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium tracking-widest ${r.bg} ${r.text}`,children:n.toUpperCase()})}async function j3(){const n=await fetch("/api/workflows");if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function N3(n){const r=n.replace(/^workflows\//,"").replace(/\.json$/,""),i=await fetch(`/api/workflows/${encodeURIComponent(r)}`,{method:"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`HTTP ${i.status}`)}}const m0=/\{\{\s*human:([^}]+?)\s*\}\}/g;function vf(n){const r=new Set;for(const i of[n.path,JSON.stringify(n.body??{}),JSON.stringify(n.inject??{}),JSON.stringify(n.condition??{})]){if(!i)continue;m0.lastIndex=0;let o;for(;(o=m0.exec(i))!==null;){const u=o[1].trim();u&&r.add(u)}}return[...r]}function w3(n){const r=new Set;return n.forEach(i=>vf(i).forEach(o=>r.add(o))),[...r]}function S3(n){return/pass|secret|token|pwd|private|credential/i.test(n)}function E3({title:n,subtitle:r,fields:i,values:o,onChange:u,onSubmit:f,onCancel:h,submitLabel:g,error:x,submitting:m}){return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:s.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-amber-500/25 theme-bg-overlay shadow-2xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b theme-border",children:[s.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-500/15 text-amber-400",children:s.jsx(zr,{className:"h-3.5 w-3.5",strokeWidth:2})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[12px] font-medium theme-text-primary",children:n}),r&&s.jsx("p",{className:"text-[10px] theme-text-faint truncate",children:r})]})]}),s.jsxs("div",{className:"space-y-2.5 p-4",children:[s.jsx("p",{className:"text-[11px] theme-text-muted",children:"This workflow needs a value only you know. The run stays paused until you answer."}),i.map(p=>s.jsxs("div",{children:[s.jsx("label",{className:"mb-1 block font-mono text-[10px] text-amber-400/90",children:`{{human:${p.key}}}`}),s.jsx("input",{autoFocus:i.length===1,type:S3(p.key)?"password":"text",value:o[p.key]??"",onChange:b=>u(p.key,b.target.value),onKeyDown:b=>{b.key==="Enter"&&f()},placeholder:p.hint??`Enter ${p.key}…`,className:"h-8 w-full rounded-lg border border-amber-500/30 theme-bg-overlay-md px-2.5 text-[12px] theme-text-primary placeholder-[var(--text-faint)] outline-none focus:border-amber-500/70 transition-colors"})]},p.key)),x&&s.jsx("p",{className:"text-[10px] text-red-400 leading-tight",children:x}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:f,disabled:!!m,className:"flex h-8 flex-1 items-center justify-center gap-1.5 rounded-lg bg-amber-500/20 border border-amber-500/40 px-3 text-[11px] font-medium text-amber-300 hover:bg-amber-500/30 transition-colors disabled:opacity-40 hover:cursor-pointer",children:[m?s.jsx(dt,{className:"h-3 w-3 animate-spin",strokeWidth:2}):s.jsx(ut,{className:"h-3 w-3",strokeWidth:2}),g]}),h&&s.jsxs("button",{type:"button",onClick:h,className:"flex h-8 items-center gap-1 rounded-lg border theme-border px-3 text-[11px] theme-text-muted hover:theme-text transition-colors hover:cursor-pointer",children:[s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})," Cancel run"]})]})]})]})})}const hy=230,Wd=64;function k3({data:n}){const r=bf(n.method),i={idle:"theme-border",running:"border-blue-500/60",passed:"border-emerald-500/40",failed:"border-red-500/40",skipped:"theme-border"},o={idle:"",running:"shadow-[0_0_12px_rgba(96,165,250,0.28)]",passed:"shadow-[0_0_8px_rgba(52,211,153,0.15)]",failed:"shadow-[0_0_8px_rgba(248,113,113,0.15)]",skipped:""},u=n.status??"idle";return s.jsxs("div",{className:`rounded-lg border theme-bg-overlay flex items-center gap-2.5 px-3 overflow-hidden transition-all duration-300 ${i[u]} ${o[u]}`,style:{width:hy,height:Wd},children:[s.jsx(jt,{type:"target",position:xe.Top,style:{background:"transparent",border:"none"}}),s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[3px] transition-colors duration-300",style:{background:u==="running"?"#60a5fa":u==="passed"?r.dot:u==="failed"?"#f87171":r.dot+"60"}}),s.jsxs("div",{className:"shrink-0 flex items-center justify-center",children:[u==="running"&&s.jsx(dt,{className:"h-3.5 w-3.5 text-blue-400 animate-spin",strokeWidth:2}),u==="passed"&&s.jsx(ut,{className:"h-3.5 w-3.5 text-emerald-400",strokeWidth:2}),u==="failed"&&s.jsx(Ht,{className:"h-3.5 w-3.5 text-red-400",strokeWidth:2}),u==="idle"&&s.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full border theme-border text-[8px] font-medium theme-text-faint",children:n.index+1}),u==="skipped"&&s.jsx("span",{className:"h-3.5 w-3.5 rounded-full border theme-border theme-bg-overlay-md"})]}),s.jsxs("div",{className:"min-w-0 flex-1 pl-0.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[s.jsx("span",{className:`text-[9px] font-medium ${r.text}`,children:n.method}),s.jsx("span",{className:"font-mono text-[10px] theme-text truncate",children:n.path}),n.result&&s.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[9px] ${n.result.passed?"text-emerald-400":"text-red-400"}`,children:[n.result.status>0?n.result.status:"ERR"," · ",n.result.durationMs,"ms"]})]}),s.jsx("p",{className:"text-[9px] theme-text-faint truncate",children:n.name})]}),s.jsx(jt,{type:"source",position:xe.Bottom,style:{background:"transparent",border:"none"}})]})}function _3({data:n}){const r=n.passed,i=r===void 0?"rgba(96,165,250,0.5)":r?"rgba(52,211,153,0.7)":"rgba(248,113,113,0.7)";return s.jsxs("div",{style:{width:40,height:40,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[s.jsx(jt,{type:"target",position:xe.Top,style:{background:"transparent",border:"none"}}),s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",children:[s.jsx("polygon",{points:"20,2 38,20 20,38 2,20",fill:"none",stroke:i,strokeWidth:"1.5"}),s.jsx("polygon",{points:"20,8 32,20 20,32 8,20",fill:i,fillOpacity:.12,stroke:"none"})]}),s.jsx("span",{style:{position:"absolute",fontSize:8,fontFamily:"monospace",color:i,top:"50%",left:"50%",transform:"translate(-50%,-50%)",whiteSpace:"nowrap"},children:"◇"}),s.jsx(jt,{type:"source",position:xe.Bottom,style:{background:"transparent",border:"none"}})]})}const C3={step:k3,condition:_3};function T3({steps:n,runState:r}){const[i,o,u]=ly([]),[f,h,g]=ry([]);j.useEffect(()=>{const v=[],N=[];let T=40;for(let _=0;_<n.length;_++){const M=n[_],A=r.stepStatuses[_]??"idle",V=r.stepResults[_]??null;if(v.push({id:`step-${_}`,type:"step",position:{x:0,y:T},data:{index:_,name:M.name,method:M.method,path:M.path,status:A,result:V}}),T+=Wd+36,M.condition){const L=`cond-${_}`,C=V?.conditionResult;v.push({id:L,type:"condition",position:{x:hy/2-20,y:T},data:{passed:C?.passed}});const D=A==="passed"?"rgba(52,211,153,0.3)":A==="failed"?"rgba(248,113,113,0.3)":"rgba(96,165,250,0.18)";if(N.push({id:`e-${_}-cond`,source:`step-${_}`,target:L,style:{stroke:D,strokeWidth:1.5},markerEnd:{type:Ba.ArrowClosed,color:D},animated:A==="running"}),T+=64,_<n.length-1){const W=C?.passed===!0?"rgba(52,211,153,0.5)":"rgba(96,165,250,0.18)",X=C?.passed===!1?"rgba(248,113,113,0.5)":"rgba(96,165,250,0.1)";N.push({id:`e-${_}-cond-pass`,source:L,target:`step-${_+1}`,label:"PASS",labelStyle:{fill:"rgba(52,211,153,0.8)",fontSize:8,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:W,strokeWidth:1.2},markerEnd:{type:Ba.ArrowClosed,color:W}}),N.push({id:`e-${_}-cond-fail`,source:L,target:`step-${_+1}`,label:`FAIL→${M.condition.onFail.toUpperCase()}`,labelStyle:{fill:"rgba(248,113,113,0.8)",fontSize:8,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:X,strokeWidth:1.2,strokeDasharray:"4 3"}})}}else if(_<n.length-1){const L=Object.keys(M.capture??{}),C=L.length>0?L.map(X=>X.split(":").pop()).join(", "):void 0,D=r.stepStatuses[_]??"idle",W=D==="passed"?"rgba(52,211,153,0.3)":D==="failed"?"rgba(248,113,113,0.3)":"rgba(96,165,250,0.18)";N.push({id:`e-${_}`,source:`step-${_}`,target:`step-${_+1}`,label:C,labelStyle:{fill:"rgba(96,165,250,0.7)",fontSize:9,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:W,strokeWidth:1.5,strokeDasharray:D==="idle"||D==="running"?"5 5":void 0},markerEnd:{type:Ba.ArrowClosed,color:D==="passed"?"rgba(52,211,153,0.4)":"rgba(96,165,250,0.3)"},animated:D==="running"})}}o(v),h(N)},[n,r.stepStatuses,r.stepResults]);const x=n.reduce((m,p)=>m+Wd+36+(p.condition?64:0),40);return s.jsx("div",{style:{height:Math.max(400,x)},className:"w-full rounded-lg overflow-hidden",children:s.jsxs(yf,{nodes:i,edges:f,onNodesChange:u,onEdgesChange:g,nodeTypes:C3,fitView:!0,fitViewOptions:{padding:.3},proOptions:{hideAttribution:!0},minZoom:.3,maxZoom:2,children:[s.jsx(fy,{variant:ln.Dots,gap:20,size:1,color:"var(--border)"}),s.jsx(uy,{showInteractive:!1,className:"theme-bg-overlay border theme-border"})]})})}function M3({runState:n,steps:r,waitingStepIndex:i}){const o=j.useRef(null);return j.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n.stepResults,n.phase]),n.phase==="idle"?null:s.jsxs("div",{className:"mt-3 rounded-lg border theme-border theme-bg-overlay",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b theme-border theme-bg-overlay-md",children:[s.jsx("span",{className:"text-[10px] font-semibold theme-text-muted uppercase tracking-wider",children:"Run Log"}),n.baseUrl&&s.jsxs("span",{className:"font-mono text-[10px] theme-text-faint",children:["→ ",n.baseUrl]}),s.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px]",children:[n.passed>0&&s.jsxs("span",{className:"text-emerald-400",children:[n.passed," passed"]}),n.failed>0&&s.jsxs("span",{className:"text-red-400",children:[n.failed," failed"]}),n.phase==="running"&&s.jsx(dt,{className:"h-3 w-3 text-blue-400 animate-spin",strokeWidth:2}),n.phase==="done"&&s.jsx(ut,{className:"h-3 w-3 text-emerald-400",strokeWidth:2}),n.phase==="aborted"&&s.jsx(Ht,{className:"h-3 w-3 text-red-400",strokeWidth:2})]})]}),s.jsxs("div",{ref:o,className:"overflow-y-auto max-h-80 font-mono text-[11px] p-3 space-y-1",children:[s.jsx("p",{className:"theme-text-faint",children:"▶ Starting workflow execution…"}),n.humanUnsupported&&s.jsxs("p",{className:"text-red-400",children:["⚠ Connected server doesn't support ","{{human:*}}"," — restart `jetic dev` from the latest build. Human values will resolve empty and the dialog will never appear."]}),(n.humanKeys??[]).filter(u=>u.source==="prompt").map(u=>s.jsxs("p",{className:"text-amber-400",children:["◉ will ask for ",`{{human:${u.key}}}`," when reached"]},`need-${u.key}`)),(n.humanKeys??[]).filter(u=>u.source!=="prompt").map(u=>s.jsxs("p",{className:"theme-text-faint",children:["↳ human ",`{{human:${u.key}}}`," ← ",my[u.source]??u.source," (ready)"]},`have-${u.key}`)),(n.notes??[]).map((u,f)=>s.jsx("p",{className:"theme-text-faint",children:u},`note-${f}`)),n.stepResults.map((u,f)=>{if(!u&&n.stepStatuses[f]!=="running")return null;const h=r[f],g=bf(h.method);return n.stepStatuses[f]==="running"?s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 theme-text-muted",children:[s.jsx(dt,{className:"h-3 w-3 animate-spin text-blue-400",strokeWidth:2}),s.jsxs("span",{className:"theme-text-faint",children:["Step ",f+1,"/",r.length]}),s.jsx("span",{className:g.text,children:h.method}),s.jsx("span",{className:"theme-text",children:h.path}),s.jsx("span",{className:"theme-text-faint",children:"…"})]}),i===f&&s.jsx("p",{className:"pl-5 text-amber-400",children:"⏳ Waiting for your input — answer the dialog to resume the run."})]},f):u?s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:u.passed?"text-emerald-400":"text-red-400",children:u.passed?"✓":"✗"}),s.jsxs("span",{className:"theme-text-faint",children:["Step ",f+1,"/",r.length]}),s.jsx("span",{className:`${g.text}`,children:h.method.padEnd(6)}),s.jsx("span",{className:"theme-text",children:h.path}),s.jsx("span",{className:`${u.passed?"text-emerald-400":"text-red-400"}`,children:u.status>0?u.status:"NO RESPONSE"}),s.jsxs("span",{className:"theme-text-faint",children:[u.durationMs,"ms"]})]}),h.name&&s.jsx("p",{className:"pl-5 theme-text-faint italic",children:h.name}),Object.entries(u.injected??{}).filter(([m])=>m!=="Content-Type").map(([m,p])=>s.jsxs("p",{className:"pl-5 theme-text-faint",children:["↳ ",s.jsxs("span",{className:"text-amber-500/80",children:[m,":"]})," ",s.jsx("span",{className:"theme-text-faint",children:String(p).length>60?String(p).slice(0,57)+"…":p})]},m)),u.captured.map((m,p)=>s.jsxs("p",{className:"pl-5 text-emerald-400",children:["↳ captured ",m]},p)),u.conditionResult&&s.jsxs("p",{className:`pl-5 ${u.conditionResult.passed?"text-purple-400":"text-orange-400"}`,children:["◇ condition ",u.conditionResult.passed?"passed":"failed"," — ",u.conditionResult.reason,!u.conditionResult.passed&&h.condition&&s.jsxs("span",{className:"text-orange-300/70",children:[" → ",h.condition.onFail,h.condition.onFail==="switch"&&h.condition.switchToWorkflow?`: ${h.condition.switchToWorkflow}`:""]})]}),u.error&&s.jsxs("p",{className:"pl-5 text-red-400",children:["Error: ",u.error]}),!u.passed&&u.responseBody&&!u.error&&s.jsxs("p",{className:"pl-5 text-red-400/80 truncate",children:["Response: ",typeof u.responseBody=="string"?u.responseBody.slice(0,120):JSON.stringify(u.responseBody).slice(0,120)]})]},f):null}),n.phase==="done"&&s.jsxs("p",{className:`mt-1 ${n.failed===0?"text-emerald-400":"text-amber-400"}`,children:["✓ Done — ",n.passed,"/",n.passed+n.failed," steps passed"]}),n.phase==="aborted"&&s.jsxs("p",{className:"mt-1 text-red-400",children:["✗ Aborted — ",n.error]}),n.phase==="error"&&s.jsxs("p",{className:"mt-1 text-red-400",children:["✗ Error — ",n.error]})]})]})}const A3=[{label:"Equality",ops:[{value:"equals",label:"equals"},{value:"not_equals",label:"not equals"}]},{label:"Comparison",ops:[{value:"greater_than",label:"greater than"},{value:"greater_than_or_equal",label:"greater than or equal"},{value:"less_than",label:"less than"},{value:"less_than_or_equal",label:"less than or equal"}]},{label:"Existence",ops:[{value:"exists",label:"exists"},{value:"not_exists",label:"does not exist"},{value:"is_empty",label:"is empty"},{value:"is_not_empty",label:"is not empty"}]},{label:"Text / Collection",ops:[{value:"contains",label:"contains"},{value:"not_contains",label:"does not contain"},{value:"starts_with",label:"starts with"},{value:"ends_with",label:"ends with"}]}];function p0(){return{left:"",operator:"equals",right:""}}function R3({stepIndex:n,existingCondition:r,capturedKeys:i,onSave:o,onRemove:u,onCancel:f}){const[h,g]=j.useState(r?.rules.all?"all":r?.rules.any?"any":"all"),x=r?.rules.all??r?.rules.any??[],[m,p]=j.useState(x.length>0?x:[p0()]),[b,v]=j.useState(r?.onFail??"abort"),[N,T]=j.useState(r?.switchToWorkflow??""),[_,M]=j.useState(r?.returnOnComplete??!0),A=(X,ie)=>{p(I=>I.map((K,ne)=>ne===X?{...K,...ie}:K))},V=()=>p(X=>[...X,p0()]),L=X=>p(ie=>ie.filter((I,K)=>K!==X)),C=()=>{const X=m.filter(I=>I.left.trim()!=="");if(X.length===0)return;const ie={rules:h==="all"?{all:X}:{any:X},onFail:b,...b==="switch"&&N.trim()?{switchToWorkflow:N.trim(),returnOnComplete:_}:{}};o(ie)},D="h-7 rounded-lg border theme-border theme-bg-overlay-md px-2 text-[11px] theme-text-primary placeholder-[var(--text-faint)] outline-none focus:border-purple-500/60 transition-colors",W=`${D} cursor-pointer`;return s.jsxs("div",{className:"mt-2 rounded-lg border border-purple-500/20 bg-purple-500/[0.04] p-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ea,{className:"h-3 w-3 text-purple-400",strokeWidth:2}),s.jsx("span",{className:"text-[10px] font-semibold text-purple-400 uppercase tracking-wider",children:"Step Condition"}),s.jsx("span",{className:"text-[10px] theme-text-faint ml-1",children:"— evaluated after this step runs"}),s.jsx("div",{className:"ml-auto flex items-center gap-1",children:["all","any"].map(X=>s.jsx("button",{type:"button",onClick:()=>g(X),className:`px-2 py-0.5 rounded text-[9px] font-semibold transition-colors hover:cursor-pointer ${h===X?"bg-purple-500/20 text-purple-400 border border-purple-500/40":"theme-bg-overlay-md theme-text-faint border theme-border hover:theme-text-muted"}`,children:X==="all"?"AND":"OR"},X))})]}),s.jsxs("div",{className:"space-y-2",children:[m.map((X,ie)=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("input",{list:`cond-left-${n}-${ie}`,value:X.left,onChange:I=>A(ie,{left:I.target.value}),placeholder:"{{workflow:key}} or value",className:`flex-1 min-w-0 ${D}`}),s.jsx("datalist",{id:`cond-left-${n}-${ie}`,children:i.map(I=>s.jsx("option",{value:`{{${I}}}`},I))}),s.jsx("select",{value:X.operator,onChange:I=>A(ie,{operator:I.target.value,right:f0.includes(I.target.value)?void 0:X.right}),className:`w-44 shrink-0 ${W}`,children:A3.map(I=>s.jsx("optgroup",{label:I.label,children:I.ops.map(K=>s.jsx("option",{value:K.value,children:K.label},K.value))},I.label))}),f0.includes(X.operator)?s.jsx("div",{className:"flex-1"}):s.jsx("input",{value:X.right??"",onChange:I=>A(ie,{right:I.target.value}),placeholder:"value or {{workflow:key}}",className:`flex-1 min-w-0 ${D}`}),m.length>1&&s.jsx("button",{type:"button",onClick:()=>L(ie),className:"shrink-0 theme-text-faint hover:text-red-400 transition-colors hover:cursor-pointer",children:s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})})]},ie)),s.jsxs("button",{type:"button",onClick:V,className:"flex items-center gap-1 text-[10px] text-purple-400/70 hover:text-purple-400 transition-colors hover:cursor-pointer",children:[s.jsx(Dt,{className:"h-3 w-3",strokeWidth:2})," Add rule"]})]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1 border-t border-purple-500/10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] theme-text-faint shrink-0",children:"If condition fails →"}),["abort","continue","switch"].map(X=>s.jsx("button",{type:"button",onClick:()=>v(X),className:`px-2 py-0.5 rounded text-[9px] font-medium capitalize transition-colors border hover:cursor-pointer ${b===X?X==="abort"?"bg-red-500/20 text-red-400 border-red-500/40":X==="continue"?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"bg-blue-500/20 text-blue-400 border-blue-500/40":"theme-bg-overlay-md theme-text-faint theme-border hover:theme-text-muted"}`,children:X},X)),b==="switch"&&s.jsx("input",{value:N,onChange:X=>T(X.target.value),placeholder:"workflow-slug",className:`flex-1 ${D}`})]}),b==="switch"&&s.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] theme-text-muted cursor-pointer select-none ml-1",children:[s.jsx("input",{type:"checkbox",checked:_,onChange:X=>M(X.target.checked),className:"rounded theme-border theme-bg-overlay-md text-purple-500 focus:ring-0"}),s.jsxs("span",{children:["Return to main workflow after completing ",s.jsx("code",{className:"text-purple-400",children:N||"sub-workflow"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:C,disabled:m.every(X=>!X.left.trim()),className:"flex items-center gap-1 rounded-lg bg-purple-500/20 border border-purple-500/40 px-3 py-1 text-[10px] text-purple-400 hover:bg-purple-500/30 transition-colors disabled:opacity-40 hover:cursor-pointer",children:[s.jsx(ut,{className:"h-3 w-3",strokeWidth:2})," Save Condition"]}),r&&s.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-1 text-[10px] text-red-400/80 hover:bg-red-500/15 transition-colors hover:cursor-pointer",children:[s.jsx(Yt,{className:"h-3 w-3",strokeWidth:2})," Remove"]}),s.jsxs("button",{type:"button",onClick:f,className:"ml-auto flex items-center gap-1 rounded-lg border theme-border px-3 py-1 text-[10px] theme-text-muted hover:theme-text transition-colors hover:cursor-pointer",children:[s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})," Cancel"]})]})]})}function z3({step:n,index:r,total:i,status:o,result:u,allSteps:f,onConditionChange:h,waitingHuman:g}){const[x,m]=j.useState(!1),[p,b]=j.useState(!1),v=n.capture&&Object.keys(n.capture).length>0,N=n.inject&&Object.keys(n.inject).length>0,T=n.body&&Object.keys(n.body).length>0,_=!!n.condition,M=vf(n),A=[];for(let C=0;C<=r;C++){const D=f[C];Object.keys(D.capture??{}).forEach(W=>A.push(W)),Object.keys(D.captureInput??{}).forEach(W=>A.push(W))}const V=g?s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-500/15 text-amber-400",title:"Waiting for your input — answer the dialog to resume",children:s.jsx(zr,{className:"h-3 w-3 animate-pulse",strokeWidth:2})}):{idle:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border theme-border text-[9px] theme-text-faint",children:r+1}),running:s.jsx(dt,{className:"h-5 w-5 text-blue-400 animate-spin",strokeWidth:2}),passed:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-400",children:s.jsx(ut,{className:"h-3 w-3",strokeWidth:2})}),failed:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-red-500/10 text-red-400",children:s.jsx(Ht,{className:"h-3 w-3",strokeWidth:2})}),skipped:s.jsx("span",{className:"h-5 w-5 rounded-full border theme-border theme-bg-overlay-md"})}[o],L=_&&n.condition?(()=>{const C=n.condition.rules.all??n.condition.rules.any??[],D=n.condition.rules.all?"AND":"OR";return`${C.length} rule${C.length!==1?"s":""} ${D} → ${n.condition.onFail}`})():null;return s.jsxs("div",{className:"relative",children:[r<i-1&&s.jsx("div",{className:`absolute left-[19px] top-[38px] bottom-0 w-px z-0 transition-colors duration-500 ${o==="passed"?"bg-emerald-500/20":"bg-[var(--border)]"}`}),s.jsxs("div",{className:"relative z-10",children:[s.jsxs("button",{type:"button",onClick:()=>m(C=>!C),className:"flex w-full items-center gap-3 px-4 py-2.5 hover:theme-bg-overlay-md transition-colors text-left hover:cursor-pointer",children:[s.jsx("span",{className:"shrink-0",children:V}),s.jsx(v3,{method:n.method}),s.jsx("span",{className:"font-mono text-xs theme-text flex-1 truncate",children:n.path}),u&&s.jsxs("span",{className:`font-mono text-[10px] ${u.passed?"text-emerald-400":"text-red-400"}`,children:[u.status>0?u.status:"ERR"," · ",u.durationMs,"ms"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[N&&s.jsx("span",{className:"rounded bg-amber-500/10 px-1 py-0.5 text-[9px] text-amber-400",children:"auth"}),v&&s.jsx("span",{className:"rounded bg-blue-500/10 px-1 py-0.5 text-[9px] text-blue-400",children:"capture"}),M.length>0&&s.jsxs("span",{title:`Needs human input at runtime: ${M.map(C=>`{{human:${C}}}`).join(", ")}`,className:"rounded bg-orange-500/10 px-1 py-0.5 text-[9px] text-orange-400 flex items-center gap-0.5",children:[s.jsx(zr,{className:"h-2.5 w-2.5",strokeWidth:2})," human"]}),_&&s.jsxs("span",{className:"rounded bg-purple-500/10 px-1 py-0.5 text-[9px] text-purple-400 flex items-center gap-0.5",children:[s.jsx(ea,{className:"h-2.5 w-2.5",strokeWidth:2})," condition"]}),u?.conditionResult&&s.jsxs("span",{className:`rounded px-1 py-0.5 text-[9px] ${u.conditionResult.passed?"bg-purple-500/10 text-purple-400":"bg-orange-500/10 text-orange-400"}`,children:["◇ ",u.conditionResult.passed?"passed":"failed"]})]}),s.jsx("span",{className:"theme-text-faint shrink-0",children:x?s.jsx(qa,{className:"h-3.5 w-3.5"}):s.jsx(bl,{className:"h-3.5 w-3.5"})})]}),x&&s.jsxs("div",{className:"ml-12 mr-4 my-3 space-y-2.5 rounded-lg border-y theme-border theme-bg-overlay p-3",children:[n.description&&s.jsx("p",{className:"text-[11px] theme-text-muted",children:n.description}),u&&s.jsxs("div",{className:`rounded-lg border px-3 py-2 ${u.passed?"border-emerald-500/15 bg-emerald-500/[0.05]":"border-red-500/15 bg-red-500/[0.05]"}`,children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Response"}),u.error?s.jsx("p",{className:"text-[11px] text-red-400",children:u.error}):s.jsx("pre",{className:"text-[10px] theme-text-muted overflow-auto max-h-24 whitespace-pre-wrap break-all",children:typeof u.responseBody=="string"?u.responseBody.slice(0,300):JSON.stringify(u.responseBody,null,2).slice(0,300)})]}),T&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Request Body"}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.body).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border theme-border theme-bg-overlay-md px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] theme-text",children:C}),s.jsx("span",{className:"font-mono text-[10px] text-blue-400/80 truncate",children:String(D)})]},C))})]}),N&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider flex items-center gap-1",children:[s.jsx(A0,{className:"h-3 w-3",strokeWidth:2})," Inject"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.inject).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/[0.05] border border-amber-500/15 px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] text-amber-400/80",children:C}),s.jsx(dl,{className:"h-3 w-3 theme-text-faint shrink-0",strokeWidth:2}),s.jsx("span",{className:"font-mono text-[10px] theme-text-muted",children:D})]},C))})]}),v&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider flex items-center gap-1",children:[s.jsx(hs,{className:"h-3 w-3",strokeWidth:2})," Capture"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.capture).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-blue-500/[0.05] border border-blue-500/15 px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] text-blue-400",children:C}),s.jsx(dl,{className:"h-3 w-3 theme-text-faint shrink-0",strokeWidth:2}),s.jsx("span",{className:"font-mono text-[10px] theme-text-muted",children:D})]},C))})]}),s.jsxs("div",{className:"pt-1",children:[_&&L&&!p&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-purple-500/20 bg-purple-500/[0.04] px-3 py-2 mb-2",children:[s.jsx(ea,{className:"h-3 w-3 text-purple-400 shrink-0",strokeWidth:2}),s.jsx("span",{className:"text-[10px] text-purple-400 flex-1",children:L}),u?.conditionResult&&s.jsx("span",{className:`text-[9px] font-medium ${u.conditionResult.passed?"text-purple-400":"text-orange-400"}`,children:u.conditionResult.passed?"✓ passed":"✗ failed"}),s.jsx("button",{type:"button",onClick:()=>b(!0),className:"shrink-0 theme-text-faint hover:text-purple-400 transition-colors hover:cursor-pointer",children:s.jsx(Ov,{className:"h-3 w-3",strokeWidth:2})})]}),p?s.jsx(R3,{stepIndex:r,existingCondition:n.condition,capturedKeys:A,onSave:C=>{h(r,C),b(!1)},onRemove:()=>{h(r,void 0),b(!1)},onCancel:()=>b(!1)}):!_&&s.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex items-center gap-1.5 text-[10px] theme-text-faint hover:text-purple-400 transition-colors hover:cursor-pointer",children:[s.jsx(Dt,{className:"h-3 w-3",strokeWidth:2}),s.jsx(ea,{className:"h-3 w-3",strokeWidth:2}),"Add Condition"]})]})]})]})]})}function Ed(n){return{phase:"idle",currentStep:-1,stepStatuses:Array(n).fill("idle"),stepResults:Array(n).fill(null),passed:0,failed:0,humanKeys:[],notes:[]}}const my={run:"pre-seeded for this run",env:"environment variable",memory:"saved human memory",prompt:"your answer"};function O3({workflow:n,onDelete:r,onViewTraces:i}){const[o,u]=j.useState(n),[f,h]=j.useState("list"),[g,x]=j.useState(!1),[m,p]=j.useState(!1),[b,v]=j.useState(!1),[N,T]=j.useState(()=>Ed(o.steps.length)),[_,M]=j.useState(void 0),[A,V]=j.useState([]),[L,C]=j.useState(null),[D,W]=j.useState(""),X=j.useRef(!1),ie=j.useRef(null),I=j.useRef(""),K=j.useRef("local-sim"),ne=j.useRef({}),ee=j.useRef(new Set),se=j.useRef(null),[S,U]=j.useState(null),[k,H]=j.useState(""),[O,z]=j.useState(null),[E,$]=j.useState(!1),Z=j.useRef(null),ae=async(q,Y)=>{const ue=o.steps.map((P,Ee)=>{if(Ee!==q)return P;if(Y===void 0){const{condition:ge,...ke}=P;return ke}return{...P,condition:Y}}),re={...o,steps:ue};u(re);try{await b3(o._file,ue)}catch{}};j.useEffect(()=>{fetch("/api/model/environments").then(q=>q.ok?q.json():null).then(q=>{if(!q)return;const Y=q.environments??[];V(Y);const ue=q.defaultEnvironment??Y.find(P=>P.default)?.name??Y[0]?.name??null;C(ue);const re=Y.find(P=>P.name===ue);re&&W(re.baseUrl)}).catch(()=>{})},[]);const oe=async()=>{if(confirm(`Delete workflow "${o.name}"? This cannot be undone.`)){v(!0);try{await N3(o._file),r()}catch(q){alert(`Failed to delete: ${q.message}`),v(!1)}}},he=()=>{if(X.current=!0,ie.current?.close(),ie.current=null,Z.current){const q=Z.current;Z.current=null,U(null),q(null)}else S&&ve();T(q=>({...q,phase:q.phase==="running"?"aborted":q.phase}))},me=async(q,Y)=>{if(!se.current)throw new Error("Run id lost — please re-run the workflow.");const ue=await fetch("/api/workflows/human-input",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:se.current,key:q,value:Y})}),re=await ue.json().catch(()=>({}));if(!ue.ok)throw new Error(re.error??`HTTP ${ue.status}`)},Se=async()=>{if(S){if(Z.current){const q=Z.current;Z.current=null,U(null),H(""),q(k);return}$(!0),z(null);try{await me(S.key,k),U(null),H("")}catch(q){z(q.message)}finally{$(!1)}}},ve=async()=>{if(S){if(Z.current){const q=Z.current;Z.current=null,U(null),H(""),z(null),q(null);return}try{await me(S.key,null)}catch{}U(null),H(""),z(null)}},Ae=()=>{he(),T(Ed(o.steps.length))},Re=async(q,Y,ue)=>{const re=new Date().toISOString(),P={id:crypto.randomUUID(),workflowName:o.name,workflowFile:o._file,startedAt:ue,finishedAt:re,durationMs:q.stepResults.reduce((ge,ke)=>ge+(ke?.durationMs??0),0),phase:q.phase==="done"?"done":q.phase==="aborted"?"aborted":"error",passed:q.passed,failed:q.failed,baseUrl:q.baseUrl,source:Y,steps:o.steps.map((ge,ke)=>{const Oe=q.stepResults[ke];return{index:ke,name:ge.name,method:ge.method,path:ge.path,description:ge.description,status:Oe?.status??0,passed:Oe?.passed??!1,durationMs:Oe?.durationMs??0,captured:Object.fromEntries((Oe?.captured??[]).map(ze=>[ze,"(captured)"])),injected:Oe?.injected??{},requestBody:ge.body,responseBody:Oe?.responseBody,error:Oe?.error??null,expectStatus:ge.expectStatus,captureSpec:ge.capture,injectSpec:ge.inject,conditionSpec:ge.condition,conditionResult:Oe?.conditionResult}})},Ee=await g2(P);M(Ee)},We=q=>{X.current=!1,se.current=null,ee.current=new Set,Z.current=null,U(null),H(""),z(null);const Y=o.steps.length;T({...Ed(Y),baseUrl:D||void 0}),M(void 0),I.current=new Date().toISOString(),K.current="local-sim",x(!0);const ue=(P,Ee,ge)=>new Promise(ke=>{H(""),z(null),U({key:P,stepIndex:Ee,stepName:ge}),Z.current=ke}),re=async()=>{T(Oe=>({...Oe,phase:"running",baseUrl:D||Oe.baseUrl})),ne.current={};let P=0,Ee=0,ge=!1,ke="";for(let Oe=0;Oe<Y&&!(X.current||ge);Oe++){const ze=o.steps[Oe],Tt=vf(ze);for(const pe of Tt){if(X.current)break;if(ne.current[`human:${pe}`]!==void 0)continue;T(je=>{const Le=[...je.stepStatuses];return Le[Oe]="running",{...je,stepStatuses:Le,currentStep:Oe}});const Ve=await ue(pe,Oe,ze.name);if(Ve===null||X.current){T(je=>({...je,phase:"aborted",error:"Run cancelled by user"}));return}ne.current[`human:${pe}`]=Ve,T(je=>({...je,notes:[...je.notes??[],`↳ human {{human:${pe}}} ← your answer`]}))}if(X.current)break;T(pe=>{const Ve=[...pe.stepStatuses];return Ve[Oe]="running",{...pe,stepStatuses:Ve,currentStep:Oe}});const Mt=600+Math.random()*800;if(await new Promise(pe=>{const Ve=setTimeout(pe,Mt),je=setInterval(()=>{X.current&&(clearTimeout(Ve),clearInterval(je),pe())},50);setTimeout(()=>clearInterval(je),Mt+100)}),X.current)break;Object.keys(ze.capture??{}).forEach(pe=>{ne.current[pe]="[simulated]"}),Object.keys(ze.captureInput??{}).forEach(pe=>{ne.current[pe]="[simulated]"});let ft;if(ze.condition&&(ft=y3(ze.condition,ne.current),!ft.passed)){const{onFail:pe,returnOnComplete:Ve}=ze.condition;pe==="abort"?(ge=!0,ke=`Condition failed at step ${Oe+1}: ${ft.reason}`):pe==="continue"?(ge=!0,ke="Condition failed → continuing without remaining steps"):pe==="switch"&&(Ve||(ge=!0,ke=`Condition failed → switched to: ${ze.condition.switchToWorkflow??"unknown"}`))}const nt=!0,pt=Math.round(Mt),at={index:Oe,step:{name:ze.name,method:ze.method,path:ze.path,description:ze.description},status:200,passed:nt,durationMs:pt,captured:Object.keys(ze.capture??{}).map(pe=>pe.split(":").pop()??pe),injected:{},responseBody:{simulated:!0},error:null,conditionResult:ft};if(P++,T(pe=>{const Ve=[...pe.stepStatuses],je=[...pe.stepResults];return Ve[Oe]="passed",je[Oe]=at,{...pe,stepStatuses:Ve,stepResults:je,passed:P,failed:Ee}}),ge)break}if(!X.current)if(ge){const Oe={phase:"aborted",stepStatuses:N.stepStatuses,stepResults:N.stepResults,passed:P,failed:Ee,baseUrl:D||void 0};T(ze=>({...ze,phase:"aborted",error:ke})),Re(Oe,"local-sim",I.current)}else{const Oe={phase:"done",stepStatuses:Array(Y).fill("passed"),stepResults:o.steps.map((ze,Tt)=>({index:Tt,step:{name:ze.name,method:ze.method,path:ze.path,description:ze.description},status:200,passed:!0,durationMs:Math.round(600+Math.random()*800),captured:Object.keys(ze.capture??{}).map(Mt=>Mt.split(":").pop()??Mt),injected:{},responseBody:{simulated:!0},error:null})),passed:P,failed:Ee};T(ze=>({...ze,phase:"done",passed:P,failed:Ee})),Re(Oe,"local-sim",I.current)}};fetch("/api/workflows/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:o._file,baseUrl:D||void 0,humanInputs:q})}).then(P=>{if(!P.ok||!P.body){re();return}K.current="api";const Ee=P.body.getReader(),ge=new TextDecoder;let ke="";T(ze=>({...ze,phase:"running"})),(async()=>{let ze=!1;for(;!X.current;){const{value:Tt,done:Mt}=await Ee.read();if(Mt)break;ze=!0,ke+=ge.decode(Tt,{stream:!0});const ft=ke.split(`
391
+ M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fill:x,fillRule:"evenodd",stroke:m,strokeWidth:p,pointerEvents:"none"})))}oy.displayName="MiniMap";var l3=j.memo(oy);function r3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},le.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function i3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function o3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},le.createElement("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 c3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("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 u3(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("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"}))}const Mr=({children:n,className:r,...i})=>le.createElement("button",{type:"button",className:$t(["react-flow__controls-button",r]),...i},n);Mr.displayName="ControlButton";const d3=n=>({isInteractive:n.nodesDraggable||n.nodesConnectable||n.elementsSelectable,minZoomReached:n.transform[2]<=n.minZoom,maxZoomReached:n.transform[2]>=n.maxZoom}),cy=({style:n,showZoom:r=!0,showFitView:i=!0,showInteractive:o=!0,fitViewOptions:u,onZoomIn:f,onZoomOut:h,onFitView:g,onInteractiveChange:x,className:m,children:p,position:b="bottom-left"})=>{const v=Nt(),[N,T]=j.useState(!1),{isInteractive:_,minZoomReached:M,maxZoomReached:A}=tt(d3,Ct),{zoomIn:V,zoomOut:L,fitView:C}=xf();if(j.useEffect(()=>{T(!0)},[]),!N)return null;const D=()=>{V(),f?.()},W=()=>{L(),h?.()},X=()=>{C(u),g?.()},ie=()=>{v.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),x?.(!_)};return le.createElement(rf,{className:$t(["react-flow__controls",m]),position:b,style:n,"data-testid":"rf__controls"},r&&le.createElement(le.Fragment,null,le.createElement(Mr,{onClick:D,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:A},le.createElement(r3,null)),le.createElement(Mr,{onClick:W,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:M},le.createElement(i3,null))),i&&le.createElement(Mr,{className:"react-flow__controls-fitview",onClick:X,title:"fit view","aria-label":"fit view"},le.createElement(o3,null)),o&&le.createElement(Mr,{className:"react-flow__controls-interactive",onClick:ie,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(u3,null):le.createElement(c3,null)),p)};cy.displayName="Controls";var uy=j.memo(cy),ln;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(ln||(ln={}));function f3({color:n,dimensions:r,lineWidth:i}){return le.createElement("path",{stroke:n,strokeWidth:i,d:`M${r[0]/2} 0 V${r[1]} M0 ${r[1]/2} H${r[0]}`})}function h3({color:n,radius:r}){return le.createElement("circle",{cx:r,cy:r,r,fill:n})}const m3={[ln.Dots]:"#91919a",[ln.Lines]:"#eee",[ln.Cross]:"#e2e2e2"},p3={[ln.Dots]:1,[ln.Lines]:1,[ln.Cross]:6},x3=n=>({transform:n.transform,patternId:`pattern-${n.rfId}`});function dy({id:n,variant:r=ln.Dots,gap:i=20,size:o,lineWidth:u=1,offset:f=2,color:h,style:g,className:x}){const m=j.useRef(null),{transform:p,patternId:b}=tt(x3,Ct),v=h||m3[r],N=o||p3[r],T=r===ln.Dots,_=r===ln.Cross,M=Array.isArray(i)?i:[i,i],A=[M[0]*p[2]||1,M[1]*p[2]||1],V=N*p[2],L=_?[V,V]:A,C=T?[V/f,V/f]:[L[0]/f,L[1]/f];return le.createElement("svg",{className:$t(["react-flow__background",x]),style:{...g,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:m,"data-testid":"rf__background"},le.createElement("pattern",{id:b+n,x:p[0]%A[0],y:p[1]%A[1],width:A[0],height:A[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},T?le.createElement(h3,{color:v,radius:V/f}):le.createElement(f3,{dimensions:L,color:v,lineWidth:u})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${b+n})`}))}dy.displayName="Background";var fy=j.memo(dy);const d0={GET:{bg:"bg-emerald-500/10",text:"text-emerald-400",dot:"#34d399"},POST:{bg:"bg-blue-500/10",text:"text-blue-400",dot:"#60a5fa"},PUT:{bg:"bg-amber-500/10",text:"text-amber-400",dot:"#fbbf24"},PATCH:{bg:"bg-orange-500/10",text:"text-orange-400",dot:"#fb923c"},DELETE:{bg:"bg-red-500/10",text:"text-red-400",dot:"#f87171"},HEAD:{bg:"theme-bg-overlay-md",text:"theme-text-muted",dot:"var(--text-muted)"},OPTIONS:{bg:"bg-purple-500/10",text:"text-purple-400",dot:"#c084fc"}};function bf(n){return d0[n.toUpperCase()]??d0.GET}const f0=["exists","not_exists","is_empty","is_not_empty"];function h0(n,r){return n.replace(/\{\{([^}]+)\}\}/g,(i,o)=>{const u=o.trim();if(u.includes(":")){const f=u.indexOf(":"),h=u.slice(0,f),g=u.slice(f+1);return r[`${h}:${g}`]??r[g]??""}return r[u]??""})}function g3(n,r){const i=h0(n.left,r),o=n.right!==void 0?h0(n.right,r):void 0;switch(n.operator){case"equals":return i===o;case"not_equals":return i!==o;case"greater_than":return Number(i)>Number(o);case"greater_than_or_equal":return Number(i)>=Number(o);case"less_than":return Number(i)<Number(o);case"less_than_or_equal":return Number(i)<=Number(o);case"exists":return i!==""&&i!==void 0;case"not_exists":return i===""||i===void 0;case"is_empty":return i===""||i===null;case"is_not_empty":return i!==""&&i!==null;case"contains":return o!==void 0&&i.includes(o);case"not_contains":return o!==void 0&&!i.includes(o);case"starts_with":return o!==void 0&&i.startsWith(o);case"ends_with":return o!==void 0&&i.endsWith(o);default:return!1}}function y3(n,r){const{rules:i}=n,o=i?.all??i?.any??[],u=!!i?.all;if(o.length===0)return{passed:!0,reason:"No rules"};const f=o.map(m=>({rule:m,ok:g3(m,r)})),h=u?f.every(m=>m.ok):f.some(m=>m.ok),g=f.filter(m=>!m.ok),x=h?`All conditions met (${u?"AND":"OR"})`:`Failed: ${g.map(m=>`${m.rule.left} ${m.rule.operator}${m.rule.right!==void 0?" "+m.rule.right:""}`).join(", ")}`;return{passed:h,reason:x}}async function b3(n,r){const i=n.replace(/^workflows\//,"").replace(/\.json$/,"");await fetch(`/api/workflows/${encodeURIComponent(i)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({steps:r})})}function v3({method:n}){const r=bf(n);return s.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium tracking-widest ${r.bg} ${r.text}`,children:n.toUpperCase()})}async function j3(){const n=await fetch("/api/workflows");if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function N3(n){const r=n.replace(/^workflows\//,"").replace(/\.json$/,""),i=await fetch(`/api/workflows/${encodeURIComponent(r)}`,{method:"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`HTTP ${i.status}`)}}const m0=/\{\{\s*human:([^}]+?)\s*\}\}/g;function vf(n){const r=new Set;for(const i of[n.path,JSON.stringify(n.body??{}),JSON.stringify(n.inject??{}),JSON.stringify(n.condition??{})]){if(!i)continue;m0.lastIndex=0;let o;for(;(o=m0.exec(i))!==null;){const u=o[1].trim();u&&r.add(u)}}return[...r]}function w3(n){const r=new Set;return n.forEach(i=>vf(i).forEach(o=>r.add(o))),[...r]}function S3(n){return/pass|secret|token|pwd|private|credential/i.test(n)}function E3({title:n,subtitle:r,fields:i,values:o,onChange:u,onSubmit:f,onCancel:h,submitLabel:g,error:x,submitting:m}){return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:s.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-amber-500/25 theme-bg-overlay shadow-2xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b theme-border",children:[s.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-500/15 text-amber-400",children:s.jsx(zr,{className:"h-3.5 w-3.5",strokeWidth:2})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[12px] font-medium theme-text-primary",children:n}),r&&s.jsx("p",{className:"text-[10px] theme-text-faint truncate",children:r})]})]}),s.jsxs("div",{className:"space-y-2.5 p-4",children:[s.jsx("p",{className:"text-[11px] theme-text-muted",children:"This workflow needs a value only you know. The run stays paused until you answer."}),i.map(p=>s.jsxs("div",{children:[s.jsx("label",{className:"mb-1 block font-mono text-[10px] text-amber-400/90",children:`{{human:${p.key}}}`}),s.jsx("input",{autoFocus:i.length===1,type:S3(p.key)?"password":"text",value:o[p.key]??"",onChange:b=>u(p.key,b.target.value),onKeyDown:b=>{b.key==="Enter"&&f()},placeholder:p.hint??`Enter ${p.key}…`,className:"h-8 w-full rounded-lg border border-amber-500/30 theme-bg-overlay-md px-2.5 text-[12px] theme-text-primary placeholder-[var(--text-faint)] outline-none focus:border-amber-500/70 transition-colors"})]},p.key)),x&&s.jsx("p",{className:"text-[10px] text-red-400 leading-tight",children:x}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:f,disabled:!!m,className:"flex h-8 flex-1 items-center justify-center gap-1.5 rounded-lg bg-amber-500/20 border border-amber-500/40 px-3 text-[11px] font-medium text-amber-300 hover:bg-amber-500/30 transition-colors disabled:opacity-40 hover:cursor-pointer",children:[m?s.jsx(dt,{className:"h-3 w-3 animate-spin",strokeWidth:2}):s.jsx(ut,{className:"h-3 w-3",strokeWidth:2}),g]}),h&&s.jsxs("button",{type:"button",onClick:h,className:"flex h-8 items-center gap-1 rounded-lg border theme-border px-3 text-[11px] theme-text-muted hover:theme-text transition-colors hover:cursor-pointer",children:[s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})," Cancel run"]})]})]})]})})}const hy=230,Wd=64;function k3({data:n}){const r=bf(n.method),i={idle:"theme-border",running:"border-blue-500/60",passed:"border-emerald-500/40",failed:"border-red-500/40",skipped:"theme-border"},o={idle:"",running:"shadow-[0_0_12px_rgba(96,165,250,0.28)]",passed:"shadow-[0_0_8px_rgba(52,211,153,0.15)]",failed:"shadow-[0_0_8px_rgba(248,113,113,0.15)]",skipped:""},u=n.status??"idle";return s.jsxs("div",{className:`rounded-lg border theme-bg-overlay flex items-center gap-2.5 px-3 overflow-hidden transition-all duration-300 ${i[u]} ${o[u]}`,style:{width:hy,height:Wd},children:[s.jsx(jt,{type:"target",position:xe.Top,style:{background:"transparent",border:"none"}}),s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[3px] transition-colors duration-300",style:{background:u==="running"?"#60a5fa":u==="passed"?r.dot:u==="failed"?"#f87171":r.dot+"60"}}),s.jsxs("div",{className:"shrink-0 flex items-center justify-center",children:[u==="running"&&s.jsx(dt,{className:"h-3.5 w-3.5 text-blue-400 animate-spin",strokeWidth:2}),u==="passed"&&s.jsx(ut,{className:"h-3.5 w-3.5 text-emerald-400",strokeWidth:2}),u==="failed"&&s.jsx(Ht,{className:"h-3.5 w-3.5 text-red-400",strokeWidth:2}),u==="idle"&&s.jsx("span",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-full border theme-border text-[8px] font-medium theme-text-faint",children:n.index+1}),u==="skipped"&&s.jsx("span",{className:"h-3.5 w-3.5 rounded-full border theme-border theme-bg-overlay-md"})]}),s.jsxs("div",{className:"min-w-0 flex-1 pl-0.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[s.jsx("span",{className:`text-[9px] font-medium ${r.text}`,children:n.method}),s.jsx("span",{className:"font-mono text-[10px] theme-text truncate",children:n.path}),n.result&&s.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[9px] ${n.result.passed?"text-emerald-400":"text-red-400"}`,children:[n.result.status>0?n.result.status:"ERR"," · ",n.result.durationMs,"ms"]})]}),s.jsx("p",{className:"text-[9px] theme-text-faint truncate",children:n.name})]}),s.jsx(jt,{type:"source",position:xe.Bottom,style:{background:"transparent",border:"none"}})]})}function _3({data:n}){const r=n.passed,i=r===void 0?"rgba(96,165,250,0.5)":r?"rgba(52,211,153,0.7)":"rgba(248,113,113,0.7)";return s.jsxs("div",{style:{width:40,height:40,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[s.jsx(jt,{type:"target",position:xe.Top,style:{background:"transparent",border:"none"}}),s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",children:[s.jsx("polygon",{points:"20,2 38,20 20,38 2,20",fill:"none",stroke:i,strokeWidth:"1.5"}),s.jsx("polygon",{points:"20,8 32,20 20,32 8,20",fill:i,fillOpacity:.12,stroke:"none"})]}),s.jsx("span",{style:{position:"absolute",fontSize:8,fontFamily:"monospace",color:i,top:"50%",left:"50%",transform:"translate(-50%,-50%)",whiteSpace:"nowrap"},children:"◇"}),s.jsx(jt,{type:"source",position:xe.Bottom,style:{background:"transparent",border:"none"}})]})}const C3={step:k3,condition:_3};function T3({steps:n,runState:r}){const[i,o,u]=ly([]),[f,h,g]=ry([]);j.useEffect(()=>{const v=[],N=[];let T=40;for(let _=0;_<n.length;_++){const M=n[_],A=r.stepStatuses[_]??"idle",V=r.stepResults[_]??null;if(v.push({id:`step-${_}`,type:"step",position:{x:0,y:T},data:{index:_,name:M.name,method:M.method,path:M.path,status:A,result:V}}),T+=Wd+36,M.condition){const L=`cond-${_}`,C=V?.conditionResult;v.push({id:L,type:"condition",position:{x:hy/2-20,y:T},data:{passed:C?.passed}});const D=A==="passed"?"rgba(52,211,153,0.3)":A==="failed"?"rgba(248,113,113,0.3)":"rgba(96,165,250,0.18)";if(N.push({id:`e-${_}-cond`,source:`step-${_}`,target:L,style:{stroke:D,strokeWidth:1.5},markerEnd:{type:Ba.ArrowClosed,color:D},animated:A==="running"}),T+=64,_<n.length-1){const W=C?.passed===!0?"rgba(52,211,153,0.5)":"rgba(96,165,250,0.18)",X=C?.passed===!1?"rgba(248,113,113,0.5)":"rgba(96,165,250,0.1)";N.push({id:`e-${_}-cond-pass`,source:L,target:`step-${_+1}`,label:"PASS",labelStyle:{fill:"rgba(52,211,153,0.8)",fontSize:8,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:W,strokeWidth:1.2},markerEnd:{type:Ba.ArrowClosed,color:W}}),N.push({id:`e-${_}-cond-fail`,source:L,target:`step-${_+1}`,label:`FAIL→${M.condition.onFail.toUpperCase()}`,labelStyle:{fill:"rgba(248,113,113,0.8)",fontSize:8,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:X,strokeWidth:1.2,strokeDasharray:"4 3"}})}}else if(_<n.length-1){const L=Object.keys(M.capture??{}),C=L.length>0?L.map(X=>X.split(":").pop()).join(", "):void 0,D=r.stepStatuses[_]??"idle",W=D==="passed"?"rgba(52,211,153,0.3)":D==="failed"?"rgba(248,113,113,0.3)":"rgba(96,165,250,0.18)";N.push({id:`e-${_}`,source:`step-${_}`,target:`step-${_+1}`,label:C,labelStyle:{fill:"rgba(96,165,250,0.7)",fontSize:9,fontFamily:"monospace"},labelBgStyle:{fill:"transparent"},style:{stroke:W,strokeWidth:1.5,strokeDasharray:D==="idle"||D==="running"?"5 5":void 0},markerEnd:{type:Ba.ArrowClosed,color:D==="passed"?"rgba(52,211,153,0.4)":"rgba(96,165,250,0.3)"},animated:D==="running"})}}o(v),h(N)},[n,r.stepStatuses,r.stepResults]);const x=n.reduce((m,p)=>m+Wd+36+(p.condition?64:0),40);return s.jsx("div",{style:{height:Math.max(400,x)},className:"w-full rounded-lg overflow-hidden",children:s.jsxs(yf,{nodes:i,edges:f,onNodesChange:u,onEdgesChange:g,nodeTypes:C3,fitView:!0,fitViewOptions:{padding:.3},proOptions:{hideAttribution:!0},minZoom:.3,maxZoom:2,children:[s.jsx(fy,{variant:ln.Dots,gap:20,size:1,color:"var(--border)"}),s.jsx(uy,{showInteractive:!1,className:"theme-bg-overlay border theme-border"})]})})}function M3({runState:n,steps:r,waitingStepIndex:i}){const o=j.useRef(null);return j.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n.stepResults,n.phase]),n.phase==="idle"?null:s.jsxs("div",{className:"mt-3 rounded-lg border theme-border theme-bg-overlay",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b theme-border theme-bg-overlay-md",children:[s.jsx("span",{className:"text-[10px] font-semibold theme-text-muted uppercase tracking-wider",children:"Run Log"}),n.baseUrl&&s.jsxs("span",{className:"font-mono text-[10px] theme-text-faint",children:["→ ",n.baseUrl]}),s.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px]",children:[n.passed>0&&s.jsxs("span",{className:"text-emerald-400",children:[n.passed," passed"]}),n.failed>0&&s.jsxs("span",{className:"text-red-400",children:[n.failed," failed"]}),n.phase==="running"&&s.jsx(dt,{className:"h-3 w-3 text-blue-400 animate-spin",strokeWidth:2}),n.phase==="done"&&s.jsx(ut,{className:"h-3 w-3 text-emerald-400",strokeWidth:2}),n.phase==="aborted"&&s.jsx(Ht,{className:"h-3 w-3 text-red-400",strokeWidth:2})]})]}),s.jsxs("div",{ref:o,className:"overflow-y-auto max-h-80 font-mono text-[11px] p-3 space-y-1",children:[s.jsx("p",{className:"theme-text-faint",children:"▶ Starting workflow execution…"}),n.humanUnsupported&&s.jsxs("p",{className:"text-red-400",children:["⚠ Connected server doesn't support ","{{human:*}}"," — restart `jetic dev` from the latest build. Human values will resolve empty and the dialog will never appear."]}),(n.humanKeys??[]).filter(u=>u.source==="prompt").map(u=>s.jsxs("p",{className:"text-amber-400",children:["◉ will ask for ",`{{human:${u.key}}}`," when reached"]},`need-${u.key}`)),(n.humanKeys??[]).filter(u=>u.source!=="prompt").map(u=>s.jsxs("p",{className:"theme-text-faint",children:["↳ human ",`{{human:${u.key}}}`," ← ",my[u.source]??u.source," (ready)"]},`have-${u.key}`)),(n.notes??[]).map((u,f)=>s.jsx("p",{className:"theme-text-faint",children:u},`note-${f}`)),n.stepResults.map((u,f)=>{if(!u&&n.stepStatuses[f]!=="running")return null;const h=r[f],g=bf(h.method);return n.stepStatuses[f]==="running"?s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 theme-text-muted",children:[s.jsx(dt,{className:"h-3 w-3 animate-spin text-blue-400",strokeWidth:2}),s.jsxs("span",{className:"theme-text-faint",children:["Step ",f+1,"/",r.length]}),s.jsx("span",{className:g.text,children:h.method}),s.jsx("span",{className:"theme-text",children:h.path}),s.jsx("span",{className:"theme-text-faint",children:"…"})]}),i===f&&s.jsx("p",{className:"pl-5 text-amber-400",children:"⏳ Waiting for your input — answer the dialog to resume the run."})]},f):u?s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:u.passed?"text-emerald-400":"text-red-400",children:u.passed?"✓":"✗"}),s.jsxs("span",{className:"theme-text-faint",children:["Step ",f+1,"/",r.length]}),s.jsx("span",{className:`${g.text}`,children:h.method.padEnd(6)}),s.jsx("span",{className:"theme-text",children:h.path}),s.jsx("span",{className:`${u.passed?"text-emerald-400":"text-red-400"}`,children:u.status>0?u.status:"NO RESPONSE"}),s.jsxs("span",{className:"theme-text-faint",children:[u.durationMs,"ms"]})]}),h.name&&s.jsx("p",{className:"pl-5 theme-text-faint italic",children:h.name}),Object.entries(u.injected??{}).filter(([m])=>m!=="Content-Type").map(([m,p])=>s.jsxs("p",{className:"pl-5 theme-text-faint",children:["↳ ",s.jsxs("span",{className:"text-amber-500/80",children:[m,":"]})," ",s.jsx("span",{className:"theme-text-faint",children:String(p).length>60?String(p).slice(0,57)+"…":p})]},m)),u.captured.map((m,p)=>s.jsxs("p",{className:"pl-5 text-emerald-400",children:["↳ captured ",m]},p)),u.conditionResult&&s.jsxs("p",{className:`pl-5 ${u.conditionResult.passed?"text-purple-400":"text-orange-400"}`,children:["◇ condition ",u.conditionResult.passed?"passed":"failed"," — ",u.conditionResult.reason,!u.conditionResult.passed&&h.condition&&s.jsxs("span",{className:"text-orange-300/70",children:[" → ",h.condition.onFail,h.condition.onFail==="switch"&&h.condition.switchToWorkflow?`: ${h.condition.switchToWorkflow}`:""]})]}),u.error&&s.jsxs("p",{className:"pl-5 text-red-400",children:["Error: ",u.error]}),!u.passed&&u.responseBody&&!u.error&&s.jsxs("p",{className:"pl-5 text-red-400/80 truncate",children:["Response: ",typeof u.responseBody=="string"?u.responseBody.slice(0,120):JSON.stringify(u.responseBody).slice(0,120)]})]},f):null}),n.phase==="done"&&s.jsxs("p",{className:`mt-1 ${n.failed===0?"text-emerald-400":"text-amber-400"}`,children:["✓ Done — ",n.passed,"/",n.passed+n.failed," steps passed"]}),n.phase==="aborted"&&s.jsxs("p",{className:"mt-1 text-red-400",children:["✗ Aborted — ",n.error]}),n.phase==="error"&&s.jsxs("p",{className:"mt-1 text-red-400",children:["✗ Error — ",n.error]})]})]})}const A3=[{label:"Equality",ops:[{value:"equals",label:"equals"},{value:"not_equals",label:"not equals"}]},{label:"Comparison",ops:[{value:"greater_than",label:"greater than"},{value:"greater_than_or_equal",label:"greater than or equal"},{value:"less_than",label:"less than"},{value:"less_than_or_equal",label:"less than or equal"}]},{label:"Existence",ops:[{value:"exists",label:"exists"},{value:"not_exists",label:"does not exist"},{value:"is_empty",label:"is empty"},{value:"is_not_empty",label:"is not empty"}]},{label:"Text / Collection",ops:[{value:"contains",label:"contains"},{value:"not_contains",label:"does not contain"},{value:"starts_with",label:"starts with"},{value:"ends_with",label:"ends with"}]}];function p0(){return{left:"",operator:"equals",right:""}}function R3({stepIndex:n,existingCondition:r,capturedKeys:i,onSave:o,onRemove:u,onCancel:f}){const[h,g]=j.useState(r?.rules?.all?"all":r?.rules?.any?"any":"all"),x=r?.rules?.all??r?.rules?.any??[],[m,p]=j.useState(x.length>0?x:[p0()]),[b,v]=j.useState(r?.onFail??"abort"),[N,T]=j.useState(r?.switchToWorkflow??""),[_,M]=j.useState(r?.returnOnComplete??!0),A=(X,ie)=>{p(I=>I.map((K,ne)=>ne===X?{...K,...ie}:K))},V=()=>p(X=>[...X,p0()]),L=X=>p(ie=>ie.filter((I,K)=>K!==X)),C=()=>{const X=m.filter(I=>I.left.trim()!=="");if(X.length===0)return;const ie={rules:h==="all"?{all:X}:{any:X},onFail:b,...b==="switch"&&N.trim()?{switchToWorkflow:N.trim(),returnOnComplete:_}:{}};o(ie)},D="h-7 rounded-lg border theme-border theme-bg-overlay-md px-2 text-[11px] theme-text-primary placeholder-[var(--text-faint)] outline-none focus:border-purple-500/60 transition-colors",W=`${D} cursor-pointer`;return s.jsxs("div",{className:"mt-2 rounded-lg border border-purple-500/20 bg-purple-500/[0.04] p-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ea,{className:"h-3 w-3 text-purple-400",strokeWidth:2}),s.jsx("span",{className:"text-[10px] font-semibold text-purple-400 uppercase tracking-wider",children:"Step Condition"}),s.jsx("span",{className:"text-[10px] theme-text-faint ml-1",children:"— evaluated after this step runs"}),s.jsx("div",{className:"ml-auto flex items-center gap-1",children:["all","any"].map(X=>s.jsx("button",{type:"button",onClick:()=>g(X),className:`px-2 py-0.5 rounded text-[9px] font-semibold transition-colors hover:cursor-pointer ${h===X?"bg-purple-500/20 text-purple-400 border border-purple-500/40":"theme-bg-overlay-md theme-text-faint border theme-border hover:theme-text-muted"}`,children:X==="all"?"AND":"OR"},X))})]}),s.jsxs("div",{className:"space-y-2",children:[m.map((X,ie)=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("input",{list:`cond-left-${n}-${ie}`,value:X.left,onChange:I=>A(ie,{left:I.target.value}),placeholder:"{{workflow:key}} or value",className:`flex-1 min-w-0 ${D}`}),s.jsx("datalist",{id:`cond-left-${n}-${ie}`,children:i.map(I=>s.jsx("option",{value:`{{${I}}}`},I))}),s.jsx("select",{value:X.operator,onChange:I=>A(ie,{operator:I.target.value,right:f0.includes(I.target.value)?void 0:X.right}),className:`w-44 shrink-0 ${W}`,children:A3.map(I=>s.jsx("optgroup",{label:I.label,children:I.ops.map(K=>s.jsx("option",{value:K.value,children:K.label},K.value))},I.label))}),f0.includes(X.operator)?s.jsx("div",{className:"flex-1"}):s.jsx("input",{value:X.right??"",onChange:I=>A(ie,{right:I.target.value}),placeholder:"value or {{workflow:key}}",className:`flex-1 min-w-0 ${D}`}),m.length>1&&s.jsx("button",{type:"button",onClick:()=>L(ie),className:"shrink-0 theme-text-faint hover:text-red-400 transition-colors hover:cursor-pointer",children:s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})})]},ie)),s.jsxs("button",{type:"button",onClick:V,className:"flex items-center gap-1 text-[10px] text-purple-400/70 hover:text-purple-400 transition-colors hover:cursor-pointer",children:[s.jsx(Dt,{className:"h-3 w-3",strokeWidth:2})," Add rule"]})]}),s.jsxs("div",{className:"flex flex-col gap-2 pt-1 border-t border-purple-500/10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] theme-text-faint shrink-0",children:"If condition fails →"}),["abort","continue","switch"].map(X=>s.jsx("button",{type:"button",onClick:()=>v(X),className:`px-2 py-0.5 rounded text-[9px] font-medium capitalize transition-colors border hover:cursor-pointer ${b===X?X==="abort"?"bg-red-500/20 text-red-400 border-red-500/40":X==="continue"?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"bg-blue-500/20 text-blue-400 border-blue-500/40":"theme-bg-overlay-md theme-text-faint theme-border hover:theme-text-muted"}`,children:X},X)),b==="switch"&&s.jsx("input",{value:N,onChange:X=>T(X.target.value),placeholder:"workflow-slug",className:`flex-1 ${D}`})]}),b==="switch"&&s.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] theme-text-muted cursor-pointer select-none ml-1",children:[s.jsx("input",{type:"checkbox",checked:_,onChange:X=>M(X.target.checked),className:"rounded theme-border theme-bg-overlay-md text-purple-500 focus:ring-0"}),s.jsxs("span",{children:["Return to main workflow after completing ",s.jsx("code",{className:"text-purple-400",children:N||"sub-workflow"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",onClick:C,disabled:m.every(X=>!X.left.trim()),className:"flex items-center gap-1 rounded-lg bg-purple-500/20 border border-purple-500/40 px-3 py-1 text-[10px] text-purple-400 hover:bg-purple-500/30 transition-colors disabled:opacity-40 hover:cursor-pointer",children:[s.jsx(ut,{className:"h-3 w-3",strokeWidth:2})," Save Condition"]}),r&&s.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-1 text-[10px] text-red-400/80 hover:bg-red-500/15 transition-colors hover:cursor-pointer",children:[s.jsx(Yt,{className:"h-3 w-3",strokeWidth:2})," Remove"]}),s.jsxs("button",{type:"button",onClick:f,className:"ml-auto flex items-center gap-1 rounded-lg border theme-border px-3 py-1 text-[10px] theme-text-muted hover:theme-text transition-colors hover:cursor-pointer",children:[s.jsx(_t,{className:"h-3 w-3",strokeWidth:2})," Cancel"]})]})]})}function z3({step:n,index:r,total:i,status:o,result:u,allSteps:f,onConditionChange:h,waitingHuman:g}){const[x,m]=j.useState(!1),[p,b]=j.useState(!1),v=n.capture&&Object.keys(n.capture).length>0,N=n.inject&&Object.keys(n.inject).length>0,T=n.body&&Object.keys(n.body).length>0,_=!!n.condition,M=vf(n),A=[];for(let C=0;C<=r;C++){const D=f[C];Object.keys(D.capture??{}).forEach(W=>A.push(W)),Object.keys(D.captureInput??{}).forEach(W=>A.push(W))}const V=g?s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-500/15 text-amber-400",title:"Waiting for your input — answer the dialog to resume",children:s.jsx(zr,{className:"h-3 w-3 animate-pulse",strokeWidth:2})}):{idle:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border theme-border text-[9px] theme-text-faint",children:r+1}),running:s.jsx(dt,{className:"h-5 w-5 text-blue-400 animate-spin",strokeWidth:2}),passed:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-400",children:s.jsx(ut,{className:"h-3 w-3",strokeWidth:2})}),failed:s.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-red-500/10 text-red-400",children:s.jsx(Ht,{className:"h-3 w-3",strokeWidth:2})}),skipped:s.jsx("span",{className:"h-5 w-5 rounded-full border theme-border theme-bg-overlay-md"})}[o],L=_&&n.condition?(()=>{const C=n.condition.rules.all??n.condition.rules.any??[],D=n.condition.rules.all?"AND":"OR";return`${C.length} rule${C.length!==1?"s":""} ${D} → ${n.condition.onFail}`})():null;return s.jsxs("div",{className:"relative",children:[r<i-1&&s.jsx("div",{className:`absolute left-[19px] top-[38px] bottom-0 w-px z-0 transition-colors duration-500 ${o==="passed"?"bg-emerald-500/20":"bg-[var(--border)]"}`}),s.jsxs("div",{className:"relative z-10",children:[s.jsxs("button",{type:"button",onClick:()=>m(C=>!C),className:"flex w-full items-center gap-3 px-4 py-2.5 hover:theme-bg-overlay-md transition-colors text-left hover:cursor-pointer",children:[s.jsx("span",{className:"shrink-0",children:V}),s.jsx(v3,{method:n.method}),s.jsx("span",{className:"font-mono text-xs theme-text flex-1 truncate",children:n.path}),u&&s.jsxs("span",{className:`font-mono text-[10px] ${u.passed?"text-emerald-400":"text-red-400"}`,children:[u.status>0?u.status:"ERR"," · ",u.durationMs,"ms"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[N&&s.jsx("span",{className:"rounded bg-amber-500/10 px-1 py-0.5 text-[9px] text-amber-400",children:"auth"}),v&&s.jsx("span",{className:"rounded bg-blue-500/10 px-1 py-0.5 text-[9px] text-blue-400",children:"capture"}),M.length>0&&s.jsxs("span",{title:`Needs human input at runtime: ${M.map(C=>`{{human:${C}}}`).join(", ")}`,className:"rounded bg-orange-500/10 px-1 py-0.5 text-[9px] text-orange-400 flex items-center gap-0.5",children:[s.jsx(zr,{className:"h-2.5 w-2.5",strokeWidth:2})," human"]}),_&&s.jsxs("span",{className:"rounded bg-purple-500/10 px-1 py-0.5 text-[9px] text-purple-400 flex items-center gap-0.5",children:[s.jsx(ea,{className:"h-2.5 w-2.5",strokeWidth:2})," condition"]}),u?.conditionResult&&s.jsxs("span",{className:`rounded px-1 py-0.5 text-[9px] ${u.conditionResult.passed?"bg-purple-500/10 text-purple-400":"bg-orange-500/10 text-orange-400"}`,children:["◇ ",u.conditionResult.passed?"passed":"failed"]})]}),s.jsx("span",{className:"theme-text-faint shrink-0",children:x?s.jsx(qa,{className:"h-3.5 w-3.5"}):s.jsx(bl,{className:"h-3.5 w-3.5"})})]}),x&&s.jsxs("div",{className:"ml-12 mr-4 my-3 space-y-2.5 rounded-lg border-y theme-border theme-bg-overlay p-3",children:[n.description&&s.jsx("p",{className:"text-[11px] theme-text-muted",children:n.description}),u&&s.jsxs("div",{className:`rounded-lg border px-3 py-2 ${u.passed?"border-emerald-500/15 bg-emerald-500/[0.05]":"border-red-500/15 bg-red-500/[0.05]"}`,children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Response"}),u.error?s.jsx("p",{className:"text-[11px] text-red-400",children:u.error}):s.jsx("pre",{className:"text-[10px] theme-text-muted overflow-auto max-h-24 whitespace-pre-wrap break-all",children:typeof u.responseBody=="string"?u.responseBody.slice(0,300):JSON.stringify(u.responseBody,null,2).slice(0,300)})]}),T&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Request Body"}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.body).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border theme-border theme-bg-overlay-md px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] theme-text",children:C}),s.jsx("span",{className:"font-mono text-[10px] text-blue-400/80 truncate",children:String(D)})]},C))})]}),N&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider flex items-center gap-1",children:[s.jsx(A0,{className:"h-3 w-3",strokeWidth:2})," Inject"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.inject).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/[0.05] border border-amber-500/15 px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] text-amber-400/80",children:C}),s.jsx(dl,{className:"h-3 w-3 theme-text-faint shrink-0",strokeWidth:2}),s.jsx("span",{className:"font-mono text-[10px] theme-text-muted",children:D})]},C))})]}),v&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider flex items-center gap-1",children:[s.jsx(hs,{className:"h-3 w-3",strokeWidth:2})," Capture"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(n.capture).map(([C,D])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-blue-500/[0.05] border border-blue-500/15 px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[10px] text-blue-400",children:C}),s.jsx(dl,{className:"h-3 w-3 theme-text-faint shrink-0",strokeWidth:2}),s.jsx("span",{className:"font-mono text-[10px] theme-text-muted",children:D})]},C))})]}),s.jsxs("div",{className:"pt-1",children:[_&&L&&!p&&s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-purple-500/20 bg-purple-500/[0.04] px-3 py-2 mb-2",children:[s.jsx(ea,{className:"h-3 w-3 text-purple-400 shrink-0",strokeWidth:2}),s.jsx("span",{className:"text-[10px] text-purple-400 flex-1",children:L}),u?.conditionResult&&s.jsx("span",{className:`text-[9px] font-medium ${u.conditionResult.passed?"text-purple-400":"text-orange-400"}`,children:u.conditionResult.passed?"✓ passed":"✗ failed"}),s.jsx("button",{type:"button",onClick:()=>b(!0),className:"shrink-0 theme-text-faint hover:text-purple-400 transition-colors hover:cursor-pointer",children:s.jsx(Ov,{className:"h-3 w-3",strokeWidth:2})})]}),p?s.jsx(R3,{stepIndex:r,existingCondition:n.condition,capturedKeys:A,onSave:C=>{h(r,C),b(!1)},onRemove:()=>{h(r,void 0),b(!1)},onCancel:()=>b(!1)}):!_&&s.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex items-center gap-1.5 text-[10px] theme-text-faint hover:text-purple-400 transition-colors hover:cursor-pointer",children:[s.jsx(Dt,{className:"h-3 w-3",strokeWidth:2}),s.jsx(ea,{className:"h-3 w-3",strokeWidth:2}),"Add Condition"]})]})]})]})]})}function Ed(n){return{phase:"idle",currentStep:-1,stepStatuses:Array(n).fill("idle"),stepResults:Array(n).fill(null),passed:0,failed:0,humanKeys:[],notes:[]}}const my={run:"pre-seeded for this run",env:"environment variable",memory:"saved human memory",prompt:"your answer"};function O3({workflow:n,onDelete:r,onViewTraces:i}){const[o,u]=j.useState(n),[f,h]=j.useState("list"),[g,x]=j.useState(!1),[m,p]=j.useState(!1),[b,v]=j.useState(!1),[N,T]=j.useState(()=>Ed(o.steps.length)),[_,M]=j.useState(void 0),[A,V]=j.useState([]),[L,C]=j.useState(null),[D,W]=j.useState(""),X=j.useRef(!1),ie=j.useRef(null),I=j.useRef(""),K=j.useRef("local-sim"),ne=j.useRef({}),ee=j.useRef(new Set),se=j.useRef(null),[S,U]=j.useState(null),[k,H]=j.useState(""),[O,z]=j.useState(null),[E,$]=j.useState(!1),Z=j.useRef(null),ae=async(q,Y)=>{const ue=o.steps.map((P,Ee)=>{if(Ee!==q)return P;if(Y===void 0){const{condition:ge,...ke}=P;return ke}return{...P,condition:Y}}),re={...o,steps:ue};u(re);try{await b3(o._file,ue)}catch{}};j.useEffect(()=>{fetch("/api/model/environments").then(q=>q.ok?q.json():null).then(q=>{if(!q)return;const Y=q.environments??[];V(Y);const ue=q.defaultEnvironment??Y.find(P=>P.default)?.name??Y[0]?.name??null;C(ue);const re=Y.find(P=>P.name===ue);re&&W(re.baseUrl)}).catch(()=>{})},[]);const oe=async()=>{if(confirm(`Delete workflow "${o.name}"? This cannot be undone.`)){v(!0);try{await N3(o._file),r()}catch(q){alert(`Failed to delete: ${q.message}`),v(!1)}}},he=()=>{if(X.current=!0,ie.current?.close(),ie.current=null,Z.current){const q=Z.current;Z.current=null,U(null),q(null)}else S&&ve();T(q=>({...q,phase:q.phase==="running"?"aborted":q.phase}))},me=async(q,Y)=>{if(!se.current)throw new Error("Run id lost — please re-run the workflow.");const ue=await fetch("/api/workflows/human-input",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:se.current,key:q,value:Y})}),re=await ue.json().catch(()=>({}));if(!ue.ok)throw new Error(re.error??`HTTP ${ue.status}`)},Se=async()=>{if(S){if(Z.current){const q=Z.current;Z.current=null,U(null),H(""),q(k);return}$(!0),z(null);try{await me(S.key,k),U(null),H("")}catch(q){z(q.message)}finally{$(!1)}}},ve=async()=>{if(S){if(Z.current){const q=Z.current;Z.current=null,U(null),H(""),z(null),q(null);return}try{await me(S.key,null)}catch{}U(null),H(""),z(null)}},Ae=()=>{he(),T(Ed(o.steps.length))},Re=async(q,Y,ue)=>{const re=new Date().toISOString(),P={id:crypto.randomUUID(),workflowName:o.name,workflowFile:o._file,startedAt:ue,finishedAt:re,durationMs:q.stepResults.reduce((ge,ke)=>ge+(ke?.durationMs??0),0),phase:q.phase==="done"?"done":q.phase==="aborted"?"aborted":"error",passed:q.passed,failed:q.failed,baseUrl:q.baseUrl,source:Y,steps:o.steps.map((ge,ke)=>{const Oe=q.stepResults[ke];return{index:ke,name:ge.name,method:ge.method,path:ge.path,description:ge.description,status:Oe?.status??0,passed:Oe?.passed??!1,durationMs:Oe?.durationMs??0,captured:Object.fromEntries((Oe?.captured??[]).map(ze=>[ze,"(captured)"])),injected:Oe?.injected??{},requestBody:ge.body,responseBody:Oe?.responseBody,error:Oe?.error??null,expectStatus:ge.expectStatus,captureSpec:ge.capture,injectSpec:ge.inject,conditionSpec:ge.condition,conditionResult:Oe?.conditionResult}})},Ee=await g2(P);M(Ee)},We=q=>{X.current=!1,se.current=null,ee.current=new Set,Z.current=null,U(null),H(""),z(null);const Y=o.steps.length;T({...Ed(Y),baseUrl:D||void 0}),M(void 0),I.current=new Date().toISOString(),K.current="local-sim",x(!0);const ue=(P,Ee,ge)=>new Promise(ke=>{H(""),z(null),U({key:P,stepIndex:Ee,stepName:ge}),Z.current=ke}),re=async()=>{T(Oe=>({...Oe,phase:"running",baseUrl:D||Oe.baseUrl})),ne.current={};let P=0,Ee=0,ge=!1,ke="";for(let Oe=0;Oe<Y&&!(X.current||ge);Oe++){const ze=o.steps[Oe],Tt=vf(ze);for(const pe of Tt){if(X.current)break;if(ne.current[`human:${pe}`]!==void 0)continue;T(je=>{const Le=[...je.stepStatuses];return Le[Oe]="running",{...je,stepStatuses:Le,currentStep:Oe}});const Ve=await ue(pe,Oe,ze.name);if(Ve===null||X.current){T(je=>({...je,phase:"aborted",error:"Run cancelled by user"}));return}ne.current[`human:${pe}`]=Ve,T(je=>({...je,notes:[...je.notes??[],`↳ human {{human:${pe}}} ← your answer`]}))}if(X.current)break;T(pe=>{const Ve=[...pe.stepStatuses];return Ve[Oe]="running",{...pe,stepStatuses:Ve,currentStep:Oe}});const Mt=600+Math.random()*800;if(await new Promise(pe=>{const Ve=setTimeout(pe,Mt),je=setInterval(()=>{X.current&&(clearTimeout(Ve),clearInterval(je),pe())},50);setTimeout(()=>clearInterval(je),Mt+100)}),X.current)break;Object.keys(ze.capture??{}).forEach(pe=>{ne.current[pe]="[simulated]"}),Object.keys(ze.captureInput??{}).forEach(pe=>{ne.current[pe]="[simulated]"});let ft;if(ze.condition&&(ft=y3(ze.condition,ne.current),!ft.passed)){const{onFail:pe,returnOnComplete:Ve}=ze.condition;pe==="abort"?(ge=!0,ke=`Condition failed at step ${Oe+1}: ${ft.reason}`):pe==="continue"?(ge=!0,ke="Condition failed → continuing without remaining steps"):pe==="switch"&&(Ve||(ge=!0,ke=`Condition failed → switched to: ${ze.condition.switchToWorkflow??"unknown"}`))}const nt=!0,pt=Math.round(Mt),at={index:Oe,step:{name:ze.name,method:ze.method,path:ze.path,description:ze.description},status:200,passed:nt,durationMs:pt,captured:Object.keys(ze.capture??{}).map(pe=>pe.split(":").pop()??pe),injected:{},responseBody:{simulated:!0},error:null,conditionResult:ft};if(P++,T(pe=>{const Ve=[...pe.stepStatuses],je=[...pe.stepResults];return Ve[Oe]="passed",je[Oe]=at,{...pe,stepStatuses:Ve,stepResults:je,passed:P,failed:Ee}}),ge)break}if(!X.current)if(ge){const Oe={phase:"aborted",stepStatuses:N.stepStatuses,stepResults:N.stepResults,passed:P,failed:Ee,baseUrl:D||void 0};T(ze=>({...ze,phase:"aborted",error:ke})),Re(Oe,"local-sim",I.current)}else{const Oe={phase:"done",stepStatuses:Array(Y).fill("passed"),stepResults:o.steps.map((ze,Tt)=>({index:Tt,step:{name:ze.name,method:ze.method,path:ze.path,description:ze.description},status:200,passed:!0,durationMs:Math.round(600+Math.random()*800),captured:Object.keys(ze.capture??{}).map(Mt=>Mt.split(":").pop()??Mt),injected:{},responseBody:{simulated:!0},error:null})),passed:P,failed:Ee};T(ze=>({...ze,phase:"done",passed:P,failed:Ee})),Re(Oe,"local-sim",I.current)}};fetch("/api/workflows/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:o._file,baseUrl:D||void 0,humanInputs:q})}).then(P=>{if(!P.ok||!P.body){re();return}K.current="api";const Ee=P.body.getReader(),ge=new TextDecoder;let ke="";T(ze=>({...ze,phase:"running"})),(async()=>{let ze=!1;for(;!X.current;){const{value:Tt,done:Mt}=await Ee.read();if(Mt)break;ze=!0,ke+=ge.decode(Tt,{stream:!0});const ft=ke.split(`
392
392
  `);ke=ft.pop()??"";for(const nt of ft){const pt=nt.trim();if(!pt.startsWith("data:"))continue;const at=pt.slice(5).trim();if(!at)continue;let pe;try{pe=JSON.parse(at)}catch{continue}if(pe.type==="human_input_required"){H(""),z(null),U({key:String(pe.key??""),stepIndex:Number(pe.stepIndex??-1),stepName:String(pe.stepName??"")});continue}T(Ve=>{const je={...Ve};if(pe.type==="start")je.phase="running",je.baseUrl=pe.baseUrl,je.humanKeys=Array.isArray(pe.humanKeys)?pe.humanKeys:[],je.notes=[],je.humanUnsupported=!Array.isArray(pe.humanKeys)&&w3(o.steps).length>0,typeof pe.runId=="string"&&(se.current=pe.runId);else if(pe.type==="human_resolved"){const Le=`${pe.index}:${pe.key}`;if(!ee.current.has(Le)){ee.current.add(Le);const Ge=my[String(pe.source)]??String(pe.source??"run");je.notes=[...je.notes??[],`↳ human {{human:${pe.key}}} ← ${Ge}`]}}else if(pe.type==="step_start"){const Le=pe.index,Ge=[...je.stepStatuses];Ge[Le]="running",je.stepStatuses=Ge,je.currentStep=Le}else if(pe.type==="step_result"){const Le=pe.index,Ge=[...je.stepStatuses],At=[...je.stepResults];Ge[Le]=pe.passed?"passed":"failed",At[Le]={index:pe.index,step:pe.step??{name:"",method:"",path:""},status:pe.status,passed:pe.passed,durationMs:pe.durationMs,captured:pe.captured??[],injected:pe.injected??{},responseBody:pe.responseBody,error:pe.error??null},pe.passed?je.passed=(je.passed??0)+1:je.failed=(je.failed??0)+1,je.stepStatuses=Ge,je.stepResults=At}else if(pe.type==="condition_result"){const Le=pe.index,Ge=[...je.stepResults];Ge[Le]&&(Ge[Le]={...Ge[Le],conditionResult:{passed:pe.passed,reason:pe.reason}},je.stepResults=Ge)}else if(pe.type==="aborted"){const Le=[...je.stepStatuses];for(let Ge=0;Ge<Le.length;Ge++)Le[Ge]==="running"?Le[Ge]="failed":Le[Ge]==="idle"&&(Le[Ge]="skipped");je.stepStatuses=Le,je.phase="aborted",je.error=pe.reason,Re(je,"api",I.current)}else pe.type==="done"&&(je.phase="done",(pe.passed>0||pe.failed>0)&&(je.passed=pe.passed,je.failed=pe.failed),pe.conditionBranch==="continue"?je.error="Condition failed → remaining steps skipped":pe.conditionBranch==="switch"&&(je.error=`Condition failed → switched to: ${pe.switchToWorkflow??"unknown"}`),Re(je,"api",I.current));return je})}}!ze&&!X.current&&re()})().catch(()=>{X.current||re()})}).catch(()=>{X.current||re()})},Te=N.phase==="running",be=N.phase!=="idle";return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>We(),className:"absolute -top-2 -right-2 flex items-center gap-1 rounded-full theme-bg-brand px-2 py-0.5 text-[10px] font-medium text-[color:var(--brand-foreground)] shadow-sm z-10 hover:opacity-90 transition-colors hover:cursor-pointer",children:[s.jsx(_d,{size:10})," Run Workflow"]}),s.jsxs("div",{className:"rounded-lg border theme-border theme-bg-overlay overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b theme-border",children:[s.jsx("button",{type:"button",onClick:()=>p(q=>!q),className:"text-[color:var(--brand)]/70 hover:text-[color:var(--brand)] transition-colors shrink-0 hover:cursor-pointer",children:m?s.jsx(bl,{className:"h-3.5 w-3.5"}):s.jsx(qa,{className:"h-3.5 w-3.5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"theme-text-primary truncate",children:o.name}),o.generatedAt&&s.jsxs("p",{className:"flex items-center gap-1 text-[10px] theme-text-faint mt-0.5",children:[s.jsx(Gr,{className:"h-2.5 w-2.5",strokeWidth:2}),new Date(o.generatedAt).toLocaleString()]})]}),s.jsxs("span",{className:"rounded-full border theme-border theme-bg-overlay-md px-2 py-0.5 text-[10px] theme-text-muted shrink-0",children:[o.steps.length," steps"]}),be&&s.jsxs("span",{className:`flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] shrink-0 ${N.phase==="done"&&N.failed===0?"bg-emerald-500/10 text-emerald-400":N.phase==="running"?"bg-blue-500/10 text-blue-400":"bg-red-500/10 text-red-400"}`,children:[N.phase==="running"&&s.jsx(dt,{className:"h-2.5 w-2.5 animate-spin",strokeWidth:2}),N.phase==="done"&&N.failed===0&&s.jsx(ut,{className:"h-2.5 w-2.5",strokeWidth:2}),(N.phase==="done"||N.phase==="aborted")&&N.failed>0&&s.jsx(Ht,{className:"h-2.5 w-2.5",strokeWidth:2}),N.phase==="running"?"Running…":N.phase==="done"?`${N.passed}/${N.passed+N.failed}`:N.phase==="aborted"?"Aborted":"Error"]}),N.humanUnsupported&&s.jsxs("span",{title:"The connected jetic dev server predates human-input support. Restart it from the latest build — human values will otherwise resolve empty and no dialog appears.",className:"flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] shrink-0 bg-red-500/10 text-red-400",children:[s.jsx(Ht,{className:"h-2.5 w-2.5",strokeWidth:2}),"Old server — no human dialog"]}),!m&&s.jsx("div",{className:"flex items-center gap-0.5 rounded-lg border theme-border theme-bg-overlay-md p-0.5 shrink-0",children:["list","graph"].map(q=>s.jsxs("button",{type:"button",onClick:()=>h(q),className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors hover:cursor-pointer ${f===q?"bg-[color:var(--brand)]/20 text-[color:var(--brand)]":"theme-text-faint hover:theme-text-muted"}`,children:[q==="list"?s.jsx(O0,{className:"h-3 w-3",strokeWidth:2}):s.jsx(Id,{className:"h-3 w-3",strokeWidth:2}),q.charAt(0).toUpperCase()+q.slice(1)]},q))}),be&&!m&&s.jsxs("button",{type:"button",onClick:()=>x(q=>!q),className:`flex items-center gap-1 rounded-lg px-2.5 py-1 text-[10px] transition-colors border theme-border hover:cursor-pointer ${g?"theme-bg-overlay-md theme-text":"theme-text-faint hover:theme-text theme-bg-overlay"}`,children:[s.jsx(_v,{className:"h-3 w-3",strokeWidth:2})," Log"]}),Te&&s.jsxs("button",{type:"button",onClick:he,className:"flex items-center gap-1 rounded-lg border border-red-500/30 bg-red-500/10 px-2.5 py-1 text-[10px] text-red-400 hover:bg-red-500/20 transition-colors shrink-0 hover:cursor-pointer",children:[s.jsx(Jv,{className:"h-3 w-3",strokeWidth:2})," Stop"]}),be&&!Te&&s.jsxs("button",{type:"button",onClick:Ae,className:"flex items-center gap-1 rounded-lg border theme-border theme-bg-overlay px-2.5 py-1 text-[10px] theme-text-muted hover:theme-text transition-colors shrink-0 hover:cursor-pointer",children:[s.jsx(Bv,{className:"h-3 w-3",strokeWidth:2})," Reset"]}),be&&!Te&&i&&s.jsxs("button",{type:"button",onClick:()=>i(o.name,_),className:"flex items-center gap-1 rounded-lg border border-[color:var(--brand)]/30 bg-[color:var(--brand)]/10 px-2.5 py-1 text-[10px] text-[color:var(--brand)] hover:bg-[color:var(--brand)]/20 transition-colors shrink-0 hover:cursor-pointer",children:[s.jsx(Vr,{className:"h-3 w-3",strokeWidth:2}),_?"View Trace":"Traces"]}),!Te&&s.jsxs("button",{type:"button",onClick:()=>We(),className:"hidden items-center gap-1.5 rounded-lg theme-bg-brand px-3 py-1.5 text-[10px] font-medium text-[color:var(--brand-foreground)] hover:opacity-90 transition-colors shrink-0 hover:cursor-pointer",children:[s.jsx(_d,{className:"h-3 w-3",strokeWidth:2}),be?"Re-run":"Run"]}),!o._legacy&&!Te&&s.jsx("button",{type:"button",onClick:oe,disabled:b,title:"Delete workflow",className:"flex items-center gap-1 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-2 py-1 text-[10px] text-red-400/80 hover:bg-red-500/20 hover:text-red-400 transition-colors shrink-0 disabled:opacity-40 hover:cursor-pointer",children:b?s.jsx(dt,{className:"h-3 w-3 animate-spin",strokeWidth:2}):s.jsx(Yt,{className:"h-3 w-3",strokeWidth:2})})]}),!m&&s.jsxs(s.Fragment,{children:[A.length>0&&s.jsxs("div",{className:"flex items-center gap-2 border-b theme-border px-4 py-2 theme-bg-overlay-md flex-wrap",children:[s.jsx(vl,{className:"h-3 w-3 theme-text-faint shrink-0",strokeWidth:2}),s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider theme-text-faint mr-1",children:"Env:"}),A.map(q=>{const Y=L===q.name;return s.jsxs("button",{type:"button",onClick:()=>{C(q.name),W(q.baseUrl)},className:`flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[10px] font-medium transition-all hover:cursor-pointer ${Y?"border-[color:var(--brand)]/40 bg-[color:var(--brand)]/10 text-[color:var(--brand)]":"theme-border theme-text-faint hover:border-[color:var(--brand)]/20 hover:theme-text-muted"}`,children:[s.jsx("span",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${Y?"bg-[color:var(--brand)]":"bg-[var(--text-faint)]"}`}),q.name]},q.name)}),L&&s.jsx("span",{className:"ml-auto font-mono text-[10px] theme-text-faint truncate max-w-[180px]",children:D})]}),g&&s.jsx("div",{className:"border-b theme-border",children:s.jsx(M3,{runState:N,steps:o.steps,waitingStepIndex:S?.stepIndex??null})}),f==="list"&&s.jsx("div",{className:"divide-y divide-[var(--border)]",children:o.steps.map((q,Y)=>s.jsx(z3,{step:q,index:Y,total:o.steps.length,status:N.stepStatuses[Y]??"idle",result:N.stepResults[Y]??null,allSteps:o.steps,onConditionChange:ae,waitingHuman:S?.stepIndex===Y},Y))}),f==="graph"&&s.jsx("div",{className:"p-4",children:s.jsx(T3,{steps:o.steps,runState:N})})]})]}),S&&s.jsx(E3,{title:"Human input required",subtitle:S.stepName?`Step ${S.stepIndex+1} · ${S.stepName}`:`Step ${S.stepIndex+1}`,fields:[{key:S.key}],values:{[S.key]:k},onChange:(q,Y)=>H(Y),onSubmit:Se,onCancel:ve,submitLabel:"Submit & resume run",error:O,submitting:E})]})}function D3(){return s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-5 py-20 text-center",children:[s.jsxs("div",{className:"relative flex h-16 w-16 items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 rounded-full bg-[color:var(--brand)]/10 blur-xl"}),s.jsx("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-full border theme-border theme-bg-overlay text-[color:var(--brand)]",children:s.jsx(ea,{className:"h-7 w-7",strokeWidth:2})})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium theme-text-primary",children:"No workflows yet"}),s.jsx("p",{className:"mt-1 text-[11px] theme-text-muted"}),s.jsxs("p",{className:"mt-1 text-[11px] theme-text-faint",children:["Workflows are stored in ",s.jsx("code",{className:"theme-text-faint",children:".jetic/workflows/"})]})]})]})}function H3({onViewTraces:n}){const[r,i]=j.useState([]),[o,u]=j.useState(!0),[f,h]=j.useState(!1),[g,x]=j.useState(null),m=j.useCallback(async(b=!1)=>{b?h(!0):u(!0),x(null);try{i(await j3())}catch(v){x(v.message)}finally{u(!1),h(!1)}},[]);j.useEffect(()=>{m()},[m]);const p=b=>{i(v=>v.filter(N=>N._file!==b))};return s.jsxs("div",{className:"flex min-h-full w-full flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between border-b theme-border px-6 py-5 sticky",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-[15px] font-medium theme-text-primary leading-none",children:"Simulations"}),s.jsx("p",{className:"mt-0.5 text-[11px] theme-text-muted",children:o?"Loading…":`${r.length} workflow${r.length!==1?"s":""} found`})]})}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{type:"button",onClick:()=>m(!0),disabled:f||o,className:"flex h-6 w-6 items-center justify-center rounded-lg border theme-border theme-bg-overlay theme-text-muted hover:theme-bg-overlay-md hover:theme-text disabled:opacity-40 transition-all hover:cursor-pointer",children:s.jsx(na,{className:`h-3.5 w-3.5 ${f?"animate-spin":""}`,strokeWidth:2})})})]}),s.jsxs("div",{className:"flex flex-1 flex-col gap-4 p-6 overflow-y-auto max-h[(calc(100vh-60px))]",children:[o&&s.jsx("div",{className:"space-y-3",children:[1,2].map(b=>s.jsx("div",{className:"h-16 animate-pulse rounded-lg border theme-border theme-bg-overlay",style:{opacity:1-b*.3}},b))}),!o&&g&&s.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-red-500/20 bg-red-500/[0.06] p-10 text-center",children:[s.jsx(Ht,{className:"h-8 w-8 text-red-400",strokeWidth:2}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-red-300",children:"Could not load simulations"}),s.jsx("p",{className:"mt-1 text-[11px] text-red-400/80",children:g})]}),s.jsx("button",{type:"button",onClick:()=>m(),className:"rounded-lg border border-red-500/20 bg-red-500/10 px-4 py-1.5 text-[11px] text-red-400 hover:bg-red-500/20 transition-colors hover:cursor-pointer",children:"Retry"})]}),!o&&!g&&r.length===0&&s.jsx(D3,{}),!o&&!g&&r.length>0&&s.jsx("div",{className:"space-y-5",children:r.map((b,v)=>s.jsx(O3,{workflow:b,onDelete:()=>p(b._file),onViewTraces:n?(N,T)=>n({workflowName:N,traceId:T}):void 0},`${b._file}-${v}`))}),!o&&!g&&r.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t theme-border pt-3 text-[10px] theme-text-faint",children:["Workflows from ",s.jsx("code",{className:"theme-text-faint",children:".jetic/workflows/"})]})]})]})}const $3={GET:{bg:"bg-emerald-500/10",text:"text-emerald-400",dot:"#34d399"},POST:{bg:"bg-blue-500/10",text:"text-blue-400",dot:"#60a5fa"},PUT:{bg:"bg-amber-500/10",text:"text-amber-400",dot:"#fbbf24"},PATCH:{bg:"bg-orange-500/10",text:"text-orange-400",dot:"#fb923c"},DELETE:{bg:"bg-red-500/10",text:"text-red-400",dot:"#f87171"},HEAD:{bg:"theme-bg-overlay-md",text:"theme-text-muted",dot:"var(--text-muted)"},OPTIONS:{bg:"bg-purple-500/10",text:"text-purple-400",dot:"#c084fc"}};function py(n){return $3[n.toUpperCase()]??{bg:"theme-bg-overlay-md",text:"theme-text-muted",dot:"var(--text-muted)"}}async function U3(){const n=await fetch("/api/model");if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function B3(){const n=await fetch("/api/model/scan",{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??`Scan failed (${n.status})`)}return(await n.json()).model}async function q3(n,r){const i=await fetch(`/api/model/endpoint/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Save failed (${i.status})`)}async function L3(n){const r=await fetch("/api/model/endpoint",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.error??`Create failed (${r.status})`)}return r.json()}function Y3({method:n}){const r=py(n);return s.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] tracking-widest ${r.bg} ${r.text}`,children:n.toUpperCase()})}function x0({value:n,onSave:r,mono:i=!0}){const[o,u]=j.useState(!1),[f,h]=j.useState(n),[g,x]=j.useState(!1),m=j.useRef(null);j.useEffect(()=>{o&&m.current?.focus()},[o]);const p=async()=>{if(f===n){u(!1);return}x(!0);try{await r(f)}finally{x(!1),u(!1)}};return o?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("input",{ref:m,value:f,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&p(),b.key==="Escape"&&(h(n),u(!1))},className:`rounded border border-blue-500/40 theme-bg-overlay-md px-1.5 py-0.5 text-xs theme-text-primary outline-none w-56 ${i?"font-mono":""}`}),s.jsx("button",{type:"button",onClick:p,disabled:g,className:"text-emerald-400 hover:text-emerald-300 hover:cursor-pointer",children:g?s.jsx(dt,{className:"h-3 w-3 animate-spin"}):s.jsx(ut,{className:"h-3 w-3"})}),s.jsx("button",{type:"button",onClick:()=>{h(n),u(!1)},className:"theme-text-faint hover:theme-text-muted hover:cursor-pointer",children:s.jsx(_t,{className:"h-3 w-3"})})]}):s.jsxs("button",{type:"button",onClick:()=>u(!0),className:`group/ie inline-flex items-center gap-1 rounded px-1 py-0.5 hover:theme-bg-overlay-md transition-colors hover:cursor-pointer ${i?"font-mono":""}`,children:[s.jsx("span",{className:"text-xs theme-text",children:n}),s.jsx(Fd,{className:"h-2.5 w-2.5 theme-text-faint opacity-0 group-hover/ie:opacity-100 transition-opacity"})]})}function V3({ep:n,onUpdate:r,onInspect:i,onViewTraces:o,onEdit:u}){const[f,h]=j.useState(!1),[g,x]=j.useState(""),m=async(v,N)=>{x("");try{await q3(v,N),r(v,N)}catch(T){x(T.message)}},p=n.requestBody?.fields??{},b=n.responses??{};return s.jsxs("div",{className:"border-b theme-border last:border-0",children:[s.jsxs("button",{type:"button",onClick:()=>h(v=>!v),className:"group flex w-full items-center gap-3 px-7 py-2.5 hover:theme-bg-overlay-md transition-colors text-left hover:cursor-pointer",children:[s.jsx("span",{className:"shrink-0 theme-text-faint",children:f?s.jsx(qa,{className:"h-3.5 w-3.5"}):s.jsx(bl,{className:"h-3.5 w-3.5"})}),s.jsx(Y3,{method:n.method}),s.jsx("span",{className:"font-mono text-xs theme-text flex-1 truncate",children:n.path}),n.security&&n.security.length>0&&s.jsx(La,{className:"h-3 w-3 text-amber-500/60 shrink-0"}),n.deprecated&&s.jsx("span",{className:"rounded text-[9px] font-medium text-amber-500/60 border border-amber-500/20 px-1 py-0.5",children:"deprecated"}),s.jsxs("span",{onClick:v=>{v.stopPropagation(),u(n)},className:"inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] border theme-border theme-text-faint hover:theme-bg-overlay-md hover:theme-text hover:cursor-pointer transition-colors",children:[s.jsx(Fd,{className:"h-2.5 w-2.5"})," EDIT"]}),s.jsx("span",{onClick:v=>{v.stopPropagation(),i(n)},className:"inline-flex items-center rounded px-1.5 py-0.5 text-[10px] border border-blue-500/40 text-blue-400 hover:bg-blue-500/10 hover:border-blue-400/60 hover:cursor-pointer transition-colors",children:"INSPECT"}),o&&s.jsxs("span",{onClick:v=>{v.stopPropagation(),o(n.path)},className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] border border-blue-500/30 text-blue-400 hover:bg-blue-500/10 hover:cursor-pointer transition-colors",children:[s.jsx(Vr,{className:"h-2.5 w-2.5"})," Traces"]}),s.jsx("span",{className:"hidden sm:block text-[10px] theme-text-faint truncate max-w-[180px]",children:n.handlerName})]}),f&&s.jsxs("div",{className:"px-10 pb-4 pt-1 space-y-3 theme-bg-overlay",children:[g&&s.jsx("p",{className:"text-xs text-red-400 rounded border border-red-500/20 bg-red-500/10 px-2 py-1",children:g}),s.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Method"}),s.jsx("select",{value:n.method,onChange:v=>m(n.id,{method:v.target.value}),className:"rounded-lg border theme-border theme-bg-overlay-md px-2 py-1 text-xs theme-text outline-none hover:cursor-pointer",children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(v=>s.jsx("option",{children:v},v))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Path"}),s.jsx(x0,{value:n.path,onSave:v=>m(n.id,{path:v})})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1 uppercase tracking-wider",children:"Handler"}),s.jsx(x0,{value:n.handlerName??"—",onSave:v=>m(n.id,{handlerName:v}),mono:!1})]})]}),n.source&&s.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] theme-text-faint",children:[s.jsx(Kd,{className:"h-3 w-3 shrink-0",strokeWidth:2}),n.source.file.split(/[/\\]/).slice(-2).join("/"),":",n.source.line]}),Object.keys(p).length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1.5 uppercase tracking-wider",children:"Request Body"}),s.jsx("div",{className:"space-y-1",children:Object.entries(p).map(([v,N])=>s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border theme-border theme-bg-overlay-md px-3 py-1.5",children:[s.jsx("span",{className:"font-mono text-[11px] theme-text",children:v}),s.jsx("span",{className:"text-[10px] theme-text-faint",children:N.type}),N.required&&s.jsx("span",{className:"text-[10px] text-rose-400",children:"required"})]},v))})]}),Object.keys(b).length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1.5 uppercase tracking-wider",children:"Responses"}),s.jsx("div",{className:"space-y-1",children:Object.entries(b).map(([v,N])=>s.jsxs("div",{className:"flex items-start gap-2 rounded-lg border theme-border theme-bg-overlay-md px-3 py-1.5",children:[s.jsx("span",{className:`font-mono text-[11px] ${v.startsWith("2")?"text-emerald-400":"text-red-400"}`,children:v}),N.schema&&s.jsx("span",{className:"text-[10px] theme-text-muted",children:Object.keys(N.schema).join(", ")})]},v))})]}),n.middleware&&n.middleware.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] theme-text-faint mb-1.5 uppercase tracking-wider",children:"Middleware"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.middleware.map((v,N)=>s.jsx("span",{className:"rounded-lg border theme-border theme-bg-overlay-md px-2 py-0.5 text-[10px] theme-text-muted",children:v.name},N))})]})]})]})}function G3({prefix:n,endpoints:r,onUpdate:i,onInspect:o,onViewTraces:u,onEdit:f}){const[h,g]=j.useState(!1);return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>g(x=>!x),className:"flex w-full items-center gap-3 px-4 py-2 hover:theme-bg-overlay-md transition-colors theme-bg-overlay hover:cursor-pointer",children:[s.jsx("span",{className:"text-blue-400",children:h?s.jsx(bl,{className:"h-3 w-3"}):s.jsx(qa,{className:"h-3 w-3"})}),s.jsx("span",{className:"font-mono text-xs font-medium text-blue-400",children:n}),s.jsx("span",{className:"ml-auto rounded-full border theme-border theme-bg-overlay-md px-2 py-0.5 text-[10px] theme-text-muted",children:r.length})]}),s.jsx("div",{className:"flex flex-col overflow-y-auto max-h-[calc(100vh-280px)]",children:!h&&r.map(x=>s.jsx(V3,{ep:x,onUpdate:i,onInspect:o,onViewTraces:u,onEdit:f},x.id))})]})}const ll=210,_r=52,kd=100,g0=14,rl=36;function X3({endpoints:n}){const r=j.useRef(null),i=new Map;for(const x of n){const m="/"+(x.path.split("/")[1]??"");i.has(m)||i.set(m,[]),i.get(m).push(x)}const o=Array.from(i.entries()),u=Math.max(1,...o.map(([,x])=>x.length)),f=o.length*ll+(o.length-1)*kd+rl*2,h=u*_r+(u-1)*g0+rl*2+24,g=new Map;return o.forEach(([,x],m)=>{const p=rl+m*(ll+kd);x.forEach((b,v)=>{g.set(b.id,{x:p,y:rl+24+v*(_r+g0)})})}),j.useEffect(()=>{const x=r.current;if(!x)return;const m=x.getContext("2d");m&&(m.clearRect(0,0,x.width,x.height),o.forEach(([,p],b)=>{if(b>=o.length-1)return;const v=o[b+1][1];p.forEach(N=>{const T=g.get(N.id);v.forEach(_=>{const M=g.get(_.id),A=T.x+ll,V=T.y+_r/2,L=M.x,C=M.y+_r/2,D=(A+L)/2;m.beginPath(),m.strokeStyle="rgba(96,165,250,0.14)",m.lineWidth=1,m.moveTo(A,V),m.bezierCurveTo(D,V,D,C,L,C),m.stroke()})})}))}),s.jsxs("div",{className:"relative overflow-auto",style:{minWidth:f,minHeight:h},children:[s.jsx("canvas",{ref:r,width:f,height:h,className:"absolute inset-0 pointer-events-none"}),o.map(([x],m)=>s.jsx("div",{className:"absolute text-[9px] font-medium text-blue-400/70 uppercase tracking-widest text-center",style:{left:rl+m*(ll+kd),top:rl,width:ll},children:x},x)),n.map(x=>{const m=g.get(x.id);if(!m)return null;const p=py(x.method);return s.jsxs("div",{className:"absolute rounded-lg border theme-border theme-bg-overlay shadow-md flex items-center gap-2 px-3 overflow-hidden hover:border-blue-500/30 transition-colors",style:{left:m.x,top:m.y,width:ll,height:_r},children:[s.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[3px]",style:{background:p.dot}}),s.jsx("span",{className:`shrink-0 text-[9px] font-medium ${p.text}`,children:x.method}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"font-mono text-[10px] theme-text truncate",children:x.path}),s.jsx("p",{className:"text-[9px] theme-text-faint truncate",children:x.handlerName})]})]},x.id)})]})}function Z3({onScan:n,scanning:r,error:i}){return s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-5 py-20 text-center",children:[s.jsxs("div",{className:"relative flex h-16 w-16 items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 rounded-full bg-blue-500/10 blur-xl"}),s.jsx("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-full border theme-border theme-bg-overlay text-blue-400",children:s.jsx(Ro,{className:"h-7 w-7",strokeWidth:2})})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium theme-text-primary",children:"No model found"}),s.jsxs("p",{className:"mt-1 text-xs theme-text-muted",children:["Scan your project to generate ",s.jsx("code",{className:"theme-text",children:".jetic/model.json"})]})]}),i&&s.jsx("p",{className:"text-xs text-red-400 max-w-xs",children:i}),s.jsxs("button",{type:"button",onClick:n,disabled:r,className:"flex items-center gap-2 rounded-lg bg-blue-500 px-5 py-2.5 text-sm font-medium text-white hover:bg-blue-400 disabled:opacity-50 transition-colors hover:cursor-pointer",children:[r?s.jsx(dt,{className:"h-4 w-4 animate-spin",strokeWidth:2}):s.jsx(Ro,{className:"h-4 w-4",strokeWidth:2}),r?"Scanning project…":"Scan Project"]})]})}const Yo=["application/json","application/x-www-form-urlencoded","multipart/form-data","text/plain","application/xml","application/octet-stream"],xy=["string","integer","number","boolean","array","object"];function W3({open:n,onClose:r,onCreated:i}){const[o,u]=j.useState("basic"),[f,h]=j.useState(!1),[g,x]=j.useState(""),[m,p]=j.useState("GET"),[b,v]=j.useState(""),[N,T]=j.useState(""),[_,M]=j.useState(""),[A,V]=j.useState(""),[L,C]=j.useState([]),[D,W]=j.useState("application/json"),[X,ie]=j.useState(""),[I,K]=j.useState(""),[ne,ee]=j.useState(!1),[se,S]=j.useState([]),[U,k]=j.useState([]),[H,O]=j.useState(!1),z=H&&!b.trim(),E=j.useRef(null);j.useEffect(()=>{n&&(u("basic"),p("GET"),v(""),T(""),M(""),V(""),C([]),W("application/json"),ie(""),K(""),ee(!1),S([]),k([]),O(!1),x(""),h(!1))},[n]),j.useEffect(()=>{if(!n)return;const Y=ue=>{ue.key==="Escape"&&r()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n,r]);const $=()=>C(Y=>[...Y,{name:"",in:"query",type:"string",required:!1,description:"",example:""}]),Z=(Y,ue)=>C(re=>re.map((P,Ee)=>Ee===Y?{...P,...ue}:P)),ae=Y=>C(ue=>ue.filter((re,P)=>P!==Y)),oe=()=>S(Y=>[...Y,{status:"200",description:"",contentType:"application/json",schema:"",example:""}]),he=(Y,ue)=>S(re=>re.map((P,Ee)=>Ee===Y?{...P,...ue}:P)),me=Y=>S(ue=>ue.filter((re,P)=>P!==Y)),Se=()=>k(Y=>[...Y,{name:""}]),ve=(Y,ue)=>k(re=>re.map((P,Ee)=>Ee===Y?{name:ue}:P)),Ae=Y=>k(ue=>ue.filter((re,P)=>P!==Y)),Re=(Y,ue)=>k(re=>{const P=[...re],Ee=Y+ue;return Ee<0||Ee>=P.length||([P[Y],P[Ee]]=[P[Ee],P[Y]]),P}),We=async()=>{if(O(!0),!b.trim()){u("basic");return}h(!0),x("");try{const Y={method:m.toUpperCase(),path:b.startsWith("/")?b:"/"+b};N.trim()&&(Y.name=N.trim()),_.trim()&&(Y.description=_.trim()),A.trim()&&(Y.tags=A.split(",").map(ge=>ge.trim()).filter(Boolean));const ue=U.filter(ge=>ge.name.trim());Y.middleware=ue.map(ge=>({name:ge.name.trim()}));const re=L.filter(ge=>ge.name.trim());if(re.length>0&&(Y.parameters=re.map(ge=>{const ke={name:ge.name,in:ge.in,schema:{type:ge.type},required:ge.required};return ge.description.trim()&&(ke.description=ge.description),ge.example.trim()&&(ke.example=ge.example),ke})),X.trim()||I.trim()){const ge={},ke={};if(X.trim())try{ke.schema=JSON.parse(X)}catch{ke.schema=X}if(I.trim())try{ke.example=JSON.parse(I)}catch{ke.example=I}ge[D]=ke,Y.requestBody={required:ne,content:ge}}const P=se.filter(ge=>ge.status.trim());if(P.length>0){const ge={};for(const ke of P){const Oe={};if(ke.description.trim()&&(Oe.description=ke.description),ke.schema.trim()||ke.example.trim()){const ze={};if(ke.schema.trim())try{ze.schema=JSON.parse(ke.schema)}catch{ze.schema=ke.schema}if(ke.example.trim())try{ze.example=JSON.parse(ke.example)}catch{ze.example=ke.example}Oe.content={[ke.contentType]:ze}}ge[ke.status]=Oe}Y.responses=ge}const Ee=await L3(Y);i(Ee.endpoint,Ee.model),r()}catch(Y){x(Y.message)}finally{h(!1)}};if(!n)return null;const Te=[{key:"basic",label:"Basic"},{key:"request",label:"Request"},{key:"responses",label:"Responses"},{key:"middleware",label:`Middleware${U.length>0?` (${U.length})`:""}`}],be="w-full rounded-lg border theme-border theme-bg-overlay px-3 py-2 text-xs theme-text placeholder-[var(--text-faint)] outline-none focus:border-blue-500/50 focus:theme-bg-overlay-md transition-all",q="block text-[10px] theme-text-faint mb-1.5 uppercase tracking-wider font-medium";return s.jsx("div",{ref:E,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:Y=>{Y.target===E.current&&r()},children:s.jsxs("div",{className:"relative w-full max-w-2xl max-h-[85vh] flex flex-col rounded-2xl border border-[var(--border-md)] shadow-2xl overflow-hidden theme-bg-surface",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b theme-border",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-blue-500/10",children:s.jsx(Pb,{className:"h-4 w-4 text-blue-400"})}),s.jsx("h2",{className:"text-sm font-medium theme-text-primary",children:"Add Endpoint"})]}),s.jsx("button",{type:"button",onClick:r,className:"theme-text-faint hover:theme-text transition-colors hover:cursor-pointer",children:s.jsx(_t,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"flex items-center gap-1 px-6 pt-4 pb-2",children:Te.map(Y=>s.jsx("button",{type:"button",onClick:()=>u(Y.key),className:`rounded-lg px-3 py-1.5 text-[11px] font-medium transition-all duration-200 hover:cursor-pointer ${o===Y.key?"bg-blue-500/15 text-blue-400 shadow-sm":"theme-text-faint hover:theme-text-muted hover:theme-bg-overlay"}`,children:Y.label},Y.key))}),g&&s.jsxs("div",{className:"mx-6 mt-2 flex items-center gap-2 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-2 text-xs text-red-400",children:[s.jsx(Ht,{className:"h-3.5 w-3.5 shrink-0"}),g]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-4",children:[o==="basic"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Method *"}),s.jsx("select",{value:m,onChange:Y=>p(Y.target.value),className:`${be} hover:cursor-pointer`,children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(Y=>s.jsx("option",{children:Y},Y))})]}),s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Path *"}),s.jsx("input",{value:b,onChange:Y=>v(Y.target.value),placeholder:"/api/users",className:`${be} font-mono ${z?"border-red-500/60 focus:border-red-500/80":""}`}),z&&s.jsx("p",{className:"text-[10px] text-red-400 mt-1",children:"Path is required"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Name"}),s.jsx("input",{value:N,onChange:Y=>T(Y.target.value),placeholder:"Create User",className:be})]}),s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Description"}),s.jsx("textarea",{value:_,onChange:Y=>M(Y.target.value),placeholder:"Creates a new user account",rows:2,className:`${be} resize-none`})]}),s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Tags"}),s.jsx("input",{value:A,onChange:Y=>V(Y.target.value),placeholder:"users, auth, public",className:be}),s.jsx("p",{className:"text-[10px] theme-text-faint mt-1",children:"Comma-separated"})]})]}),o==="request"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:q+" mb-0",children:"Parameters"}),s.jsxs("button",{type:"button",onClick:$,className:"flex items-center gap-1 rounded-lg px-2 py-1 text-[10px] font-medium text-blue-400 hover:bg-blue-500/10 transition-colors hover:cursor-pointer",children:[s.jsx(Dt,{className:"h-3 w-3"})," Add Parameter"]})]}),L.length===0&&s.jsx("p",{className:"text-[10px] theme-text-faint italic",children:"No parameters added yet"}),s.jsx("div",{className:"space-y-2",children:L.map((Y,ue)=>s.jsxs("div",{className:"rounded-lg border theme-border theme-bg-overlay p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{value:Y.name,onChange:re=>Z(ue,{name:re.target.value}),placeholder:"Parameter name",className:`${be} font-mono`})}),s.jsx("select",{value:Y.in,onChange:re=>Z(ue,{in:re.target.value}),className:`${be} w-28 hover:cursor-pointer`,children:["query","path","header","cookie"].map(re=>s.jsx("option",{children:re},re))}),s.jsx("select",{value:Y.type,onChange:re=>Z(ue,{type:re.target.value}),className:`${be} w-28 hover:cursor-pointer`,children:xy.map(re=>s.jsx("option",{children:re},re))}),s.jsx("button",{type:"button",onClick:()=>ae(ue),className:"mt-1.5 theme-text-faint hover:text-red-400 transition-colors hover:cursor-pointer",children:s.jsx(Yt,{className:"h-3.5 w-3.5"})})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] theme-text-muted hover:cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:Y.required,onChange:re=>Z(ue,{required:re.target.checked}),className:"accent-blue-500"}),"Required"]}),s.jsx("input",{value:Y.description,onChange:re=>Z(ue,{description:re.target.value}),placeholder:"Description",className:`${be} flex-1 text-[10px]`}),s.jsx("input",{value:Y.example,onChange:re=>Z(ue,{example:re.target.value}),placeholder:"Example",className:`${be} w-32 text-[10px] font-mono`})]})]},ue))})]}),s.jsx("div",{className:"border-t theme-border"}),s.jsxs("div",{children:[s.jsx("p",{className:q,children:"Request Body"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:q,children:"Content Type"}),s.jsx("select",{value:D,onChange:Y=>W(Y.target.value),className:`${be} hover:cursor-pointer`,children:Yo.map(Y=>s.jsx("option",{children:Y},Y))})]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] theme-text-muted mt-5 hover:cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:ne,onChange:Y=>ee(Y.target.checked),className:"accent-blue-500"}),"Required"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:q,children:"Schema (JSON)"}),s.jsx("textarea",{value:X,onChange:Y=>ie(Y.target.value),placeholder:`{
393
393
  "type": "object",
394
394
  "properties": {