1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./koenig-lexical-BCKRQdew.js","./index-DP-kiU4l.js","./index-CnFnRBGY.css"])))=>i.map(i=>d[i]); 2import{r as C,j as h,d2 as Ta,dM as za,c3 as Ra,e as pe,aC as $a,bj as Nn,G as le,cq as Mr,cr as jr,cs as Ir,ct as Ar,cW as Dr,cX as Pr,cY as Tr,aO as On,aN as La,cA as Bn,dN as Ha,aM as zr,f as Pe,aD as Oa,dB as Ba,aK as Qt,B as ae,dO as Rr,dr as Vn,ds as $r,dt as Va,b7 as Fa,D as Wa,v as Ya,x as Xa,a2 as It,a3 as At,a4 as Dt,a5 as Pt,a6 as Tt,a7 as zt,a8 as Rt,dw as Za,dP as Lr,aq as Hr,aL as Ua,I as qa,aR as Ga,S as Ka,b8 as Qa,aX as Ja,b9 as ec,ba as tc,bc as nc,u as oc,dQ as rc}from"./index-DP-kiU4l.js";import{M as Fn}from"./mail-DFU1I2oY.js";import{C as Wn,P as sc}from"./power-NMpsxtrH.js";import{i as Ie,c as wo,a as vo,b as ic,d as gn}from"./value-BGBiTkF3.js";import{u as ac,a as cc,b as lc,k as uc,c as dc,f as fc}from"./use-pintura-config-B8j2836G.js";import{d as hc,v as gc,e as pc,u as mc,c as xc}from"./automated-emails-Dp-M05u9.js";import{T as yc,a as wc,b as bo}from"./tabs-X7v2-Dz5.js";import{u as vc}from"./newsletters-DI0eDSNC.js";import{S as bc}from"./send-Crdd2vmY.js";import{M as Cn,r as _c,a as Ec,b as _o,i as Sc,c as Nc,A as Cc,d as kc,e as Mc}from"./automations-CRhhOzzr.js";import{C as Eo}from"./checkbox-DfHUSZiw.js";import{L as So}from"./label-yIFiQmWa.js";import{S as jc,a as Ic}from"./select-DsQGUlhL.js";import{C as Ac}from"./circle-alert-DrssO2Qm.js";import{P as Dc}from"./pencil-BqK8SR2d.js";import"./offers-D4o1qACi.js";import"./posts-C_w_MPZT.js";import"./index-Dpsi-jGc.js";import"./chevron-up-BIc3zf3M.js";function Pc(e){C.useEffect(()=>{if(!e)return;const t=n=>{n.preventDefault(),n.returnValue=""};return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}},[e])}var No=180/Math.PI,kn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Or(e,t,n,o,r,s){var i,a,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*No,skewX:Math.atan(c)*No,scaleX:i,scaleY:a}}var Et;function Tc(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?kn:Or(t.a,t.b,t.c,t.d,t.e,t.f)}function zc(e){return e==null||(Et||(Et=document.createElementNS("http://www.w3.org/2000/svg","g")),Et.setAttribute("transform",e),!(e=Et.transform.baseVal.consolidate()))?kn:(e=e.matrix,Or(e.a,e.b,e.c,e.d,e.e,e.f))}function Br(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function s(l,f,d,u,g,m){if(l!==d||f!==u){var y=g.push("translate(",null,t,null,n);m.push({i:y-4,x:Ie(l,d)},{i:y-2,x:Ie(f,u)})}else(d||u)&&g.push("translate("+d+t+u+n)}function i(l,f,d,u){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),u.push({i:d.push(r(d)+"rotate(",null,o)-2,x:Ie(l,f)})):f&&d.push(r(d)+"rotate("+f+o)}function a(l,f,d,u){l!==f?u.push({i:d.push(r(d)+"skewX(",null,o)-2,x:Ie(l,f)}):f&&d.push(r(d)+"skewX("+f+o)}function c(l,f,d,u,g,m){if(l!==d||f!==u){var y=g.push(r(g)+"scale(",null,",",null,")");m.push({i:y-4,x:Ie(l,d)},{i:y-2,x:Ie(f,u)})}else(d!==1||u!==1)&&g.push(r(g)+"scale("+d+","+u+")")}return function(l,f){var d=[],u=[];return l=e(l),f=e(f),s(l.translateX,l.translateY,f.translateX,f.translateY,d,u),i(l.rotate,f.rotate,d,u),a(l.skewX,f.skewX,d,u),c(l.scaleX,l.scaleY,f.scaleX,f.scaleY,d,u),l=f=null,function(g){for(var m=-1,y=u.length,w;++m<y;)d[(w=u[m]).i]=w.x(g);return d.join("")}}}var Rc=Br(Tc,"px, ","px)","deg)"),$c=Br(zc,", ",")",")"),Lc=1e-12;function Co(e){return((e=Math.exp(e))+1/e)/2}function Hc(e){return((e=Math.exp(e))-1/e)/2}function Oc(e){return((e=Math.exp(2*e))-1)/(e+1)}const $t=(function e(t,n,o){function r(s,i){var a=s[0],c=s[1],l=s[2],f=i[0],d=i[1],u=i[2],g=f-a,m=d-c,y=g*g+m*m,w,x;if(y<Lc)x=Math.log(u/l)/t,w=function(j){return[a+j*g,c+j*m,l*Math.exp(t*j*x)]};else{var _=Math.sqrt(y),p=(u*u-l*l+o*y)/(2*l*n*_),v=(u*u-l*l-o*y)/(2*u*n*_),N=Math.log(Math.sqrt(p*p+1)-p),E=Math.log(Math.sqrt(v*v+1)-v);x=(E-N)/t,w=function(j){var D=j*x,P=Co(N),O=l/(n*_)*(P*Oc(t*D+N)-Hc(N));return[a+O*g,c+O*m,l*P/Co(t*D+N)]}}return w.duration=x*1e3*t/Math.SQRT2,w}return r.rho=function(s){var i=Math.max(.001,+s),a=i*i,c=a*a;return e(i,a,c)},r})(Math.SQRT2,2,4),ko=({icon:e,label:t,description:n,onClick:o})=>h.jsxs("button",{className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-none",type:"button",onClick:o,children:[h.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-text-secondary",children:h.jsx(e,{className:"size-4"})}),h.jsxs("div",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"font-medium",children:t}),h.jsx("span",{className:"text-xs text-text-secondary",children:n})]})]}),Vr=({onPick:e})=>h.jsxs("div",{className:"flex w-64 flex-col gap-1 p-1","data-testid":"step-picker",children:[h.jsx(ko,{description:"Send an email",icon:Fn,label:"Email",onClick:()=>e("send_email")}),h.jsx(ko,{description:"Wait a set amount of time",icon:Wn,label:"Wait",onClick:()=>e("wait")})]});function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Bc={value:()=>{}};function Jt(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Lt(n)}function Lt(e){this._=e}function Vc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Lt.prototype=Jt.prototype={constructor:Lt,on:function(e,t){var n=this._,o=Vc(e+"",n),r,s=-1,i=o.length;if(arguments.length<2){for(;++s<i;)if((r=(e=o[s]).type)&&(r=Fc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(r=(e=o[s]).type)n[r]=Mo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Mo(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Lt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,s;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,r=s.length;o<r;++o)s[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)}};function Fc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}
vendor: 6,766 bytes, line 2
2function Mo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Bc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Mn="http://www.w3.org/1999/xhtml";const jo={svg:"http://www.w3.org/2000/svg",xhtml:Mn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function en(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),jo.hasOwnProperty(t)?{space:jo[t],local:e}:e}function Wc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Mn&&t.documentElement.namespaceURI===Mn?t.createElement(e):t.createElementNS(n,e)}}function Yc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Fr(e){var t=en(e);return(t.local?Yc:Wc)(t)}function Xc(){}function Yn(e){return e==null?Xc:function(){return this.querySelector(e)}}function Zc(e){typeof e!="function"&&(e=Yn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,a=o[r]=new Array(i),c,l,f=0;f<i;++f)(c=s[f])&&(l=e.call(c,c.__data__,f,s))&&("__data__"in c&&(l.__data__=c.__data__),a[f]=l);return new ue(o,this._parents)}function Uc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qc(){return[]}function Wr(e){return e==null?qc:function(){return this.querySelectorAll(e)}}function Gc(e){return function(){return Uc(e.apply(this,arguments))}}function Kc(e){typeof e=="function"?e=Gc(e):e=Wr(e);for(var t=this._groups,n=t.length,o=[],r=[],s=0;s<n;++s)for(var i=t[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(o.push(e.call(c,c.__data__,l,i)),r.push(c));return new ue(o,r)}function Yr(e){return function(){return this.matches(e)}}function Xr(e){return function(t){return t.matches(e)}}var Qc=Array.prototype.find;function Jc(e){return function(){return Qc.call(this.children,e)}}function el(){return this.firstElementChild}function tl(e){return this.select(e==null?el:Jc(typeof e=="function"?e:Xr(e)))}var nl=Array.prototype.filter;function ol(){return Array.from(this.children)}function rl(e){return function(){return nl.call(this.children,e)}}function sl(e){return this.selectAll(e==null?ol:rl(typeof e=="function"?e:Xr(e)))}function il(e){typeof e!="function"&&(e=Yr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,a=o[r]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new ue(o,this._parents)}function Zr(e){return new Array(e.length)}function al(){return new ue(this._enter||this._groups.map(Zr),this._parents)}function Ft(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ft.prototype={constructor:Ft,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function cl(e){return function(){return e}}function ll(e,t,n,o,r,s){for(var i=0,a,c=t.length,l=s.length;i<l;++i)(a=t[i])?(a.__data__=s[i],o[i]=a):n[i]=new Ft(e,s[i]);for(;i<c;++i)(a=t[i])&&(r[i]=a)}function ul(e,t,n,o,r,s,i){var a,c,l=new Map,f=t.length,d=s.length,u=new Array(f),g;for(a=0;a<f;++a)(c=t[a])&&(u[a]=g=i.call(c,c.__data__,a,t)+"",l.has(g)?r[a]=c:l.set(g,c));for(a=0;a<d;++a)g=i.call(e,s[a],a,s)+"",(c=l.get(g))?(o[a]=c,c.__data__=s[a],l.delete(g)):n[a]=new Ft(e,s[a]);for(a=0;a<f;++a)(c=t[a])&&l.get(u[a])===c&&(r[a]=c)}function dl(e){return e.__data__}function fl(e,t){if(!arguments.length)return Array.from(this,dl);var n=t?ul:ll,o=this._parents,r=this._groups;typeof e!="function"&&(e=cl(e));for(var s=r.length,i=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var f=o[l],d=r[l],u=d.length,g=hl(e.call(f,f&&f.__data__,l,o)),m=g.length,y=a[l]=new Array(m),w=i[l]=new Array(m),x=c[l]=new Array(u);n(f,d,y,w,x,g,t);for(var _=0,p=0,v,N;_<m;++_)if(v=y[_]){for(_>=p&&(p=_+1);!(N=w[p])&&++p<m;);v._next=N||null}}return i=new ue(i,o),i._enter=a,i._exit=c,i}function hl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gl(){return new ue(this._exit||this._groups.map(Zr),this._parents)}function pl(e,t,n){var o=this.enter(),r=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),o&&r?o.merge(r).order():r}function ml(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,s=o.length,i=Math.min(r,s),a=new Array(r),c=0;c<i;++c)for(var l=n[c],f=o[c],d=l.length,u=a[c]=new Array(d),g,m=0;m<d;++m)(g=l[m]||f[m])&&(u[m]=g);for(;c<r;++c)a[c]=n[c];return new ue(a,this._parents)}function xl(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,s=o[r],i;--r>=0;)(i=o[r])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function yl(e){e||(e=wl);function t(d,u){return d&&u?e(d.__data__,u.__data__):!d-!u}for(var n=this._groups,o=n.length,r=new Array(o),s=0;s<o;++s){for(var i=n[s],a=i.length,c=r[s]=new Array(a),l,f=0;f<a;++f)(l=i[f])&&(c[f]=l);c.sort(t)}return new ue(r,this._parents).order()}function wl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function vl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function bl(){return Array.from(this)}function _l(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length;r<s;++r){var i=o[r];if(i)return i}return null}function El(){let e=0;for(const t of this)++e;return e}function Sl(){return!this.node()}function Nl(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],s=0,i=r.length,a;s<i;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function Cl(e){return function(){this.removeAttribute(e)}}function kl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ml(e,t){return function(){this.setAttribute(e,t)}}function jl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Il(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Al(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Dl(e,t){var n=en(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?kl:Cl:typeof t=="function"?n.local?Al:Il:n.local?jl:Ml)(n,t))}function Ur(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Pl(e){return function(){this.style.removeProperty(e)}}function Tl(e,t,n){return function(){this.style.setProperty(e,t,n)}}
vendor: 5,006 bytes, line 2
2function zl(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Rl(e,t,n){return arguments.length>1?this.each((t==null?Pl:typeof t=="function"?zl:Tl)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Ur(e).getComputedStyle(e,null).getPropertyValue(t)}function $l(e){return function(){delete this[e]}}function Ll(e,t){return function(){this[e]=t}}function Hl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ol(e,t){return arguments.length>1?this.each((t==null?$l:typeof t=="function"?Hl:Ll)(e,t)):this.node()[e]}function qr(e){return e.trim().split(/^|\s+/)}function Xn(e){return e.classList||new Gr(e)}function Gr(e){this._node=e,this._names=qr(e.getAttribute("class")||"")}Gr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Kr(e,t){for(var n=Xn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Qr(e,t){for(var n=Xn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Bl(e){return function(){Kr(this,e)}}function Vl(e){return function(){Qr(this,e)}}function Fl(e,t){return function(){(t.apply(this,arguments)?Kr:Qr)(this,e)}}function Wl(e,t){var n=qr(e+"");if(arguments.length<2){for(var o=Xn(this.node()),r=-1,s=n.length;++r<s;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Fl:t?Bl:Vl)(n,t))}function Yl(){this.textContent=""}function Xl(e){return function(){this.textContent=e}}function Zl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Ul(e){return arguments.length?this.each(e==null?Yl:(typeof e=="function"?Zl:Xl)(e)):this.node().textContent}function ql(){this.innerHTML=""}function Gl(e){return function(){this.innerHTML=e}}function Kl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ql(e){return arguments.length?this.each(e==null?ql:(typeof e=="function"?Kl:Gl)(e)):this.node().innerHTML}function Jl(){this.nextSibling&&this.parentNode.appendChild(this)}function eu(){return this.each(Jl)}function tu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nu(){return this.each(tu)}function ou(e){var t=typeof e=="function"?e:Fr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ru(){return null}function su(e,t){var n=typeof e=="function"?e:Fr(e),o=t==null?ru:typeof t=="function"?t:Yn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function iu(){var e=this.parentNode;e&&e.removeChild(this)}function au(){return this.each(iu)}function cu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function lu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uu(e){return this.select(e?lu:cu)}function du(e){return arguments.length?this.property("__data__",e):this.node().__data__}function fu(e){return function(t){e.call(this,t,this.__data__)}}function hu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function gu(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++o]=s;++o?t.length=o:delete this.__on}}}function pu(e,t,n){return function(){var o=this.__on,r,s=fu(t);if(o){for(var i=0,a=o.length;i<a;++i)if((r=o[i]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},o?o.push(r):this.__on=[r]}}function mu(e,t,n){var o=hu(e+""),r,s=o.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,f;c<l;++c)for(r=0,f=a[c];r<s;++r)if((i=o[r]).type===f.type&&i.name===f.name)return f.value}return}for(a=t?pu:gu,r=0;r<s;++r)this.each(a(o[r],t,n));return this}function Jr(e,t,n){var o=Ur(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function xu(e,t){return function(){return Jr(this,e,t)}}function yu(e,t){return function(){return Jr(this,e,t.apply(this,arguments))}}function wu(e,t){return this.each((typeof t=="function"?yu:xu)(e,t))}function*vu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length,i;r<s;++r)(i=o[r])&&(yield i)}var es=[null];function ue(e,t){this._groups=e,this._parents=t}
vendor: 7,408 bytes, line 2
2function xt(){return new ue([[document.documentElement]],es)}function bu(){return this}ue.prototype=xt.prototype={constructor:ue,select:Zc,selectAll:Kc,selectChild:tl,selectChildren:sl,filter:il,data:fl,enter:al,exit:gl,join:pl,merge:ml,selection:bu,order:xl,sort:yl,call:vl,nodes:bl,node:_l,size:El,empty:Sl,each:Nl,attr:Dl,style:Rl,property:Ol,classed:Wl,text:Ul,html:Ql,raise:eu,lower:nu,append:ou,insert:su,remove:au,clone:uu,datum:du,on:mu,dispatch:wu,[Symbol.iterator]:vu};function ce(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],es)}function _u(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=_u(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Eu={passive:!1},ct={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Fe(e){e.preventDefault(),e.stopImmediatePropagation()}function ts(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Fe,ct);"onselectstart"in t?n.on("selectstart.drag",Fe,ct):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ns(e,t){var n=e.document.documentElement,o=ce(e).on("dragstart.drag",null);t&&(o.on("click.drag",Fe,ct),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const St=e=>()=>e;function jn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:s,x:i,y:a,dx:c,dy:l,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:f}})}jn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Su(e){return!e.ctrlKey&&!e.button}function Nu(){return this.parentNode}function Cu(e,t){return t??{x:e.x,y:e.y}}function ku(){return navigator.maxTouchPoints||"ontouchstart"in this}function os(){var e=Su,t=Nu,n=Cu,o=ku,r={},s=Jt("start","drag","end"),i=0,a,c,l,f,d=0;function u(v){v.on("mousedown.drag",g).filter(o).on("touchstart.drag",w).on("touchmove.drag",x,Eu).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(v,N){if(!(f||!e.call(this,v,N))){var E=p(this,t.call(this,v,N),v,N,"mouse");E&&(ce(v.view).on("mousemove.drag",m,ct).on("mouseup.drag",y,ct),ts(v.view),pn(v),l=!1,a=v.clientX,c=v.clientY,E("start",v))}}function m(v){if(Fe(v),!l){var N=v.clientX-a,E=v.clientY-c;l=N*N+E*E>d}r.mouse("drag",v)}function y(v){ce(v.view).on("mousemove.drag mouseup.drag",null),ns(v.view,l),Fe(v),r.mouse("end",v)}function w(v,N){if(e.call(this,v,N)){var E=v.changedTouches,j=t.call(this,v,N),D=E.length,P,O;for(P=0;P<D;++P)(O=p(this,j,v,N,E[P].identifier,E[P]))&&(pn(v),O("start",v,E[P]))}}function x(v){var N=v.changedTouches,E=N.length,j,D;for(j=0;j<E;++j)(D=r[N[j].identifier])&&(Fe(v),D("drag",v,N[j]))}function _(v){var N=v.changedTouches,E=N.length,j,D;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),j=0;j<E;++j)(D=r[N[j].identifier])&&(pn(v),D("end",v,N[j]))}function p(v,N,E,j,D,P){var O=s.copy(),A=de(P||E,N),z,H,b;if((b=n.call(v,new jn("beforestart",{sourceEvent:E,target:u,identifier:D,active:i,x:A[0],y:A[1],dx:0,dy:0,dispatch:O}),j))!=null)return z=b.x-A[0]||0,H=b.y-A[1]||0,function M(S,k,I){var T=A,R;switch(S){case"start":r[D]=M,R=i++;break;case"end":delete r[D],--i;case"drag":A=de(I||k,N),R=i;break}O.call(S,v,new jn(S,{sourceEvent:k,subject:b,target:u,identifier:D,active:R,x:A[0]+z,y:A[1]+H,dx:A[0]-T[0],dy:A[1]-T[1],dispatch:O}),j)}}return u.filter=function(v){return arguments.length?(e=typeof v=="function"?v:St(!!v),u):e},u.container=function(v){return arguments.length?(t=typeof v=="function"?v:St(v),u):t},u.subject=function(v){return arguments.length?(n=typeof v=="function"?v:St(v),u):n},u.touchable=function(v){return arguments.length?(o=typeof v=="function"?v:St(!!v),u):o},u.on=function(){var v=s.on.apply(s,arguments);return v===s?u:v},u.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,u):Math.sqrt(d)},u}var Ye=0,rt=0,nt=0,rs=1e3,Wt,st,Yt=0,ze=0,tn=0,lt=typeof performance=="object"&&performance.now?performance:Date,ss=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Zn(){return ze||(ss(Mu),ze=lt.now()+tn)}function Mu(){ze=0}function Xt(){this._call=this._time=this._next=null}Xt.prototype=is.prototype={constructor:Xt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Zn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Wt=this,st=this),this._call=e,this._time=n,In()},stop:function(){this._call&&(this._call=null,this._time=1/0,In())}};function is(e,t,n){var o=new Xt;return o.restart(e,t,n),o}function ju(){Zn(),++Ye;for(var e=Wt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ye}function Io(){ze=(Yt=lt.now())+tn,Ye=rt=0;try{ju()}finally{Ye=0,Au(),ze=0}}function Iu(){var e=lt.now(),t=e-Yt;t>rs&&(tn-=t,Yt=e)}function Au(){for(var e,t=Wt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Wt=n);st=e,In(o)}function In(e){if(!Ye){rt&&(rt=clearTimeout(rt));var t=e-ze;t>24?(e<1/0&&(rt=setTimeout(Io,e-lt.now()-tn)),nt&&(nt=clearInterval(nt))):(nt||(Yt=lt.now(),nt=setInterval(Iu,rs)),Ye=1,ss(Io))}}function Ao(e,t,n){var o=new Xt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Du=Jt("start","end","cancel","interrupt"),Pu=[],as=0,Do=1,An=2,Ht=3,Po=4,Dn=5,Ot=6;function nn(e,t,n,o,r,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Tu(e,n,{name:t,index:o,group:r,on:Du,tween:Pu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:as})}function Un(e,t){var n=ge(e,t);if(n.state>as)throw new Error("too late; already scheduled");return n}function xe(e,t){var n=ge(e,t);if(n.state>Ht)throw new Error("too late; already running");return n}function ge(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Tu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=is(s,0,n.time);function s(l){n.state=Do,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var f,d,u,g;if(n.state!==Do)return c();for(f in o)if(g=o[f],g.name===n.name){if(g.state===Ht)return Ao(i);g.state===Po?(g.state=Ot,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete o[f]):+f<t&&(g.state=Ot,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete o[f])}if(Ao(function(){n.state===Ht&&(n.state=Po,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=An,n.on.call("start",e,e.__data__,n.index,n.group),n.state===An){for(n.state=Ht,r=new Array(u
vendor: 4,852 bytes, line 2
2=n.tween.length),f=0,d=-1;f<u;++f)(g=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++d]=g);r.length=d+1}}function a(l){for(var f=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Dn,1),d=-1,u=r.length;++d<u;)r[d].call(e,f);n.state===Dn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ot,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Bt(e,t){var n=e.__transition,o,r,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){s=!1;continue}r=o.state>An&&o.state<Dn,o.state=Ot,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}s&&delete e.__transition}}function zu(e){return this.each(function(){Bt(this,e)})}function Ru(e,t){var n,o;return function(){var r=xe(this,e),s=r.tween;if(s!==n){o=n=s;for(var i=0,a=o.length;i<a;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}r.tween=o}}function $u(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var s=xe(this,e),i=s.tween;if(i!==o){r=(o=i).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}s.tween=r}}function Lu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=ge(this.node(),n).tween,r=0,s=o.length,i;r<s;++r)if((i=o[r]).name===e)return i.value;return null}return this.each((t==null?Ru:$u)(n,e,t))}function qn(e,t,n){var o=e._id;return e.each(function(){var r=xe(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return ge(r,o).value[t]}}function cs(e,t){var n;return(typeof t=="number"?Ie:t instanceof wo?vo:(n=wo(t))?(t=n,vo):ic)(e,t)}function Hu(e){return function(){this.removeAttribute(e)}}function Ou(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Bu(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttribute(e);return i===r?null:i===o?s:s=t(o=i,n)}}function Vu(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===r?null:i===o?s:s=t(o=i,n)}}function Fu(e,t,n){var o,r,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=a+"",i===c?null:i===o&&c===r?s:(r=c,s=t(o=i,a)))}}function Wu(e,t,n){var o,r,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=a+"",i===c?null:i===o&&c===r?s:(r=c,s=t(o=i,a)))}}function Yu(e,t){var n=en(e),o=n==="transform"?$c:cs;return this.attrTween(e,typeof t=="function"?(n.local?Wu:Fu)(n,o,qn(this,"attr."+e,t)):t==null?(n.local?Ou:Hu)(n):(n.local?Vu:Bu)(n,o,t))}function Xu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Uu(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&Zu(e,s)),n}return r._value=t,r}function qu(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&Xu(e,s)),n}return r._value=t,r}function Gu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=en(e);return this.tween(n,(o.local?Uu:qu)(o,t))}function Ku(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function Qu(e,t){return t=+t,function(){Un(this,e).delay=t}}function Ju(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ku:Qu)(t,e)):ge(this.node(),t).delay}function ed(e,t){return function(){xe(this,e).duration=+t.apply(this,arguments)}}function td(e,t){return t=+t,function(){xe(this,e).duration=t}}function nd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ed:td)(t,e)):ge(this.node(),t).duration}function od(e,t){if(typeof t!="function")throw new Error;return function(){xe(this,e).ease=t}}function rd(e){var t=this._id;return arguments.length?this.each(od(t,e)):ge(this.node(),t).ease}function sd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;xe(this,e).ease=n}}function id(e){if(typeof e!="function")throw new Error;return this.each(sd(this._id,e))}function ad(e){typeof e!="function"&&(e=Yr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,a=o[r]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new be(o,this._parents,this._name,this._id)}function cd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,s=Math.min(o,r),i=new Array(o),a=0;a<s;++a)for(var c=t[a],l=n[a],f=c.length,d=i[a]=new Array(f),u,g=0;g<f;++g)(u=c[g]||l[g])&&(d[g]=u);for(;a<o;++a)i[a]=t[a];return new be(i,this._parents,this._name,this._id)}function ld(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>
vendor: 15,124 bytes, line 2
2=0&&(t=t.slice(0,n)),!t||t==="start"})}function ud(e,t,n){var o,r,s=ld(t)?Un:xe;return function(){var i=s(this,e),a=i.on;a!==o&&(r=(o=a).copy()).on(t,n),i.on=r}}function dd(e,t){var n=this._id;return arguments.length<2?ge(this.node(),n).on.on(e):this.each(ud(n,e,t))}function fd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function hd(){return this.on("end.remove",fd(this._id))}function gd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yn(e));for(var o=this._groups,r=o.length,s=new Array(r),i=0;i<r;++i)for(var a=o[i],c=a.length,l=s[i]=new Array(c),f,d,u=0;u<c;++u)(f=a[u])&&(d=e.call(f,f.__data__,u,a))&&("__data__"in f&&(d.__data__=f.__data__),l[u]=d,nn(l[u],t,n,u,l,ge(f,n)));return new be(s,this._parents,t,n)}function pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Wr(e));for(var o=this._groups,r=o.length,s=[],i=[],a=0;a<r;++a)for(var c=o[a],l=c.length,f,d=0;d<l;++d)if(f=c[d]){for(var u=e.call(f,f.__data__,d,c),g,m=ge(f,n),y=0,w=u.length;y<w;++y)(g=u[y])&&nn(g,t,n,y,u,m);s.push(u),i.push(f)}return new be(s,i,t,n)}var md=xt.prototype.constructor;function xd(){return new md(this._groups,this._parents)}function yd(e,t){var n,o,r;return function(){var s=We(this,e),i=(this.style.removeProperty(e),We(this,e));return s===i?null:s===n&&i===o?r:r=t(n=s,o=i)}}function ls(e){return function(){this.style.removeProperty(e)}}function wd(e,t,n){var o,r=n+"",s;return function(){var i=We(this,e);return i===r?null:i===o?s:s=t(o=i,n)}}function vd(e,t,n){var o,r,s;return function(){var i=We(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),We(this,e))),i===c?null:i===o&&c===r?s:(r=c,s=t(o=i,a))}}function bd(e,t){var n,o,r,s="style."+t,i="end."+s,a;return function(){var c=xe(this,e),l=c.on,f=c.value[s]==null?a||(a=ls(t)):void 0;(l!==n||r!==f)&&(o=(n=l).copy()).on(i,r=f),c.on=o}}function _d(e,t,n){var o=(e+="")=="transform"?Rc:cs;return t==null?this.styleTween(e,yd(e,o)).on("end.style."+e,ls(e)):typeof t=="function"?this.styleTween(e,vd(e,o,qn(this,"style."+e,t))).each(bd(this._id,e)):this.styleTween(e,wd(e,o,t),n).on("end.style."+e,null)}function Ed(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Sd(e,t,n){var o,r;function s(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&Ed(e,i,n)),o}return s._value=t,s}function Nd(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Sd(e,t,n??""))}function Cd(e){return function(){this.textContent=e}}function kd(e){return function(){var t=e(this);this.textContent=t??""}}function Md(e){return this.tween("text",typeof e=="function"?kd(qn(this,"text",e)):Cd(e==null?"":e+""))}function jd(e){return function(t){this.textContent=e.call(this,t)}}function Id(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&jd(r)),t}return o._value=e,o}function Ad(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Id(e))}function Dd(){for(var e=this._name,t=this._id,n=us(),o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var f=ge(c,t);nn(c,e,n,l,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new be(o,this._parents,e,n)}function Pd(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(s,i){var a={value:i},c={value:function(){--r===0&&s()}};n.each(function(){var l=xe(this,o),f=l.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&s()})}var Td=0;function be(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function us(){return++Td}var we=xt.prototype;be.prototype={constructor:be,select:gd,selectAll:pd,selectChild:we.selectChild,selectChildren:we.selectChildren,filter:ad,merge:cd,selection:xd,transition:Dd,call:we.call,nodes:we.nodes,node:we.node,size:we.size,empty:we.empty,each:we.each,on:dd,attr:Yu,attrTween:Gu,style:_d,styleTween:Nd,text:Md,textTween:Ad,remove:hd,tween:Lu,delay:Ju,duration:nd,ease:rd,easeVarying:id,end:Pd,[Symbol.iterator]:we[Symbol.iterator]};function zd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Rd={time:null,delay:0,duration:250,ease:zd};function $d(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Ld(e){var t,n;e instanceof be?(t=e._id,e=e._name):(t=us(),(n=Rd).time=Zn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&nn(c,e,t,l,i,n||$d(c,t));return new be(o,this._parents,e,t)}xt.prototype.interrupt=zu;xt.prototype.transition=Ld;const Nt=e=>()=>e;function Hd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function ve(e,t,n){this.k=e,this.x=t,this.y=n}ve.prototype={constructor:ve,scale:function(e){return e===1?this:new ve(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ve(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var on=new ve(1,0,0);ds.prototype=ve.prototype;function ds(e){for(;!e.__zoom;)if(!(e=e.parentNode))return on;return e.__zoom}function mn(e){e.stopImmediatePropagation()}function ot(e){e.preventDefault(),e.stopImmediatePropagation()}function Od(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Bd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function To(){return this.__zoom||on}function Vd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function fs(){var e=Od,t=Bd,n=Wd,o=Vd,r=Fd,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=$t,l=Jt("start","zoom","end"),f,d,u,g=500,m=150,y=0,w=10;function x(b){b.property("__zoom",To).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(b,M,S,k){var I=b.selection?b.selection():b;I.property("__zoom",To),b!==I?N(b,M,S,k):I.interrupt().each(function(){E(this,arguments).event(k).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},x.scaleBy=function(b,M,S,k){x.scaleTo(b,function(){var I=this.__zoom.k,T=typeof M=="function"?M.apply(this,arguments):M;return I*T},S,k)},x.scaleTo=function(b,M,S,k){x.transform(b,function(){var I=t.apply(this,arguments),T=this.__zoom,R=S==null?v(I):typeof S=="function"?S.apply(this,arguments):S,L=T.invert(R),$=typeof M=="function"?M.apply(this,arguments):M;return n(p(_(T,$),R,L),I,i)},S,k)},x.translateBy=function(b,M,S,k){x.transform(b,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),i)},null,k)},x.translateTo=function(b,M,S,k,I){x.transform(b,function(){var T=t.apply(this,arguments),R=this.__zoom,L=k==null?v(T):typeof k=="function"?k.apply(this,arguments):k;return n(on.translate(L[0],L[1]).scale(R.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof S=="function"?-S.apply(this,arguments):-S),T,i)},k,I)};function _(b,M){return M=Math.max(s[0],Math.min(s[1],M)),M===b.k?b:new ve(M,b.x,b.y)}function p(b,M,S){var k=M[0]-S[0]*b.k,I=M[1]-S[1]*b.k;return k===b.x&&I===b.y?b:new ve(b.k,k,I)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function N(b,M,S,k){b.on("start.zoom",function(){E(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(k).end()}).tween("zoom",function(){var I=this,T=arguments,R=E(I,T).event(k),L=t.apply(I,T),$=S==null?v(L):typeof S=="function"?S.apply(I,T):S,W=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),F=I.__zoom,Z=typeof M=="function"?M.apply(I,T):M,G=c(F.invert($).concat(W/F.k),Z.invert($).concat(W/Z.k));return function(V){if(V===1)V=Z;else{var B=G(V),X=W/B[2];V=new ve(X,$[0]-B[0]*X,$[1]-B[1]*X)}R.zoom(null,V)}})}function E(b,M,S){return!S&&b.__zooming||new j(b,M)}function j(b,M){this.that=b,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,M),this.taps=0}j.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,M){return this.mouse&&b!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var M=ce(this.that).datum();l.call(b,this.that,new Hd(b,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:l}),M)}};function D(b,...M){if(!e.apply(this,arguments))return;var S=E(this,M).event(b),k=this.__zoom,I=Math.max(s[0],Math.min(s[1],k.k*Math.pow(2,o.apply(this,arguments)))),T=de(b);if(S.wheel)(S.mouse[0][0]!==T[0]||S.mouse[0][1]!==T[1])&&(S.mouse[1]=k.invert(S.mouse[0]=T)),clearTimeout(S.wheel);else{if(k.k===I)return;S.mouse=[T,k.invert(T)],Bt(this),S.start()}ot(b),S.wheel=setTimeout(R,m),S.zoom("mouse",n(p(_(k,I),S.mouse[0],S.mouse[1]),S.extent,i));function R(){S.wheel=null,S.end()}}function P(b,...M){if(u||!e.apply(this,arguments))return;var S=b.currentTarget,k=E(this,M,!0).event(b),I=ce(b.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",W,!0),T=de(b,S),R=b.clientX,L=b.clientY;ts(b.view),mn(b),k.mouse=[T,this.__zoom.invert(T)],Bt(this),k.start();function $(F){if(ot(F),!k.moved){var Z=F.clientX-R,G=F.clientY-L;k.moved=Z*Z+G*G>y}k.event(F).zoom("mouse",n(p(k.that.__zoom,k.mouse[0]=de(F,S),k.mouse[1]),k.extent,i))}function W(F){I.on("mousemove.zoom mouseup.zoom",null),ns(F.view,k.moved),ot(F),k.event(F).end()}}function O(b,...M){if(e.apply(this,arguments)){var S=this.__zoom,k=de(b.changedTouches?b.changedTouches[0]:b,this),I=S.invert(k),T=S.k*(b.shiftKey?.5:2),R=n(p(_(S,T),k,I),t.apply(this,M),i);ot(b),a>0?ce(this).transition().duration(a).call(N,R,k,b):ce(this).call(x.transform,R,k,b)}}function A(b,...M){if(e.apply(this,arguments)){var S=b.touches,k=S.length,I=E(this,M,b.changedTouches.length===k).event(b),T,R,L,$;for(mn(b),R=0;R<k;++R)L=S[R],$=de(L,this),$=[$,this.__zoom.invert($),L.identifier],I.touch0?!I.touch1&&I.touch0[2]!==$[2]&&(I.touch1=$,I.taps=0):(I.touch0=$,T=!0,I.taps=1+!!f);f&&(f=clearTimeout(f)),T&&(I.taps<2&&(d=$[0],f=setTimeout(function(){f=null},g)),Bt(this),I.start())}}function z(b,...M){if(this.__zooming){var S=E(this,M).event(b),k=b.changedTouches,I=k.length,T,R,L,$;for(ot(b),T=0;T<I;++T)R=k[T],L=de(R,this),S.touch0&&S.touch0[2]===R.identifier?S.touch0[0]=L:S.touch1&&S.touch1[2]===R.identifier&&(S.touch1[0]=L);if(R=S.that.__zoom,S.touch1){var W=S.touch0[0],F=S.touch0[1],Z=S.touch1[0],G=S.touch1[1],V=(V=Z[0]-W[0])*V+(V=Z[1]-W[1])*V,B=(B=G[0]-F[0])*B+(B=G[1]-F[1])*B;R=_(R,Math.sqrt(V/B)),L=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],$=[(F[0]+G[0])/2,(F[1]+G[1])/2]}else if(S.touch0)L=S.touch0[0],$=S.touch0[1];else return;S.zoom("touch",n(p(R,L,$),S.extent,i))}}function H(b,...M){if(this.__zooming){var S=E(this,M).event(b),k=b.changedTouches,I=k.length,T,R;for(mn(b),u&&clearTimeout(u),u=setTimeout(function(){u=null},g),T=0;T<I;++T)R=k[T],S.touch0&&S.touch0[2]===R.identifier?delete S.touch0:S.touch1&&S.touch1[2]===R.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(R=de(R,this),Math.hypot(d[0]-R[0],d[1]-R[1])<w)){var L=ce(this).on("dblclick.zoom");L&&L.apply(this,arguments)}}}return x.wheelDelta=function(b){return arguments.length?(o=typeof b=="function"?b:Nt(+b),x):o},x.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Nt(!!b),x):e},x.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:Nt(!!b),x):r},x.extent=function(b){return arguments.length?(t=typeof b=="function"?b:Nt([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),x):t},x.scaleExtent=function(b){return arguments.length?(s[0]=+b[0],s[1]=+b[1],x):[s[0],s[1]]},x.translateExtent=function(b){return arguments.length?(i[0][0]=+b[0][0],i[1][0]=+b[1][0],i[0][1]=+b[0][1],i[1][1]=+b[1][1],x):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},x.constrain=function(b){return arguments.length?(n=b,x):n},x.duration=function(b){return arguments.length?(a=+b,x):a},x.interpolate=function(b){return arguments.length?(c=b,x):c},x.on=function(){var b=l.on.apply(l,arguments);return b===l?x:b},x.clickDistance=function(b){return arguments.length?(y=(b=+b)*b,x):Math.sqrt(y)},x.tapDistance=function(b){return arguments.length?(w=+b,x):w},x}const me={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>
2`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ut=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],hs=["Enter"," ","Escape"],gs={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Xe;(function(e){e.Strict="strict",e.Loose="loose"})(Xe||(Xe={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var dt;(function(e){e.Partial="partial",e.Full="full"})(dt||(dt={}));const ps={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ke;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ke||(ke={}));var Zt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Zt||(Zt={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const zo={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function ms(e){return e===null?null:e?"valid":"invalid"}const xs=e=>"id"in e&&"source"in e&&"target"in e,Yd=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),yt=(e,t=[0,0])=>{const{width:n,height:o}=_e(e),r=e.origin??t,s=n*r[0],i=o*r[1];return{x:e.position.x-s,y:e.position.y-i}},Xd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const s=typeof r=="string";let i=!t.nodeLookup&&!s?r:void 0;t.nodeLookup&&(i=s?t.nodeLookup.get(r):Gn(r)?r:t.nodeLookup.get(r.id));const a=i?Ut(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return rn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return sn(n)},wt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=rn(n,Ut(r)),o=!0)}),o?sn(n):{x:0,y:0,width:0,height:0}},Kn=(e,t,[n,o,r]=[0,0,1],s=!1,i=!1)=>{const a={...bt(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const l of e.values()){const{measured:f,selectable:d=!0,hidden:u=!1}=l;if(i&&!d||u)continue;const g=f.width??l.width??l.initialWidth??null,m=f.height??l.height??l.initialHeight??null,y=ft(a,Ue(l)),w=(g??0)*(m??0),x=s&&y>0;(!l.internals.handleBounds||x||y>=w||l.dragging)&&c.push(l)}return c},Zd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Ud(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}
2async function qd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:s},i){if(e.size===0)return Promise.resolve(!0);const a=Ud(e,i),c=wt(a),l=Qn(c,t,n,i?.minZoom??r,i?.maxZoom??s,i?.padding??.1);return await o.setViewport(l,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function ys({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:s}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},f=i.origin??o;let d=i.extent||r;if(i.extent==="parent"&&!i.expandParent)if(!a)s?.("005",me.error005());else{const g=a.measured.width,m=a.measured.height;g&&m&&(d=[[c,l],[c+g,l+m]])}else a&&qe(i.extent)&&(d=[[i.extent[0][0]+c,i.extent[0][1]+l],[i.extent[1][0]+c,i.extent[1][1]+l]]);const u=qe(d)?Re(t,d,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&s?.("015",me.error015()),{position:{x:u.x-c+(i.measured.width??0)*f[0],y:u.y-l+(i.measured.height??0)*f[1]},positionAbsolute:u}}async function Gd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const s=new Set(e.map(u=>u.id)),i=[];for(const u of n){if(u.deletable===!1)continue;const g=s.has(u.id),m=!g&&u.parentId&&i.find(y=>y.id===u.parentId);(g||m)&&i.push(u)}const a=new Set(t.map(u=>u.id)),c=o.filter(u=>u.deletable!==!1),f=Zd(i,c);for(const u of c)a.has(u.id)&&!f.find(m=>m.id===u.id)&&f.push(u);if(!r)return{edges:f,nodes:i};const d=await r({nodes:i,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:i}:{edges:[],nodes:[]}:d}const Ze=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Re=(e={x:0,y:0},t,n)=>({x:Ze(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ze(e.y,t[0][1],t[1][1]-(n?.height??0))});function ws(e,t,n){const{width:o,height:r}=_e(n),{x:s,y:i}=n.internals.positionAbsolute;return Re(e,[[s,i],[s+o,i+r]],t)}const Ro=(e,t,n)=>e<t?Ze(Math.abs(e-t),1,t)/t:e>n?-Ze(Math.abs(e-n),1,t)/t:0,vs=(e,t,n=15,o=40)=>{const r=Ro(e.x,o,t.width-o)*n,s=Ro(e.y,o,t.height-o)*n;return[r,s]},rn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Pn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),sn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ue=(e,t=[0,0])=>{const{x:n,y:o}=Gn(e)?e.internals.positionAbsolute:yt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{const{x:n,y:o}=Gn(e)?e.internals.positionAbsolute:yt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},bs=(e,t)=>sn(rn(Pn(e),Pn(t))),ft=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},$o=e=>fe(e.width)&&fe(e.height)&&fe(e.x)&&fe(e.y),fe=e=>!isNaN(e)&&isFinite(e),Kd=(e,t)=>{},vt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bt=({x:e,y:t},[n,o,r],s=!1,i=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return s?vt(a,i):a},qt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function He(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Qd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=He(e,n),r=He(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=He(e.top??e.y??0,n),r=He(e.bottom??e.y??0,n),s=He(e.left??e.x??0,t),i=He(e.right??e.x??0,t);return{top:o,right:i,bottom:r,left:s,x:s+i,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Jd(e,t,n,o,r,s){const{x:i,y:a}=qt(e,[t,n,o]),{x:c,y:l}=qt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=r-c,d=s-l;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(d)}}const Qn=(e,t,n,o,r,s)=>{const i=Qd(s,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c
2),f=Ze(l,o,r),d=e.x+e.width/2,u=e.y+e.height/2,g=t/2-d*f,m=n/2-u*f,y=Jd(e,g,m,f,t,n),w={left:Math.min(y.left-i.left,0),top:Math.min(y.top-i.top,0),right:Math.min(y.right-i.right,0),bottom:Math.min(y.bottom-i.bottom,0)};return{x:g-w.left+w.right,y:m-w.top+w.bottom,zoom:f}},ht=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function qe(e){return e!=null&&e!=="parent"}function _e(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function _s(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Es(e,t={width:0,height:0},n,o,r){const s={...e},i=o.get(n);if(i){const a=i.origin||r;s.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return s}function Lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ef(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function tf(e){return{...gs,...e||{}}}function it(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:s,y:i}=he(e),a=bt({x:s-(r?.left??0),y:i-(r?.top??0)},o),{x:c,y:l}=n?vt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Jn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ss=e=>e?.getRootNode?.()||window?.document,nf=["INPUT","SELECT","TEXTAREA"];function Ns(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:nf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".
2nokey")}const Cs=e=>"clientX"in e,he=(e,t)=>{const n=Cs(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Ho=(e,t,n,o,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:r,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...Jn(i)}})};function ks({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:i,targetControlY:a}){const c=e*.125+r*.375+i*.375+n*.125,l=t*.125+s*.375+a*.375+o*.125,f=Math.abs(c-e),d=Math.abs(l-t);return[c,l,f,d]}function Ct(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Oo({pos:e,x1:t,y1:n,x2:o,y2:r,c:s}){switch(e){case Y.Left:return[t-Ct(t-o,s),n];case Y.Right:return[t+Ct(o-t,s),n];case Y.Top:return[t,n-Ct(n-r,s)];case Y.Bottom:return[t,n+Ct(r-n,s)]}}function Ms({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:s=Y.Top,curvature:i=.25}){const[a,c]=Oo({pos:n,x1:e,y1:t,x2:o,y2:r,c:i}),[l,f]=Oo({pos:s,x1:o,y1:r,x2:e,y2:t,c:i}),[d,u,g,m]=ks({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${o},${r}`,d,u,g,m]}function js({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,s=n<e?n+r:n-r,i=Math.abs(o-t)/2,a=o<t?o+i:o-i;return[s,a,r,i]}function of({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return o;const i=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return i+a}function rf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const s=rn(Ut(e),Ut(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const i={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ft(i,sn(s))>0}const sf=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,af=(e,t)=>
2t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),cf=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||sf;let r;return xs(e)?r={...e}:r={...e,id:o(e)},af(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Is({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,s,i,a]=js({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,s,i,a]}const Bo={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},lf=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Vo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function uf({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:o=Y.Top,center:r,offset:s,stepPosition:i}){const a=Bo[t],c=Bo[o],l={x:e.x+a.x*s,y:e.y+a.y*s},f={x:n.x+c.x*s,y:n.y+c.y*s},d=lf({source:l,sourcePosition:t,target:f}),u=d.x!==0?"x":"y",g=d[u];let m=[],y,w;const x={x:0,y:0},_={x:0,y:0},[,,p,v]=js({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[u]*c[u]===-1){u==="x"?(y=r.x??l.x+(f.x-l.x)*i,w=r.y??(l.y+f.y)/2):(y=r.x??(l.x+f.x)/2,w=r.y??l.y+(f.y-l.y)*i);const D=[{x:y,y:l.y},{x:y,y:f.y}],P=[{x:l.x,y:w},{x:f.x,y:w}];a[u]===g?m=u==="x"?D:P:m=u==="x"?P:D}else{const D=[{x:l.x,y:f.y}],P=[{x:f.x,y:l.y}];if(u==="x"?m=a.x===g?P:D:m=a.y===g?D:P,t===o){const b=Math.abs(e[u]-n[u]);if(b<=s){const M=Math.min(s-1,s-b);a[u]===g?x[u]=(l[u]>e[u]?-1:1)*M:_[u]=(f[u]>n[u]?-1:1)*M}}if(t!==o){const b=u==="x"?"y":"x",M=a[u]===c[b],S=l[b]>f[b],k=l[b]<f[b];(a[u]===1&&(!M&&S||M&&k)||a[u]!==1&&(!M&&k||M&&S))&&(m=u==="x"?D:P)}const O={x:l.x+x.x,y:l.y+x.y},A={x:f.x+_.x,y:f.y+_.y},z=Math.max(Math.abs(O.x-m[0].x),Math.abs(A.x-m[0].x)),H=Math.max(Math.abs(O.y-m[0].y),Math.abs(A.y-m[0].y));z>=H?(y=(O.x+A.x)/2,w=m[0].y):(y=m[0].x,w=(O.y+A.y)/2)}const N={x:l.x+x.x,y:l.y+x.y},E={x:f.x+_.x,y:f.y+_.y};return[[e,...N.x!==m[0].x||N.y!==m[0].y?[N]:[],...m,...E.x!==m[m.length-1].x||E.y!==m[m.length-1].y?[E]:[],n],y,w,p,v]}function df(e,t,n,o){const r=Math.min(Vo(e,t)/2,Vo(t,n)/2,o),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const l=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${s+r*l},${i}Q ${s},${i} ${s},${i+r*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${s},${i+r*c}Q ${s},${i} ${s+r*a},${i}`}function Gt({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:s=Y.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20,stepPosition:f=.5}){const[d,u,g,m,y]=uf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:a,y:c},offset:l,stepPosition:f});let w=`M${d[0].x} ${d[0].y}`;for(let x=1;x<d.length-1;x++)w+=df(d[x-1],d[x],d[x+1],i);return w+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[w,u,g,m,y]}function Fo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ff(e){const{sourceNode:t,targetNode:n}=e;if(!Fo(t)||!Fo(n))return null;const o=t.internals.handleBounds||Wo(t.handles),r=n.internals.handleBounds||Wo(n.handles),s=Yo(o?.source??[],e.sourceHandle),i=Yo(e.connectionMode===Xe.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!s||!i)return e.onError?.("008",me.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=s?.position||Y.Bottom,c=i?.position||Y.Top,l=$e(t,s,a),f=$e(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Wo(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function $e(e,t,n=Y.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,s=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??_e(e);if(o)return{x:r+i/2,y:s+a/2};switch(t?.position??n){case Y.Top:return{x:r+i/2,y:s};case Y.Right:return{x:r+i,y:s+a/2};case Y.Bottom:return{x:r+i/2,y:s+a};case Y.Left:return{x:r,y:s+a/2}}}function Yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Tn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function hf(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const s=new Set;return e.reduce((i,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=Tn(c,t);s.has(l)||(i.push({id:l,color:c.color||n,...c}),s.add(l))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const As=1e3,gf=10,eo={nodeOrigin:[0,0],nodeExtent:ut,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},pf={...eo,checkEquality:!0};function to(e,t){const n={...e};
2for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function mf(e,t,n){const o=to(eo,n);for(const r of e.values())if(r.parentId)oo(r,e,t,o);else{const s=yt(r,o.nodeOrigin),i=qe(r.extent)?r.extent:o.nodeExtent,a=Re(s,i,_e(r));r.internals.positionAbsolute=a}}function xf(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const s={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(s):r.type==="target"&&o.push(s)}return{source:n,target:o}}function no(e){return e==="manual"}function zn(e,t,n,o={}){const r=to(pf,o),s={i:0},i=new Map(t),a=r?.elevateNodesOnSelect&&!no(r.zIndexMode)?As:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let d=i.get(f.id);if(r.checkEquality&&f===d?.internals.userNode)t.set(f.id,d);else{const u=yt(f,r.nodeOrigin),g=qe(f.extent)?f.extent:r.nodeExtent,m=Re(u,g,_e(f));d={...r.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:m,handleBounds:xf(f,d),z:Ds(f,a,r.zIndexMode),userNode:f}},t.set(f.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),f.parentId&&oo(d,t,n,o,s),l||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function yf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function oo(e,t,n,o,r){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=to(eo,o),l=e.parentId,f=t.get(l);if(!f){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}yf(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*gf),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const d=s&&!no(c)?As:0,{x:u,y:g,z:m}=wf(e,f,i,a,d,c),{positionAbsolute:y}=e.internals,w=u!==y.x||g!==y.y;(w||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:u,y:g}:y,z:m}})}function Ds(e,t,n){const o=fe(e.zIndex)?e.zIndex:0;return no(n)?o:o+(e.selected?t:0)}function wf(e,t,n,o,r,s){const{x:i,y:a}=t.internals.positionAbsolute,c=_e(e),l=yt(e,n),f=qe(e.extent)?Re(l,e.extent,c):l;let d=Re({x:i+f.x,y:a+f.y},o,c);e.extent==="parent"&&(d=ws(d,c,t));const u=Ds(e,r,s),g=t.internals.z??0;return{x:d.x,y:d.y,z:g>=u?g+1:u}}function ro(e,t,n,o=[0,0]){const r=[],s=new Map;for(const i of e){const a=t.get(i.parentId);if(!a)continue;const c=s.get(i.parentId)?.expandedRect??Ue(a),l=bs(c,i.rect);s.set(i.parentId,{expandedRect:l,parent:a})}return s.size>0&&s.forEach(({expandedRect:i,parent:a},c)=>{const l=a.internals.positionAbsolute,f=_e(a),d=a.origin??o,u=i.x<l.x?Math.round(Math.abs(l.x-i.x)):0,g=i.y<l.y?Math.round(Math.abs(l.y-i.y)):0,m=Math.max(f.width,Math.round(i.width)),y=Math.max(f.height,Math.round(i.height)),w=(m-f.width)*d[0],x=(y-f.height)*d[1];(u>0||g>0||w||x)&&(r.push({id:c,type:"position",position:{x:a.position.x-u+w,y:a.position.y-g+x}}),n.get(c)?.forEach(_=>{e.some(p=>p.id===_.id)||r.push({id:_.id,type:"position",position:{x:_.position.x+u,y:_.position.y+g}})})),(f.width<i.width||f.height<i.height||u||g)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(u?d[0]*u-w:0),height:y+(g?d[1]*g-x:0)}})}),r}function vf(e,t,n,o,r,s,i){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],f=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(f.transform),u=[];for(const g of e.values()){const m=t.get(g.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const y=Jn(g.nodeElement),w=m.measured.width!==y.width||m.measured.height!==y.height;if(!!(y.width&&y.height&&(w||!m.internals.handleBounds||g.force))){const _=g.nodeElement.getBoundingClientRect(),p=qe(m.extent)?m.extent:s;let{positionAbsolute:v}=m.internals;m.parentId&&m.extent==="parent"?v=ws(v,y,t.get(m.parentId)):p&&(v=Re(v,p,y)
2);const N={...m,measured:y,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Ho("source",g.nodeElement,_,d,m.id),target:Ho("target",g.nodeElement,_,d,m.id)}}};t.set(m.id,N),m.parentId&&oo(N,t,n,{nodeOrigin:r,zIndexMode:i}),c=!0,w&&(l.push({id:m.id,type:"dimensions",dimensions:y}),m.expandParent&&m.parentId&&u.push({id:m.id,parentId:m.parentId,rect:Ue(N,r)}))}}if(u.length>0){const g=ro(u,t,n,r);l.push(...g)}return{changes:l,updatedInternals:c}}async function bf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:s}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],o),a=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(a)}function Xo(e,t,n,o,r,s){let i=r;const a=o.get(i)||new Map;o.set(i,a.set(n,t)),i=`${r}-${e}`;const c=o.get(i)||new Map;if(o.set(i,c.set(n,t)),s){i=`${r}-${e}-${s}`;const l=o.get(i)||new Map;o.set(i,l.set(n,t))}}function Ps(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:s,sourceHandle:i=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:s,sourceHandle:i,targetHandle:a},l=`${r}-${i}--${s}-${a}`,f=`${s}-${a}--${r}-${i}`;Xo("source",c,f,e,r,i),Xo("target",c,l,e,s,a),t.set(o.id,o)}}function Ts(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ts(n,t):!1}function Zo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function _f(e,t,n,o){const r=new Map;for(const[s,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!Ts(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(s);a&&r.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[i,a]of t){const c=n.get(i)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:o}:r[0],r]}function Ef({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:o-r.distance.y},i=vt(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Sf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let s={x:null,y:null},i=0,a=new Map,c=!1,l={x:0,y:0},f=null,d=!1,u=null,g=!1,m=!1,y=null;function w({noDragClassName:_,handleSelector:p,domNode:v,isSelectable:N,nodeId:E,nodeClickDistance:j=0}){u=ce(v);function D({x:z,y:H}
2){const{nodeLookup:b,nodeExtent:M,snapGrid:S,snapToGrid:k,nodeOrigin:I,onNodeDrag:T,onSelectionDrag:R,onError:L,updateNodePositions:$}=t();s={x:z,y:H};let W=!1;const F=a.size>1,Z=F&&M?Pn(wt(a)):null,G=F&&k?Ef({dragItems:a,snapGrid:S,x:z,y:H}):null;for(const[V,B]of a){if(!b.has(V))continue;let X={x:z-B.distance.x,y:H-B.distance.y};k&&(X=G?{x:Math.round(X.x+G.x),y:Math.round(X.y+G.y)}:vt(X,S));let Q=null;if(F&&M&&!B.extent&&Z){const{positionAbsolute:q}=B.internals,ee=q.x-Z.x+M[0][0],ne=q.x+B.measured.width-Z.x2+M[1][0],te=q.y-Z.y+M[0][1],ie=q.y+B.measured.height-Z.y2+M[1][1];Q=[[ee,te],[ne,ie]]}const{position:K,positionAbsolute:U}=ys({nodeId:V,nextPosition:X,nodeLookup:b,nodeExtent:Q||M,nodeOrigin:I,onError:L});W=W||B.position.x!==K.x||B.position.y!==K.y,B.position=K,B.internals.positionAbsolute=U}if(m=m||W,!!W&&($(a,!0),y&&(o||T||!E&&R))){const[V,B]=xn({nodeId:E,dragItems:a,nodeLookup:b});o?.(y,a,V,B),T?.(y,V,B),E||R?.(y,B)}}async function P(){if(!f)return;const{transform:z,panBy:H,autoPanSpeed:b,autoPanOnNodeDrag:M}=t();if(!M){c=!1,cancelAnimationFrame(i);return}const[S,k]=vs(l,f,b);(S!==0||k!==0)&&(s.x=(s.x??0)-S/z[2],s.y=(s.y??0)-k/z[2],await H({x:S,y:k})&&D(s)),i=requestAnimationFrame(P)}function O(z){const{nodeLookup:H,multiSelectionActive:b,nodesDraggable:M,transform:S,snapGrid:k,snapToGrid:I,selectNodesOnDrag:T,onNodeDragStart:R,onSelectionDragStart:L,unselectNodesAndEdges:$}=t();d=!0,(!T||!N)&&!b&&E&&(H.get(E)?.selected||$()),N&&T&&E&&e?.(E);const W=it(z.sourceEvent,{transform:S,snapGrid:k,snapToGrid:I,containerBounds:f});if(s=W,a=_f(H,M,W,E),a.size>0&&(n||R||!E&&L)){const[F,Z]=xn({nodeId:E,dragItems:a,nodeLookup:H});n?.(z.sourceEvent,a,F,Z),R?.(z.sourceEvent,F,Z),E||L?.(z.sourceEvent,Z)}}const A=os().clickDistance(j).on("start",z=>{const{domNode:H,nodeDragThreshold:b,transform:M,snapGrid:S,snapToGri
2d:k}=t();f=H?.getBoundingClientRect()||null,g=!1,m=!1,y=z.sourceEvent,b===0&&O(z),s=it(z.sourceEvent,{transform:M,snapGrid:S,snapToGrid:k,containerBounds:f}),l=he(z.sourceEvent,f)}).on("drag",z=>{const{autoPanOnNodeDrag:H,transform:b,snapGrid:M,snapToGrid:S,nodeDragThreshold:k,nodeLookup:I}=t(),T=it(z.sourceEvent,{transform:b,snapGrid:M,snapToGrid:S,containerBounds:f});if(y=z.sourceEvent,(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1||E&&!I.has(E))&&(g=!0),!g){if(!c&&H&&d&&(c=!0,P()),!d){const R=he(z.sourceEvent,f),L=R.x-l.x,$=R.y-l.y;Math.sqrt(L*L+$*$)>k&&O(z)}(s.x!==T.xSnapped||s.y!==T.ySnapped)&&a&&d&&(l=he(z.sourceEvent,f),D(T))}}).on("end",z=>{if(!(!d||g)&&(c=!1,d=!1,cancelAnimationFrame(i),a.size>0)){const{nodeLookup:H,updateNodePositions:b,onNodeDragStop:M,onSelectionDragStop:S}=t();if(m&&(b(a,!1),m=!1),r||M||!E&&S){const[k,I]=xn({nodeId:E,dragItems:a,nodeLookup:H,dragging:!1});r?.(z.sourceEvent,a,k,I),M?.(z.sourceEvent,k,I),E||S?.(z.sourceEvent,I)}}}).filter(z=>{const H=z.target;return!z.button&&(!_||!Zo(H,`.${_}`,v))&&(!p||Zo(H,p,v))});u.call(A)}function x(){u?.on(".drag",null)}return{update:w,destroy:x}}function Nf(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())ft(r,Ue(s))>0&&o.push(s);return o}const Cf=250;function kf(e,t,n,o){let r=[],s=1/0;const i=Nf(e,n,t+Cf);for(const a of i){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:f,y:d}=$e(a,l,l.position,!0),u=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(d-e.y,2));u>t||(u<s?(r=[{...l,x:f,y:d}],s=u):u===s&&r.push({...l,x:f,y:d}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function zs(e,t,n,o,r,s=!1){const i=o.get(e);if(!i)return null;const a=r==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&s?{...c,...$e(i,c,c.position,!0)}:c}function Rs(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Mf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const $s=()=>!0;function jf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:s,isTarget:i,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:f,flowId:d,panBy:u,cancelConnection:g,onConnectStart:m,onConnect:y,onConnectEnd:w,isValidConnection:x=$s,onReconnectEnd:_,updateConnection:p,getTransform:v,getFromHandle:N,autoPanSpeed:E,dragThreshold:j=1,handleDomNode:D}){const P=Ss(e.target);let O=0,A;const{x:z,y:H}=he(e),b=Rs(s,D),M=a?.getBoundingClientRect();let S=!1;if(!M||!b)return;const k=zs(r,b,o,c,t);if(!k)return;let I=he(e,M),T=!1,R=null,L=!1,$=null;function W(){if(!f||!M)return;const[K,U]=vs(I,M,E);u({x:K,y:U}),O=requestAnimationFrame(W)}const F={...k,nodeId:r,type:b,position:k.position},Z=c.get(r);let V={inProgress:!0,isValid:null,from:$e(Z,F,Y.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:Z,to:I,toHandle:null,toPosition:zo[F.position],toNode:null,pointer:I};function B(){S=!0,p(V),m?.(e,{nodeId:r,handleId:o,handleType:b})}j===0&&B();function X(K){if(!S){const{x:ie,y:Ee}=he(K),ye=ie-z,je=Ee-H;if(!(ye*ye+je*je>j*j))return;B()}if(!N()||!F){Q(K);return}const U=v();I=he(K,M),A=kf(bt(I,U,!1,[1,1]),n,c,F),T||(W(),T=!0);const q=Ls(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:i?"target":"source",isValidConnection:x,doc:P,lib:l,flowId:d,nodeLookup:c});$=q.handleDomNode,R=q.connection,L=Mf(!!A,q.isValid);const ee=c.get(r),ne=ee?$e(ee,F,Y.Left,!0):V.from,te={...V,from:ne,isValid:L,to:q.toHandle&&L?qt({x:q.toHandle.x,y:q.toHandle.y},U):I,toHandle:q.toHandle,toPosition:L&&q.toHandle?q.toHandle.position:zo[F.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:I};p(te),V=te}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(S){(A||$)&&R&&L&&y?.(R);const{inProgress:U,...q}=V,ee={...q,toPosition:V.toHandle?V.toPosition:null};w?.(K,ee),s&&_?.(K,ee)}g(),cancelAnimationFrame(O),T=!1,L=!1,R=null,$=null,P.removeEventListener("mousemove",X),P.removeEventListener("mouseup",Q),P.removeEventListener("touchmove",X),P.removeEventListener("touchend",Q)}}P.addEventListener("mousemove",X),P.addEventListener("mouseup",Q),P.addEventListener("touchmove",X),P.addEventListener("touchend",Q)}function Ls(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:s,doc:i,lib:a,flowId:c,isValidConnection:l=$s,nodeLookup:f}){const d=s==="target",u=t?i.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:m}=he(e),y=i.elementFromPoint(g,m),w=y?.classList.contains(`${a}
2-flow__handle`)?y:u,x={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const _=Rs(void 0,w),p=w.getAttribute("data-nodeid"),v=w.getAttribute("data-handleid"),N=w.classList.contains("connectable"),E=w.classList.contains("connectableend");if(!p||!_)return x;const j={source:d?p:o,sourceHandle:d?v:r,target:d?o:p,targetHandle:d?r:v};x.connection=j;const P=N&&E&&(n===Xe.Strict?d&&_==="source"||!d&&_==="target":p!==o||v!==r);x.isValid=P&&l(j),x.toHandle=zs(p,_,v,f,n,!0)}return x}const Rn={onPointerDown:jf,isValid:Ls};function If({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ce(e);function s({translateExtent:a,width:c,height:l,zoomStep:f=1,pannable:d=!0,zoomable:u=!0,inversePan:g=!1}){const m=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=p.sourceEvent.ctrlKey&&ht()?10:1,E=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,j=v[2]*Math.pow(2,E*N);t.scaleTo(j)};let y=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},x=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],E=[N[0]-y[0],N[1]-y[1]];y=N;const j=o()*Math.max(v[2],Math.log(v[2]))*(g?-1:1),D={x:v[0]-E[0]*j,y:v[1]-E[1]*j},P=[[0,0],[c,l]];t.setViewportConstrained({x:D.x,y:D.y,zoom:v[2]},P,a)},_=fs().on("start",w).on("zoom",d?x:null).on("zoom.wheel",u?m:null);r.call(_,{})}function i(){r.on("zoom",null)}return{update:s,destroy:i,pointer:de}}const an=e=>({x:e.x,y:e.y,zoom:e.k}),yn=({x:e,y:t,zoom:n})=>on.translate(e,t).scale(n),Oe=(e,t)=>e.target.closest(`.${t}`),Hs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Af=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,wn=(e,t=0,n=Af,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Os=e=>{const t=e.ctrlKey&&ht()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Df({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return f=>{if(Oe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&i){const w=de(f),x=Os(f),_=d*Math.pow(2,x);o.scaleTo(n,_,w,f);return}const u=f.deltaMode===1?20:1;let g=r===Te.Vertical?0:f.deltaX*u,m=r===Te.Horizontal?0:f.deltaY*u;!ht()&&f.shiftKey&&r!==Te.Vertical&&(g=f.deltaY*u,m=0),o.translateBy(n,-(g/d)*s,-(m/d)*s,{internal:!0});const y=an(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,y),e.panScrollTimeout=setTimeout(()=>{l?.(f,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(f,y))}}function Pf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const s=o.type==="wheel",i=!t&&s&&!o.ctrlKey,a=Oe(o,e);if(o.ctrlKey&&s&&a&&o.preventDefault(),i||a)return null;o.preventDefault(),n.call(this,o,r)}}function Tf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=an(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function zf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return s=>{e.usedRightMouseButton=!!(n&&Hs(t,e.mouseButton??0)),s.sourceEvent?.sync||o([s.transform.x,s.transform.y,s.transform.k]),r&&!s.sourceEvent?.internal&&r?.(s.sourceEvent,an(s.transform))}}function Rf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:s}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&Hs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=an(i.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(i.sourceEvent,a)},n?150:0)}}}function $f({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:s,userSelectionActive:i,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:f}){return d=>{const u=e||t,g=n&&d.ctrlKey,m=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Oe(d,`${l}-flow__node`)||Oe(d,`${l}-flow__edge`)))return!0;
2if(!o&&!u&&!r&&!s&&!n||i||f&&!m||Oe(d,a)&&m||Oe(d,c)&&(!m||r&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!u&&!r&&!g&&m||!o&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(o)&&!o.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&y}}function Lf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),d=fs().scaleExtent([t,n]).translateExtent(o),u=ce(e).call(d);_({x:r.x,y:r.y,zoom:Ze(r.zoom,t,n)},[[0,0],[f.width,f.height]],o);const g=u.on("wheel.zoom"),m=u.on("dblclick.zoom");d.wheelDelta(Os);function y(A,z){return u?new Promise(H=>{d?.interpolate(z?.interpolate==="linear"?gn:$t).transform(wn(u,z?.duration,z?.ease,()=>H(!0)),A)}):Promise.resolve(!1)}function w({noWheelClassName:A,noPanClassName:z,onPaneContextMenu:H,userSelectionActive:b,panOnScroll:M,panOnDrag:S,panOnScrollMode:k,panOnScrollSpeed:I,preventScrolling:T,zoomOnPinch:R,zoomOnScroll:L,zoomOnDoubleClick:$,zoomActivationKeyPressed:W,lib:F,onTransformChange:Z,connectionInProgress:G,paneClickDistance:V,selectionOnDrag:B}){b&&!l.isZoomingOrPanning&&x();const X=M&&!W&&!b;d.clickDistance(B?1/0:!fe(V)||V<0?0:V);const Q=X?Df({zoomPanValues:l,noWheelClassName:A,d3Selection:u,d3Zoom:d,panOnScrollMode:k,panOnScrollSpeed:I,zoomOnPinch:R,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):Pf({noWheelClassName:A,preventScrolling:T,d3ZoomHandler:g});if(u.on("wheel.zoom",Q,{passive:!1}),!b){const U=Tf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});d.on("start",U);const q=zf({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!H,onPanZoom:s,onTransformChange:Z});d.on("zoom",q);const ee=Rf({zoomPanValues:l,panOnDrag:S,panOnScroll:M,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:c});d.on("end",ee)}const K=$f({zoomActivationKeyPressed:W,panOnDrag:S,zoomOnScroll:L,panOnScroll:M,zoomOnDoubleClick:$,zoomOnPinch:R,userSelectionActive:b,noPanClassName:z,noWheelClassName:A,lib:F,connectionInProgress:G});d.filter(K),$?u.on("dblclick.zoom",m):u.on("dblclick.zoom",null)}function x(){d.on("zoom",null)}async function _(A,z,H){const b=yn(A),M=d?.constrain()(b,z,H);return M&&await y(M),new Promise(S=>S(M))}async function p(A,z){const H=yn(A);return await y(H,z),new Promise(b=>b(H))}function v(A){if(u){const z=yn(A),H=u.property("__zoom");(H.k!==A.zoom||H.x!==A.x||H.y!==A.y)&&d?.transform(u,z,null,{sync:!0})}}function N(){const A=u?ds(u.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function E(A,z){return u?new Promise(H=>{d?.interpolate(z?.interpolate==="linear"?gn:$t).scaleTo(wn(u,z?.duration,z?.ease,()=>H(!0)),A)}):Promise.resolve(!1)}function j(A,z){return u?new Promise(H=>{d?.interpolate(z?.interpolate==="linear"?gn:$t).scaleBy(wn(u,z?.duration,z?.ease,()=>H(!0)),A)}):Promise.resolve(!1)}function D(A){d?.scaleExtent(A)}function P(A){d?.translateExtent(A)}function O(A){const z=!fe(A)||A<0?0:A;d?.clickDistance(z)}return{update:w,destroy:x,setViewport:p,setViewportConstrained:_,getViewport:N,scaleTo:E,scaleBy:j,setScaleExtent:D,setTranslateExtent:P,syncViewport:v,setClickDistance:O}}var Ge;(function(e){e.Line="line",e.Handle="handle"})(Ge||(Ge={}));function Hf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:s}){const i=e-t,a=n-o,c=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&r&&(c[0]=c[0]*-1),a&&s&&(c[1]=c[1]*-1),c}function Uo(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Se(e,t){return Math.max(0,t-e)}function Ne(e,t){return Math.max(0,e-t)}function kt(e,t,n){return Math.max(0,t-e,e-n)}function qo(e,t){return e?!t:t}function Of(e,t,n,o,r,s,i,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:f,isVertical:d}=t,u=f&&d,{xSnapped:g,ySnapped:m}=n,{minWidth:y,maxWidth:w,minHeight:x,maxHeight:_}=o,{x:p,y:v,width:N,height:E,aspectRatio:j}=e;let D=Math.floor(f?g-e.pointerX:0),P=Math.floor(d?m-e.pointerY:0);const O=N+(c?-D:D),A=E+(l?-P:P),z=-s[0]*N,H=-s[1]*E;let b=kt(O,y,w),M=kt(A,x,_);if(i){let I=0,T=0;c&&D<0?I=Se(p+D+z,i[0][0]):!c&&D>0&&(I=Ne(p+O+z,i[1][0])),l&&P<0?T=Se(v+P+H,i[0][1]):!l&&P>0&&(T=Ne(v+A+H,i[1][1])),b=Math.max(b,I),M=Math.max(M,T)}if(a){let I=0,T=0;c&&D>0?I=Ne(p+D,a[0][0]):!c&&D<0&&(I=Se(p+O,a[1][0])),l&&P>0?T=Ne(v+P,a[0][1]):!l&&P<0&&(T=Se(v+A,a[1][1])),b=Math.max(b,I),M=Math.max(M,T)}if(r){if(f){const I=kt(O/j,x,_)*j;if(b=Math.max(b,I),i){let T=0;!c&&!l||c&&!l&&u?T=Ne(v+H+O/j,i[1][1])*j:T=Se(v+H+(c?D:-D)/j,i[0][1])*j,b=Math.max(b,T)}if(a){let T=0;!c&&!l||c&&!l&&u?T=Se(v+O/j,a[1][1])*j:T=Ne(v+(c?D:-D)/j,a[0][1])*j,b=Math.max(b,T)}}if(d){const I=kt(A*j,y,w)/j;if(M=Math.max(M,I),i){let T=0;!c&&!l||l&&!c&&u?T=Ne(p+A*j+z,i[1][0])/j:T=Se(p+(l?P:-P)*j+z,i[0][0])/j,M=Math.max(M,T)}if(a){let T=0;!c&&!l||l&&!c&&u?T=Se(p+A*j,a[1][0])/j:T=Ne(p+(l?P:-P)*j,a[0][0])/j,M=Math.max(M,T)}}}P=P+(P<0?M:-M),D=D+(D<0?b:-b),r&&(u?O>A*j?P=(qo(c,l)?-D:D)/j:D=(qo(c,l)?-P:P)*j:f?(P=D/j,l=c):(D=P*j,c=l));const S=c?p+D:p,k=l?v+P:v;return{width:N+(c?-D:D),height:E+(l?-P:P),x:s[0]*D*(c?-1:1)+S,y:s[1]*P*(l?-1:1)+k}}const Bs={width:0,height:0,x:0,y:0},Bf={...Bs,pointerX:0,pointerY:0,aspectRatio:1};function Vf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Ff(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,a=n[0]*s,c=n[1]*i;return[[o-a,r-c],[o+s-a,r+i-c]]}function Wf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const s=ce(e);let i={controlDirection:Uo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:f,keepAspectRatio:d,resizeDirection:u,onResizeStart:g,onResize:m,onResizeEnd:y,shouldResize:w}){let x={...Bs},_={...Bf};i={boundaries:f,resizeDirection:u,keepAspectRatio:d,controlDirection:Uo(l)};let p,v=null,N=[],E,j,D,P=!1;const O=os().on("start",A=>
2{const{nodeLookup:z,transform:H,snapGrid:b,snapToGrid:M,nodeOrigin:S,paneDomNode:k}=n();if(p=z.get(t),!p)return;v=k?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:T}=it(A.sourceEvent,{transform:H,snapGrid:b,snapToGrid:M,containerBounds:v});x={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},_={...x,pointerX:I,pointerY:T,aspectRatio:x.width/x.height},E=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(E=z.get(p.parentId),j=E&&p.extent==="parent"?Vf(E):void 0),N=[],D=void 0;for(const[R,L]of z)if(L.parentId===t&&(N.push({id:R,position:{...L.position},extent:L.extent}),L.extent==="parent"||L.expandParent)){const $=Ff(L,p,L.origin??S);D?D=[[Math.min($[0][0],D[0][0]),Math.min($[0][1],D[0][1])],[Math.max($[1][0],D[1][0]),Math.max($[1][1],D[1][1])]]:D=$}g?.(A,{...x})}).on("drag",A=>{const{transform:z,snapGrid:H,snapToGrid:b,nodeOrigin:M}=n(),S=it(A.sourceEvent,{transform:z,snapGrid:H,snapToGrid:b,containerBounds:v}),k=[];if(!p)return;const{x:I,y:T,width:R,height:L}=x,$={},W=p.origin??M,{width:F,height:Z,x:G,y:V}=Of(_,i.controlDirection,S,i.boundaries,i.keepAspectRatio,W,j,D),B=F!==R,X=Z!==L,Q=G!==I&&B,K=V!==T&&X;if(!Q&&!K&&!B&&!X)return;if((Q||K||W[0]===1||W[1]===1)&&($.x=Q?G:x.x,$.y=K?V:x.y,x.x=$.x,x.y=$.y,N.length>0)){const ne=G-I,te=V-T;for(const ie of N)ie.position={x:ie.position.x-ne+W[0]*(F-R),y:ie.position.y-te+W[1]*(Z-L)},k.push(ie)}if((B||X)&&($.width=B&&(!i.resizeDirection||i.resizeDirection==="horizontal")?F:x.width,$.height=X&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:x.height,x.width=$.width,x.height=$.height),E&&p.expandParent){const ne=W[0]*($.width??0);$.x&&$.x<ne&&(x.x=ne,_.x=_.x-($.x-ne));const te=W[1]*($.height??0);$.y&&$.y<te&&(x.y=te,_.y=_.y-($.y-te))}const U=Hf({width:x.width,prevWidth:R,height:x.height,prevHeight:L,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),q={...x,direction:U};w?.(A,q)!==!1&&(P=!0,m?.(A,q),o($,k))}).on("end",A=>{P&&(y?.(A,{...x}),r?.({...x}),P=!1)});s.call(O)}function c(){s.on(".drag",null)}return{update:a,destroy:c}}var vn={exports:{}},bn={};var Go;function Yf(){if(Go)return bn;Go=1;var e=Ta(),t=za();function n(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return bn.useSyncExternalStoreWithSelector=function(l,f,d,u,g){var m=s(null);if(m.current===null){var y={hasValue:!1,value:null};m.current=y}else y=m.current;m=a(function(){function x(E){if(!_){if(_=!0,p=E,E=u(E),g!==void 0&&y.hasValue){var j=y.value;if(g(j,E))return v=j}return v=E}if(j=v,o(p,E))return j;var D=u(E);return g!==void 0&&g(j,D)?(p=E,j):(p=E,v=D)}var _=!1,p,v,N=d===void 0?null:d;return[function(){return x(f())},N===null?void 0:function(){return x(N())}]},[f,d,u,g]);var w=r(l,m[0],m[1]);return i(function(){y.hasValue=!0,y.value=w},[w]),c(w),w},bn}var Ko;function Xf(){return Ko||(Ko=1,vn.exports=Yf()),vn.exports}var Zf=Xf();const Uf=Ra(Zf),qf={},Qo=e=>{let t;const n=new Set,o=(f,d)=>{const u=typeof f=="function"?f(t):f;if(!Object.is(u,t)){const g=t;t=d??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(m=>m(t,g))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(qf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},Gf=e=>e?Qo(e):Qo,{useDebugValue:Kf}=pe,{useSyncExternalStoreWithSelector:Qf}=Uf,Jf=e=>e;function Vs(e,t=Jf,n){const o=Qf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Kf(o),o}const Jo=(e,t)=>{const n=Gf(e),o=(r,s=t)=>Vs(n,r,s);return Object.assign(o,n),o},eh=(e,t)=>e?Jo(e,t):Jo;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const cn=C.createContext(null),th=cn.Provider,Fs=me.error001();function J(e,t){const n=C.useContext(cn);if(n===null)throw new Error(Fs);return Vs(n,e,t)}function re(){const e=C.useContext(cn);if(e===null)throw new Error(Fs);return C.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const er={display:"none"},nh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ws="react-flow__node-desc",Ys="react-flow__edge-desc",oh="react-flow__aria-live",rh=e=>e.ariaLiveMessage,sh=e=>e.ariaLabelConfig;function ih({rfId:e}){const t=J(rh);return h.jsx("div",{id:`${oh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:nh,children:t})}function ah({rfId:e,disableKeyboardA11y:t}){const n=J(sh);return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:`${Ws}-${e}`,style:er,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),h.jsx("div",{id:`${Ys}-${e}`,style:er,children:n["edge.a11yDescription.default"]}),!t&&h.jsx(ih,{rfId:e})]})}const ln=C.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},s)=>{const i=`${e}`.split("-");return h.jsx("div",{className:se(["react-flow__panel",n,...i]),style:o,ref:s,...r,children:t})});ln.displayName="Panel";function ch({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:h.jsx(ln,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:h.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}
2const lh=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Mt=e=>e.id;function uh(e,t){return oe(e.selectedNodes.map(Mt),t.selectedNodes.map(Mt))&&oe(e.selectedEdges.map(Mt),t.selectedEdges.map(Mt))}function dh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=J(lh,uh);return C.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,o,e]),null}const fh=e=>!!e.onSelectionChangeHandlers;function hh({onSelectionChange:e}){const t=J(fh);return e||t?h.jsx(dh,{onSelectionChange:e}):null}const $n=typeof window<"u"?C.useLayoutEffect:C.useEffect,Xs=[0,0],gh={x:0,y:0,zoom:1},ph=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],tr=[...ph,"rfId"],mh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),nr={translateExtent:ut,nodeOrigin:Xs,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function xh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:c}=J(mh,oe),l=re();$n(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=nr,a()}),[]);const f=C.useRef(nr);return $n(()=>{for(const d of tr){const u=e[d],g=f.current[d];u!==g&&(typeof e[d]>"u"||(d==="nodes"?t(u):d==="edges"?n(u):d==="minZoom"?o(u):d==="maxZoom"?r(u):d==="translateExtent"?s(u):d==="nodeExtent"?i(u):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:tf(u)}):d==="fitView"?l.setState({fitViewQueued:u}):d==="fitViewOptions"?l.setState({fitViewOptions:u}):l.setState({[d]:u})))}f.current=e},tr.map(d=>e[d])),null}function or(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function yh(e){const[t,n]=C.useState(e==="system"?null:e);return C.useEffect(()=>{if(e!=="system"){n(e);return}const o=or(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:or()?.matches?"dark":"light"}const rr=typeof document<"u"?document:null;function gt(e=null,t={target:rr,actInsideInputWithModifier:!0}){const[n,o]=C.useState(!1),r=C.useRef(!1),s=C.useRef(new Set([])),[i,a]=C.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",` 3`).replace(` 4 5`,` 6+`).split(` 7`)),f=l.reduce((d,u)=>d.concat(...u),[]);return[l,f]}return[[],[]]},[e]);return C.useEffect(()=>{const c=t?.target??rr,l=t?.actInsideInputWithModifier??!0;if(e!==null){const f=g=>{if(r.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!r.current||r.current&&!l)&&Ns(g))return!1;const y=ir(g.code,a);if(s.current.add(g[y]),sr(i,s.current,!1)){const w=g.composedPath?.()?.[0]||g.target,x=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(r.current||!x)&&g.preventDefault(),o(!0)}},d=g=>{const m=ir(g.code,a);sr(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(g[m]),g.key==="Meta"&&s.current.clear(),r.current=!1},u=()=>{s.current.clear(),o(!1)};return c?.addEventListener("keydown",f),c?.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{c?.removeEventListener("keydown",f),c?.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,o]),n}function sr(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ir(e,t){return t.includes(e)?"code":"key"}const wh=()=>{const e=re();return C.useMemo(()=>({zoomIn:t=>
7{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??s},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:s,maxZoom:i,panZoom:a}=e.getState(),c=Qn(t,o,r,s,i,n?.padding??.1);return a?(await a.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:a,y:c}=i.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},f=n.snapGrid??r,d=n.snapToGrid??s;return bt(l,o,d,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:s}=o.getBoundingClientRect(),i=qt(t,n);return{x:i.x+r,y:i.y+s}}}),[])};function Zs(e,t){const n=[],o=new Map,r=[];for(const s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")o.set(s.id,[s]);else{const i=o.get(s.id);i?i.push(s):o.set(s.id,[s])}for(const s of t){const i=o.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const a={...s};for(const c of i)vh(c,a);n.push(a)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function vh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function bh(e,t){return Zs(e,t)}function _h(e,t){return Zs(e,t)}function Ae(e,t){return{id:e,type:"select",selected:t}}function Be(e,t=new Set,n=!1){const o=[];for(const[r,s]of e){const i=t.has(r);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),o.push(Ae(s.id,i)))}return o}function ar({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,s]of e.entries()){const i=t.get(s.id),a=i?.internals?.userNode??i;a!==void 0&&a!==s&&n.push({id:s.id,item:s,type:"replace"}),a===void 0&&n.push({item:s,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function cr(e){return{id:e.id,type:"remove"}}const lr=e=>Yd(e),Eh=e=>xs(e);function Us(e){return C.forwardRef(e)}function ur(e){const[t,n]=C.useState(BigInt(0)),[o]=C.useState(()=>Sh(()=>n(r=>r+BigInt(1))));return $n(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Sh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const qs=C.createContext(null);function Nh({children:e}){const t=re(),n=C.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:f,onNodesChange:d,nodeLookup:u,fitViewQueued:g,onNodesChangeMiddlewareMap:m}=t.getState();let y=c;for(const x of a)y=typeof x=="function"?x(y):x;let w=ar({items:y,lookup:u});for(const x of m.values())w=x(w);f&&l(y),w.length>0?d?.(w):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:x,nodes:_,setNodes:p}=t.getState();x&&p(_)})},[]),o=ur(n),r=C.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:f,onEdgesChange:d,edgeLookup:u}=t.getState();let g=c;for(const m of a)g=typeof m=="function"?m(g):m;f?l(g):d&&d(ar({items:g,lookup:u}))},[]),s=ur(r),i=C.useMemo(()=>({nodeQueue:o,edgeQueue:s}),[]);return h.jsx(qs.Provider,{value:i,children:e})}function Ch(){const e=C.useContext(qs);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const kh=e=>!!e.panZoom;function so(){const e=wh(),t=re(),n=Ch(),o=J(kh),r=C.useMemo(()=>{const s=d=>t.getState().nodeLookup.get(d),i=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{const{nodeLookup:u,nodeOrigin:g}=t.getState(),m=lr(d)?d:u.get(d.id),y=m.parentId?Es(m.position,m.measured,m.parentId,u,g):m.position,w={...m,position:y,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return Ue(w)},l=(d,u,g={replace:!1})=>{i(m=>m.map(y=>{if(y.id===d){const w=typeof u=="function"?u(y):u;return g.replace&&lr(w)?w:{...y,...w}}return y}
7))},f=(d,u,g={replace:!1})=>{a(m=>m.map(y=>{if(y.id===d){const w=typeof u=="function"?u(y):u;return g.replace&&Eh(w)?w:{...y,...w}}return y}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>s(d)?.internals.userNode,getInternalNode:s,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(u=>({...u}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:i,setEdges:a,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(g=>[...g,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(g=>[...g,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:g}=t.getState(),[m,y,w]=g;return{nodes:d.map(x=>({...x})),edges:u.map(x=>({...x})),viewport:{x:m,y,zoom:w}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:g,edges:m,onNodesDelete:y,onEdgesDelete:w,triggerNodeChanges:x,triggerEdgeChanges:_,onDelete:p,onBeforeDelete:v}=t.getState(),{nodes:N,edges:E}=await Gd({nodesToRemove:d,edgesToRemove:u,nodes:g,edges:m,onBeforeDelete:v}),j=E.length>0,D=N.length>0;if(j){const P=E.map(cr);w?.(E),_(P)}if(D){const P=N.map(cr);y?.(N),x(P)}return(D||j)&&p?.({nodes:N,edges:E}),{deletedNodes:N,deletedEdges:E}},getIntersectingNodes:(d,u=!0,g)=>{const m=$o(d),y=m?d:c(d),w=g!==void 0;return y?(g||t.getState().nodes).filter(x=>{const _=t.getState().nodeLookup.get(x.id);if(_&&!m&&(x.id===d.id||!_.internals.positionAbsolute))return!1;const p=Ue(w?x:_),v=ft(p,y);return u&&v>0||v>=p.width*p.height||v>=y.width*y.height}):[]},isNodeIntersecting:(d,u,g=!0)=>{const y=$o(d)?d:c(d);if(!y)return!1;const w=ft(y,u);return g&&w>0||w>=u.width*u.height||w>=y.width*y.height},updateNode:l,updateNodeData:(d,u,g={replace:!1})=>{l(d,m=>{const y=typeof u=="function"?u(m):u;return g.replace?{...m,data:y}:{...m,data:{...m.data,...y}}},g)},updateEdge:f,updateEdgeData:(d,u,g={replace:!1})=>{f(d,m=>{const y=typeof u=="function"?u(m):u;return g.replace?{...m,data:y}:{...m,data:{...m.data,...y}}},g)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:g}=t.getState();return Xd(d,{nodeLookup:u,nodeOrigin:g})},getHandleConnections:({type:d,id:u,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}-${d}${u?`-${u}`:""}`)?.values()??[]),getNodeConnections:({type:d,handleId:u,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}${d?u?`-${d}-${u}`:`-${d}`:""}`)?.values()??[]),fitView:async d=>{const u=t.getState().fitViewResolver??ef();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(g=>[...g]),u.promise}}},[]);return C.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const dr=e=>e.selected,Mh=typeof window<"u"?window:void 0;function jh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:o}=so(),r=gt(e,{actInsideInputWithModifier:!1}),s=gt(t,{target:Mh});C.useEffect(()=>{if(r){const{edges:i,nodes:a}=n.getState();o({nodes:a.filter(dr),edges:i.filter(dr)}),n.setState({nodesSelectionActive:!1})}},[r]),C.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function Ih(e){const t=re();C.useEffect(()=>{const n=()=>
7{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=Jn(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",me.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const un={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ah=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Dh({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:s=Te.Free,zoomOnDoubleClick:i=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:f,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:g=!0,children:m,noWheelClassName:y,noPanClassName:w,onViewportChange:x,isControlledViewport:_,paneClickDistance:p,selectionOnDrag:v}){const N=re(),E=C.useRef(null),{userSelectionActive:j,lib:D,connectionInProgress:P}=J(Ah,oe),O=gt(u),A=C.useRef();Ih(E);const z=C.useCallback(H=>{x?.({x:H[0],y:H[1],zoom:H[2]}),_||N.setState({transform:H})},[x,_]);return C.useEffect(()=>{if(E.current){A.current=Lf({domNode:E.current,minZoom:f,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:S=>N.setState(k=>k.paneDragging===S?k:{paneDragging:S}),onPanZoomStart:(S,k)=>{const{onViewportChangeStart:I,onMoveStart:T}=N.getState();T?.(S,k),I?.(k)},onPanZoom:(S,k)=>{const{onViewportChange:I,onMove:T}=N.getState();T?.(S,k),I?.(k)},onPanZoomEnd:(S,k)=>{const{onViewportChangeEnd:I,onMoveEnd:T}=N.getState();T?.(S,k),I?.(k)}});const{x:H,y:b,zoom:M}=A.current.getViewport();return N.setState({panZoom:A.current,transform:[H,b,M],domNode:E.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),C.useEffect(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:s,zoomOnDoubleClick:i,panOnDrag:a,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:w,userSelectionActive:j,noWheelClassName:y,lib:D,onTransformChange:z,connectionInProgress:P,selectionOnDrag:v,paneClickDistance:p})},[e,t,n,o,r,s,i,a,O,g,w,j,y,D,z,P,v,p]),h.jsx("div",{className:"react-flow__renderer",ref:E,style:un,children:m})}const Ph=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Th(){const{userSelectionActive:e,userSelectionRect:t}=J(Ph,oe);return e&&t?h.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const _n=(e,t)=>n=>{n.target===t.current&&e?.(n)},zh=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Rh({isSelecting:e,selectionKeyPressed:t,selectionMode:n=dt.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:u,onPaneMouseLeave:g,children:m}){const y=re(),{userSelectionActive:w,elementsSelectable:x,dragging:_,connectionInProgress:p}=J(zh,oe),v=x&&(e||w),N=C.useRef(null),E=C.useRef(),j=C.useRef(new Set),D=C.useRef(new Set),P=C.useRef(!1),O=I=>{if(P.current||p){P.current=!1;return}c?.(I),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},A=I=>{if(Array.isArray(o)&&o?.includes(2)){I.preventDefault();return}l?.(I)},z=f?I=>f(I):void 0,H=I=>{P.current&&(I.stopPropagation(),P.current=!1)},b=I=>{const{domNode:T}=y.getState();if(E.current=T?.getBoundingClientRect(),!E.current)return;const R=I.target===N.current;if(!R&&!!I.target.closest(".nokey")||!e||!(s&&R||t)||I.button!==0||!I.isPrimary)return;I.target?.setPointerCapture?.(I.pointerId),P.current=!1;const{x:W,y:F}=he(I.nativeEvent,E.current);y.setState({userSelectionRect:{width:0,height:0,startX:W,startY:F,x:W,y:F}}),R||(I.stopPropagation(),I.preventDefault())},M=I=>{const{userSelectionRect:T,transform:R,nodeLookup:L,edgeLookup:$,connectionLookup:W,triggerNodeChanges:F,triggerEdgeChanges:Z,defaultEdgeOptions:G,resetSelectedElements:V}
7=y.getState();if(!E.current||!T)return;const{x:B,y:X}=he(I.nativeEvent,E.current),{startX:Q,startY:K}=T;if(!P.current){const te=t?0:r;if(Math.hypot(B-Q,X-K)<=te)return;V(),i?.(I)}P.current=!0;const U={startX:Q,startY:K,x:B<Q?B:Q,y:X<K?X:K,width:Math.abs(B-Q),height:Math.abs(X-K)},q=j.current,ee=D.current;j.current=new Set(Kn(L,U,R,n===dt.Partial,!0).map(te=>te.id)),D.current=new Set;const ne=G?.selectable??!0;for(const te of j.current){const ie=W.get(te);if(ie)for(const{edgeId:Ee}of ie.values()){const ye=$.get(Ee);ye&&(ye.selectable??ne)&&D.current.add(Ee)}}if(!Lo(q,j.current)){const te=Be(L,j.current,!0);F(te)}if(!Lo(ee,D.current)){const te=Be($,D.current);Z(te)}y.setState({userSelectionRect:U,userSelectionActive:!0,nodesSelectionActive:!1})},S=I=>{I.button===0&&(I.target?.releasePointerCapture?.(I.pointerId),!w&&I.target===N.current&&y.getState().userSelectionRect&&O?.(I),y.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(a?.(I),y.setState({nodesSelectionActive:j.current.size>0})))},k=o===!0||Array.isArray(o)&&o.includes(0);return h.jsxs("div",{className:se(["react-flow__pane",{draggable:k,dragging:_,selection:e}]),onClick:v?void 0:_n(O,N),onContextMenu:_n(A,N),onWheel:_n(z,N),onPointerEnter:v?void 0:d,onPointerMove:v?M:u,onPointerUp:v?S:void 0,onPointerDownCapture:v?b:void 0,onClickCapture:v?H:void 0,onPointerLeave:g,ref:N,style:un,children:[m,h.jsx(Th,{})]})}function Ln({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c?.("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(s({nodes:[l],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Gs({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,nodeClickDistance:i}){const a=re(),[c,l]=C.useState(!1),f=C.useRef();return C.useEffect(()=>{f.current=Sf({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Ln({id:d,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),C.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:i}),()=>{f.current?.destroy()}},[n,o,t,s,e,r,i]),c}const $h=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ks(){const e=re();return C.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:s,nodesDraggable:i,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:f}=e.getState(),d=new Map,u=$h(i),g=r?s[0]:5,m=r?s[1]:5,y=n.direction.x*g*n.factor,w=n.direction.y*m*n.factor;for(const[,x]of l){if(!u(x))continue;let _={x:x.internals.positionAbsolute.x+y,y:x.internals.positionAbsolute.y+w};r&&(_=vt(_,s));const{position:p,positionAbsolute:v}=ys({nodeId:x.id,nextPosition:_,nodeLookup:l,nodeExtent:o,nodeOrigin:f,onError:a});x.position=p,x.internals.positionAbsolute=v,d.set(x.id,x)}c(d)},[])}const io=C.createContext(null),Lh=io.Provider;io.Consumer;const Qs=()=>C.useContext(io),Hh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Oh=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:s,connection:i}=o,{fromHandle:a,toHandle:c,isValid:l}=i,f=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:f,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:s===Xe.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:f&&l}};function Bh({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:c,className:l,onMouseDown:f,onTouchStart:d,...u},g){const m=i||null,y=e==="target",w=re(),x=Qs(),{connectOnClick:_,noPanClassName:p,rfId:v}=J(Hh,oe),{connectingFrom:N,connectingTo:E,clickConnecting:j,isPossibleEndHandle:D,connectionInProcess:P,clickConnectionInProcess:O,valid:A}=J(Oh(x,m,e),oe);x||w.getState().onError?.("010",me.error010());const z=M=>{const{defaultEdgeOptions:S,onConnect:k,hasDefaultEdges:I}=w.getState(),T={...S,...M};if(I){const{edges:R,setEdges:L}=w.getState();L(cf(T,R))}k?.(T),a?.(T)},H=M=>
7{if(!x)return;const S=Cs(M.nativeEvent);if(r&&(S&&M.button===0||!S)){const k=w.getState();Rn.onPointerDown(M.nativeEvent,{handleDomNode:M.currentTarget,autoPanOnConnect:k.autoPanOnConnect,connectionMode:k.connectionMode,connectionRadius:k.connectionRadius,domNode:k.domNode,nodeLookup:k.nodeLookup,lib:k.lib,isTarget:y,handleId:m,nodeId:x,flowId:k.rfId,panBy:k.panBy,cancelConnection:k.cancelConnection,onConnectStart:k.onConnectStart,onConnectEnd:(...I)=>w.getState().onConnectEnd?.(...I),updateConnection:k.updateConnection,onConnect:z,isValidConnection:n||((...I)=>w.getState().isValidConnection?.(...I)??!0),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:k.autoPanSpeed,dragThreshold:k.connectionDragThreshold})}S?f?.(M):d?.(M)},b=M=>{const{onClickConnectStart:S,onClickConnectEnd:k,connectionClickStartHandle:I,connectionMode:T,isValidConnection:R,lib:L,rfId:$,nodeLookup:W,connection:F}=w.getState();if(!x||!I&&!r)return;if(!I){S?.(M.nativeEvent,{nodeId:x,handleId:m,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:x,type:e,id:m}});return}const Z=Ss(M.target),G=n||R,{connection:V,isValid:B}=Rn.isValid(M.nativeEvent,{handle:{nodeId:x,id:m,type:e},connectionMode:T,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:G,flowId:$,doc:Z,lib:L,nodeLookup:W});B&&V&&z(V);const X=structuredClone(F);delete X.inProgress,X.toPosition=X.toHandle?X.toHandle.position:null,k?.(M,X),w.setState({connectionClickStartHandle:null})};return h.jsx("div",{"data-handleid":m,"data-nodeid":x,"data-handlepos":t,"data-id":`${v}-${x}-${m}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!y,target:y,connectable:o,connectablestart:r,connectableend:s,clickconnecting:j,connectingfrom:N,connectingto:E,valid:A,connectionindicator:o&&(!P||D)&&(P||O?s:r)}]),onMouseDown:H,onTouchStart:H,onClick:_?b:void 0,ref:g,...u,children:c})}const pt=C.memo(Us(Bh));function Vh({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return h.jsxs(h.Fragment,{children:[e?.label,h.jsx(pt,{type:"source",position:n,isConnectable:t})]})}function Fh({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:o=Y.Bottom}){return h.jsxs(h.Fragment,{children:[h.jsx(pt,{type:"target",position:n,isConnectable:t}),e?.label,h.jsx(pt,{type:"source",position:o,isConnectable:t})]})}function Wh(){return null}function Yh({data:e,isConnectable:t,targetPosition:n=Y.Top}){return h.jsxs(h.Fragment,{children:[h.jsx(pt,{type:"target",position:n,isConnectable:t}),e?.label]})}const Kt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},fr={input:Vh,default:Fh,output:Yh,group:Wh};function Xh(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const Zh=e=>{const{width:t,height:n,x:o,y:r}=wt(e.nodeLookup,{filter:s=>!!s.selected});return{width:fe(t)?t:null,height:fe(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function Uh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=re(),{width:r,height:s,transformString:i,userSelectionActive:a}=J(Zh,oe),c=Ks(),l=C.useRef(null);C.useEffect(()=>{n||l.current?.focus({preventScroll:!0})},[n]);const f=!a&&r!==null&&s!==null;if(Gs({nodeRef:l,disabled:!f}),!f)return null;const d=e?g=>{const m=o.getState().nodes.filter(y=>y.selected);e(g,m)}:void 0,u=g=>{Object.prototype.hasOwnProperty.call(Kt,g.key)&&(g.preventDefault(),c({direction:Kt[g.key],factor:g.shiftKey?4:1}))};return h.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:h.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:r,height:s}})})}const hr=typeof window<"u"?window:void 0,qh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Js({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:f,selectionMode:d,onSelectionStart:u,onSelectionEnd:g,multiSelectionKeyCode:m,panActivationKeyCode:y,zoomActivationKeyCode:w,elementsSelectable:x,zoomOnScroll:_,zoomOnPinch:p,panOnScroll:v,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:D,defaultViewport:P,translateExtent:O,minZoom:A,maxZoom:z,preventScrolling:H,onSelectionContextMenu:b,noWheelClassName:M,noPanClassName:S,disableKeyboardA11y:k,onViewportChange:I,isControlledViewport:T}){const{nodesSelectionActive:R,userSelectionActive:L}=J(qh,oe),$=gt(l,{target:hr}),W=gt(y,{target:hr}),F=W||D,Z=W||v,G=f&&F!==!0,V=$||L||G;return jh({deleteKeyCode:c,multiSelectionKeyCode:m}),h.jsx(Dh,{onPaneContextMenu:s,elementsSelectable:x,zoomOnScroll:_,zoomOnPinch:p,panOnScroll:Z,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!$&&F,defaultViewport:P,translateExtent:O,minZoom:A,maxZoom:z,zoomActivationKeyCode:w,preventScrolling:H,noWheelClassName:M,noPanClassName:S,onViewportChange:I,isControlledViewport:T,paneClickDistance:a,selectionOnDrag:G,children:h.jsxs(Rh,{onSelectionStart:u,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:F,isSelecting:!!V,selectionMode:d,selectionKeyPressed:$,paneClickDistance:a,selectionOnDrag:G,children:[e,R&&h.jsx(Uh,{onSelectionContextMenu:b,noPanClassName:S,disableKeyboardA11y:k})]})})}Js.displayName="FlowRenderer";
7const Gh=C.memo(Js),Kh=e=>t=>e?Kn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Qh(e){return J(C.useCallback(Kh(e),[e]),oe)}const Jh=e=>e.updateNodeInternals;function eg(){const e=J(Jh),[t]=C.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const s=r.target.getAttribute("data-id");o.set(s,{id:s,nodeElement:r.target,force:!0})}),e(o)}));return C.useEffect(()=>()=>{t?.disconnect()},[t]),t}function tg({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=re(),s=C.useRef(null),i=C.useRef(null),a=C.useRef(e.sourcePosition),c=C.useRef(e.targetPosition),l=C.useRef(t),f=n&&!!e.internals.handleBounds;return C.useEffect(()=>{s.current&&!e.hidden&&(!f||i.current!==s.current)&&(i.current&&o?.unobserve(i.current),o?.observe(s.current),i.current=s.current)},[f,e.hidden]),C.useEffect(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),C.useEffect(()=>{if(s.current){const d=l.current!==t,u=a.current!==e.sourcePosition,g=c.current!==e.targetPosition;(d||u||g)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function ng({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:s,onDoubleClick:i,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:f,resizeObserver:d,noDragClassName:u,noPanClassName:g,disableKeyboardA11y:m,rfId:y,nodeTypes:w,nodeClickDistance:x,onError:_}){const{node:p,internals:v,isParent:N}=J(B=>{const X=B.nodeLookup.get(e),Q=B.parentLookup.has(e);return{node:X,internals:X.internals,isParent:Q}},oe);let E=p.type||"default",j=w?.[E]||fr[E];j===void 0&&(_?.("003",me.error003(E)),E="default",j=w?.default||fr.default);const D=!!(p.draggable||a&&typeof p.draggable>"u"),P=!!(p.selectable||c&&typeof p.selectable>"u"),O=!!(p.connectable||l&&typeof p.connectable>"u"),A=!!(p.focusable||f&&typeof p.focusable>"u"),z=re(),H=_s(p),b=tg({node:p,nodeType:E,hasDimensions:H,resizeObserver:d}),M=Gs({nodeRef:b,disabled:p.hidden||!D,noDragClassName:u,handleSelector:p.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:x}),S=Ks();if(p.hidden)return null;const k=_e(p),I=Xh(p),T=P||D||t||n||o||r,R=n?B=>n(B,{...v.userNode}):void 0,L=o?B=>o(B,{...v.userNode}):void 0,$=r?B=>r(B,{...v.userNode}):void 0,W=s?B=>s(B,{...v.userNode}):void 0,F=i?B=>i(B,{...v.userNode}):void 0,Z=B=>{const{selectNodesOnDrag:X,nodeDragThreshold:Q}=z.getState();P&&(!X||!D||Q>0)&&Ln({id:e,store:z,nodeRef:b}),t&&t(B,{...v.userNode})},G=B=>{if(!(Ns(B.nativeEvent)||m)){if(hs.includes(B.key)&&P){const X=B.key==="Escape";Ln({id:e,store:z,unselect:X,nodeRef:b})}else if(D&&p.selected&&Object.prototype.hasOwnProperty.call(Kt,B.key)){B.preventDefault();const{ariaLabelConfig:X}=z.getState();z.setState({ariaLiveMessage:X["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),S({direction:Kt[B.key],factor:B.shiftKey?4:1})}}},V=()=>{if(m||!b.current?.matches(":focus-visible"))return;const{transform:B,width:X,height:Q,autoPanOnNodeFocus:K,setCenter:U}=z.getState();if(!K)return;Kn(new Map([[e,p]]),{x:0,y:0,width:X,height:Q},B,!0).length>0||U(p.position.x+k.width/2,p.position.y+k.height/2,{zoom:B[2]})};return h.jsx("div",{className:se(["react-flow__node",`react-flow__node-${E}`,{[g]:D},p.className,{selected:p.selected,selectable:P,parent:N,draggable:D,dragging:M}]),ref:b,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:H?"visible":"hidden",...p.style,...I},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:L,onMouseLeave:$,onContextMenu:W,onClick:Z,onDoubleClick:F,onKeyDown:A?G:void 0,tabIndex:A?0:void 0,onFocus:A?V:void 0,role:p.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${Ws}-${y}`,"aria-label":p.ariaLabel,...p.domAttributes,children:h.jsx(Lh,{value:e,children:h.jsx(j,{id:e,data:p.data,type:E,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:p.selected??!1,selectable:P,draggable:D,deletable:p.deletable??!0,isConnectable:O,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:
7M,dragHandle:p.dragHandle,zIndex:v.z,parentId:p.parentId,...k})})})}var og=C.memo(ng);const rg=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function ei(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:s}=J(rg,oe),i=Qh(e.onlyRenderVisibleElements),a=eg();return h.jsx("div",{className:"react-flow__nodes",style:un,children:i.map(c=>h.jsx(og,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:s},c))})}ei.displayName="NodeRenderer";const sg=C.memo(ei);function ig(e){return J(C.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const s=n.nodeLookup.get(r.source),i=n.nodeLookup.get(r.target);s&&i&&rf({sourceNode:s,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),oe)}const ag=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return h.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},cg=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return h.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},gr={[Zt.Arrow]:ag,[Zt.ArrowClosed]:cg};function lg(e){const t=re();return C.useMemo(()=>Object.prototype.hasOwnProperty.call(gr,e)?gr[e]:(t.getState().onError?.("009",me.error009(e)),null),[e])}const ug=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=lg(t);return c?h.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:h.jsx(c,{color:n,strokeWidth:i})}):null},ti=({defaultColor:e,rfId:t})=>{const n=J(s=>s.edges),o=J(s=>s.defaultEdgeOptions),r=C.useMemo(()=>hf(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?h.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:h.jsx("defs",{children:r.map(s=>h.jsx(ug,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};ti.displayName="MarkerDefinitions";var dg=C.memo(ti);function ni({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...f}){const[d,u]=C.useState({x:1,y:0,width:0,height:0}),g=se(["react-flow__edge-textwrapper",l]),m=C.useRef(null);return C.useEffect(()=>{if(m.current){const y=m.current.getBBox();u({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?h.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:g,visibility:d.width?"visible":"hidden",...f,children:[r&&h.jsx("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),h.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:m,style:o,children:n}),c]}):null}ni.displayName="EdgeText";const fg=C.memo(ni);function Ke({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=2
vendor: 4,169 bytes, line 7
70,...f}){return h.jsxs(h.Fragment,{children:[h.jsx("path",{...f,d:e,fill:"none",className:se(["react-flow__edge-path",f.className])}),l?h.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&fe(t)&&fe(n)?h.jsx(fg,{x:t,y:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function pr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function oi({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:s=Y.Top}){const[i,a]=pr({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=pr({pos:s,x1:o,y1:r,x2:e,y2:t}),[f,d,u,g]=ks({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${i},${a} ${c},${l} ${o},${r}`,f,d,u,g]}function ri(e){return C.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i,targetPosition:a,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:w,interactionWidth:x})=>{const[_,p,v]=oi({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:a}),N=e.isInternal?void 0:t;return h.jsx(Ke,{id:N,path:_,labelX:p,labelY:v,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:w,interactionWidth:x})})}const hg=ri({isInternal:!1}),si=ri({isInternal:!0});hg.displayName="SimpleBezierEdge";si.displayName="SimpleBezierEdgeInternal";function ii(e){return C.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:d,style:u,sourcePosition:g=Y.Bottom,targetPosition:m=Y.Top,markerEnd:y,markerStart:w,pathOptions:x,interactionWidth:_})=>{const[p,v,N]=Gt({sourceX:n,sourceY:o,sourcePosition:g,targetX:r,targetY:s,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),E=e.isInternal?void 0:t;return h.jsx(Ke,{id:E,path:p,labelX:v,labelY:N,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:d,style:u,markerEnd:y,markerStart:w,interactionWidth:_})})}const ai=ii({isInternal:!1}),ci=ii({isInternal:!0});ai.displayName="SmoothStepEdge";ci.displayName="SmoothStepEdgeInternal";function li(e){return C.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return h.jsx(ai,{...n,id:o,pathOptions:C.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const gg=li({isInternal:!1}),ui=li({isInternal:!0});gg.displayName="StepEdge";ui.displayName="StepEdgeInternal";function di(e){return C.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:d,style:u,markerEnd:g,markerStart:m,interactionWidth:y})=>{const[w,x,_]=Is({sourceX:n,sourceY:o,targetX:r,targetY:s}),p=e.isInternal?void 0:t;return h.jsx(Ke,{id:p,path:w,labelX:x,labelY:_,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:d,style:u,markerEnd:g,markerStart:m,interactionWidth:y})})}const pg=di({isInternal:!1}),fi=di({isInternal:!0});pg.displayName="StraightEdge";fi.displayName="StraightEdgeInternal";function hi(e){return C.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:w,pathOptions:x,interactionWidth:_})=>{const[p,v,N]=Ms({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:a,curvature:x?.curvature}),E=e.isInternal?void 0:t;return h.jsx(Ke,{id:E,path:p,labelX:v,labelY:N,label:c,labelStyle:l,labelShowBg:f,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:w,interactionWidth:_})})}const mg=hi({isInternal:!1}),gi=hi({isInternal:!0});mg.displayName="BezierEdge";gi.displayName="BezierEdgeInternal";const mr={default:gi,straight:fi,step:ui,smoothstep:ci,simplebezier:si},xr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null}
7,xg=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,yg=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,yr="react-flow__edgeupdater";function wr({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:i,type:a}){return h.jsx("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:i,className:se([yr,`${yr}-${a}`]),cx:xg(t,o,e),cy:yg(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function wg({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:f,onReconnectEnd:d,setReconnecting:u,setUpdateHover:g}){const m=re(),y=(v,N)=>{if(v.button!==0)return;const{autoPanOnConnect:E,domNode:j,connectionMode:D,connectionRadius:P,lib:O,onConnectStart:A,cancelConnection:z,nodeLookup:H,rfId:b,panBy:M,updateConnection:S}=m.getState(),k=N.type==="target",I=(L,$)=>{u(!1),d?.(L,n,N.type,$)},T=L=>l?.(n,L),R=(L,$)=>{u(!0),f?.(v,n,N.type),A?.(L,$)};Rn.onPointerDown(v.nativeEvent,{autoPanOnConnect:E,connectionMode:D,connectionRadius:P,domNode:j,handleId:N.id,nodeId:N.nodeId,nodeLookup:H,isTarget:k,edgeUpdaterType:N.type,lib:O,flowId:b,cancelConnection:z,panBy:M,isValidConnection:(...L)=>m.getState().isValidConnection?.(...L)??!0,onConnect:T,onConnectStart:R,onConnectEnd:(...L)=>m.getState().onConnectEnd?.(...L),onReconnectEnd:I,updateConnection:S,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},w=v=>y(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=v=>y(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),_=()=>g(!0),p=()=>g(!1);return h.jsxs(h.Fragment,{children:[(e===!0||e==="source")&&h.jsx(wr,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:w,onMouseEnter:_,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&h.jsx(wr,{position:c,centerX:s,centerY:i,radius:t,onMouseDown:x,onMouseEnter:_,onMouseOut:p,type:"target"})]})}function vg({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:s,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:f,onReconnect:d,onReconnectStart:u,onReconnectEnd:g,rfId:m,edgeTypes:y,noPanClassName:w,onError:x,disableKeyboardA11y:_}){let p=J(U=>U.edgeLookup.get(e));const v=J(U=>U.defaultEdgeOptions);p=v?{...v,...p}:p;let N=p.type||"default",E=y?.[N]||mr[N];E===void 0&&(x?.("011",me.error011(N)),N="default",E=y?.default||mr.default);const j=!!(p.focusable||t&&typeof p.focusable>"u"),D=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),P=!!(p.selectable||o&&typeof p.selectable>"u"),O=C.useRef(null),[A,z]=C.useState(!1),[H,b]=C.useState(!1),M=re(),{zIndex:S,sourceX:k,sourceY:I,targetX:T,targetY:R,sourcePosition:L,targetPosition:$}=J(C.useCallback(U=>{const q=U.nodeLookup.get(p.source),ee=U.nodeLookup.get(p.target);if(!q||!ee)return{zIndex:p.zIndex,...xr};const ne=ff({id:e,sourceNode:q,targetNode:ee,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:U.connectionMode,onError:x});return{zIndex:of({selected:p.selected,zIndex:p.zIndex,sourceNode:q,targetNode:ee,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode}),...ne||xr}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),oe),W=C.useMemo(()=>p.markerStart?`url('#${Tn(p.markerStart,m)}')`:void 0,[p.markerStart,m]),F=C.useMemo(()=>p.markerEnd?`url('#${Tn(p.markerEnd,m)}')`:void 0,[p.markerEnd,m]);if(p.hidden||k===null||I===null||T===null||R===null)return null;const Z=U=>{const{addSelectedEdges:q,unselectNodesAndEdges:ee,multiSelectionActive:ne}=M.getState();P&&(M.setState({nodesSelectionActive:!1}),p.selected&&ne?(ee({nodes:[],edges:[p]}),O.current?.blur()):q([e])),r&&r(U,p)},G=s?U=>{s(U,{...p})}:void 0,V=i?U=>{i(U,{...p})}:void 0,B=a?U=>{a(U,{...p})}:void 0,X=c?U=>{c(U,{...p})}:void 0,Q=l?U=>{l(U,{...p})}:void 0,K=U=>{if(!_&&hs.includes(U.key)&&P){const{unselectNodesAndEdges:q,addSelectedEdges:ee}=M.getState();U.key==="Escape"?(O.current?.blur(),q({edges:[p]})):ee([e])}};return h.jsx("svg",{style:{zIndex:S},children:h.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${N}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!P&&!r,updating:A,selectable:P}]),onClick:Z,onDoubleClick:G,onContextMenu:V,onMouseEnter:B,onMouseMove:X,onMouseLeave:Q,onKeyDown:j?K:void 0,tabIndex:j?0:void 0,role:p.ariaRole??(j?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":j?`${Ys}-${m}`:void 0,ref:O,...p.domAttributes,children:[!H&&h.jsx(E,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:P,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:k,sourceY:I,targetX:T,targetY:R,sourcePosition:L,targetPosition:$,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:W,markerEnd:F,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),D&&h.jsx(wg,{edge:p,isReconnectable:D,reconnectRadius:f,onReconnect:d,onReconnectStart:u,onReconnectEnd:g,sourceX:k,sourceY:I,targetX:T,targetY:R,sourcePosition:L,targetPosition:$,setUpdateHover:z,setReconnecting:b})]})})}var bg=C.memo(vg);const _g=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function pi({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:f,re
7connectRadius:d,onEdgeDoubleClick:u,onReconnectStart:g,onReconnectEnd:m,disableKeyboardA11y:y}){const{edgesFocusable:w,edgesReconnectable:x,elementsSelectable:_,onError:p}=J(_g,oe),v=ig(t);return h.jsxs("div",{className:"react-flow__edges",children:[h.jsx(dg,{defaultColor:e,rfId:n}),v.map(N=>h.jsx(bg,{id:N,edgesFocusable:w,edgesReconnectable:x,elementsSelectable:_,noPanClassName:r,onReconnect:s,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:f,reconnectRadius:d,onDoubleClick:u,onReconnectStart:g,onReconnectEnd:m,rfId:n,onError:p,edgeTypes:o,disableKeyboardA11y:y},N))]})}pi.displayName="EdgeRenderer";const Eg=C.memo(pi),Sg=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Ng({children:e}){const t=J(Sg);return h.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Cg(e){const t=so(),n=C.useRef(!1);C.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const kg=e=>e.panZoom?.syncViewport;function Mg(e){const t=J(kg),n=re();return C.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function jg(e){return e.connection.inProgress?{...e.connection,to:bt(e.connection.to,e.transform)}:{...e.connection}}function Ig(e){return jg}function Ag(e){const t=Ig();return J(t,oe)}const Dg=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Pg({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:s,height:i,isValid:a,inProgress:c}=J(Dg,oe);return!(s&&r&&c)?null:h.jsx("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:h.jsx("g",{className:se(["react-flow__connection",ms(a)]),children:h.jsx(mi,{style:t,type:n,CustomComponent:o,isValid:a})})})}const mi=({style:e,type:t=ke.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:s,fromNode:i,fromHandle:a,fromPosition:c,to:l,toNode:f,toHandle:d,toPosition:u,pointer:g}=Ag();if(!r)return;if(n)return h.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:a,fromX:s.x,fromY:s.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:u,connectionStatus:ms(o),toNode:f,toHandle:d,pointer:g});let m="";const y={sourceX:s.x,sourceY:s.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:u};switch(t){case ke.Bezier:[m]=Ms(y);break;case ke.SimpleBezier:[m]=oi(y);break;case ke.Step:[m]=Gt({...y,borderRadius:0});break;case ke.SmoothStep:[m]=Gt(y);break;default:[m]=Is(y)}return h.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};mi.displayName="ConnectionLine";const Tg={};function vr(e=Tg){C.useRef(e),re(),C.useEffect(()=>{},[e])}function zg(){re(),C.useRef(!1),C.useEffect(()=>{},[])}function xi({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:f,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:g,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:w,connectionLineContainerStyle:x,selectionKeyCode:_,selectionOnDrag:p,selectionMode:v,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:j,deleteKeyCode:D,onlyRenderVisibleElements:P,elementsSelectable:O,defaultViewport:A,translateExtent:z,minZoom:H,maxZoom:b,preventScrolling:M,defaultMarkerColor:S,zoomOnScroll:k,zoomOnPinch:I,panOnScroll:T,panOnScrollSpeed:R,panOnScrollMode:L,zoomOnDoubleClick:$,panOnDrag:W,onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:V,onPaneScroll:B,onPaneContextMenu:X,paneClickDistance:Q,nodeClickDistance:K,onEdgeContextMenu:U,onEdgeMouseEnter:q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:ie,onReconnectStart:Ee,onReconnectEnd:ye,noDragClassName:je,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,nodeExtent:dn,rfId:_t,viewport:Le,onViewportChange:tt}){return vr(e),vr(t),zg(),Cg(n),Mg(Le),h.jsx(Gh,{onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:V,onPaneContextMenu:X,onPaneScroll:B,paneClickDistance:Q,deleteKeyCode:D,selectionKeyCode:_,selectionOnDrag:p,selectionMode:v,onSelectionStart:u,onSelectionEnd:g,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:j,elementsSelectable:O,zoomOnScroll:k,zoomOnPinch:I,zoomOnDoubleClick:$,panOnScroll:T,panOnScrollSpeed:R,panOnScrollMode:L,panOnDrag:W,defaultViewport:A,translateExtent:z,minZoom:H,maxZoom:b,onSelectionContextMenu:d,preventScrolling:M,noDragClassName:je,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,onViewportChange:tt,isControlledViewport:!!Le,children:h.jsxs(Ng,{children:[h.jsx(Eg,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:ie,onReconnectStart:Ee,onReconnectEnd:ye,onlyRenderVisibleElements:P,onEdgeContextMenu:U,onEdgeMouseEnter:q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:S,noPanClassName:Je,disableKeyboardA11y:et,rfId:_t}),h.jsx(Pg,{style:y,type:m,component:w,containerStyle:x}),h.jsx("div",{className:"react-flow__edgelabel-renderer"}),h.jsx(sg,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:f,nodeClickDistance:K,onlyRenderVisibleElements:P,noPanClassName:Je,noDragClassName:je,disableKeyboardA11y:et,nodeExtent:dn,rfId:_t}),h.jsx("div",{className:"react-flow__viewport-portal"})]})})}xi.displayName="GraphView";const Rg=C.memo(xi),br=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:f,nodeExtent:d,zIndexMode:u="basic"}={})=>{const g=new Map,m=new Map,y=new Map,w=new Map,x=o??t??[],_=n??e??[],p=f??[0,0],v=d??ut;Ps(y,w,x);const{nodesInitialized:N}=zn(_,g,m,{nodeOrigin:p,nodeExtent:v,zIndexMode:u});let E=[0,0,1];if(i&&r&&s){const j=wt(g,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:D,y:P,zoom:O}=Qn(j,r,s,c,l,a?.padding??.1);E=[D,P,O]}return{rfId:"1",width:r??0,height:s??0,transform:E,nodes:_,nodesInitialized:N,nodeLookup:g,parentLookup:m,edges:x,edgeLookup:w,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:ut,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Xe.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGri
7d:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ps},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Kd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:gs,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},$g=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:f,nodeExtent:d,zIndexMode:u})=>eh((g,m)=>{async function y(){const{nodeLookup:w,panZoom:x,fitViewOptions:_,fitViewResolver:p,width:v,height:N,minZoom:E,maxZoom:j}=m();x&&(await qd({nodes:w,width:v,height:N,panZoom:x,minZoom:E,maxZoom:j},_),p?.resolve(!0),g({fitViewResolver:null}))}return{...br({nodes:e,edges:t,width:r,height:s,fitView:i,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:f,nodeExtent:d,defaultNodes:n,defaultEdges:o,zIndexMode:u}),setNodes:w=>{const{nodeLookup:x,parentLookup:_,nodeOrigin:p,elevateNodesOnSelect:v,fitViewQueued:N,zIndexMode:E,nodesSelectionActive:j}=m(),{nodesInitialized:D,hasSelectedNodes:P}=zn(w,x,_,{nodeOrigin:p,nodeExtent:d,elevateNodesOnSelect:v,checkEquality:!0,zIndexMode:E}),O=j&&P;N&&D?(y(),g({nodes:w,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):g({nodes:w,nodesInitialized:D,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:x,edgeLookup:_}=m();Ps(x,_,w),g({edges:w})},setDefaultNodesAndEdges:(w,x)=>{if(w){const{setNodes:_}=m();_(w),g({hasDefaultNodes:!0})}if(x){const{setEdges:_}=m();_(x),g({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:x,nodeLookup:_,parentLookup:p,domNode:v,nodeOrigin:N,nodeExtent:E,debug:j,fitViewQueued:D,zIndexMode:P}=m(),{changes:O,updatedInternals:A}=vf(w,_,p,v,N,E,P);A&&(mf(_,p,{nodeOrigin:N,nodeExtent:E,zIndexMode:P}),D?(y(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),O?.length>0&&(j&&console.log("React Flow: trigger node changes",O),x?.(O)))},updateNodePositions:(w,x=!1)=>{const _=[];let p=[];const{nodeLookup:v,triggerNodeChanges:N,connection:E,updateConnection:j,onNodesChangeMiddlewareMap:D}=m();for(const[P,O]of w){const A=v.get(P),z=!!(A?.expandParent&&A?.parentId&&O?.position),H={id:P,type:"position",position:z?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:x};if(A&&E.inProgress&&E.fromNode.id===A.id){const b=$e(A,E.fromHandle,Y.Left,!0);j({...E,from:b})}z&&A.parentId&&_.push({id:P,parentId:A.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),p.push(H)}if(_.length>0){const{parentLookup:P,nodeOrigin:O}=m(),A=ro(_,v,P,O);p.push(...A)}for(const P of D.values())p=P(p);N(p)},triggerNodeChanges:w=>{const{onNodesChange:x,setNodes:_,nodes:p,hasDefaultNodes:v,debug:N}=m();if(w?.length){if(v){const E=bh(w,p);_(E)}N&&console.log("React Flow: trigger node changes",w),x?.(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:x,setEdges:_,edges:p,hasDefaultEdges:v,debug:N}=m();if(w?.length){if(v){const E=_h(w,p);_(E)}N&&console.log("React Flow: trigger edge changes",w),x?.(w)}},addSelectedNodes:w=>{const{multiSelectionActive:x,edgeLookup:_,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:N}=m();if(x){const E=w.map(j=>Ae(j,!0));v(E);return}v(Be(p,new Set([...w]),!0)),N(Be(_))},addSelectedEdges:w=>{const{multiSelectionActive:x,edgeLookup:_,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:N}=m();if(x){const E=w.map(j=>Ae(j,!0));N(E);return}N(Be(_,new Set([...w]))),v(Be(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:x}={})=>{const{edges:_,nodes:p,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:E}=m(),j=w||p,D=x||_,P=[];for(const A of j){if(!A.selected)continue;const z=v.get(A.id);z&&(z.selected=!1),P.push(Ae(A.id,!1))}const O=[];for(const A of D)A.selected&&O.push(Ae(A.id,!1));N(P),E(O)},setMinZoom:w=>
7{const{panZoom:x,maxZoom:_}=m();x?.setScaleExtent([w,_]),g({minZoom:w})},setMaxZoom:w=>{const{panZoom:x,minZoom:_}=m();x?.setScaleExtent([_,w]),g({maxZoom:w})},setTranslateExtent:w=>{m().panZoom?.setTranslateExtent(w),g({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:x,triggerNodeChanges:_,triggerEdgeChanges:p,elementsSelectable:v}=m();if(!v)return;const N=x.reduce((j,D)=>D.selected?[...j,Ae(D.id,!1)]:j,[]),E=w.reduce((j,D)=>D.selected?[...j,Ae(D.id,!1)]:j,[]);_(N),p(E)},setNodeExtent:w=>{const{nodes:x,nodeLookup:_,parentLookup:p,nodeOrigin:v,elevateNodesOnSelect:N,nodeExtent:E,zIndexMode:j}=m();w[0][0]===E[0][0]&&w[0][1]===E[0][1]&&w[1][0]===E[1][0]&&w[1][1]===E[1][1]||(zn(x,_,p,{nodeOrigin:v,nodeExtent:w,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:j}),g({nodeExtent:w}))},panBy:w=>{const{transform:x,width:_,height:p,panZoom:v,translateExtent:N}=m();return bf({delta:w,panZoom:v,transform:x,translateExtent:N,width:_,height:p})},setCenter:async(w,x,_)=>{const{width:p,height:v,maxZoom:N,panZoom:E}=m();if(!E)return Promise.resolve(!1);const j=typeof _?.zoom<"u"?_.zoom:N;return await E.setViewport({x:p/2-w*j,y:v/2-x*j,zoom:j},{duration:_?.duration,ease:_?.ease,interpolate:_?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...ps}})},updateConnection:w=>{g({connection:w})},reset:()=>g({...br()})}},Object.is);function Lg({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:s,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:f,nodeExtent:d,zIndexMode:u,children:g}){const[m]=C.useState(()=>$g({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:l,minZoom:i,maxZoom:a,fitViewOptions:c,nodeOrigin:f,nodeExtent:d,zIndexMode:u}));return h.jsx(th,{value:m,children:h.jsx(Nh,{children:g})})}function Hg({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:d,nodeExtent:u,zIndexMode:g}){return C.useContext(cn)?h.jsx(h.Fragment,{children:e}):h.jsx(Lg,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:f,nodeOrigin:d,nodeExtent:u,zIndexMode:g,children:e})}const Og={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Bg({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s,edgeTypes:i,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:f,onMoveStart:d,onMoveEnd:u,onConnect:g,onConnectStart:m,onConnectEnd:y,onClickConnectStart:w,onClickConnectEnd:x,onNodeMouseEnter:_,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:N,onNodeDoubleClick:E,onNodeDragStart:j,onNodeDrag:D,onNodeDragStop:P,onNodesDelete:O,onEdgesDelete:A,onDelete:z,onSelectionChange:H,onSelectionDragStart:b,onSelectionDrag:M,onSelectionDragStop:S,onSelectionContextMenu:k,onSelectionStart:I,onSelectionEnd:T,onBeforeDelete:R,connectionMode:L,connectionLineType:$=ke.Bezier,connectionLineStyle:W,connectionLineComponent:F,connectionLineContainerStyle:Z,deleteKeyCode:G="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:B=!1,selectionMode:X=dt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:K=ht()?"Meta":"Control",zoomActivationKeyCode:U=ht()?"Meta":"Control",snapToGrid:q,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:ie,autoPanOnNodeFocus:Ee,nodesConnectable:ye,nodesFocusable:je,nodeOrigin:Qe=Xs,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:dn=!0,defaultViewport:_t=gh,minZoom:Le=.5,maxZoom:tt=2,translateExtent:lo=ut,preventScrolling:Ai=!0,nodeExtent:fn,defaultMarkerColor:Di="#b1b1b7",zoomOnScroll:Pi=!0,zoomOnPinch:Ti=!0,panOnScroll:zi=!1,panOnScrollSpeed:Ri=.5,panOnScrollMode:$i=Te.Free,zoomOnDoubleClick:Li=!0,panOnDrag:Hi=!0,onPaneClick:Oi,onPaneMouseEnter:Bi,onPaneMouseMove:Vi,onPaneMouseLeave:Fi,onPaneScroll:Wi,onPaneContextMenu:Yi,paneClickDistance:Xi=1,nodeClickDistance:Zi=0,children:Ui,onReconnect:qi,onReconnectStart:Gi,onReconnectEnd:Ki,onEdgeContextMenu:Qi,onEdgeDoubleClick:Ji,onEdgeMouseEnter:ea,onEdgeMouseMove:ta,onEdgeMouseLeave:na,reconnectRadius:oa=10,onNodesChange:ra,onEdgesChange:sa,noDragClassName:ia="nodrag",noWheelClassName:aa="nowheel",noPanClassName:uo="nopan",fitView:fo,fitViewOptions:ho,connectOnClick:ca,attributionPosition:la,proOptions:ua,defaultEdgeOptions:da,elevateNodesOnSelect:fa=!0,elevateEdgesOnSelect:ha=!1,disableKeyboardA11y:go=!1,autoPanOnConnect:ga,autoPanOnNodeDrag:pa,autoPanSpeed:ma,connectionRadius:xa,isValidConnection:ya,onError:wa,style:va,id:po,nodeDragThreshold:ba,connectionDragThreshold:_a,viewport:Ea,onViewportChange:Sa,width:Na,height:Ca,colorMode:ka="light",debug:Ma,onScroll:mo,ariaLabelConfig:ja,zIndexMode:xo="basic",...Ia},Aa){const hn=po||"1",Da=yh(ka),Pa=C.useCallback(yo=>{yo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),mo?.(yo)},[mo]);return h.jsx("div",{"data-testid":"rf__wrapper",...Ia,onScroll:Pa,style:{...va,...Og},ref:Aa,className:se(["react-flow",r,Da]),id:po,role:"application",children:h.jsxs(Hg,{nodes:e,edges:t,width:Na,height:Ca,fitView:fo,fitViewOptions:ho,minZoom:Le,maxZoom:tt,nodeOrigin:Qe,nodeExtent:fn,zIndexMode:xo,children:[h.jsx(xh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:g,onConnectStart:m,onConnectEnd:y,onClickConnectStart:w,onClickConnectEnd:x,nodesDraggable:ie,autoPanOnNodeFocus:Ee,nodesConnectable:ye,nodesFocusable:je,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:dn,elevateNodesOnSelect:fa,elevateEdgesOnSelect:ha,minZ
7oom:Le,maxZoom:tt,nodeExtent:fn,onNodesChange:ra,onEdgesChange:sa,snapToGrid:q,snapGrid:ee,connectionMode:L,translateExtent:lo,connectOnClick:ca,defaultEdgeOptions:da,fitView:fo,fitViewOptions:ho,onNodesDelete:O,onEdgesDelete:A,onDelete:z,onNodeDragStart:j,onNodeDrag:D,onNodeDragStop:P,onSelectionDrag:M,onSelectionDragStart:b,onSelectionDragStop:S,onMove:f,onMoveStart:d,onMoveEnd:u,noPanClassName:uo,nodeOrigin:Qe,rfId:hn,autoPanOnConnect:ga,autoPanOnNodeDrag:pa,autoPanSpeed:ma,onError:wa,connectionRadius:xa,isValidConnection:ya,selectNodesOnDrag:te,nodeDragThreshold:ba,connectionDragThreshold:_a,onBeforeDelete:R,debug:Ma,ariaLabelConfig:ja,zIndexMode:xo}),h.jsx(Rg,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:_,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:N,onNodeDoubleClick:E,nodeTypes:s,edgeTypes:i,connectionLineType:$,connectionLineStyle:W,connectionLineComponent:F,connectionLineContainerStyle:Z,selectionKeyCode:V,selectionOnDrag:B,selectionMode:X,deleteKeyCode:G,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:U,onlyRenderVisibleElements:ne,defaultViewport:_t,translateExtent:lo,minZoom:Le,maxZoom:tt,preventScrolling:Ai,zoomOnScroll:Pi,zoomOnPinch:Ti,zoomOnDoubleClick:Li,panOnScroll:zi,panOnScrollSpeed:Ri,panOnScrollMode:$i,panOnDrag:Hi,onPaneClick:Oi,onPaneMouseEnter:Bi,onPaneMouseMove:Vi,onPaneMouseLeave:Fi,onPaneScroll:Wi,onPaneContextMenu:Yi,paneClickDistance:Xi,nodeClickDistance:Zi,onSelectionContextMenu:k,onSelectionStart:I,onSelectionEnd:T,onReconnect:qi,onReconnectStart:Gi,onReconnectEnd:Ki,onEdgeContextMenu:Qi,onEdgeDoubleClick:Ji,onEdgeMouseEnter:ea,onEdgeMouseMove:ta,onEdgeMouseLeave:na,reconnectRadius:oa,defaultMarkerColor:Di,noDragClassName:ia,noWheelClassName:aa,noPanClassName:uo,rfId:hn,disableKeyboardA11y:go,nodeExtent:fn,viewport:Ea,onViewportChange:Sa}),h.jsx(hh,{onSelectionChange:H}),Ui,h.jsx(ch,{proOptions:ua,position:la}),h.jsx(ah,{rfId:hn,disableKeyboardA11y:go})]})})}var Vg=Us(Bg);const Fg=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function Wg({children:e}){const t=J(Fg);return t?$a.createPortal(e,t):null}function Yg({dimensions:e,lineWidth:t,variant:n,className:o}){return h.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,o])})}function Xg({radius:e,className:t}){return h.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var Me;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Me||(Me={}));const Zg={[Me.Dots]:1,[Me.Lines]:1,[Me.Cross]:6},Ug=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function yi({id:e,variant:t=Me.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=0,color:i,bgColor:a,style:c,className:l,patternClassName:f}){const d=C.useRef(null),{transform:u,patternId:g}=J(Ug,oe),m=o||Zg[t],y=t===Me.Dots,w=t===Me.Cross,x=Array.isArray(n)?n:[n,n],_=[x[0]*u[2]||1,x[1]*u[2]||1],p=m*u[2],v=Array.isArray(s)?s:[s,s],N=w?[p,p]:_,E=[v[0]*u[2]||1+N[0]/2,v[1]*u[2]||1+N[1]/2],j=`${g}${e||""}`;return h.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...un,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:d,"data-testid":"rf__background",children:[h.jsx("pattern",{id:j,x:u[0]%_[0],y:u[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:y?h.jsx(Xg,{radius:p/2,className:f}):h.jsx(Yg,{dimensions:N,lineWidth:r,variant:t,className:f})}),h.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}yi.displayName="Background";const qg=C.memo(yi);function Gg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:h.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Kg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:h.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Qg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:h.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Jg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function ep(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function jt({children:e,className:t,...n}){return h.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const tp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function wi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:c,className:l,children:f,position:d="bottom-left",orientation:u="vertical","aria-label":g}){const m=re(),{isInteractive:y,minZoomReached:w,maxZoomReached:x,ariaLabelConfig:_}=J(tp,oe),{zoomIn:p,zoomOut:v,fitView:N}=so(),E=()=>{p(),s?.()},j=()=>{v(),i?.()},D=()=>{N(r),a?.()},P=()=>{m.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c?.(!y)},O=u==="horizontal"?"horizontal":"vertical";return h.jsxs(ln,{className:se(["react-flow__controls",O,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":g??_["controls.ariaLabel"],children:[t&&h.jsxs(h.Fragment,{children:[h.jsx(jt,{onClick:E,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:x,children:h.jsx(Gg,{})}),h.jsx(jt,{onClick:j,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:w,children:h.jsx(Kg,{})})]}),n&&h.jsx(jt,{className:"react-flow__controls-fitview",onClick:D,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:h.jsx(Qg,{})}),o&&h.jsx(jt,{className:"react-flow__controls-interactive",onClick:P,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:y?h.jsx(ep,{}):h.jsx(Jg,{})}),f]})}wi.displayName="Controls";C.memo(wi);function np({id:e,x:t,y:n,width:o,height:r,style:s,color:i,strokeColor:a,strokeWidth:c,className:l,borderRadius:f,shapeRendering:d,selected:u,onClick:g}){const{background:m,backgroundColor:y}=s||{},w=i||m||y;return h.jsx("rect",{className:se(["react-flow__minimap-node",{selected:u},l]),x:t,y:n,rx:f,ry:f,width:o,height:r,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:d,onClick:g?x=>g(x,e):void 0})}const op=C.memo(np),rp=e=>e.nodes.map(t=>
7t.id),En=e=>e instanceof Function?e:()=>e;function sp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:s=op,onClick:i}){const a=J(rp,oe),c=En(t),l=En(e),f=En(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return h.jsx(h.Fragment,{children:a.map(u=>h.jsx(ap,{id:u,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:s,onClick:i,shapeRendering:d},u))})}function ip({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:a,onClick:c}){const{node:l,x:f,y:d,width:u,height:g}=J(m=>{const y=m.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const w=y.internals.userNode,{x,y:_}=y.internals.positionAbsolute,{width:p,height:v}=_e(w);return{node:w,x,y:_,width:p,height:v}},oe);return!l||l.hidden||!_s(l)?null:h.jsx(a,{x:f,y:d,width:u,height:g,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:s,shapeRendering:i,onClick:c,id:l.id})}const ap=C.memo(ip);var cp=C.memo(sp);const lp=200,up=150,dp=e=>!e.hidden,fp=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?bs(wt(e.nodeLookup,{filter:dp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},hp="react-flow__minimap-desc";function vi({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:f,maskStrokeWidth:d,position:u="bottom-right",onClick:g,onNodeClick:m,pannable:y=!1,zoomable:w=!1,ariaLabel:x,inversePan:_,zoomStep:p=1,offsetScale:v=5}){const N=re(),E=C.useRef(null),{boundingRect:j,viewBB:D,rfId:P,panZoom:O,translateExtent:A,flowWidth:z,flowHeight:H,ariaLabelConfig:b}=J(fp,oe),M=e?.width??lp,S=e?.height??up,k=j.width/M,I=j.height/S,T=Math.max(k,I),R=T*M,L=T*S,$=v*T,W=j.x-(R-j.width)/2-$,F=j.y-(L-j.height)/2-$,Z=R+$*2,G=L+$*2,V=`${hp}-${P}`,B=C.useRef(0),X=C.useRef();B.current=T,C.useEffect(()=>{if(E.current&&O)return X.current=If({domNode:E.current,panZoom:O,getTransform:()=>N.getState().transform,getViewScale:()=>B.current}),()=>{X.current?.destroy()}},[O]),C.useEffect(()=>{X.current?.update({translateExtent:A,width:z,height:H,inversePan:_,pannable:y,zoomStep:p,zoomable:w})},[y,w,_,p,A,z,H]);const Q=g?q=>{const[ee,ne]=X.current?.pointer(q)||[0,0];g(q,{x:ee,y:ne})}:void 0,K=m?C.useCallback((q,ee)=>{const ne=N.getState().nodeLookup.get(ee).internals.userNode;m(q,ne)},[]):void 0,U=x??b["minimap.ariaLabel"];return h.jsx(ln,{position:u,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:h.jsxs("svg",{width:M,height:S,viewBox:`${W} ${F} ${Z} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":V,ref:E,onClick:Q,children:[U&&h.jsx("title",{id:V,children:U}),h.jsx(cp,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:a}),h.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-$},${F-$}h${Z+$*2}v${G+$*2}h${-Z-$*2}z 8 M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}vi.displayName="MiniMap";C.memo(vi);const gp=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,pp={[Ge.Line]:"right",[Ge.Handle]:"bottom-right"};function mp({nodeId:e,position:t,variant:n=Ge.Handle,className:o,style:r=void 0,children:s,color:i,minWidth:a=10,minHeight:c=10,maxWidth:l
8=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:g=!0,shouldResize:m,onResizeStart:y,onResize:w,onResizeEnd:x}){const _=Qs(),p=typeof e=="string"?e:_,v=re(),N=C.useRef(null),E=n===Ge.Handle,j=J(C.useCallback(gp(E&&g),[E,g]),oe),D=C.useRef(null),P=t??pp[n];C.useEffect(()=>{if(!(!N.current||!p))return D.current||(D.current=Wf({domNode:N.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:A,transform:z,snapGrid:H,snapToGrid:b,nodeOrigin:M,domNode:S}=v.getState();return{nodeLookup:A,transform:z,snapGrid:H,snapToGrid:b,nodeOrigin:M,paneDomNode:S}},onChange:(A,z)=>{const{triggerNodeChanges:H,nodeLookup:b,parentLookup:M,nodeOrigin:S}=v.getState(),k=[],I={x:A.x,y:A.y},T=b.get(p);if(T&&T.expandParent&&T.parentId){const R=T.origin??S,L=A.width??T.measured.width??0,$=A.height??T.measured.height??0,W={id:T.id,parentId:T.parentId,rect:{width:L,height:$,...Es({x:A.x??T.position.x,y:A.y??T.position.y},{width:L,height:$},T.parentId,b,R)}},F=ro([W],b,M,S);k.push(...F),I.x=A.x?Math.max(R[0]*L,A.x):void 0,I.y=A.y?Math.max(R[1]*$,A.y):void 0}if(I.x!==void 0&&I.y!==void 0){const R={id:p,type:"position",position:{...I}};k.push(R)}if(A.width!==void 0&&A.height!==void 0){const L={id:p,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};k.push(L)}for(const R of z){const L={...R,type:"position"};k.push(L)}H(k)},onEnd:({width:A,height:z})=>{const H={id:p,type:"dimensions",resizing:!1,dimensions:{width:A,height:z}};v.getState().triggerNodeChanges([H])}})),D.current.update({controlPosition:P,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:f},keepAspectRatio:d,resizeDirection:u,onResizeStart:y,onResize:w,onResizeEnd:x,shouldResize:m}),()=>{D.current?.destroy()}},[P,a,c,l,f,d,y,w,x,m]);const O=P.split("-");return h.jsx("div",{className:se(["react-flow__resize-control","nodrag",...O,n,o]),ref:N,style:{...r,scale:j,...i&&{[E?"backgroundColor":"borderColor"]:i}},children:s})}C.memo(mp);const xp="border-transparent bg-blue-500 text-white shadow-sm hover:bg-blue-600",_r="var(--xy-edge-stroke)",yp="var(--color-blue-500)",wp=({id:e,sourceX:t,sourceY:n,targetX:o,targetY:r,sourcePosition:s,targetPosition:i,data:a})=>{const[c,l]=C.useState(!1),[f,d]=C.useState(!1),u=a,[g,m,y]=Gt({sourceX:t,sourceY:n,sourcePosition:s,targetX:o,targetY:r,targetPosition:i}),w={stroke:f||c?yp:_r};if(!u)return h.jsx(Ke,{id:e,path:g,style:{stroke:_r}});const x=N=>{l(!1),u.onPick(N,{sourceId:u.sourceId,targetId:u.targetId})},_=c||f,p=h.jsx("button",{"aria-label":"Insert step here",className:le("flex size-7 items-center justify-center rounded-full border transition-opacity focus-visible:opacity-100 focus-visible:outline-none",xp,_?"opacity-100":"opacity-0",u.disabled&&"cursor-not-allowed!"),"data-testid":`add-step-button-${u.sourceId}-${u.targetId}`,disabled:u.disabled,type:"button",children:h.jsx(Nn,{className:"size-4",strokeWidth:1.5})});let v;return u.disabled?v=u.disabledReason?h.jsx(Mr,{delayDuration:150,children:h.jsxs(jr,{children:[h.jsx(Ir,{asChild:!0,children:h.jsx("span",{tabIndex:0,children:p})}),h.jsx(Ar,{children:u.disabledReason})]})}):p:v=h.jsxs(Dr,{open:c,onOpenChange:l,children:[h.jsx(Pr,{asChild:!0,children:p}),h.jsx(Tr,{align:"center",className:"p-0",side:"right",children:h.jsx(Vr,{onPick:x})})]}),h.jsxs("g",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[h.jsx(Ke,{id:e,interactionWidth:30,path:g,style:w}),h.jsx(Wg,{children:h.jsx("div",{className:"pointer-events-auto absolute",style:{transform:`translate(-50%, -50%) translate(${m}px, ${y}px)`},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:h.jsx("div",{className:"flex h-10 w-16 items-center justify-center",children:v})})})]})},vp=()=>{const{data:e}=On(),{data:t}=La(),n=e?.settings||[],o=t?.site?.url||"",[r="all",s=!1,i=!1]=Bn(n,["members_signup_access","donations_enabled","recommendations_enabled"]);return ac({siteUrl:o,membersSignupAccess:typeof r=="string"?r:"all",donationsEnabled:!!s,recommendationsEnabled:!!i})},bp={useFileUpload:dc,fileTypes:uc},_p=pe.lazy(()=>Oa(()=>import("./koenig-lexical-BCKRQdew.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.EmailEditor})));class Ep extends pe.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?h.jsx("div",{className:"p-6 text-sm text-destructive",children:"Something went wrong loading the editor."}):this.props.children}}const Sp=le("text-[1.6rem] leading-[1.6] tracking-[-0.01em] pb-10","dark:text-white dark:selection:bg-[rgba(88,101,116,0.99)]","[&_.koenig-lexical-editor-input-placeholder]:font-sans! [&_.koenig-lexical-editor-input-placeholder]:text-[1.6rem] [&_.koenig-lexical-editor-input-placeholder]:tracking-tight","[&_:is(h2,h3)]:dark:text-white","[&_.koenig-lexical_input]:text-[1.4rem]","[&_[data-kg-plus-button]]:top-[-4px]","[&_[data-kg-card-selected]]:isolate","[&_:is(p,blockquote,aside,ul,ol)]:tracking-tight","[&_figcaption_:is(p,blockquote,aside,ul,ol)]:text-[1.4rem] [&_figcaption_:is(p,blockquote,aside,ul,ol)]:tracking-[.025em]","[&_figcaption_p]:mb-0","[&_:is(h1)]:text-[36px] [&_:is(h2)]:text-[32px] [&_:is(h3)]:text-[26px] [&_:is(h4)]:text-[21px] [&_:is(h5)]:text-[19px] [&_:is(h6)]:text-[19px] [&_:is(h1,h2,h3,h4,h5,h6)]:mb-[0.5em]","[&_:is(hr)]:pt-0","[&_p]:mb-4 [&_strong]:font-semibold","[&_[data-kg-settings-panel]_p]:!mb-0","[&_.not-kg-prose>div]:font-sans! [&_.not-kg-prose>div]:tracking-tight! [&_.not-kg-prose>div]:text-[1.6rem]! [&_.not-kg-prose>div]:leading-[1.6]!","[&_.kg-inherit-styles_p]:mb-0!","[&_.kg-inherit-styles]:pt-[3px]!","[&_.koenig-lexical-cta-label_p]:!text-[12.5px]"),Np=({value:e,placeholder:t,className:n,onChange:o})=>{const r=C.useRef(null),s=C.useRef(e),{unsplashConfig:i}=Ha(),a=cc(),{data:c}=On(),{data:l}=zr(),f=c?.settings||[],d=l?.config,{fetchAutocompleteLinks:u,searchLinks:g}=vp(),m=lc(),y=d?.tenor?.googleApiKey?d.tenor:null,[w]=Bn(f,["transistor"]),x=C.useMemo(()=>({unsplash:i,pinturaConfig:a,tenor:y,fetchEmbed:m,fetchAutocompleteLinks:u,searchLinks:g,feature:{transistor:w},visibilitySettings:"none"}),[i,a,y,m,u,g,w]),_=C.useCallback(E=>{r.current=E},[]),p=C.useCallback(E=>{o&&E&&typeof E=="object"&&o(JSON.stringify(E))},[o]),v=C.useCallback(E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&E.stopPropagation()},[]),N=E=>{r.current&&fc(r.current,E)};return h.jsx("div",{className:"h-full",onKeyDown:v,onMouseDown:N,children:h.jsx(Ep,{children:h.jsx(C.Suspense,{fallback:h.jsx(Pe,{size:"lg"}),children:h.jsx("div",{className:le("koenig-react-editor w-full",Sp,n),children:h.jsx(_p,{cardConfig:x,className:"koenig-lexical koenig-lexical-editor-input",darkMode:!1,fileUploader:bp,initialEditorState:s.current,placeholderText:t,registerAPI:_,onChange:p})})})})})},Cp=pe.memo(Np),kp=({previewState:e})=>{const[t,n]=C.useState(null),[o,r]=C.useState(!1),s=C.useRef(!1),i=C.useRef(null),a=C.useRef(null),c=C.useRef(null),l=C.useRef(null);function f(){a.current?.disconnect(),a.current=null,c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null),l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null)}const d=e.status==="success"?e.html:"";C.useEffect(()=>(f(),s.current=!1,r(!1),n(null),()=>{f()}),[d,e.status]);function u(){const w=i.current,x=w?.contentDocument;if(!w||!x)return;x.documentElement.style.overflowY="hidden",x.body.style.overflowY="hidden";const _=Math.max(x.documentElement?.scrollHeight||0,x.body?.scrollHeight||0,x.documentElement?.offsetHeight||0,x.body?.offsetHeight||0);_>0&&(n(p=>p===_?p:_),!s.current&&l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=window.requestAnimationFrame(()=>{l.current=null,s.current=!0,r(!0)})})))}function g(){c.current!==null&&window.cancelAnimationFrame(c.current),c.current=window.requestAnimationFrame(()=>{c.current=null,u()})}function m(){const w=i.current,x=w?.contentDocument;if(!(!w||!x)&&(f(),g(),typeof ResizeObserver<"u")){const _=new ResizeObserver(()=>{g()});_.observe(x.documentElement),_.observe(x.body),a.current=_}}const y=e.status==="loading"||e.status==="success"&&!o;return h.jsxs("div",{className:"relative w-full","data-testid":"email-preview",children:[y&&h.jsx("div",{className:"flex min-h-full items-start justify-center pt-24","data-testid":"email-preview-loading",style:t?{height:`${t}px`}:void 0,children:h.jsx(Pe,{size:"md"})}),e.status==="success"&&h.jsx("div",{"aria-hidden":!o,className:le("w-full",!o&&"pointer-events-none absolute left-0 top-0 opacity-0"),children:h.jsx("iframe",{ref:i,className:"w-full rounded bg-white","data-testid":"email-preview-iframe",sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",srcDoc:e.html,style:{height:t?`${t}px`:"600px"},title:"Email preview",onLoad:m})}),(e.status==="error"||e.status==="invalid")&&h.jsx("div",{className:"flex h-full items-center justify-center px-4","data-testid":"email-preview-error",children:h.jsx("span",{className:"text-sm text-destructive",children:e.message})})]})},Mp=({automatedEmailId:e,subject:t,lexical:n,validateForm:o,onClose:r})=>{const{data:s}=Ba(),{mutateAsync:i}=hc(),[a,c]=C.useState(s?.email||""),[l,f]=C.useState(""),[d,u]=C.useState("idle"),g=C.useRef(null);C.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]),C.useEffect(()=>{s?.email&&c(s.email)},[s?.email]),C.useEffect(()=>{const y=w=>{w.key==="Escape"&&(w.stopPropagation(),r())};return document.addEventListener("keydown",y,!0),()=>document.removeEventListener("keydown",y,!0)},[r]);const m=async()=>
8{if(f(""),!gc.isEmail(a)){f("Please enter a valid email address");return}if(!o()){f("Please complete the required fields");return}u("sending");try{await i({id:e,email:a,subject:t,lexical:n}),u("sent"),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>u("idle"),2e3)}catch(y){u("idle");let w;y instanceof Rr&&y.data&&y.data.errors[0]?w=y.data.errors[0].context||y.data.errors[0].message:y instanceof Error&&(w=y.message),f(w||"Failed to send test email")}};return h.jsxs("div",{className:"absolute top-full right-0 z-10 mt-2 w-[260px] rounded border border-grey-250 bg-white p-4 shadow-lg dark:border-grey-925 dark:bg-grey-975","data-testid":"test-email-dropdown",children:[h.jsxs("div",{className:"mb-3",children:[h.jsx("label",{className:"mb-2 block text-sm font-semibold",htmlFor:"test-email-input",children:"Send test email"}),h.jsx(Qt,{id:"test-email-input",placeholder:"[email protected]",value:a,onChange:y=>{c(y.target.value)}})]}),h.jsx(ae,{className:"w-full",disabled:d==="sending",onClick:m,children:d==="sent"?"Sent":d==="sending"?"Sending...":"Send"}),l&&h.jsx("span",{className:"mt-2 block text-xs text-destructive",children:l})]})},ao=(e,t,n)=>Vn(t)&&!$r(t)&&n?n:e.sender_email||n||"",jp=(e,t,n,o)=>e.sender_reply_to==="newsletter"?Vn(t)?"":ao(e,t,o):e.sender_reply_to==="support"?n||o||"":e.sender_reply_to,Ip=(e,t,n,o)=>{const r=jp(e,t,n,o);return r||(e.sender_reply_to==="newsletter"?ao(e,t,o)||n||o||"":n||o||"")},Hn={free:"member-welcome-email-free",paid:"member-welcome-email-paid"},Ce=e=>e?.trim()||"",Sn=(...e)=>e.map(Ce).find(Boolean)||"",Ap=({automatedEmails:e=[],config:t,defaultEmailAddress:n,newsletter:o,siteTitle:r,supportEmailAddress:s})=>{const i=e.find(j=>j.slug===Hn.free),a=e.find(j=>j.slug===Hn.paid),c=Sn(i?.sender_name,a?.sender_name),l=Sn(i?.sender_email,a?.sender_email),f=Sn(i?.sender_reply_to,a?.sender_reply_to),d=Ce(o?.sender_name),u=o?Ce(ao(o,t,n||void 0)):"",g=o?Ce(Ip(o,t,s||void 0,n||void 0)):"",m=d||Ce(r)||"Your site name",y=u||Ce(n),w=g||Ce(s)||Ce(n),x=c||m,_=l||y||"",p=f||w||"",v=p!==""&&p!==_,N=Vn(t),E=$r(t);return{hasDistinctReplyTo:v,replyToEmailInput:f,replyToEmailPlaceholder:w,resolvedReplyToEmail:p,resolvedSenderEmail:_,resolvedSenderName:x,senderEmailDomain:E?Va(t):null,senderEmailInput:l,senderEmailPlaceholder:y,senderNameInput:c,senderNamePlaceholder:m,showSenderEmailInput:!N||E}},Dp=e=>{if(!e)return!0;try{const n=JSON.parse(e)?.root?.children;return!n||n.length===0||n.length===1&&n[0].type==="paragraph"&&(!n[0].children||n[0].children.length===0)}catch{return!0}},bi=e=>{const t={};return e.subject?.trim()||(t.subject="A subject is required"),Dp(e.lexical)&&(t.lexical="Email content is required"),t},Pp=e=>{if(typeof DOMParser>"u")return e;const n=new DOMParser().parseFromString(e,"text/html");return n.querySelectorAll("a[href]").forEach(o=>{o.target="_blank",o.rel="noopener noreferrer"}),`<!doctype html>${n.documentElement.outerHTML}`},Tp=e=>{const t="Failed to render preview";return e instanceof Rr&&e.data?.errors?.[0]?e.data.errors[0].context||e.data.errors[0].message||t:e instanceof Error&&e.message?e.message:t},zp=({automatedEmailId:e,previewWelcomeEmail:t,setErrors:n})=>{const[o,r]=C.useState({status:"idle"}),s=C.useRef(0),i=()=>{s.current+=1,r({status:"idle"})},a=async l=>{const f=s.current+1;s.current=f;const d=bi(l);if(n(d),!!(d.subject||d.lexical)){r({status:"invalid",message:d.subject||d.lexical});return}r({status:"loading"});try{const g=await t({id:e,subject:l.subject,lexical:l.lexical});if(s.current!==f)return;const m=g.automated_emails?.[0];if(!m?.html||!m?.plaintext||!m?.subject)throw new Error("Preview response was incomplete");r({status:"success",preview:{...m,html:Pp(m.html)}})}catch(g){if(s.current!==f)return;r({status:"error",message:Tp(g)})}};let c={status:"loading"};return o.status==="success"?c={status:"success",html:o.preview.html}:(o.status==="error"||o.status==="invalid")&&(c={status:o.status,message:o.message}),{previewFrameState:c,previewState:o,enterPreview:a,exitPreview:i}},Rp=(e=[])=>{const{data:t}=On(),{data:n}=zr(),o=t?.settings||[],r=C.useMemo(()=>n?.config||{},[n]),[s,i,a]=Bn(o,["title","default_email_address","support_email_address"]),{data:c}=vc({searchParams:{filter:"status:active",limit:"1"}}),l=c?.newsletters?.[0];return C.useMemo(()=>Ap({automatedEmails:e,config:r,defaultEmailAddress:i,newsletter:l,siteTitle:s,supportEmailAddress:a}),[e,r,i,l,s,a])},_i=pe.forwardRef(({title:e,centeredHeaderContent:t,headerActions:n,children:o,className:r,isEditMode:s=!1},i)=>h.jsxs("div",{ref:i,className:le("flex h-full w-full flex-col gap-0 overflow-hidden p-0",s?"bg-white":"bg-gray-100","dark:bg-gray-975",r),children:[h.jsxs("div",{className:"sticky top-0 grid shrink-0 grid-cols-[1fr_auto_1fr] items-center border-b border-gray-200 bg-white px-5 py-3 dark:border-gray-900 dark:bg-gray-975",children:[h.jsx("h3",{className:"justify-self-start text-xl font-semibold",children:e}),h.jsx("div",{className:"justify-self-center",children:t}),h.jsx("div",{className:"flex items-center gap-2 justify-self-end",children:n})]}),h.jsx("div",{className:"flex min-h-0 grow flex-col overflow-y-auto [scrollbar-gutter:stable]",children:o})]}));_i.displayName="EmailPreviewModalContent";const $p=({children:e,className:t})=>h.jsx("div",{className:le("relative z-20 isolate mx-auto w-full max-w-[780px] rounded-t-lg border border-b-0 border-gray-200 bg-white px-6 py-4 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:bg-grey-975",t),children:e}),Lp=({children:e,className:t})=>h.jsx("div",{className:le("flex mx-auto w-full rounded-b-lg transition-[max-width,height,padding] duration-300 ease-out motion-reduce:transition-none dark:border-grey-900 dark:shadow-none grow max-w-[780px]",t),children:e}),Hp=({initialSubject:e,initialLexical:t,onClose:n,onSave:o})=>{const{mutateAsync:r}=pc(),{data:s}=mc(),[i,a]=C.useState(!1),[c,l]=C.useState("edit"),[f,d]=C.useState(null),[u,g]=C.useState(!1),m=C.useRef(null),y=C.useRef(t||""),w=C.useRef(!1),x=Fa(),_=s?.automated_emails||[],{resolvedSenderName:p,resolvedSenderEmail:v,resolvedReplyToEmail:N,hasDistinctReplyTo:E}=Rp(_),j=(_.find(V=>V.slug===Hn.free)||_[0])?.id||"",{formState:D,saveState:P,updateForm:O,setFormState:A,setErrors:z,handleSave:H,okProps:b,errors:M,validate:S}
8=xc({initialState:{subject:e||"",lexical:t||""},savingDelay:500,onSave:async V=>{o({subject:V.subject,lexical:V.lexical})},onSaveError:x,onValidate:bi}),k=b.label||"Save",{previewFrameState:I,enterPreview:T,exitPreview:R}=zp({automatedEmailId:j,previewWelcomeEmail:r,setErrors:z}),L=P==="unsaved",$=C.useCallback(()=>{L?g(!0):n()},[L,n]),W=C.useCallback(async()=>{await H({fakeWhenUnchanged:!0})&&n()},[H,n]);C.useEffect(()=>{const V=B=>{m.current&&!m.current.contains(B.target)&&a(!1)};return i&&document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[i]);const F=C.useRef(W);C.useEffect(()=>{F.current=W},[W]),C.useEffect(()=>{const V=B=>{(B.metaKey||B.ctrlKey)&&B.key==="s"&&(B.preventDefault(),F.current())};return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[]);const Z=C.useCallback(V=>{l(V),V==="preview"?(d(null),T(D)):(a(!1),d(null),R())},[T,R,D]),G=C.useCallback(V=>{if(!w.current){y.current=V,A(B=>({...B,lexical:V}));return}V!==y.current?O(B=>({...B,lexical:V})):A(B=>({...B,lexical:V}))},[A,O]);return h.jsxs(h.Fragment,{children:[h.jsx(Wa,{open:!0,onOpenChange:V=>{V||$()},children:h.jsxs(Ya,{"aria-describedby":void 0,className:"top-0 left-0 h-[100dvh] w-full max-w-full translate-x-0 translate-y-0 grid-rows-[1fr] gap-0 rounded-none border-0 p-0 shadow-none outline-hidden sm:rounded-none dark:bg-[#151719]",onEscapeKeyDown:V=>{V.preventDefault(),V.stopPropagation(),$()},children:[h.jsx(Xa,{className:"sr-only",children:"Edit email"}),h.jsx(_i,{centeredHeaderContent:h.jsx(yc,{"data-testid":"email-mode-toggle",value:c,variant:"segmented-sm",onValueChange:V=>V&&Z(V),children:h.jsxs(wc,{className:"grid w-[240px] grid-cols-2 bg-gray-100 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.04)]",children:[h.jsx(bo,{className:"w-full justify-center data-[state=active]:bg-white dark:data-[state=active]:bg-white dark:data-[state=active]:text-black","data-testid":"email-mode-edit",value:"edit",children:"Email content"}),h.jsx(bo,{className:"w-full justify-center","data-testid":"email-mode-preview",value:"preview",children:"Preview"})]})}),headerActions:h.jsxs(h.Fragment,{children:[h.jsx(ae,{variant:"outline",onClick:$,children:"Close"}),h.jsx(ae,{disabled:b.disabled,onClick:W,children:k})]}),isEditMode:c==="edit",title:"Edit email",children:h.jsxs("div",{className:"flex grow flex-col items-center p-6",children:[c==="preview"&&h.jsx($p,{className:"border-x-0 border-t-0 border-b",children:h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex items-center py-1",children:[h.jsx("div",{className:"w-20 shrink-0 text-sm font-semibold",children:"From:"}),h.jsx("div",{className:"min-w-0 grow pr-4 text-sm",children:h.jsxs("span",{className:"flex gap-1 truncate whitespace-nowrap",children:[h.jsx("span",{children:p}),h.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:`<${v}>`})]})}),h.jsxs("div",{ref:m,className:"relative",children:[h.jsxs(ae,{variant:"outline",onClick:()=>a(!i),children:[h.jsx(bc,{className:"size-4"}),"Test"]}),i&&h.jsx(Mp,{automatedEmailId:j,lexical:D.lexical,subject:D.subject,validateForm:S,onClose:()=>a(!1)})]})]}),E&&h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"w-20 shrink-0 text-sm font-semibold",children:"Reply-to:"}),h.jsx("div",{className:"grow text-sm text-gray-500 dark:text-gray-400",children:N})]}),h.jsxs("div",{className:"flex items-center",children:[h.jsx("div",{className:"w-20 shrink-0 text-sm font-semibold",children:"Subject:"}),h.jsxs("div",{className:"grow",children:[h.jsx(Qt,{className:"w-full","data-testid":"email-preview-subject",value:f??D.subject,onChange:V=>{const B=V.target.value;d(B),O(X=>({...X,subject:B}))}}),M.subject&&h.jsx("span",{className:"mt-2 block text-xs text-destructive",children:M.subject})]})]})]})}),h.jsxs(Lp,{className:le(c==="preview"&&"shadow-sm bg-white dark:bg-grey-975",c==="edit"&&"px-6",c==="edit"&&"rounded-lg",c==="edit"&&M.lexical&&"border border-red-500"),children:[h.jsx("div",{className:le("mx-auto w-full max-w-[600px] pt-10 pb-8 transition-[max-width,padding] duration-300 ease-out motion-reduce:transition-none",c==="preview"&&"hidden"),"data-testid":"email-editor",onFocus:()=>{w.current=!0},children:h.jsx(Cp,{className:"automation-email-editor",placeholder:"Write your email content...",value:D.lexical,onCh
8ange:G})}),c==="preview"&&h.jsx(kp,{previewState:I})]}),c==="edit"&&M.lexical&&h.jsx("span",{className:"mt-2 block max-w-[740px] text-xs text-destructive",children:M.lexical})]})})]})}),h.jsx(It,{open:u,onOpenChange:g,children:h.jsxs(At,{children:[h.jsxs(Dt,{children:[h.jsx(Pt,{children:"Discard changes?"}),h.jsx(Tt,{children:"Your changes to this email haven't been saved."})]}),h.jsxs(zt,{children:[h.jsx(Rt,{children:"Keep editing"}),h.jsx(ae,{variant:"destructive",onClick:()=>{g(!1),n()},children:"Discard"})]})]})})]})},Ei=30,Op=/^\d+$/,Vt=0,Bp=256,Vp=Vt+Bp/2,Er=180,Fp=40,Wp=`Limit of ${Hr(Cn)} steps reached`,Yp="var(--xy-edge-stroke)",De="__trigger__",Ve="__tail__",Xp=({sourceId:e,targetId:t})=>({previousActionId:e===De?void 0:e,nextActionId:t===Ve?void 0:t}),Zp={opacity:0,pointerEvents:"none",background:"transparent",border:"none"},mt=({type:e,position:t})=>h.jsx(pt,{isConnectable:!1,position:t,style:Zp,type:e}),Si=({children:e,className:t,data:n})=>h.jsx("button",{"aria-label":n.value?`${n.label}: ${n.value}`:n.label,"aria-pressed":n.selected,className:le("flex w-64 items-center gap-3 rounded-lg border border-border-default bg-surface-elevated px-4 py-3 text-left text-sm text-foreground shadow-sm transition-colors hover:border-border-strong focus-visible:border-border-strong focus-visible:outline-none",n.selected&&"border-blue-500 shadow-[inset_0_0_0_1px_var(--color-blue-500),0_1px_2px_0_rgb(0_0_0_/_0.05)]",t),type:"button",onClick:n.onSelect,children:e}),Ni=({data:e})=>{const t=e.icon;return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-text-secondary",children:h.jsx(t,{className:"size-4"})}),h.jsxs("div",{className:"flex min-w-0 flex-col text-left",children:[h.jsx("span",{className:"text-xs text-text-secondary",children:e.label}),e.value&&h.jsx("span",{className:"truncate font-medium",children:e.value})]})]})},Ci=pe.memo(({data:e})=>h.jsxs(Si,{data:e,children:[h.jsx(Ni,{data:e}),h.jsx(mt,{position:Y.Bottom,type:"source"})]}));Ci.displayName="TriggerNode";const ki=pe.memo(({data:e})=>h.jsxs(Si,{data:e,children:[h.jsx(mt,{position:Y.Top,type:"target"}),h.jsx(Ni,{data:e}),h.jsx(mt,{position:Y.Bottom,type:"source"})]}));ki.displayName="StepNode";const Up=({data:e})=>{const[t,n]=C.useState(!1),o=s=>{n(!1),e.onPick(s,e.anchor)},r="flex h-12 w-64 items-center justify-center rounded-lg border border-dashed border-border-default bg-surface-page transition-colors hover:border-border-strong focus-visible:border-border-strong focus-visible:outline-none";if(e.disabled){const s=h.jsxs("div",{"aria-disabled":"true",className:le(r,"cursor-not-allowed opacity-60"),"data-testid":"add-step-tail-button",children:[h.jsx(mt,{position:Y.Top,type:"target"}),h.jsx(Nn,{className:"size-5 text-text-secondary",strokeWidth:1.5})]});return e.disabledReason?h.jsx(Mr,{delayDuration:150,children:h.jsxs(jr,{children:[h.jsx(Ir,{asChild:!0,children:h.jsx("span",{tabIndex:0,children:s})}),h.jsx(Ar,{children:e.disabledReason})]})}):s}return h.jsxs(Dr,{open:t,onOpenChange:n,children:[h.jsxs(Pr,{"aria-label":"Add step",className:le(r,"cursor-pointer"),"data-testid":"add-step-tail-button",children:[h.jsx(mt,{position:Y.Top,type:"target"}),h.jsx(Nn,{className:"size-5 text-text-secondary",strokeWidth:1.5})]}),h.jsx(Tr,{align:"center",className:"p-0",side:"top",children:h.jsx(Vr,{onPick:o})})]})},qp={trigger:Ci,step:ki,tail:Up},Gp={"add-step-edge":wp},Mi=e=>{if(e<=0)throw new Error("Wait time must be a positive number of hours.");if(e%24===0){const t=e/24;return t===1?"1 day":`${t} days`}return e===1?"1 hour":`${e} hours`},Kp=e=>{switch(e.type){case"wait":return{icon:Wn,label:"Wait",value:Mi(e.data.wait_hours)};case"send_email":return{icon:Fn,label:"Send email",value:e.data.email_subject};default:{const t=e;throw new Error(`Unknown automation action type: ${t}`)}}},Qp=e=>{if(e.actions.length===0)return[];const t=new Map(e.actions.map(c=>[c.id,c])),n=new Set(e.edges.map(c=>c.target_action_id)),o=e.actions.find(c=>!n.has(c.id));if(!o)throw new Error(`Could not determine the starting step for automation ${e.id}.`);const r=new Map(e.edges.map(c=>[c.source_action_id,c.target_action_id])),s=[],i=new Set;let a=o;for(;a;){if(i.has(a.id))throw new Error(`Detected a loop in automation ${e.id}.`);s.push(a),i.add(a.id);const c=r.get(a.id);a=c?t.get(c):void 0}if(s.length!==e.actions.length)throw new Error(`Some steps in automation ${e.id} are missing or disconnected.`);return s},Jp=({automation:e,disabled:t,onPick:n,onSelectStep:o,selectedStepId:r})=>
8{const s=Qp(e),i={draggable:!1,selectable:!1,connectable:!1,focusable:!1},a=t?Wp:void 0,l={sourceId:s[s.length-1]?.id??De,targetId:Ve},f=[{id:De,type:"trigger",position:{x:Vt,y:0},data:{icon:Lr,label:"Trigger",value:"Member signs up",selected:r===De,onSelect:()=>o(De)},...i}];s.forEach((g,m)=>{f.push({id:g.id,type:"step",position:{x:Vt,y:Er*(m+1)},data:{...Kp(g),selected:r===g.id,onSelect:()=>o(g.id)},...i})}),f.push({id:Ve,type:"tail",position:{x:Vt,y:Er*(s.length+1)},data:{disabled:t,disabledReason:a,onPick:n,anchor:l},draggable:!1,connectable:!1});const d=[];let u=De;return s.forEach(g=>{const m={sourceId:u,targetId:g.id,disabled:t,disabledReason:a,onPick:n};d.push({id:`e-${u}-${g.id}`,source:u,target:g.id,type:"add-step-edge",focusable:!1,data:m}),u=g.id}),d.push({id:`e-${u}-${Ve}`,source:u,target:Ve,type:"smoothstep",focusable:!1,style:{stroke:Yp}}),{nodes:f,edges:d}},em=e=>({x:Math.round(e/2-Vp),y:Fp,zoom:1}),tm={"member-welcome-email-free":["free"],"member-welcome-email-paid":["paid"]},nm=({automation:e,stepId:t,onDelete:n,onUpdateWait:o,onUpdateSubject:r,onEditEmail:s})=>{if(!t)return null;if(t===De)return{icon:Lr,label:"Trigger",title:"Member signs up",memberTiers:tm[e.slug]??[],type:"trigger"};const i=e.actions.find(a=>a.id===t);if(!i)return null;switch(i.type){case"wait":{const a=Mi(i.data.wait_hours);return{icon:Wn,label:"Wait",title:a,action:i,onDelete:()=>n(i.id),onUpdate:c=>o(i.id,c),type:"wait"}}case"send_email":return{icon:Fn,label:"Send email",title:i.data.email_subject||"No subject",action:i,onDelete:()=>n(i.id),onUpdateSubject:a=>r(i.id,a),onEditEmail:()=>s(i.id),type:"send_email"};default:{const a=i;throw new Error(`Unknown automation action type: ${a}`)}}},co=({label:e,children:t})=>h.jsxs("label",{className:"flex flex-col gap-2",children:[h.jsx("span",{className:"text-xs font-medium text-text-secondary",children:e}),t]}),ji=({value:e})=>h.jsx(jc,{value:e,children:h.jsx(Ic,{disabled:!0,children:h.jsx("span",{children:e})})}),om=({memberTiers:e})=>h.jsxs("div",{className:"flex flex-col gap-5",children:[h.jsx(co,{label:"Trigger",children:h.jsx(ji,{value:"New member sign up"})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Members"}),h.jsxs(So,{className:"flex items-center gap-2 text-sm font-normal text-foreground",children:[h.jsx(Eo,{checked:e.includes("free"),disabled:!0}),"Free"]}),h.jsxs(So,{className:"flex items-center gap-2 text-sm font-normal text-foreground",children:[h.jsx(Eo,{checked:e.includes("paid"),disabled:!0}),"Paid"]})]})]}),Ii=({onClick:e})=>h.jsxs(ae,{className:"w-full border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground",type:"button",variant:"outline",onClick:e,children:[h.jsx(Ua,{className:"size-4"}),"Delete step"]}),Sr=e=>{const t=Number(e);return!Op.test(e)||!Number.isInteger(t)||t<1||t>Ei?null:t},rm=({action:e,onUpdate:t,onDelete:n})=>{if(e.data.wait_hours%24!==0)throw new Error(`WaitSidebarBody: wait_hours must be a multiple of 24, received ${e.data.wait_hours}`);const o=e.data.wait_hours/24,[r,s]=C.useState(String(o)),i=Number(r),a=Sr(r)!==null,c=i===1?"Day":"Days",l=d=>{const u=d*24;u!==e.data.wait_hours&&t(u)},f=d=>{const u=d.target.value;s(u);const g=Sr(u);g!==null&&l(g)};return h.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[h.jsxs(co,{label:"Wait for",children:[h.jsxs("div",{className:"grid grid-cols-[6rem_1fr] gap-2",children:[h.jsx(Qt,{"aria-invalid":!a,inputMode:"numeric",value:r,onChange:f}),h.jsx(ji,{value:c})]}),!a&&h.jsxs("span",{className:"text-xs text-red",children:["Enter a whole number between 1 and ",Hr(Ei)," days."]})]}),h.jsx("div",{className:"mt-auto pt-6",children:h.jsx(Ii,{onClick:n})})]})},sm=({action:e,onUpdateSubject:t,onEditEmail:n,onDelete:o})=>h.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[h.jsx(co,{label:"Subject line",children:h.jsx(Qt,{placeholder:"Subject line",value:e.data.email_subject,onChange:r=>t(r.target.value)})}),h.jsxs(ae,{className:"w-full",type:"button",variant:"outline",onClick:n,children:[h.jsx(Dc,{className:"size-4"}),"Edit email"]}),h.jsx("div",{className:"mt-auto pt-6",children:h.jsx(Ii,{onClick:o})})]}),im=({detail:e})=>{switch(e.type){case"trigger":return h.jsx(om,{memberTiers:e.memberTiers});case"wait":return h.jsx(rm,{action:e.action,onDelete:e.onDelete,onUpdate:e.onUpdate},e.action.id);case"send_email":return h.jsx(sm,{action:e.action,onDelete:e.onDelete,onEditEmail:e.onEditEmail,onUpdateSubject:e.onUpdateSubject},e.action.id);default:{const t=e;throw new Error(`Unknown sidebar type: ${t}`)}}},am=({detail:e})=>{const t=e.icon;return h.jsxs("div",{className:"flex min-h-full flex-col gap-6",children:[h.jsx("div",{className:"flex items-start gap-4",children:h.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[h.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-text-secondary",children:h.jsx(t,{className:"size-4"})}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("span",{className:"block text-xs text-text-secondary",children:e.label}),h.jsx("h2",{className:"truncate text-base leading-tight font-semibold text-foreground",children:e.title})]})]})}),h.jsx(im,{detail:e})]})},cm=({detail:e,isEmailModalOpen:t,onClose:n})=>(C.useEffect(()=>{if(!e)return;const o=r=>{if(r.key==="Escape"){if(t)return;n()}};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[e,t,n]),h.jsx("aside",{"aria-hidden":!e,"aria-label":"Step details",className:le("absolute inset-y-0 right-0 z-[1] flex w-[calc(100%-6rem)] max-w-none translate-x-full flex-col gap-6 overflow-y-auto border-l border-border-default bg-background p-6 shadow-lg transition-transform duration-200 ease-out sm:w-[36rem]",e?"translate-x-0":"pointer-events-none"),"data-state":e?"open":"closed","data-testid":"automation-step-sidebar",children:e&&h.jsx(am,{detail:e})})),lm={wait:Nc,send_email:Sc},um=({automation:e,isLoading:t,isError:n,onChange:o})=>{const[r,s]=C.useState(null),i=r?.id??null,a=C.useCallback((_,p)=>
8{if(!e||e.actions.length>=Cn)return;const v=Xp(p),N=lm[_],E=N({detail:e,anchor:v});o(E)},[e,o]),c=C.useCallback(_=>{if(!e)return;const p=_c({detail:e,actionId:_});s(null),o(p)},[e,o]),l=C.useCallback((_,p)=>{e&&o(Ec({detail:e,actionId:_,waitHours:p}))},[e,o]),f=C.useCallback((_,p)=>{if(!e)return;const v=e.actions.find(N=>N.id===_&&N.type==="send_email");v&&o(_o({detail:e,actionId:_,emailSubject:p,emailLexical:v.data.email_lexical}))},[e,o]),d=_=>{s({id:_,isEditingEmail:!0})},u=r?.isEditingEmail&&e?e.actions.find(_=>_.id===r.id&&_.type==="send_email"):void 0,g=C.useRef(em(window.innerWidth)),m=C.useMemo(()=>e?Jp({automation:e,disabled:e.actions.length>=Cn,onPick:a,onSelectStep:_=>s({id:_,isEditingEmail:!1}),selectedStepId:i}):null,[e,a,i]),y=e?nm({automation:e,onDelete:c,onUpdateWait:l,onUpdateSubject:f,onEditEmail:d,stepId:i}):null,w=C.useCallback(()=>{s(null)},[]),x=()=>{u&&s({id:u.id,isEditingEmail:!1})};return t?h.jsx("div",{className:"flex flex-1 items-center justify-center bg-surface-page","data-testid":"automation-canvas-loading",children:h.jsx(Pe,{size:"lg"})}):n||!e||!m?h.jsx("div",{className:"flex flex-1 items-start justify-center bg-surface-page px-4 py-8",children:h.jsx(Za,{className:"max-w-md",role:"alert",variant:"destructive",children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx(Ac,{className:"mt-0.5 size-5 text-red"}),h.jsxs("div",{children:[h.jsx("strong",{className:"block",children:"Couldn't load automation"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Try refreshing the page."})]})]})})}):h.jsxs("div",{className:"relative flex-1 overflow-hidden bg-surface-page","data-testid":"automation-canvas",children:[h.jsx(Vg,{className:"[--xy-background-color:var(--surface-page)] [--xy-background-pattern-color:var(--border-subtle)] [--xy-edge-stroke:var(--border-subtle)] dark:[--xy-background-pattern-color:var(--color-grey-900)] dark:[--xy-edge-stroke:var(--color-grey-800)]",defaultViewport:g.current,edges:m.edges,edgesFocusable:!1,edgeTypes:Gp,nodes:m.nodes,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,nodeTypes:qp,proOptions:{hideAttribution:!0},zoomOnScroll:!1,panOnScroll:!0,onNodeClick:(_,p)=>{p.id!==Ve&&s({id:p.id,isEditingEmail:!1})},onPaneClick:w,children:h.jsx(qg,{})}),h.jsx(cm,{detail:y,isEmailModalOpen:!!u,onClose:w}),u&&e&&h.jsx(Hp,{initialLexical:u.data.email_lexical,initialSubject:u.data.email_subject,onClose:x,onSave:({subject:_,lexical:p})=>{o(_o({detail:e,actionId:u.id,emailSubject:_,emailLexical:p})),s({id:u.id,isEditingEmail:!1})}})]})},dm=({automation:e,isLoadingAutomation:t,isSaveButtonEnabled:n,isPublishButtonEnabled:o,saveButtonVariant:r,publishButtonVariant:s,isTurnOffButtonEnabled:i,saveButtonChildren:a,publishButtonChildren:c,onSave:l,onPublish:f,onTurnOff:d})=>{const u=e?.name,g=e?.status;return h.jsxs("header",{className:"relative z-10 flex h-14 shrink-0 items-center justify-between bg-background px-4 shadow-sm",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[h.jsx(ae,{size:"icon",variant:"ghost",asChild:!0,children:h.jsx(qa,{"aria-label":"Back to automations",to:"/automations",children:h.jsx(Ga,{strokeWidth:2})})}),t?h.jsx(Ka,{className:"h-5 w-40"}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"truncate font-medium",children:u}),g&&h.jsx(Cc,{status:g})]})]}),h.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[g==="active"&&h.jsxs(Qa,{children:[h.jsx(Ja,{asChild:!0,children:h.jsx(ae,{"aria-label":"Automation options",size:"icon",variant:"ghost",children:h.jsx(ec,{})})}),h.jsx(tc,{align:"end",children:h.jsxs(nc,{disabled:!i,onSelect:d,children:[h.jsx(sc,{className:"size-4"}),"Turn off"]})})]}),g==="inactive"&&h.jsx(ae,{disabled:!n,variant:r,onClick:l,children:a}),h.jsx(ae,{disabled:!o,variant:s,onClick:f,children:c})]})]})};var Nr=Object.prototype.hasOwnProperty;function Cr(e,t,n){for(n of e.keys())if(at(n,t))return n}function at(e,t){var n,o,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&at(e[o],t[o]););return o===-1}if(n===Set){if(e.size!==t.size)return!1;for(o of e)if(r=o,r&&typeof r=="object"&&(r=Cr(t,r),!r)||!t.has(r))return!1;return!0}
8if(n===Map){if(e.size!==t.size)return!1;for(o of e)if(r=o[0],r&&typeof r=="object"&&(r=Cr(t,r),!r)||!at(o[1],t.get(r)))return!1;return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((o=e.byteLength)===t.byteLength)for(;o--&&e.getInt8(o)===t.getInt8(o););return o===-1}if(ArrayBuffer.isView(e)){if((o=e.byteLength)===t.byteLength)for(;o--&&e[o]===t[o];);return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(Nr.call(e,n)&&++o&&!Nr.call(t,n)||!(n in t)||!at(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}const kr=e=>({status:e.status,actions:e.actions,edges:e.edges}),fm=e=>{switch(e){case"failed to publish":case"failed to re-publish":case"failed to save":case"failed to unpublish":return!0;case"confirming re-publish":case"confirming unpublish":case"idle":case"publishing":case"re-publishing":case"saving":case"unpublishing":return!1;default:{const t=e;throw new Error(`Unhandled edit state: ${t}`)}}},Dm=()=>{const{id:e=""}=oc(),{data:t,isLoading:n,isError:o}=kc(e,{defaultErrorHandler:!1}),r=t?.automations[0],s=Mc(),[i,a]=pe.useState("idle"),[c,l]=pe.useState(void 0);pe.useEffect(()=>{r&&l(S=>S?.id===r.id?S:r)},[r]);const f=!!c&&!!r&&!at(kr(c),kr(r)),d=S=>{l(S),a(k=>fm(k)?"idle":k)},u=S=>{if(!c)throw new Error("Cannot edit an automation that has not loaded.");let k,I;const T=c.status,R=S??T,L=`${T} -> ${R}`;switch(L){case"active -> active":k="re-publishing",I="failed to re-publish";break;case"inactive -> inactive":k="saving",I="failed to save";break;case"inactive -> active":k="publishing",I="failed to publish";break;case"active -> inactive":k="unpublishing",I="failed to unpublish";break;default:{const $=L;throw new Error(`Unhandled status transition: ${$}`)}}a(k),s.mutate({id:c.id,status:R,actions:c.actions,edges:c.edges},{onSuccess:$=>{l($.automations[0]),a("idle")},onError:()=>a(I)})};let g=!1,m=!1,y=!1,w=!!c&&c.actions.length>0&&c.status==="inactive"&&f,x="secondary",_="Save",p=!!c&&c.actions.length>0&&(c.status==="inactive"||f),v="default",N=c?.status==="active"?f?"Publish changes":"Published":"Publish",E=!0,j="Turn off",D=!0,P="default",O="Publish changes";switch(i){case"idle":break;case"saving":y=!0,w=!1,p=!1,E=!1,_=h.jsxs(h.Fragment,{children:[h.jsx(Pe,{size:"sm"}),h.jsx("span",{className:"sr-only",children:"Saving..."})]});break;case"publishing":y=!0,w=!1,p=!1,E=!1,N=h.jsxs(h.Fragment,{children:[h.jsx(Pe,{color:"light",size:"sm"}),h.jsx("span",{className:"sr-only",children:"Publishing..."})]});break;case"re-publishing":y=!0,m=!0,p=!1,E=!1,D=!1,O=h.jsxs(h.Fragment,{children:[h.jsx(Pe,{color:"light",size:"sm"}),h.jsx("span",{className:"sr-only",children:"Publishing..."})]});break;case"unpublishing":y=!0,g=!0,w=!1,p=!1,E=!1,j=h.jsxs(h.Fragment,{children:[h.jsx(Pe,{color:"light",size:"sm"}),h.jsx("span",{className:"sr-only",children:"Turning off..."})]});break;case"confirming unpublish":g=!0,w=!1,p=!1,E=!1;break;case"confirming re-publish":m=!0,p=!1,E=!1;break;case"failed to save":x="destructive",_="Retry";break;case"failed to publish":v="destructive",N="Retry";break;case"failed to re-publish":m=!0,p=!1,E=!1,P="destructive",O="Retry";break;case"failed to unpublish":g=!0,E=!0,j="Retry";break;default:{const S=i;throw new Error(`Unhandled edit state: ${S}`)}}const A=S=>{a(k=>{switch(k){case"confirming unpublish":case"failed to unpublish":return S?k:"idle";case"idle":return S?"confirming unpublish":k;default:return k}})},z=S=>{a(k=>{switch(k){case"confirming re-publish":case"failed to re-publish":return S?k:"idle";case"idle":return S?"confirming re-publish":k;default:return k}})},H=()=>{const S=c?.status;switch(S){case void 0:throw new Error("Cannot publish an automation that has not loaded.");case"active":a("confirming re-publish");break;case"inactive":u("active");break;default:{const k=S;throw new Error(`Unhandled status: ${k}`)}}};Pc(y||f);const b=rc(({currentLocation:S,nextLocation:k})=>f&&S.pathname!==k.pathname),M=S=>{!S&&b.state==="blocked"&&b.reset()};return h.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-background","data-testid":"automation-editor",children:[h.jsx(dm,{automation:c,isLoadingAutomation:n,isPublishButtonEnabled:p,isSaveButtonEnabled:w,isTurnOffButtonEnabled:E,publishButtonChildren:N,publishButtonVariant:v,saveButtonChildren:_,saveButtonVariant:x,onPublish:H,onSave:()=>u(),onTurnOff:()=>a("confirming unpublish")}),h.jsx(um,{automation:c,isError:o,isLoading:n,onChange:d}),h.jsx(It,{open:b.state==="blocked",onOpenChange:M,children:h.jsxs(At,{children:[h.jsxs(Dt,{children:[h.jsx(Pt,{children:"Discard unsaved changes?"}),h.jsx(Tt,{children:"Your changes will be lost if you leave this automation."})]}),h.jsxs(zt,{children:[h.jsx(Rt,{children:"Keep working"}),h.jsx(ae,{variant:"destructive",onClick:()=>b.proceed?.(),children:"Discard changes"})]})]})}),h.jsx(It,{open:g,onOpenChange:A,children:h.jsxs(At,{children:[h.jsxs(Dt,{children:[h.jsx(Pt,{children:"Turn off this automation?"}),h.jsx(Tt,{children:"It will stop running until you turn it back on."})]}),h.jsxs(zt,{children:[h.jsx(Rt,{disabled:y,children:"Cancel"}),h.jsx(ae,{disabled:y,variant:i==="failed to unpublish"?"destructive":"default",onClick:()=>u("inactive"),children:j})]})]})}),h.jsx(It,{open:m,onOpenChange:z,children:h.jsxs(At,{children:[h.jsxs(Dt,{children:[h.jsx(Pt,{children:"Update automation?"}),h.jsx(Tt,{children:"This will update the automation for new runs of the automation, as well as any actively-running ones."})]}),h.jsxs(zt,{children:[h.jsx(Rt,{disabled:y,children:"Cancel"}),h.jsx(ae,{disabled:!D,variant:P,onClick:()=>u(),children:O})]})]})})]})};export{Dm as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.