@dudousxd/nestjs-durable-dashboard 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +0,0 @@
1
- var kr=e=>{throw TypeError(e)};var jn=(e,t,n)=>t.has(e)||kr("Cannot "+n);var ne=(e,t,n)=>(jn(e,t,"read from private field"),n?n.call(e):t.get(e)),Be=(e,t,n)=>t.has(e)?kr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ve=(e,t,n,r)=>(jn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Oe=(e,t,n)=>(jn(e,t,"access private method"),n);import{S as $a,s as za,h as jr,g as Ia,n as As,u as sn,r as $,a as Aa,b as Pa,c as Yt,i as Ps,j as h,K as Ln,X as Ge,B as Ts,d as Ta,e as pt,R as Da,C as Ds,f as Ra,k as ue,l as Ha,m as La,o as sr,p as Fa,q as Ba,t as Va,P as Oa,v as Cn,w as Xa,Q as Ya,x as qa,y as Wa}from"./index-CeRgaeH7.js";var Ie,Ae,oe,ye,Ne,Ft,Fn,Is,Ga=(Is=class extends $a{constructor(t,n){super();Be(this,Ne);Be(this,Ie);Be(this,Ae);Be(this,oe);Be(this,ye);Ve(this,Ie,t),this.setOptions(n),this.bindMethods(),Oe(this,Ne,Ft).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=ne(this,Ie).defaultMutationOptions(t),za(this.options,n)||ne(this,Ie).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ne(this,oe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&jr(n.mutationKey)!==jr(this.options.mutationKey)?this.reset():((r=ne(this,oe))==null?void 0:r.state.status)==="pending"&&ne(this,oe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=ne(this,oe))==null||t.removeObserver(this)}onMutationUpdate(t){Oe(this,Ne,Ft).call(this),Oe(this,Ne,Fn).call(this,t)}getCurrentResult(){return ne(this,Ae)}reset(){var t;(t=ne(this,oe))==null||t.removeObserver(this),Ve(this,oe,void 0),Oe(this,Ne,Ft).call(this),Oe(this,Ne,Fn).call(this)}mutate(t,n){var r;return Ve(this,ye,n),(r=ne(this,oe))==null||r.removeObserver(this),Ve(this,oe,ne(this,Ie).getMutationCache().build(ne(this,Ie),this.options)),ne(this,oe).addObserver(this),ne(this,oe).execute(t)}},Ie=new WeakMap,Ae=new WeakMap,oe=new WeakMap,ye=new WeakMap,Ne=new WeakSet,Ft=function(){var n;const t=((n=ne(this,oe))==null?void 0:n.state)??Ia();Ve(this,Ae,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Fn=function(t){As.batch(()=>{var n,r,s,i,o,a,c,l;if(ne(this,ye)&&this.hasListeners()){const u=ne(this,Ae).variables,f=ne(this,Ae).context;(t==null?void 0:t.type)==="success"?((r=(n=ne(this,ye)).onSuccess)==null||r.call(n,t.data,u,f),(i=(s=ne(this,ye)).onSettled)==null||i.call(s,t.data,null,u,f)):(t==null?void 0:t.type)==="error"&&((a=(o=ne(this,ye)).onError)==null||a.call(o,t.error,u,f),(l=(c=ne(this,ye)).onSettled)==null||l.call(c,void 0,t.error,u,f))}this.listeners.forEach(u=>{u(ne(this,Ae))})})},Is);function lt(e,t){const n=sn(),[r]=$.useState(()=>new Ga(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const s=$.useSyncExternalStore($.useCallback(o=>r.subscribe(As.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=$.useCallback((o,a)=>{r.mutate(o,a).catch(Aa)},[r]);if(s.error&&Pa(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function Ka(e,t){if(!e)return t;const n=new Map(e.timeline.map(r=>[r.seq,r]));return{...t,timeline:t.timeline.map(r=>{var i,o;if((r.status==="pending"||r.status==="running")&&(((i=r.events)==null?void 0:i.length)??0)===0){const a=(o=n.get(r.seq))==null?void 0:o.events;if(a!=null&&a.length)return{...r,events:a}}return r})}}function qt(e){return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function Cr(e,t){return qt(new Date(t).getTime()-new Date(e).getTime())}function Mr(e){return ir(new Date(e).getTime())}function ir(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})}const Rs={ok:"border-emerald-500/25 bg-emerald-500/10 text-emerald-300",failed:"border-red-500/25 bg-red-500/10 text-red-300",skipped:"border-amber-500/25 bg-amber-500/10 text-amber-300"},Ua={debug:"text-zinc-500",info:"text-zinc-300",warn:"text-amber-300",error:"text-red-300"},Za=["ok","failed","skipped"];function Hs({e}){return h.jsxs("div",{className:"flex gap-2 py-0.5",children:[h.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:ir(e.at)}),h.jsx("span",{className:`shrink-0 uppercase ${Ua[e.level]}`,children:e.level}),h.jsx("span",{className:"min-w-0 break-words text-zinc-300",children:e.message})]})}function $r({sub:e,showGroup:t=!0}){var a,c;const n=((a=e.terminal)==null?void 0:a.message)!==void 0&&e.terminal.message!==e.name,r=e.phases.length>0||e.logs.length>0||n,[s,i]=$.useState(e.status==="failed"),o=e.status?Rs[e.status]:"border-amber-500/25 bg-amber-500/10 text-amber-300";return h.jsxs("li",{className:`rounded-md border ${o}`,children:[h.jsxs("button",{type:"button",disabled:!r,onClick:()=>i(l=>!l),className:"flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left text-[11.5px] disabled:cursor-default","aria-expanded":r?s:void 0,children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r&&h.jsx("span",{className:`text-[9px] text-zinc-500 transition-transform duration-150 ${s?"":"-rotate-90"}`,children:"▼"}),h.jsx("span",{className:"mono truncate text-zinc-200",children:e.name}),t&&e.group&&h.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-wider text-zinc-500",children:e.group})]}),h.jsxs("span",{className:"mono flex shrink-0 items-center gap-2 text-[10px] uppercase tracking-wider",children:[e.durationMs!==void 0&&h.jsx("span",{className:"tnum text-zinc-400",children:qt(e.durationMs)}),h.jsx("span",{children:e.status??"running"})]})]}),s&&h.jsxs("div",{className:"border-t border-[var(--line)]/60 px-2.5 py-2",children:[e.phases.length>0&&h.jsx("ul",{className:"mono mb-2 flex flex-col gap-0.5 text-[10.5px]",children:e.phases.map((l,u)=>h.jsxs("li",{className:"flex gap-2",children:[h.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:ir(l.at)}),h.jsx("span",{className:"text-zinc-400",children:l.phase}),e.startedAt!==void 0&&h.jsxs("span",{className:"text-zinc-600 tnum",children:["+",qt(l.at-e.startedAt)]})]},`${l.at}-${l.phase}-${u}`))}),((c=e.terminal)==null?void 0:c.message)&&e.terminal.message!==e.name&&h.jsx("div",{className:`mono mb-2 rounded border p-2 text-[11px] ${e.status==="failed"?"border-red-500/25 bg-red-500/10 text-red-200":"border-[var(--line)] bg-black/20 text-zinc-300"}`,children:e.terminal.message}),e.logs.length>0&&h.jsx("div",{className:"mono flex flex-col gap-0.5 text-[11px]",children:e.logs.map((l,u)=>h.jsx(Hs,{e:l},`${l.at}-${u}`))})]})]})}function Qa({events:e}){const{subs:t,stepLogs:n}=Ta(e),r=Za.map(i=>[i,t.filter(o=>o.status===i).length]).filter(([,i])=>i>0),s=t.some(i=>i.group);return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsxs("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["sub-processes · ",t.length]}),h.jsx("span",{className:"mono flex gap-2 text-[10px] uppercase tracking-wider",children:r.map(([i,o])=>h.jsxs("span",{className:Rs[i].split(" ").pop(),children:[o," ",i]},i))})]}),s?Object.entries(t.reduce((i,o)=>{const a=o.group??"—";return i[a]===void 0&&(i[a]=[]),i[a].push(o),i},{})).sort(([i],[o])=>i==="—"?1:o==="—"?-1:i.localeCompare(o)).map(([i,o])=>h.jsxs("div",{className:"mb-2",children:[h.jsx("div",{className:"mono mb-1 text-[10px] uppercase tracking-wider text-zinc-500",children:i}),h.jsx("ul",{className:"flex flex-col gap-1",children:o.map(a=>h.jsx($r,{sub:a,showGroup:!1},a.id))})]},i)):h.jsx("ul",{className:"flex flex-col gap-1",children:t.map(i=>h.jsx($r,{sub:i},i.id))})]}),n.length>0&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["logs · ",n.length]}),h.jsx("div",{className:"mono max-h-64 overflow-auto rounded-lg border border-[var(--line)] bg-black/40 p-2.5 text-[11px] leading-relaxed",children:n.map((i,o)=>h.jsx(Hs,{e:i},`${i.at}-${o}`))})]})]})}function Ja({value:e}){const[t,n]=$.useState(!1);return h.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:text-zinc-200",onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1200)}catch{}},children:[t?h.jsx(Ds,{width:11,height:11}):h.jsx(Ra,{width:11,height:11}),t?"copied":"copy"]})}function Wt({label:e,value:t}){const n=typeof t=="string"?t:JSON.stringify(t,null,2);return h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:e}),h.jsx(Ja,{value:n})]}),h.jsx("pre",{className:"mono max-h-64 overflow-auto rounded-lg border border-[var(--line)] bg-black/40 p-3 text-[11.5px] leading-relaxed text-zinc-300",children:n})]})}function je({k:e,v:t,mono:n=!0}){return h.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",children:[h.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-[0.16em] text-zinc-600",children:e}),h.jsx("span",{className:`truncate text-right text-[12px] text-zinc-200 ${n?"mono tnum":""}`,children:t})]})}function ec({id:e,onOpenRun:t}){const{data:n}=pt({queryKey:["run",e],queryFn:()=>ue.run(e)}),[r,s]=$.useState(new Set),i=o=>s(a=>{const c=new Set(a);return c.has(o)?c.delete(o):c.add(o),c});return n?n.timeline.length===0?h.jsxs("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:["no steps recorded yet — child ",n.run.status]}):h.jsx("div",{className:"mt-2 max-h-80 space-y-1 overflow-auto rounded-md border border-[var(--line)] bg-black/20 p-1.5",children:h.jsx(Da,{run:n.run,timeline:n.timeline,depth:0,onSelect:()=>{},onOpenRun:t??(()=>{}),expanded:r,onToggleChild:i})}):h.jsx("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:"loading child run…"})}function tc({step:e,run:t,onClose:n,onOpenRun:r}){const s=Yt(e),[i,o]=$.useState(!1),a=e.status==="failed",c=e.status==="pending"||e.status==="running",l=Ps(e.kind),u=Cr(t.createdAt,e.startedAt),f=e.enqueuedAt?new Date(e.startedAt).getTime()-new Date(e.enqueuedAt).getTime():0;return h.jsxs("aside",{className:"absolute inset-y-0 right-0 z-20 flex w-[380px] max-w-[90%] flex-col border-l border-[var(--line)] bg-[var(--panel)]/95 shadow-2xl backdrop-blur-md rise",children:[h.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`grid h-6 w-6 shrink-0 place-items-center rounded-md ${a?"bg-red-500/15 text-red-300":c?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:h.jsx(l,{width:13,height:13})}),h.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.name})]}),h.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:[e.status," · ",Ln[e.kind]??e.kind]})]}),h.jsx("button",{type:"button",onClick:n,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--line)] text-zinc-500 transition-colors hover:text-zinc-200","aria-label":"Close",children:h.jsx(Ge,{})})]}),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[h.jsxs("div",{className:"rounded-lg border border-[var(--line)] bg-black/20 px-3.5 py-1",children:[h.jsx(je,{k:"seq",v:`#${e.seq}`}),f>=1&&h.jsx(je,{k:"queued",v:h.jsx("span",{className:"text-sky-300",children:qt(f)})}),h.jsx(je,{k:"duration",v:c?h.jsx("span",{className:"text-amber-300",children:"running…"}):Cr(e.startedAt,e.finishedAt)}),h.jsx(je,{k:"attempts",v:h.jsxs("span",{className:e.attempts>1?"text-amber-300":"",children:[e.attempts>1&&h.jsx(Ts,{width:11,height:11,className:"mr-1 inline"}),e.attempts]})}),e.workerGroup&&h.jsx(je,{k:"worker",v:`@${e.workerGroup}`}),h.jsx(je,{k:"started",v:Mr(e.startedAt)}),h.jsx(je,{k:"finished",v:Mr(e.finishedAt)}),h.jsx(je,{k:"offset",v:`+${u}`})]}),a&&e.error&&h.jsxs("section",{className:"rise",children:[h.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),h.jsx("div",{className:"mono rounded-lg border border-red-500/25 bg-red-500/10 p-3 text-[11.5px] leading-relaxed text-red-200",children:e.error.message})]}),e.events&&e.events.length>0&&h.jsx(Qa,{events:e.events}),s&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:"child run"}),r&&h.jsx("button",{type:"button",onClick:()=>r(s),className:"mono rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:text-zinc-200",children:"open ↗"})]}),h.jsxs("button",{type:"button",onClick:()=>o(d=>!d),className:"flex w-full items-center gap-2 rounded-md border border-indigo-500/30 bg-indigo-500/10 px-2.5 py-1.5 text-left transition-colors hover:bg-indigo-500/20",title:i?"Collapse child run":"Expand child run inline",children:[h.jsx("span",{className:"inline-block text-[9px] text-indigo-300 transition-transform",style:{transform:i?"rotate(90deg)":"rotate(0deg)"},children:"▸"}),h.jsx("span",{className:"mono truncate text-[11px] text-indigo-300",children:s})]}),i&&h.jsx(ec,{id:s,onOpenRun:r})]}),e.input!==void 0&&h.jsx(Wt,{label:"input",value:e.input}),e.output!==void 0&&h.jsx(Wt,{label:"output",value:e.output})]})]})}function nc({run:e,onClose:t}){const n=e.input===void 0&&e.output===void 0&&!e.error;return h.jsxs("aside",{className:"absolute inset-y-0 right-0 z-30 flex w-[380px] max-w-[90%] flex-col border-l border-[var(--line)] bg-[var(--panel)]/95 shadow-2xl backdrop-blur-md rise",children:[h.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.workflow}),h.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:["run · ",e.status]})]}),h.jsx("button",{type:"button",onClick:t,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--line)] text-zinc-500 transition-colors hover:text-zinc-200","aria-label":"Close",children:h.jsx(Ge,{})})]}),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[e.error&&h.jsxs("section",{className:"rise",children:[h.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),h.jsx("div",{className:"mono rounded-lg border border-red-500/25 bg-red-500/10 p-3 text-[11.5px] leading-relaxed text-red-200",children:e.error.message})]}),e.input!==void 0&&h.jsx(Wt,{label:"input",value:e.input}),e.output!==void 0&&h.jsx(Wt,{label:"output",value:e.output}),n&&h.jsx("div",{className:"text-sm text-zinc-600",children:"No input/output recorded."})]})]})}function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var rc={value:()=>{}};function on(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Bt(n)}function Bt(e){this._=e}function sc(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Bt.prototype=on.prototype={constructor:Bt,on:function(e,t){var n=this._,r=sc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=ic(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<o;)if(s=(e=r[i]).type)n[s]=zr(n[s],e.name,t);else if(t==null)for(s in n)n[s]=zr(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Bt(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function ic(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function zr(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=rc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bn="http://www.w3.org/1999/xhtml";const Ir={svg:"http://www.w3.org/2000/svg",xhtml:Bn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function an(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ir.hasOwnProperty(t)?{space:Ir[t],local:e}:e}function oc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Bn&&t.documentElement.namespaceURI===Bn?t.createElement(e):t.createElementNS(n,e)}}function ac(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ls(e){var t=an(e);return(t.local?ac:oc)(t)}function cc(){}function or(e){return e==null?cc:function(){return this.querySelector(e)}}function lc(e){typeof e!="function"&&(e=or(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=new Array(o),c,l,u=0;u<o;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new le(r,this._parents)}function uc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function dc(){return[]}function Fs(e){return e==null?dc:function(){return this.querySelectorAll(e)}}function fc(e){return function(){return uc(e.apply(this,arguments))}}function hc(e){typeof e=="function"?e=fc(e):e=Fs(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var o=t[i],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),s.push(c));return new le(r,s)}function Bs(e){return function(){return this.matches(e)}}function Vs(e){return function(t){return t.matches(e)}}var pc=Array.prototype.find;function gc(e){return function(){return pc.call(this.children,e)}}function mc(){return this.firstElementChild}function xc(e){return this.select(e==null?mc:gc(typeof e=="function"?e:Vs(e)))}var yc=Array.prototype.filter;function wc(){return Array.from(this.children)}function vc(e){return function(){return yc.call(this.children,e)}}function bc(e){return this.selectAll(e==null?wc:vc(typeof e=="function"?e:Vs(e)))}function Nc(e){typeof e!="function"&&(e=Bs(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],c,l=0;l<o;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function Os(e){return new Array(e.length)}function _c(){return new le(this._enter||this._groups.map(Os),this._parents)}function Gt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Gt.prototype={constructor:Gt,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 Ec(e){return function(){return e}}function Sc(e,t,n,r,s,i){for(var o=0,a,c=t.length,l=i.length;o<l;++o)(a=t[o])?(a.__data__=i[o],r[o]=a):n[o]=new Gt(e,i[o]);for(;o<c;++o)(a=t[o])&&(s[o]=a)}function kc(e,t,n,r,s,i,o){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),p;for(a=0;a<u;++a)(c=t[a])&&(d[a]=p=o.call(c,c.__data__,a,t)+"",l.has(p)?s[a]=c:l.set(p,c));for(a=0;a<f;++a)p=o.call(e,i[a],a,i)+"",(c=l.get(p))?(r[a]=c,c.__data__=i[a],l.delete(p)):n[a]=new Gt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(s[a]=c)}function jc(e){return e.__data__}function Cc(e,t){if(!arguments.length)return Array.from(this,jc);var n=t?kc:Sc,r=this._parents,s=this._groups;typeof e!="function"&&(e=Ec(e));for(var i=s.length,o=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],f=s[l],d=f.length,p=Mc(e.call(u,u&&u.__data__,l,r)),g=p.length,m=a[l]=new Array(g),N=o[l]=new Array(g),y=c[l]=new Array(d);n(u,f,m,N,y,p,t);for(var E=0,v=0,w,C;E<g;++E)if(w=m[E]){for(E>=v&&(v=E+1);!(C=N[v])&&++v<g;);w._next=C||null}}return o=new le(o,r),o._enter=a,o._exit=c,o}function Mc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function $c(){return new le(this._exit||this._groups.map(Os),this._parents)}function zc(e,t,n){var r=this.enter(),s=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),r&&s?r.merge(s).order():s}function Ic(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,o=Math.min(s,i),a=new Array(s),c=0;c<o;++c)for(var l=n[c],u=r[c],f=l.length,d=a[c]=new Array(f),p,g=0;g<f;++g)(p=l[g]||u[g])&&(d[g]=p);for(;c<s;++c)a[c]=n[c];return new le(a,this._parents)}function Ac(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],o;--s>=0;)(o=r[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function Pc(e){e||(e=Tc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var o=n[i],a=o.length,c=s[i]=new Array(a),l,u=0;u<a;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new le(s,this._parents).order()}function Tc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Dc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Rc(){return Array.from(this)}function Hc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var o=r[s];if(o)return o}return null}function Lc(){let e=0;for(const t of this)++e;return e}function Fc(){return!this.node()}function Bc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,o=s.length,a;i<o;++i)(a=s[i])&&e.call(a,a.__data__,i,s);return this}function Vc(e){return function(){this.removeAttribute(e)}}function Oc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Xc(e,t){return function(){this.setAttribute(e,t)}}function Yc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function qc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Wc(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 Gc(e,t){var n=an(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Oc:Vc:typeof t=="function"?n.local?Wc:qc:n.local?Yc:Xc)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Kc(e){return function(){this.style.removeProperty(e)}}function Uc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Zc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Qc(e,t,n){return arguments.length>1?this.each((t==null?Kc:typeof t=="function"?Zc:Uc)(e,t,n??"")):Ke(this.node(),e)}function Ke(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function Jc(e){return function(){delete this[e]}}function el(e,t){return function(){this[e]=t}}function tl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function nl(e,t){return arguments.length>1?this.each((t==null?Jc:typeof t=="function"?tl:el)(e,t)):this.node()[e]}function Ys(e){return e.trim().split(/^|\s+/)}function ar(e){return e.classList||new qs(e)}function qs(e){this._node=e,this._names=Ys(e.getAttribute("class")||"")}qs.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 Ws(e,t){for(var n=ar(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function Gs(e,t){for(var n=ar(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function rl(e){return function(){Ws(this,e)}}function sl(e){return function(){Gs(this,e)}}function il(e,t){return function(){(t.apply(this,arguments)?Ws:Gs)(this,e)}}function ol(e,t){var n=Ys(e+"");if(arguments.length<2){for(var r=ar(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?il:t?rl:sl)(n,t))}function al(){this.textContent=""}function cl(e){return function(){this.textContent=e}}function ll(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ul(e){return arguments.length?this.each(e==null?al:(typeof e=="function"?ll:cl)(e)):this.node().textContent}function dl(){this.innerHTML=""}function fl(e){return function(){this.innerHTML=e}}function hl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function pl(e){return arguments.length?this.each(e==null?dl:(typeof e=="function"?hl:fl)(e)):this.node().innerHTML}function gl(){this.nextSibling&&this.parentNode.appendChild(this)}function ml(){return this.each(gl)}function xl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yl(){return this.each(xl)}function wl(e){var t=typeof e=="function"?e:Ls(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function vl(){return null}function bl(e,t){var n=typeof e=="function"?e:Ls(e),r=t==null?vl:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Nl(){var e=this.parentNode;e&&e.removeChild(this)}function _l(){return this.each(Nl)}function El(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kl(e){return this.select(e?Sl:El)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Cl(e){return function(t){e.call(this,t,this.__data__)}}function Ml(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function $l(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function zl(e,t,n){return function(){var r=this.__on,s,i=Cl(t);if(r){for(var o=0,a=r.length;o<a;++o)if((s=r[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function Il(e,t,n){var r=Ml(e+""),s,i=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(s=0,u=a[c];s<i;++s)if((o=r[s]).type===u.type&&o.name===u.name)return u.value}return}for(a=t?zl:$l,s=0;s<i;++s)this.each(a(r[s],t,n));return this}function Ks(e,t,n){var r=Xs(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Al(e,t){return function(){return Ks(this,e,t)}}function Pl(e,t){return function(){return Ks(this,e,t.apply(this,arguments))}}function Tl(e,t){return this.each((typeof t=="function"?Pl:Al)(e,t))}function*Dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,o;s<i;++s)(o=r[s])&&(yield o)}var Us=[null];function le(e,t){this._groups=e,this._parents=t}function St(){return new le([[document.documentElement]],Us)}function Rl(){return this}le.prototype=St.prototype={constructor:le,select:lc,selectAll:hc,selectChild:xc,selectChildren:bc,filter:Nc,data:Cc,enter:_c,exit:$c,join:zc,merge:Ic,selection:Rl,order:Ac,sort:Pc,call:Dc,nodes:Rc,node:Hc,size:Lc,empty:Fc,each:Bc,attr:Gc,style:Qc,property:nl,classed:ol,text:ul,html:pl,raise:ml,lower:yl,append:wl,insert:bl,remove:_l,clone:kl,datum:jl,on:Il,dispatch:Tl,[Symbol.iterator]:Dl};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Us)}function Hl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Hl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ll={passive:!1},gt={capture:!0,passive:!1};function Mn(e){e.stopImmediatePropagation()}function qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Zs(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",qe,gt);"onselectstart"in t?n.on("selectstart.drag",qe,gt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Qs(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",qe,gt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const zt=e=>()=>e;function Vn(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Vn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Fl(e){return!e.ctrlKey&&!e.button}function Bl(){return this.parentNode}function Vl(e,t){return t??{x:e.x,y:e.y}}function Ol(){return navigator.maxTouchPoints||"ontouchstart"in this}function Js(){var e=Fl,t=Bl,n=Vl,r=Ol,s={},i=on("start","drag","end"),o=0,a,c,l,u,f=0;function d(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",N).on("touchmove.drag",y,Ll).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,C){if(!(u||!e.call(this,w,C))){var R=v(this,t.call(this,w,C),w,C,"mouse");R&&(ce(w.view).on("mousemove.drag",g,gt).on("mouseup.drag",m,gt),Zs(w.view),Mn(w),l=!1,a=w.clientX,c=w.clientY,R("start",w))}}function g(w){if(qe(w),!l){var C=w.clientX-a,R=w.clientY-c;l=C*C+R*R>f}s.mouse("drag",w)}function m(w){ce(w.view).on("mousemove.drag mouseup.drag",null),Qs(w.view,l),qe(w),s.mouse("end",w)}function N(w,C){if(e.call(this,w,C)){var R=w.changedTouches,j=t.call(this,w,C),z=R.length,A,P;for(A=0;A<z;++A)(P=v(this,j,w,C,R[A].identifier,R[A]))&&(Mn(w),P("start",w,R[A]))}}function y(w){var C=w.changedTouches,R=C.length,j,z;for(j=0;j<R;++j)(z=s[C[j].identifier])&&(qe(w),z("drag",w,C[j]))}function E(w){var C=w.changedTouches,R=C.length,j,z;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),j=0;j<R;++j)(z=s[C[j].identifier])&&(Mn(w),z("end",w,C[j]))}function v(w,C,R,j,z,A){var P=i.copy(),L=de(A||R,C),T,D,x;if((x=n.call(w,new Vn("beforestart",{sourceEvent:R,target:d,identifier:z,active:o,x:L[0],y:L[1],dx:0,dy:0,dispatch:P}),j))!=null)return T=x.x-L[0]||0,D=x.y-L[1]||0,function k(_,I,b){var S=L,M;switch(_){case"start":s[z]=k,M=o++;break;case"end":delete s[z],--o;case"drag":L=de(b||I,C),M=o;break}P.call(_,w,new Vn(_,{sourceEvent:I,subject:x,target:d,identifier:z,active:M,x:L[0]+T,y:L[1]+D,dx:L[0]-S[0],dy:L[1]-S[1],dispatch:P}),j)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:zt(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:zt(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:zt(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:zt(!!w),d):r},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,d):Math.sqrt(f)},d}function cr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ei(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kt(){}var mt=.7,Kt=1/mt,We="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ge="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Xl=/^#([0-9a-f]{3,8})$/,Yl=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),ql=new RegExp(`^rgb\\(${ge},${ge},${ge}\\)$`),Wl=new RegExp(`^rgba\\(${We},${We},${We},${xt}\\)$`),Gl=new RegExp(`^rgba\\(${ge},${ge},${ge},${xt}\\)$`),Kl=new RegExp(`^hsl\\(${xt},${ge},${ge}\\)$`),Ul=new RegExp(`^hsla\\(${xt},${ge},${ge},${xt}\\)$`),Ar={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};cr(kt,yt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Pr,formatHex:Pr,formatHex8:Zl,formatHsl:Ql,formatRgb:Tr,toString:Tr});function Pr(){return this.rgb().formatHex()}function Zl(){return this.rgb().formatHex8()}function Ql(){return ti(this).formatHsl()}function Tr(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Xl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Dr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?It(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?It(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yl.exec(e))?new ae(t[1],t[2],t[3],1):(t=ql.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wl.exec(e))?It(t[1],t[2],t[3],t[4]):(t=Gl.exec(e))?It(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Kl.exec(e))?Lr(t[1],t[2]/100,t[3]/100,1):(t=Ul.exec(e))?Lr(t[1],t[2]/100,t[3]/100,t[4]):Ar.hasOwnProperty(e)?Dr(Ar[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Dr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function It(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Jl(e){return e instanceof kt||(e=yt(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function On(e,t,n,r){return arguments.length===1?Jl(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}cr(ae,On,ei(kt,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Re(this.r),Re(this.g),Re(this.b),Ut(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Rr,formatHex:Rr,formatHex8:eu,formatRgb:Hr,toString:Hr}));function Rr(){return`#${De(this.r)}${De(this.g)}${De(this.b)}`}function eu(){return`#${De(this.r)}${De(this.g)}${De(this.b)}${De((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hr(){const e=Ut(this.opacity);return`${e===1?"rgb(":"rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e===1?")":`, ${e})`}`}function Ut(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Re(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function De(e){return e=Re(e),(e<16?"0":"")+e.toString(16)}function Lr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,r)}function ti(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=yt(e)),!e)return new fe;if(e instanceof fe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,a=i-s,c=(i+s)/2;return a?(t===i?o=(n-r)/a+(n<r)*6:n===i?o=(r-t)/a+2:o=(t-n)/a+4,a/=c<.5?i+s:2-i-s,o*=60):a=c>0&&c<1?0:o,new fe(o,a,c,e.opacity)}function tu(e,t,n,r){return arguments.length===1?ti(e):new fe(e,t,n,r??1)}function fe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}cr(fe,tu,ei(kt,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new fe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new ae($n(e>=240?e-240:e+120,s,r),$n(e,s,r),$n(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new fe(Fr(this.h),At(this.s),At(this.l),Ut(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ut(this.opacity);return`${e===1?"hsl(":"hsla("}${Fr(this.h)}, ${At(this.s)*100}%, ${At(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fr(e){return e=(e||0)%360,e<0?e+360:e}function At(e){return Math.max(0,Math.min(1,e||0))}function $n(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ni=e=>()=>e;function nu(e,t){return function(n){return e+n*t}}function ru(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function su(e){return(e=+e)==1?ri:function(t,n){return n-t?ru(t,n,e):ni(isNaN(t)?n:t)}}function ri(e,t){var n=t-e;return n?nu(e,n):ni(isNaN(e)?t:e)}const Br=function e(t){var n=su(t);function r(s,i){var o=n((s=On(s)).r,(i=On(i)).r),a=n(s.g,i.g),c=n(s.b,i.b),l=ri(s.opacity,i.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=c(u),s.opacity=l(u),s+""}}return r.gamma=e,r}(1);function $e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Xn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,zn=new RegExp(Xn.source,"g");function iu(e){return function(){return e}}function ou(e){return function(t){return e(t)+""}}function au(e,t){var n=Xn.lastIndex=zn.lastIndex=0,r,s,i,o=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Xn.exec(e))&&(s=zn.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),a[o]?a[o]+=i:a[++o]=i),(r=r[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,c.push({i:o,x:$e(r,s)})),n=zn.lastIndex;return n<t.length&&(i=t.slice(n),a[o]?a[o]+=i:a[++o]=i),a.length<2?c[0]?ou(c[0].x):iu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}var Vr=180/Math.PI,Yn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function si(e,t,n,r,s,i){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*Vr,skewX:Math.atan(c)*Vr,scaleX:o,scaleY:a}}var Pt;function cu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Yn:si(t.a,t.b,t.c,t.d,t.e,t.f)}function lu(e){return e==null||(Pt||(Pt=document.createElementNS("http://www.w3.org/2000/svg","g")),Pt.setAttribute("transform",e),!(e=Pt.transform.baseVal.consolidate()))?Yn:(e=e.matrix,si(e.a,e.b,e.c,e.d,e.e,e.f))}function ii(e,t,n,r){function s(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,p,g){if(l!==f||u!==d){var m=p.push("translate(",null,t,null,n);g.push({i:m-4,x:$e(l,f)},{i:m-2,x:$e(u,d)})}else(f||d)&&p.push("translate("+f+t+d+n)}function o(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(s(f)+"rotate(",null,r)-2,x:$e(l,u)})):u&&f.push(s(f)+"rotate("+u+r)}function a(l,u,f,d){l!==u?d.push({i:f.push(s(f)+"skewX(",null,r)-2,x:$e(l,u)}):u&&f.push(s(f)+"skewX("+u+r)}function c(l,u,f,d,p,g){if(l!==f||u!==d){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:$e(l,f)},{i:m-2,x:$e(u,d)})}else(f!==1||d!==1)&&p.push(s(p)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),o(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(p){for(var g=-1,m=d.length,N;++g<m;)f[(N=d[g]).i]=N.x(p);return f.join("")}}}var uu=ii(cu,"px, ","px)","deg)"),du=ii(lu,", ",")",")"),fu=1e-12;function Or(e){return((e=Math.exp(e))+1/e)/2}function hu(e){return((e=Math.exp(e))-1/e)/2}function pu(e){return((e=Math.exp(2*e))-1)/(e+1)}const gu=function e(t,n,r){function s(i,o){var a=i[0],c=i[1],l=i[2],u=o[0],f=o[1],d=o[2],p=u-a,g=f-c,m=p*p+g*g,N,y;if(m<fu)y=Math.log(d/l)/t,N=function(j){return[a+j*p,c+j*g,l*Math.exp(t*j*y)]};else{var E=Math.sqrt(m),v=(d*d-l*l+r*m)/(2*l*n*E),w=(d*d-l*l-r*m)/(2*d*n*E),C=Math.log(Math.sqrt(v*v+1)-v),R=Math.log(Math.sqrt(w*w+1)-w);y=(R-C)/t,N=function(j){var z=j*y,A=Or(C),P=l/(n*E)*(A*pu(t*z+C)-hu(C));return[a+P*p,c+P*g,l*A/Or(t*z+C)]}}return N.duration=y*1e3*t/Math.SQRT2,N}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,c=a*a;return e(o,a,c)},s}(Math.SQRT2,2,4);var Ue=0,ut=0,at=0,oi=1e3,Zt,dt,Qt=0,Le=0,cn=0,wt=typeof performance=="object"&&performance.now?performance:Date,ai=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lr(){return Le||(ai(mu),Le=wt.now()+cn)}function mu(){Le=0}function Jt(){this._call=this._time=this._next=null}Jt.prototype=ci.prototype={constructor:Jt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?lr():+n)+(t==null?0:+t),!this._next&&dt!==this&&(dt?dt._next=this:Zt=this,dt=this),this._call=e,this._time=n,qn()},stop:function(){this._call&&(this._call=null,this._time=1/0,qn())}};function ci(e,t,n){var r=new Jt;return r.restart(e,t,n),r}function xu(){lr(),++Ue;for(var e=Zt,t;e;)(t=Le-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ue}function Xr(){Le=(Qt=wt.now())+cn,Ue=ut=0;try{xu()}finally{Ue=0,wu(),Le=0}}function yu(){var e=wt.now(),t=e-Qt;t>oi&&(cn-=t,Qt=e)}function wu(){for(var e,t=Zt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Zt=n);dt=e,qn(r)}function qn(e){if(!Ue){ut&&(ut=clearTimeout(ut));var t=e-Le;t>24?(e<1/0&&(ut=setTimeout(Xr,e-wt.now()-cn)),at&&(at=clearInterval(at))):(at||(Qt=wt.now(),at=setInterval(yu,oi)),Ue=1,ai(Xr))}}function Yr(e,t,n){var r=new Jt;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var vu=on("start","end","cancel","interrupt"),bu=[],li=0,qr=1,Wn=2,Vt=3,Wr=4,Gn=5,Ot=6;function ln(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Nu(e,n,{name:t,index:r,group:s,on:vu,tween:bu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:li})}function ur(e,t){var n=pe(e,t);if(n.state>li)throw new Error("too late; already scheduled");return n}function me(e,t){var n=pe(e,t);if(n.state>Vt)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Nu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=ci(i,0,n.time);function i(l){n.state=qr,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,f,d,p;if(n.state!==qr)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Vt)return Yr(o);p.state===Wr?(p.state=Ot,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[u]):+u<t&&(p.state=Ot,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete r[u])}if(Yr(function(){n.state===Vt&&(n.state=Wr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Wn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Wn){for(n.state=Vt,s=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=p);s.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Gn,1),f=-1,d=s.length;++f<d;)s[f].call(e,u);n.state===Gn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ot,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Xt(e,t){var n=e.__transition,r,s,i=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){i=!1;continue}s=r.state>Wn&&r.state<Gn,r.state=Ot,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}i&&delete e.__transition}}function _u(e){return this.each(function(){Xt(this,e)})}function Eu(e,t){var n,r;return function(){var s=me(this,e),i=s.tween;if(i!==n){r=n=i;for(var o=0,a=r.length;o<a;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}s.tween=r}}function Su(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=me(this,e),o=i.tween;if(o!==r){s=(r=o).slice();for(var a={name:t,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===t){s[c]=a;break}c===l&&s.push(a)}i.tween=s}}function ku(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=pe(this.node(),n).tween,s=0,i=r.length,o;s<i;++s)if((o=r[s]).name===e)return o.value;return null}return this.each((t==null?Eu:Su)(n,e,t))}function dr(e,t,n){var r=e._id;return e.each(function(){var s=me(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return pe(s,r).value[t]}}function ui(e,t){var n;return(typeof t=="number"?$e:t instanceof yt?Br:(n=yt(t))?(t=n,Br):au)(e,t)}function ju(e){return function(){this.removeAttribute(e)}}function Cu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mu(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttribute(e);return o===s?null:o===r?i:i=t(r=o,n)}}function $u(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttributeNS(e.space,e.local);return o===s?null:o===r?i:i=t(r=o,n)}}function zu(e,t,n){var r,s,i;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a)))}}function Iu(e,t,n){var r,s,i;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a)))}}function Au(e,t){var n=an(e),r=n==="transform"?du:ui;return this.attrTween(e,typeof t=="function"?(n.local?Iu:zu)(n,r,dr(this,"attr."+e,t)):t==null?(n.local?Cu:ju)(n):(n.local?$u:Mu)(n,r,t))}function Pu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Tu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Du(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Tu(e,i)),n}return s._value=t,s}function Ru(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Pu(e,i)),n}return s._value=t,s}function Hu(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 r=an(e);return this.tween(n,(r.local?Du:Ru)(r,t))}function Lu(e,t){return function(){ur(this,e).delay=+t.apply(this,arguments)}}function Fu(e,t){return t=+t,function(){ur(this,e).delay=t}}function Bu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Lu:Fu)(t,e)):pe(this.node(),t).delay}function Vu(e,t){return function(){me(this,e).duration=+t.apply(this,arguments)}}function Ou(e,t){return t=+t,function(){me(this,e).duration=t}}function Xu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Vu:Ou)(t,e)):pe(this.node(),t).duration}function Yu(e,t){if(typeof t!="function")throw new Error;return function(){me(this,e).ease=t}}function qu(e){var t=this._id;return arguments.length?this.each(Yu(t,e)):pe(this.node(),t).ease}function Wu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;me(this,e).ease=n}}function Gu(e){if(typeof e!="function")throw new Error;return this.each(Wu(this._id,e))}function Ku(e){typeof e!="function"&&(e=Bs(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],c,l=0;l<o;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new _e(r,this._parents,this._name,this._id)}function Uu(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),o=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,f=o[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(f[p]=d);for(;a<r;++a)o[a]=t[a];return new _e(o,this._parents,this._name,this._id)}function Zu(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Qu(e,t,n){var r,s,i=Zu(t)?ur:me;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function Ju(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(Qu(n,e,t))}function ed(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function td(){return this.on("end.remove",ed(this._id))}function nd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var a=r[o],c=a.length,l=i[o]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,ln(l[d],t,n,d,l,pe(u,n)));return new _e(i,this._parents,t,n)}function rd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fs(e));for(var r=this._groups,s=r.length,i=[],o=[],a=0;a<s;++a)for(var c=r[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),p,g=pe(u,n),m=0,N=d.length;m<N;++m)(p=d[m])&&ln(p,t,n,m,d,g);i.push(d),o.push(u)}return new _e(i,o,t,n)}var sd=St.prototype.constructor;function id(){return new sd(this._groups,this._parents)}function od(e,t){var n,r,s;return function(){var i=Ke(this,e),o=(this.style.removeProperty(e),Ke(this,e));return i===o?null:i===n&&o===r?s:s=t(n=i,r=o)}}function di(e){return function(){this.style.removeProperty(e)}}function ad(e,t,n){var r,s=n+"",i;return function(){var o=Ke(this,e);return o===s?null:o===r?i:i=t(r=o,n)}}function cd(e,t,n){var r,s,i;return function(){var o=Ke(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Ke(this,e))),o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a))}}function ld(e,t){var n,r,s,i="style."+t,o="end."+i,a;return function(){var c=me(this,e),l=c.on,u=c.value[i]==null?a||(a=di(t)):void 0;(l!==n||s!==u)&&(r=(n=l).copy()).on(o,s=u),c.on=r}}function ud(e,t,n){var r=(e+="")=="transform"?uu:ui;return t==null?this.styleTween(e,od(e,r)).on("end.style."+e,di(e)):typeof t=="function"?this.styleTween(e,cd(e,r,dr(this,"style."+e,t))).each(ld(this._id,e)):this.styleTween(e,ad(e,r,t),n).on("end.style."+e,null)}function dd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function fd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&dd(e,o,n)),r}return i._value=t,i}function hd(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,fd(e,t,n??""))}function pd(e){return function(){this.textContent=e}}function gd(e){return function(){var t=e(this);this.textContent=t??""}}function md(e){return this.tween("text",typeof e=="function"?gd(dr(this,"text",e)):pd(e==null?"":e+""))}function xd(e){return function(t){this.textContent=e.call(this,t)}}function yd(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&xd(s)),t}return r._value=e,r}function wd(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,yd(e))}function vd(){for(var e=this._name,t=this._id,n=fi(),r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var u=pe(c,t);ln(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new _e(r,this._parents,e,n)}function bd(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,o){var a={value:o},c={value:function(){--s===0&&i()}};n.each(function(){var l=me(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),s===0&&i()})}var Nd=0;function _e(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function fi(){return++Nd}var xe=St.prototype;_e.prototype={constructor:_e,select:nd,selectAll:rd,selectChild:xe.selectChild,selectChildren:xe.selectChildren,filter:Ku,merge:Uu,selection:id,transition:vd,call:xe.call,nodes:xe.nodes,node:xe.node,size:xe.size,empty:xe.empty,each:xe.each,on:Ju,attr:Au,attrTween:Hu,style:ud,styleTween:hd,text:md,textTween:wd,remove:td,tween:ku,delay:Bu,duration:Xu,ease:qu,easeVarying:Gu,end:bd,[Symbol.iterator]:xe[Symbol.iterator]};function _d(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ed={time:null,delay:0,duration:250,ease:_d};function Sd(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 kd(e){var t,n;e instanceof _e?(t=e._id,e=e._name):(t=fi(),(n=Ed).time=lr(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,c,l=0;l<a;++l)(c=o[l])&&ln(c,e,t,l,o,n||Sd(c,t));return new _e(r,this._parents,e,t)}St.prototype.interrupt=_u;St.prototype.transition=kd;const Tt=e=>()=>e;function jd(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function we(e,t,n){this.k=e,this.x=t,this.y=n}we.prototype={constructor:we,scale:function(e){return e===1?this:new we(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new we(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 un=new we(1,0,0);hi.prototype=we.prototype;function hi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return un;return e.__zoom}function In(e){e.stopImmediatePropagation()}function ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Cd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Md(){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 Gr(){return this.__zoom||un}function $d(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Id(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function pi(){var e=Cd,t=Md,n=Id,r=$d,s=zd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=gu,l=on("start","zoom","end"),u,f,d,p=500,g=150,m=0,N=10;function y(x){x.property("__zoom",Gr).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(x,k,_,I){var b=x.selection?x.selection():x;b.property("__zoom",Gr),x!==b?C(x,k,_,I):b.interrupt().each(function(){R(this,arguments).event(I).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},y.scaleBy=function(x,k,_,I){y.scaleTo(x,function(){var b=this.__zoom.k,S=typeof k=="function"?k.apply(this,arguments):k;return b*S},_,I)},y.scaleTo=function(x,k,_,I){y.transform(x,function(){var b=t.apply(this,arguments),S=this.__zoom,M=_==null?w(b):typeof _=="function"?_.apply(this,arguments):_,H=S.invert(M),F=typeof k=="function"?k.apply(this,arguments):k;return n(v(E(S,F),M,H),b,o)},_,I)},y.translateBy=function(x,k,_,I){y.transform(x,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),o)},null,I)},y.translateTo=function(x,k,_,I,b){y.transform(x,function(){var S=t.apply(this,arguments),M=this.__zoom,H=I==null?w(S):typeof I=="function"?I.apply(this,arguments):I;return n(un.translate(H[0],H[1]).scale(M.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof _=="function"?-_.apply(this,arguments):-_),S,o)},I,b)};function E(x,k){return k=Math.max(i[0],Math.min(i[1],k)),k===x.k?x:new we(k,x.x,x.y)}function v(x,k,_){var I=k[0]-_[0]*x.k,b=k[1]-_[1]*x.k;return I===x.x&&b===x.y?x:new we(x.k,I,b)}function w(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function C(x,k,_,I){x.on("start.zoom",function(){R(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(I).end()}).tween("zoom",function(){var b=this,S=arguments,M=R(b,S).event(I),H=t.apply(b,S),F=_==null?w(H):typeof _=="function"?_.apply(b,S):_,Y=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),V=b.__zoom,O=typeof k=="function"?k.apply(b,S):k,X=c(V.invert(F).concat(Y/V.k),O.invert(F).concat(Y/O.k));return function(G){if(G===1)G=O;else{var B=X(G),W=Y/B[2];G=new we(W,F[0]-B[0]*W,F[1]-B[1]*W)}M.zoom(null,G)}})}function R(x,k,_){return!_&&x.__zooming||new j(x,k)}function j(x,k){this.that=x,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,k),this.taps=0}j.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,k){return this.mouse&&x!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var k=ce(this.that).datum();l.call(x,this.that,new jd(x,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),k)}};function z(x,...k){if(!e.apply(this,arguments))return;var _=R(this,k).event(x),I=this.__zoom,b=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,r.apply(this,arguments)))),S=de(x);if(_.wheel)(_.mouse[0][0]!==S[0]||_.mouse[0][1]!==S[1])&&(_.mouse[1]=I.invert(_.mouse[0]=S)),clearTimeout(_.wheel);else{if(I.k===b)return;_.mouse=[S,I.invert(S)],Xt(this),_.start()}ct(x),_.wheel=setTimeout(M,g),_.zoom("mouse",n(v(E(I,b),_.mouse[0],_.mouse[1]),_.extent,o));function M(){_.wheel=null,_.end()}}function A(x,...k){if(d||!e.apply(this,arguments))return;var _=x.currentTarget,I=R(this,k,!0).event(x),b=ce(x.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",Y,!0),S=de(x,_),M=x.clientX,H=x.clientY;Zs(x.view),In(x),I.mouse=[S,this.__zoom.invert(S)],Xt(this),I.start();function F(V){if(ct(V),!I.moved){var O=V.clientX-M,X=V.clientY-H;I.moved=O*O+X*X>m}I.event(V).zoom("mouse",n(v(I.that.__zoom,I.mouse[0]=de(V,_),I.mouse[1]),I.extent,o))}function Y(V){b.on("mousemove.zoom mouseup.zoom",null),Qs(V.view,I.moved),ct(V),I.event(V).end()}}function P(x,...k){if(e.apply(this,arguments)){var _=this.__zoom,I=de(x.changedTouches?x.changedTouches[0]:x,this),b=_.invert(I),S=_.k*(x.shiftKey?.5:2),M=n(v(E(_,S),I,b),t.apply(this,k),o);ct(x),a>0?ce(this).transition().duration(a).call(C,M,I,x):ce(this).call(y.transform,M,I,x)}}function L(x,...k){if(e.apply(this,arguments)){var _=x.touches,I=_.length,b=R(this,k,x.changedTouches.length===I).event(x),S,M,H,F;for(In(x),M=0;M<I;++M)H=_[M],F=de(H,this),F=[F,this.__zoom.invert(F),H.identifier],b.touch0?!b.touch1&&b.touch0[2]!==F[2]&&(b.touch1=F,b.taps=0):(b.touch0=F,S=!0,b.taps=1+!!u);u&&(u=clearTimeout(u)),S&&(b.taps<2&&(f=F[0],u=setTimeout(function(){u=null},p)),Xt(this),b.start())}}function T(x,...k){if(this.__zooming){var _=R(this,k).event(x),I=x.changedTouches,b=I.length,S,M,H,F;for(ct(x),S=0;S<b;++S)M=I[S],H=de(M,this),_.touch0&&_.touch0[2]===M.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===M.identifier&&(_.touch1[0]=H);if(M=_.that.__zoom,_.touch1){var Y=_.touch0[0],V=_.touch0[1],O=_.touch1[0],X=_.touch1[1],G=(G=O[0]-Y[0])*G+(G=O[1]-Y[1])*G,B=(B=X[0]-V[0])*B+(B=X[1]-V[1])*B;M=E(M,Math.sqrt(G/B)),H=[(Y[0]+O[0])/2,(Y[1]+O[1])/2],F=[(V[0]+X[0])/2,(V[1]+X[1])/2]}else if(_.touch0)H=_.touch0[0],F=_.touch0[1];else return;_.zoom("touch",n(v(M,H,F),_.extent,o))}}function D(x,...k){if(this.__zooming){var _=R(this,k).event(x),I=x.changedTouches,b=I.length,S,M;for(In(x),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),S=0;S<b;++S)M=I[S],_.touch0&&_.touch0[2]===M.identifier?delete _.touch0:_.touch1&&_.touch1[2]===M.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(M=de(M,this),Math.hypot(f[0]-M[0],f[1]-M[1])<N)){var H=ce(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(x){return arguments.length?(r=typeof x=="function"?x:Tt(+x),y):r},y.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Tt(!!x),y):e},y.touchable=function(x){return arguments.length?(s=typeof x=="function"?x:Tt(!!x),y):s},y.extent=function(x){return arguments.length?(t=typeof x=="function"?x:Tt([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),y):t},y.scaleExtent=function(x){return arguments.length?(i[0]=+x[0],i[1]=+x[1],y):[i[0],i[1]]},y.translateExtent=function(x){return arguments.length?(o[0][0]=+x[0][0],o[1][0]=+x[1][0],o[0][1]=+x[0][1],o[1][1]=+x[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},y.constrain=function(x){return arguments.length?(n=x,y):n},y.duration=function(x){return arguments.length?(a=+x,y):a},y.interpolate=function(x){return arguments.length?(c=x,y):c},y.on=function(){var x=l.on.apply(l,arguments);return x===l?y:x},y.clickDistance=function(x){return arguments.length?(m=(x=+x)*x,y):Math.sqrt(m)},y.tapDistance=function(x){return arguments.length?(N=+x,y):N},y}const Ee={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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", 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=>`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.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],gi=["Enter"," ","Escape"];var Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var He;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(He||(He={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const mi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var ze;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ze||(ze={}));var en;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(en||(en={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Kr={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function xi(e){return e===null?null:e?"valid":"invalid"}const yi=e=>"id"in e&&"source"in e&&"target"in e,Ad=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),fr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),jt=(e,t=[0,0])=>{const{width:n,height:r}=Se(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},Pd=(e,t={nodeOrigin:[0,0],nodeLookup:void 0})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let o=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(o=i?t.nodeLookup.get(s):fr(s)?s:t.nodeLookup.get(s.id));const a=o?tn(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return dn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fn(n)},Ct=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(r=>{if(t.filter===void 0||t.filter(r)){const s=tn(r);n=dn(n,s)}}),fn(n)},wi=(e,t,[n,r,s]=[0,0,1],i=!1,o=!1)=>{const a={...Mt(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const l of e.values()){const{measured:u,selectable:f=!0,hidden:d=!1}=l;if(o&&!f||d)continue;const p=u.width??l.width??l.initialWidth??null,g=u.height??l.height??l.initialHeight??null,m=Nt(a,Je(l)),N=(p??0)*(g??0),y=i&&m>0;(!l.internals.handleBounds||y||m>=N||l.dragging)&&c.push(l)}return c},Td=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Kn(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Un({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},o){if(e.size===0)return Promise.resolve(!1);const a=Ct(e),c=hr(a,t,n,(o==null?void 0:o.minZoom)??s,(o==null?void 0:o.maxZoom)??i,(o==null?void 0:o.padding)??.1);return await r.setViewport(c,{duration:o==null?void 0:o.duration}),Promise.resolve(!0)}function vi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const o=n.get(e),a=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=o.origin??r;let f=s;if(o.extent==="parent"&&!o.expandParent)if(!a)i==null||i("005",Ee.error005());else{const p=a.measured.width,g=a.measured.height;p&&g&&(f=[[c,l],[c+p,l+g]])}else a&&et(o.extent)&&(f=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);const d=et(f)?Fe(t,f,o.measured):t;return{position:{x:d.x-c+o.measured.width*u[0],y:d.y-l+o.measured.height*u[1]},positionAbsolute:d}}async function Dd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(d=>d.id)),o=[];for(const d of n){if(d.deletable===!1)continue;const p=i.has(d.id),g=!p&&d.parentId&&o.find(m=>m.id===d.parentId);(p||g)&&o.push(d)}const a=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),u=Td(o,c);for(const d of c)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!s)return{edges:u,nodes:o};const f=await s({nodes:o,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:o}:{edges:[],nodes:[]}:f}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Fe=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function bi(e,t,n){const{width:r,height:s}=Se(n),{x:i,y:o}=n.internals.positionAbsolute;return Fe(e,[[i,o],[i+r,o+s]],t)}const Ur=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Ni=(e,t,n=15,r=40)=>{const s=Ur(e.x,r,t.width-r)*n,i=Ur(e.y,r,t.height-r)*n;return[s,i]},dn=(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)}),Zn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),fn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Je=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:jt(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},tn=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:jt(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},_i=(e,t)=>fn(dn(Zn(e),Zn(t))),Nt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Zr=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),Rd=(e,t)=>{},hn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Mt=({x:e,y:t},[n,r,s],i=!1,o=[1,1])=>{const a={x:(e-n)/s,y:(t-r)/s};return i?hn(a,o):a},Ei=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),hr=(e,t,n,r,s,i)=>{const o=t/(e.width*(1+i)),a=n/(e.height*(1+i)),c=Math.min(o,a),l=Qe(c,r,s),u=e.x+e.width/2,f=e.y+e.height/2,d=t/2-u*l,p=n/2-f*l;return{x:d,y:p,zoom:l}},nn=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!==void 0&&e!=="parent"}function Se(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Si(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ki(e,t={width:0,height:0},n,r,s){const i={...e},o=r.get(n);if(o){const a=o.origin||s;i.x+=o.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=o.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ft(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:o}=ve(e),a=Mt({x:i-((s==null?void 0:s.left)??0),y:o-((s==null?void 0:s.top)??0)},r),{x:c,y:l}=n?hn(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const pn=e=>({width:e.offsetWidth,height:e.offsetHeight}),ji=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Hd=["INPUT","SELECT","TEXTAREA"];function Qn(e){var r,s,i;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return Hd.includes(t==null?void 0:t.nodeName)||((i=t==null?void 0:t.hasAttribute)==null?void 0:i.call(t,"contenteditable"))||!!(t!=null&&t.closest(".nokey"))}const Ci=e=>"clientX"in e,ve=(e,t)=>{var i,o;const n=Ci(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Qr=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(o=>{const a=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:e,nodeId:s,position:o.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...pn(o)}})};function Mi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:o,targetControlY:a}){const c=e*.125+s*.375+o*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jr({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case q.Left:return[t-Dt(t-r,i),n];case q.Right:return[t+Dt(r-t,i),n];case q.Top:return[t,n-Dt(n-s,i)];case q.Bottom:return[t,n+Dt(s-n,i)]}}function $i({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:s,targetPosition:i=q.Top,curvature:o=.25}){const[a,c]=Jr({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[l,u]=Jr({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[f,d,p,g]=Mi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${r},${s}`,f,d,p,g]}function zi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,o=Math.abs(r-t)/2,a=r<t?r+o:r-o;return[i,a,s,o]}function Ld({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1}){if(!s)return r;const i=n||t.selected||e.selected,o=Math.max(e.internals.z||0,t.internals.z||0,1e3);return r+(i?o:0)}function Fd({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=dn(tn(e),tn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const o={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Nt(o,fn(i))>0}const Bd=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Vd=(e,t)=>t.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)),Od=(e,t)=>{if(!e.source||!e.target)return t;let n;return yi(e)?n={...e}:n={...e,id:Bd(e)},Vd(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function Ii({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,o,a]=zi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const es={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},Xd=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.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},ts=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Yd({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:s,offset:i}){const o=es[t],a=es[r],c={x:e.x+o.x*i,y:e.y+o.y*i},l={x:n.x+a.x*i,y:n.y+a.y*i},u=Xd({source:c,sourcePosition:t,target:l}),f=u.x!==0?"x":"y",d=u[f];let p=[],g,m;const N={x:0,y:0},y={x:0,y:0},[E,v,w,C]=zi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[f]*a[f]===-1){g=s.x??E,m=s.y??v;const j=[{x:g,y:c.y},{x:g,y:l.y}],z=[{x:c.x,y:m},{x:l.x,y:m}];o[f]===d?p=f==="x"?j:z:p=f==="x"?z:j}else{const j=[{x:c.x,y:l.y}],z=[{x:l.x,y:c.y}];if(f==="x"?p=o.x===d?z:j:p=o.y===d?j:z,t===r){const D=Math.abs(e[f]-n[f]);if(D<=i){const x=Math.min(i-1,i-D);o[f]===d?N[f]=(c[f]>e[f]?-1:1)*x:y[f]=(l[f]>n[f]?-1:1)*x}}if(t!==r){const D=f==="x"?"y":"x",x=o[f]===a[D],k=c[D]>l[D],_=c[D]<l[D];(o[f]===1&&(!x&&k||x&&_)||o[f]!==1&&(!x&&_||x&&k))&&(p=f==="x"?j:z)}const A={x:c.x+N.x,y:c.y+N.y},P={x:l.x+y.x,y:l.y+y.y},L=Math.max(Math.abs(A.x-p[0].x),Math.abs(P.x-p[0].x)),T=Math.max(Math.abs(A.y-p[0].y),Math.abs(P.y-p[0].y));L>=T?(g=(A.x+P.x)/2,m=p[0].y):(g=p[0].x,m=(A.y+P.y)/2)}return[[e,{x:c.x+N.x,y:c.y+N.y},...p,{x:l.x+y.x,y:l.y+y.y},n],g,m,w,C]}function qd(e,t,n,r){const s=Math.min(ts(e,t)/2,ts(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+s*l},${o}Q ${i},${o} ${i},${o+s*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${o+s*c}Q ${i},${o} ${i+s*a},${o}`}function Jn({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:s,targetPosition:i=q.Top,borderRadius:o=5,centerX:a,centerY:c,offset:l=20}){const[u,f,d,p,g]=Yd({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:c},offset:l});return[u.reduce((N,y,E)=>{let v="";return E>0&&E<u.length-1?v=qd(u[E-1],y,u[E+1],o):v=`${E===0?"M":"L"}${y.x} ${y.y}`,N+=v,N},""),f,d,p,g]}function ns(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Wd(e){var f;const{sourceNode:t,targetNode:n}=e;if(!ns(t)||!ns(n))return null;const r=t.internals.handleBounds||rs(t.handles),s=n.internals.handleBounds||rs(n.handles),i=ss((r==null?void 0:r.source)??[],e.sourceHandle),o=ss(e.connectionMode===Ze.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!o)return(f=e.onError)==null||f.call(e,"008",Ee.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||q.Bottom,c=(o==null?void 0:o.position)||q.Top,l=_t(t,i,a),u=_t(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function rs(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function _t(e,t,n=q.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??Se(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case q.Top:return{x:s+o/2,y:i};case q.Right:return{x:s+o,y:i+a/2};case q.Bottom:return{x:s+o/2,y:i+a};case q.Left:return{x:s,y:i+a/2}}}function ss(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function er(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Gd(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((o,a)=>([a.markerStart||r,a.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const l=er(c,t);i.has(l)||(o.push({id:l,color:c.color||n,...c}),i.add(l))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))}const pr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,defaults:{}},Kd={...pr,checkEquality:!0};function gr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Ud(e,t,n){const r=gr(pr,n);for(const s of e.values())if(s.parentId)mr(s,e,t,r);else{const i=jt(s,r.nodeOrigin),o=et(s.extent)?s.extent:r.nodeExtent,a=Fe(i,o,Se(s));s.internals.positionAbsolute=a}}function tr(e,t,n,r){var a,c;const s=gr(Kd,r),i=new Map(t),o=s!=null&&s.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const l of e){let u=i.get(l.id);if(s.checkEquality&&l===(u==null?void 0:u.internals.userNode))t.set(l.id,u);else{const f=jt(l,s.nodeOrigin),d=et(l.extent)?l.extent:s.nodeExtent,p=Fe(f,d,Se(l));u={...s.defaults,...l,measured:{width:(a=l.measured)==null?void 0:a.width,height:(c=l.measured)==null?void 0:c.height},internals:{positionAbsolute:p,handleBounds:l.measured?u==null?void 0:u.internals.handleBounds:void 0,z:Ai(l,o),userNode:l}},t.set(l.id,u)}l.parentId&&mr(u,t,n,r)}}function Zd(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 mr(e,t,n,r){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:o}=gr(pr,r),a=e.parentId,c=t.get(a);if(!c){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Zd(e,n);const l=s?1e3:0,{x:u,y:f,z:d}=Qd(e,c,i,o,l),{positionAbsolute:p}=e.internals,g=u!==p.x||f!==p.y;(g||d!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:g?{x:u,y:f}:p,z:d})}function Ai(e,t){return(he(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Qd(e,t,n,r,s){const{x:i,y:o}=t.internals.positionAbsolute,a=Se(e),c=jt(e,n),l=et(e.extent)?Fe(c,e.extent,a):c;let u=Fe({x:i+l.x,y:o+l.y},r,a);e.extent==="parent"&&(u=bi(u,a,t));const f=Ai(e,s),d=t.internals.z??0;return{x:u.x,y:u.y,z:d>f?d:f}}function xr(e,t,n,r=[0,0]){var o;const s=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((o=i.get(a.parentId))==null?void 0:o.expandedRect)??Je(c),u=_i(l,a.rect);i.set(a.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var v;const u=c.internals.positionAbsolute,f=Se(c),d=c.origin??r,p=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,g=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,m=Math.max(f.width,Math.round(a.width)),N=Math.max(f.height,Math.round(a.height)),y=(m-f.width)*d[0],E=(N-f.height)*d[1];(p>0||g>0||y||E)&&(s.push({id:l,type:"position",position:{x:c.position.x-p+y,y:c.position.y-g+E}}),(v=n.get(l))==null||v.forEach(w=>{e.some(C=>C.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+g}})})),(f.width<a.width||f.height<a.height||p||g)&&s.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(p?d[0]*p-y:0),height:N+(g?d[1]*g-E:0)}})}),s}function Jd(e,t,n,r,s,i){const o=r==null?void 0:r.querySelector(".xyflow__viewport");let a=!1;if(!o)return{changes:[],updatedInternals:a};const c=[],l=window.getComputedStyle(o),{m22:u}=new window.DOMMatrixReadOnly(l.transform),f=[];for(const d of e.values()){const p=t.get(d.id);if(p)if(p.hidden)p.internals={...p.internals,handleBounds:void 0},a=!0;else{const g=pn(d.nodeElement),m=p.measured.width!==g.width||p.measured.height!==g.height;if(!!(g.width&&g.height&&(m||!p.internals.handleBounds||d.force))){const y=d.nodeElement.getBoundingClientRect(),E=et(p.extent)?p.extent:i;let{positionAbsolute:v}=p.internals;p.parentId&&p.extent==="parent"?v=bi(v,g,t.get(p.parentId)):E&&(v=Fe(v,E,g)),p.measured=g,p.internals={...p.internals,positionAbsolute:v,handleBounds:{source:Qr("source",d.nodeElement,y,u,p.id),target:Qr("target",d.nodeElement,y,u,p.id)}},p.parentId&&mr(p,t,n,{nodeOrigin:s}),a=!0,m&&(c.push({id:p.id,type:"dimensions",dimensions:g}),p.expandParent&&p.parentId&&f.push({id:p.id,parentId:p.parentId,rect:Je(p,s)}))}}}if(f.length>0){const d=xr(f,t,n,s);c.push(...d)}return{changes:c,updatedInternals:a}}async function ef({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r),a=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(a)}function Pi(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:o=null,targetHandle:a=null}=r,c=`${s}-source-${o}`,l=`${i}-target-${a}`,u=e.get(c)||new Map,f=e.get(l)||new Map,d={edgeId:r.id,source:s,target:i,sourceHandle:o,targetHandle:a};t.set(r.id,r),e.set(c,u.set(`${i}-${a}`,d)),e.set(l,f.set(`${s}-${o}`,d))}}function Ti(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ti(n,t):!1}function is(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n)return!1;r=r.parentElement}while(r);return!1}function tf(e,t,n,r){const s=new Map;for(const[i,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Ti(o,e))&&(o.draggable||t&&typeof o.draggable>"u")){const a=e.get(i);a&&s.set(i,{id:i,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 s}function An({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var o,a,c;const s=[];for(const[l,u]of t){const f=(o=n.get(l))==null?void 0:o.internals.userNode;f&&s.push({...f,position:u.position,dragging:r})}if(!e)return[s[0],s];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function nf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},o=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,p=!1;function g({noDragClassName:N,handleSelector:y,domNode:E,isSelectable:v,nodeId:w,nodeClickDistance:C=0}){d=ce(E);function R({x:P,y:L},T){const{nodeLookup:D,nodeExtent:x,snapGrid:k,snapToGrid:_,nodeOrigin:I,onNodeDrag:b,onSelectionDrag:S,onError:M,updateNodePositions:H}=t();i={x:P,y:L};let F=!1,Y={x:0,y:0,x2:0,y2:0};if(a.size>1&&x){const V=Ct(a);Y=Zn(V)}for(const[V,O]of a){if(!D.has(V))continue;let X={x:P-O.distance.x,y:L-O.distance.y};_&&(X=hn(X,k));let G=[[x[0][0],x[0][1]],[x[1][0],x[1][1]]];if(a.size>1&&x&&!O.extent){const{positionAbsolute:Z}=O.internals,U=Z.x-Y.x+x[0][0],K=Z.x+O.measured.width-Y.x2+x[1][0],J=Z.y-Y.y+x[0][1],ee=Z.y+O.measured.height-Y.y2+x[1][1];G=[[U,J],[K,ee]]}const{position:B,positionAbsolute:W}=vi({nodeId:V,nextPosition:X,nodeLookup:D,nodeExtent:G,nodeOrigin:I,onError:M});F=F||O.position.x!==B.x||O.position.y!==B.y,O.position=B,O.internals.positionAbsolute=W}if(F&&(H(a,!0),T&&(r||b||!w&&S))){const[V,O]=An({nodeId:w,dragItems:a,nodeLookup:D});r==null||r(T,a,V,O),b==null||b(T,V,O),w||S==null||S(T,O)}}async function j(){if(!u)return;const{transform:P,panBy:L,autoPanSpeed:T}=t(),[D,x]=Ni(l,u,T);(D!==0||x!==0)&&(i.x=(i.x??0)-D/P[2],i.y=(i.y??0)-x/P[2],await L({x:D,y:x})&&R(i,null)),o=requestAnimationFrame(j)}function z(P){var F;const{nodeLookup:L,multiSelectionActive:T,nodesDraggable:D,transform:x,snapGrid:k,snapToGrid:_,selectNodesOnDrag:I,onNodeDragStart:b,onSelectionDragStart:S,unselectNodesAndEdges:M}=t();f=!0,(!I||!v)&&!T&&w&&((F=L.get(w))!=null&&F.selected||M()),v&&I&&w&&(e==null||e(w));const H=ft(P.sourceEvent,{transform:x,snapGrid:k,snapToGrid:_,containerBounds:u});if(i=H,a=tf(L,D,H,w),a.size>0&&(n||b||!w&&S)){const[Y,V]=An({nodeId:w,dragItems:a,nodeLookup:L});n==null||n(P.sourceEvent,a,Y,V),b==null||b(P.sourceEvent,Y,V),w||S==null||S(P.sourceEvent,V)}}const A=Js().clickDistance(C).on("start",P=>{const{domNode:L,nodeDragThreshold:T,transform:D,snapGrid:x,snapToGrid:k}=t();u=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,T===0&&z(P),i=ft(P.sourceEvent,{transform:D,snapGrid:x,snapToGrid:k,containerBounds:u}),l=ve(P.sourceEvent,u)}).on("drag",P=>{const{autoPanOnNodeDrag:L,transform:T,snapGrid:D,snapToGrid:x,nodeDragThreshold:k,nodeLookup:_}=t(),I=ft(P.sourceEvent,{transform:T,snapGrid:D,snapToGrid:x,containerBounds:u});if((P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||w&&!_.has(w))&&(p=!0),!p){if(!c&&L&&f&&(c=!0,j()),!f){const b=I.xSnapped-(i.x??0),S=I.ySnapped-(i.y??0);Math.sqrt(b*b+S*S)>k&&z(P)}(i.x!==I.xSnapped||i.y!==I.ySnapped)&&a&&f&&(l=ve(P.sourceEvent,u),R(I,P.sourceEvent))}}).on("end",P=>{if(!(!f||p)&&(c=!1,f=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:L,updateNodePositions:T,onNodeDragStop:D,onSelectionDragStop:x}=t();if(T(a,!1),s||D||!w&&x){const[k,_]=An({nodeId:w,dragItems:a,nodeLookup:L,dragging:!1});s==null||s(P.sourceEvent,a,k,_),D==null||D(P.sourceEvent,k,_),w||x==null||x(P.sourceEvent,_)}}}).filter(P=>{const L=P.target;return!P.button&&(!N||!is(L,`.${N}`,E))&&(!y||is(L,y,E))});d.call(A)}function m(){d==null||d.on(".drag",null)}return{update:g,destroy:m}}function rf(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Nt(s,Je(i))>0&&r.push(i);return r}const sf=250;function of(e,t,n,r){var a,c;let s=[],i=1/0;const o=rf(e,n,t+sf);for(const l of o){const u=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:d,y:p}=_t(l,f,f.position,!0),g=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(p-e.y,2));g>t||(g<i?(s=[{...f,x:d,y:p}],i=g):g===i&&s.push({...f,x:d,y:p}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(u=>u.type===l)??s[0]}return s[0]}function Di(e,t,n,r,s,i=!1){var l,u,f;const o=r.get(e);if(!o)return null;const a=s==="strict"?(l=o.internals.handleBounds)==null?void 0:l[t]:[...((u=o.internals.handleBounds)==null?void 0:u.source)??[],...((f=o.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,..._t(o,c,c.position,!0)}:c}function Ri(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function af(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hi=()=>!0;function cf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:o,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:p,onConnectStart:g,onConnect:m,onConnectEnd:N,isValidConnection:y=Hi,onReconnectEnd:E,updateConnection:v,getTransform:w,getFromHandle:C,autoPanSpeed:R}){const j=ji(e.target);let z=0,A;const{x:P,y:L}=ve(e),T=j==null?void 0:j.elementFromPoint(P,L),D=Ri(i,T),x=a==null?void 0:a.getBoundingClientRect();if(!x||!D)return;const k=Di(s,D,r,c,t);if(!k)return;let _=ve(e,x),I=!1,b=null,S=!1,M=null;function H(){if(!u||!x)return;const[W,Z]=Ni(_,x,R);d({x:W,y:Z}),z=requestAnimationFrame(H)}const F={...k,nodeId:s,type:D,position:k.position},Y=c.get(s),O={inProgress:!0,isValid:null,from:_t(Y,F,q.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:Y,to:_,toHandle:null,toPosition:Kr[F.position],toNode:null};v(O);let X=O;g==null||g(e,{nodeId:s,handleId:r,handleType:D});function G(W){if(!C()||!F){B(W);return}const Z=w();_=ve(W,x),A=of(Mt(_,Z,!1,[1,1]),n,c,F),I||(H(),I=!0);const U=Li(W,{handle:A,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:j,lib:l,flowId:f,nodeLookup:c});M=U.handleDomNode,b=U.connection,S=af(!!A,U.isValid);const K={...X,isValid:S,to:A&&S?Ei({x:A.x,y:A.y},Z):_,toHandle:U.toHandle,toPosition:S&&U.toHandle?U.toHandle.position:Kr[F.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null};S&&A&&X.toHandle&&K.toHandle&&X.toHandle.type===K.toHandle.type&&X.toHandle.nodeId===K.toHandle.nodeId&&X.toHandle.id===K.toHandle.id&&X.to.x===K.to.x&&X.to.y===K.to.y||(v(K),X=K)}function B(W){(A||M)&&b&&S&&(m==null||m(b));const{inProgress:Z,...U}=X,K={...U,toPosition:X.toHandle?X.toPosition:null};N==null||N(W,K),i&&(E==null||E(W,K)),p(),cancelAnimationFrame(z),I=!1,S=!1,b=null,M=null,j.removeEventListener("mousemove",G),j.removeEventListener("mouseup",B),j.removeEventListener("touchmove",G),j.removeEventListener("touchend",B)}j.addEventListener("mousemove",G),j.addEventListener("mouseup",B),j.addEventListener("touchmove",G),j.addEventListener("touchend",B)}function Li(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:o,lib:a,flowId:c,isValidConnection:l=Hi,nodeLookup:u}){const f=i==="target",d=t?o.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:g}=ve(e),m=o.elementFromPoint(p,g),N=m!=null&&m.classList.contains(`${a}-flow__handle`)?m:d,y={handleDomNode:N,isValid:!1,connection:null,toHandle:null};if(N){const E=Ri(void 0,N),v=N.getAttribute("data-nodeid"),w=N.getAttribute("data-handleid"),C=N.classList.contains("connectable"),R=N.classList.contains("connectableend");if(!v||!E)return y;const j={source:f?v:r,sourceHandle:f?w:s,target:f?r:v,targetHandle:f?s:w};y.connection=j;const A=C&&R&&(n===Ze.Strict?f&&E==="source"||!f&&E==="target":v!==r||w!==s);y.isValid=A&&l(j),y.toHandle=Di(v,E,w,u,n,!1)}return y}const nr={onPointerDown:cf,isValid:Li};function lf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=10,pannable:f=!0,zoomable:d=!0,inversePan:p=!1}){const g=v=>{const w=n();if(v.sourceEvent.type!=="wheel"||!t)return;const C=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*u,R=w[2]*Math.pow(2,C);t.scaleTo(R)};let m=[0,0];const N=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(m=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},y=v=>{const w=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;const C=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],R=[C[0]-m[0],C[1]-m[1]];m=C;const j=r()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),z={x:w[0]-R[0]*j,y:w[1]-R[1]*j},A=[[0,0],[c,l]];t.setViewportConstrained({x:z.x,y:z.y,zoom:w[2]},A,a)},E=pi().on("start",N).on("zoom",f?y:null).on("zoom.wheel",d?g:null);s.call(E,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:de}}const uf=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,gn=e=>({x:e.x,y:e.y,zoom:e.k}),Pn=({x:e,y:t,zoom:n})=>un.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Fi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Tn=(e,t=0,n=()=>{})=>{const r=typeof t=="number"&&t>0;return r||n(),r?e.transition().duration(t).on("end",n):e},Bi=e=>{const t=e.ctrlKey&&nn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function df({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Xe(u,t))return!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&o){const N=de(u),y=Bi(u),E=f*Math.pow(2,y);r.scaleTo(n,E,N,u);return}const d=u.deltaMode===1?20:1;let p=s===He.Vertical?0:u.deltaX*d,g=s===He.Horizontal?0:u.deltaY*d;!nn()&&u.shiftKey&&s!==He.Vertical&&(p=u.deltaY*d,g=0),r.translateBy(n,-(p/f)*i,-(g/f)*i,{internal:!0});const m=gn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,a==null||a(u,m)),e.isPanScrolling&&(c==null||c(u,m),e.panScrollTimeout=setTimeout(()=>{l==null||l(u,m),e.isPanScrolling=!1},150))}}function ff({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){if(!t&&r.type==="wheel"&&!r.ctrlKey||Xe(r,e))return null;r.preventDefault(),n.call(this,r,s)}}function hf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,o,a;if((i=r.sourceEvent)!=null&&i.internal)return;const s=gn(r.transform);e.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function pf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var o,a;e.usedRightMouseButton=!!(n&&Fi(t,e.mouseButton??0)),(o=i.sourceEvent)!=null&&o.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((a=i.sourceEvent)!=null&&a.internal)&&(s==null||s(i.sourceEvent,gn(i.transform)))}}function gf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return o=>{var a;if(!((a=o.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&Fi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&i(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),s&&uf(e.prevViewport,o.transform))){const c=gn(o.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,c)},n?150:0)}}}function mf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:c,lib:l}){return u=>{var g;const f=e||t,d=n&&u.ctrlKey;if(u.button===1&&u.type==="mousedown"&&(Xe(u,`${l}-flow__node`)||Xe(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!s&&!i&&!n||o||Xe(u,a)&&u.type==="wheel"||Xe(u,c)&&(u.type!=="wheel"||s&&u.type==="wheel"&&!e)||!n&&u.ctrlKey&&u.type==="wheel")return!1;if(!n&&u.type==="touchstart"&&((g=u.touches)==null?void 0:g.length)>1)return u.preventDefault(),!1;if(!f&&!s&&!d&&u.type==="wheel"||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const p=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||u.type==="wheel")&&p}}function xf({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:r,translateExtent:s,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),d=pi().clickDistance(!he(r)||r<0?0:r).scaleExtent([t,n]).translateExtent(s),p=ce(e).call(d);v({x:i.x,y:i.y,zoom:Qe(i.zoom,t,n)},[[0,0],[f.width,f.height]],s);const g=p.on("wheel.zoom"),m=p.on("dblclick.zoom");d.wheelDelta(Bi);function N(T,D){return p?new Promise(x=>{d==null||d.transform(Tn(p,D==null?void 0:D.duration,()=>x(!0)),T)}):Promise.resolve(!1)}function y({noWheelClassName:T,noPanClassName:D,onPaneContextMenu:x,userSelectionActive:k,panOnScroll:_,panOnDrag:I,panOnScrollMode:b,panOnScrollSpeed:S,preventScrolling:M,zoomOnPinch:H,zoomOnScroll:F,zoomOnDoubleClick:Y,zoomActivationKeyPressed:V,lib:O,onTransformChange:X}){k&&!u.isZoomingOrPanning&&E();const B=_&&!V&&!k?df({zoomPanValues:u,noWheelClassName:T,d3Selection:p,d3Zoom:d,panOnScrollMode:b,panOnScrollSpeed:S,zoomOnPinch:H,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:c}):ff({noWheelClassName:T,preventScrolling:M,d3ZoomHandler:g});if(p.on("wheel.zoom",B,{passive:!1}),!k){const Z=hf({zoomPanValues:u,onDraggingChange:l,onPanZoomStart:a});d.on("start",Z);const U=pf({zoomPanValues:u,panOnDrag:I,onPaneContextMenu:!!x,onPanZoom:o,onTransformChange:X});d.on("zoom",U);const K=gf({zoomPanValues:u,panOnDrag:I,panOnScroll:_,onPaneContextMenu:x,onPanZoomEnd:c,onDraggingChange:l});d.on("end",K)}const W=mf({zoomActivationKeyPressed:V,panOnDrag:I,zoomOnScroll:F,panOnScroll:_,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:k,noPanClassName:D,noWheelClassName:T,lib:O});d.filter(W),Y?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function E(){d.on("zoom",null)}async function v(T,D,x){const k=Pn(T),_=d==null?void 0:d.constrain()(k,D,x);return _&&await N(_),new Promise(I=>I(_))}async function w(T,D){const x=Pn(T);return await N(x,D),new Promise(k=>k(x))}function C(T){if(p){const D=Pn(T),x=p.property("__zoom");(x.k!==T.zoom||x.x!==T.x||x.y!==T.y)&&(d==null||d.transform(p,D,null,{sync:!0}))}}function R(){const T=p?hi(p.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function j(T,D){return p?new Promise(x=>{d==null||d.scaleTo(Tn(p,D==null?void 0:D.duration,()=>x(!0)),T)}):Promise.resolve(!1)}function z(T,D){return p?new Promise(x=>{d==null||d.scaleBy(Tn(p,D==null?void 0:D.duration,()=>x(!0)),T)}):Promise.resolve(!1)}function A(T){d==null||d.scaleExtent(T)}function P(T){d==null||d.translateExtent(T)}function L(T){const D=!he(T)||T<0?0:T;d==null||d.clickDistance(D)}return{update:y,destroy:E,setViewport:w,setViewportConstrained:v,getViewport:R,scaleTo:j,scaleBy:z,setScaleExtent:A,setTranslateExtent:P,syncViewport:C,setClickDistance:L}}var ht;(function(e){e.Line="line",e.Handle="handle"})(ht||(ht={}));function yf({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const o=e-t,a=n-r,c=[o>0?1:o<0?-1:0,a>0?1:a<0?-1:0];return o&&s&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function wf(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Ce(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function Rt(e,t,n){return Math.max(0,t-e,e-n)}function os(e,t){return e?!t:t}function vf(e,t,n,r,s,i,o,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:m,maxWidth:N,minHeight:y,maxHeight:E}=r,{x:v,y:w,width:C,height:R,aspectRatio:j}=e;let z=Math.floor(u?p-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const P=C+(c?-z:z),L=R+(l?-A:A),T=-i[0]*C,D=-i[1]*R;let x=Rt(P,m,N),k=Rt(L,y,E);if(o){let b=0,S=0;c&&z<0?b=Ce(v+z+T,o[0][0]):!c&&z>0&&(b=Me(v+P+T,o[1][0])),l&&A<0?S=Ce(w+A+D,o[0][1]):!l&&A>0&&(S=Me(w+L+D,o[1][1])),x=Math.max(x,b),k=Math.max(k,S)}if(a){let b=0,S=0;c&&z>0?b=Me(v+z,a[0][0]):!c&&z<0&&(b=Ce(v+P,a[1][0])),l&&A>0?S=Me(w+A,a[0][1]):!l&&A<0&&(S=Ce(w+L,a[1][1])),x=Math.max(x,b),k=Math.max(k,S)}if(s){if(u){const b=Rt(P/j,y,E)*j;if(x=Math.max(x,b),o){let S=0;!c&&!l||c&&!l&&d?S=Me(w+D+P/j,o[1][1])*j:S=Ce(w+D+(c?z:-z)/j,o[0][1])*j,x=Math.max(x,S)}if(a){let S=0;!c&&!l||c&&!l&&d?S=Ce(w+P/j,a[1][1])*j:S=Me(w+(c?z:-z)/j,a[0][1])*j,x=Math.max(x,S)}}if(f){const b=Rt(L*j,m,N)/j;if(k=Math.max(k,b),o){let S=0;!c&&!l||l&&!c&&d?S=Me(v+L*j+T,o[1][0])/j:S=Ce(v+(l?A:-A)*j+T,o[0][0])/j,k=Math.max(k,S)}if(a){let S=0;!c&&!l||l&&!c&&d?S=Ce(v+L*j,a[1][0])/j:S=Me(v+(l?A:-A)*j,a[0][0])/j,k=Math.max(k,S)}}}A=A+(A<0?k:-k),z=z+(z<0?x:-x),s&&(d?P>L*j?A=(os(c,l)?-z:z)/j:z=(os(c,l)?-A:A)*j:u?(A=z/j,l=c):(z=A*j,c=l));const _=c?v+z:v,I=l?w+A:w;return{width:C+(c?-z:z),height:R+(l?-A:A),x:i[0]*z*(c?-1:1)+_,y:i[1]*A*(l?-1:1)+I}}const Vi={width:0,height:0,x:0,y:0},bf={...Vi,pointerX:0,pointerY:0,aspectRatio:1};function Nf(e){return[[0,0],[e.measured.width,e.measured.height]]}function _f(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,o=e.measured.height??0,a=n[0]*i,c=n[1]*o;return[[r-a,s-c],[r+i-a,s+o-c]]}function Ef({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=ce(e);function o({controlPosition:c,boundaries:l,keepAspectRatio:u,onResizeStart:f,onResize:d,onResizeEnd:p,shouldResize:g}){let m={...Vi},N={...bf};const y=wf(c);let E,v=null,w=[],C,R,j;const z=Js().on("start",A=>{const{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:x,paneDomNode:k}=n();if(E=P.get(t),!E)return;v=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:I}=ft(A.sourceEvent,{transform:L,snapGrid:T,snapToGrid:D,containerBounds:v});m={width:E.measured.width??0,height:E.measured.height??0,x:E.position.x??0,y:E.position.y??0},N={...m,pointerX:_,pointerY:I,aspectRatio:m.width/m.height},C=void 0,E.parentId&&(E.extent==="parent"||E.expandParent)&&(C=P.get(E.parentId),R=C&&E.extent==="parent"?Nf(C):void 0),w=[],j=void 0;for(const[b,S]of P)if(S.parentId===t&&(w.push({id:b,position:{...S.position},extent:S.extent}),S.extent==="parent"||S.expandParent)){const M=_f(S,E,S.origin??x);j?j=[[Math.min(M[0][0],j[0][0]),Math.min(M[0][1],j[0][1])],[Math.max(M[1][0],j[1][0]),Math.max(M[1][1],j[1][1])]]:j=M}f==null||f(A,{...m})}).on("drag",A=>{const{transform:P,snapGrid:L,snapToGrid:T,nodeOrigin:D}=n(),x=ft(A.sourceEvent,{transform:P,snapGrid:L,snapToGrid:T,containerBounds:v}),k=[];if(!E)return;const{x:_,y:I,width:b,height:S}=m,M={},H=E.origin??D,{width:F,height:Y,x:V,y:O}=vf(N,y,x,l,u,H,R,j),X=F!==b,G=Y!==S,B=V!==_&&X,W=O!==I&&G;if(!B&&!W&&!X&&!G)return;if((B||W||H[0]===1||H[1]===1)&&(M.x=B?V:m.x,M.y=W?O:m.y,m.x=M.x,m.y=M.y,w.length>0)){const J=V-_,ee=O-I;for(const ie of w)ie.position={x:ie.position.x-J+H[0]*(F-b),y:ie.position.y-ee+H[1]*(Y-S)},k.push(ie)}if((X||G)&&(M.width=X?F:m.width,M.height=G?Y:m.height,m.width=M.width,m.height=M.height),C&&E.expandParent){const J=H[0]*(M.width??0);M.x&&M.x<J&&(m.x=J,N.x=N.x-(M.x-J));const ee=H[1]*(M.height??0);M.y&&M.y<ee&&(m.y=ee,N.y=N.y-(M.y-ee))}const Z=yf({width:m.width,prevWidth:b,height:m.height,prevHeight:S,affectsX:y.affectsX,affectsY:y.affectsY}),U={...m,direction:Z};(g==null?void 0:g(A,U))!==!1&&(d==null||d(A,U),r(M,k))}).on("end",A=>{p==null||p(A,{...m}),s==null||s()});i.call(z)}function a(){i.on(".drag",null)}return{update:o,destroy:a}}var Oi={exports:{}},Xi={},Yi={exports:{}},qi={};/**
2
- * @license React
3
- * use-sync-external-store-shim.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var tt=$;function Sf(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kf=typeof Object.is=="function"?Object.is:Sf,jf=tt.useState,Cf=tt.useEffect,Mf=tt.useLayoutEffect,$f=tt.useDebugValue;function zf(e,t){var n=t(),r=jf({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return Mf(function(){s.value=n,s.getSnapshot=t,Dn(s)&&i({inst:s})},[e,n,t]),Cf(function(){return Dn(s)&&i({inst:s}),e(function(){Dn(s)&&i({inst:s})})},[e]),$f(n),n}function Dn(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kf(e,n)}catch{return!0}}function If(e,t){return t()}var Af=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?If:zf;qi.useSyncExternalStore=tt.useSyncExternalStore!==void 0?tt.useSyncExternalStore:Af;Yi.exports=qi;var Pf=Yi.exports;/**
10
- * @license React
11
- * use-sync-external-store-shim/with-selector.production.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var mn=$,Tf=Pf;function Df(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Rf=typeof Object.is=="function"?Object.is:Df,Hf=Tf.useSyncExternalStore,Lf=mn.useRef,Ff=mn.useEffect,Bf=mn.useMemo,Vf=mn.useDebugValue;Xi.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=Lf(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=Bf(function(){function c(p){if(!l){if(l=!0,u=p,p=r(p),s!==void 0&&o.hasValue){var g=o.value;if(s(g,p))return f=g}return f=p}if(g=f,Rf(u,p))return g;var m=r(p);return s!==void 0&&s(g,m)?(u=p,g):(u=p,f=m)}var l=!1,u,f,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,s]);var a=Hf(e,i[0],i[1]);return Ff(function(){o.hasValue=!0,o.value=a},[a]),Vf(a),a};Oi.exports=Xi;var Of=Oi.exports;const Xf=Ha(Of),Yf={},as=e=>{let t;const n=new Set,r=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,p))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Yf?"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(r,s,c);return c},qf=e=>e?as(e):as,{useDebugValue:Wf}=La,{useSyncExternalStoreWithSelector:Gf}=Xf,Kf=e=>e;function Wi(e,t=Kf,n){const r=Gf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Wf(r),r}const cs=(e,t)=>{const n=qf(e),r=(s,i=t)=>Wi(n,s,i);return Object.assign(r,n),r},Uf=(e,t)=>e?cs(e,t):cs;function re(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[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const xn=$.createContext(null),Zf=xn.Provider,Gi=Ee.error001();function Q(e,t){const n=$.useContext(xn);if(n===null)throw new Error(Gi);return Wi(n,e,t)}function te(){const e=$.useContext(xn);if(e===null)throw new Error(Gi);return $.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ls={display:"none"},Qf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ki="react-flow__node-desc",Ui="react-flow__edge-desc",Jf="react-flow__aria-live",eh=e=>e.ariaLiveMessage;function th({rfId:e}){const t=Q(eh);return h.jsx("div",{id:`${Jf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Qf,children:t})}function nh({rfId:e,disableKeyboardA11y:t}){return h.jsxs(h.Fragment,{children:[h.jsxs("div",{id:`${Ki}-${e}`,style:ls,children:["Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),h.jsx("div",{id:`${Ui}-${e}`,style:ls,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&h.jsx(th,{rfId:e})]})}const rh=e=>e.userSelectionActive?"none":"all",yr=$.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const o=Q(rh),a=`${e}`.split("-");return h.jsx("div",{className:se(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},ref:i,...s,children:t})});function sh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:h.jsx(yr,{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"})})}const ih=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Ht=e=>e.id;function oh(e,t){return re(e.selectedNodes.map(Ht),t.selectedNodes.map(Ht))&&re(e.selectedEdges.map(Ht),t.selectedEdges.map(Ht))}function ah({onSelectionChange:e}){const t=te(),{selectedNodes:n,selectedEdges:r}=Q(ih,oh);return $.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const ch=e=>!!e.onSelectionChangeHandlers;function lh({onSelectionChange:e}){const t=Q(ch);return e||t?h.jsx(ah,{onSelectionChange:e}):null}const Zi=[0,0],uh={x:0,y:0,zoom:1},dh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","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","onBeforeDelete","debug","autoPanSpeed","paneClickDistance"],us=[...dh,"rfId"],fh=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,setPaneClickDistance:e.setPaneClickDistance}),ds={translateExtent:vt,nodeOrigin:Zi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function hh(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:c,setPaneClickDistance:l}=Q(fh,re),u=te();$.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=ds,a()}),[]);const f=$.useRef(ds);return $.useEffect(()=>{for(const d of us){const p=e[d],g=f.current[d];p!==g&&(typeof e[d]>"u"||(d==="nodes"?t(p):d==="edges"?n(p):d==="minZoom"?r(p):d==="maxZoom"?s(p):d==="translateExtent"?i(p):d==="nodeExtent"?o(p):d==="paneClickDistance"?l(p):d==="fitView"?u.setState({fitViewOnInit:p}):d==="fitViewOptions"?u.setState({fitViewOnInitOptions:p}):u.setState({[d]:p})))}f.current=e},us.map(d=>e[d])),null}function fs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ph(e){var r;const[t,n]=$.useState(e==="system"?null:e);return $.useEffect(()=>{if(e!=="system"){n(e);return}const s=fs(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=fs())!=null&&r.matches?"dark":"light"}const hs=typeof document<"u"?document:null;function Et(e=null,t={target:hs,actInsideInputWithModifier:!0}){const[n,r]=$.useState(!1),s=$.useRef(!1),i=$.useRef(new Set([])),[o,a]=$.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
18
- `).replace(`
19
-
20
- `,`
21
- +`).split(`
22
- `)),u=l.reduce((f,d)=>f.concat(...d),[]);return[l,u]}return[[],[]]},[e]);return $.useEffect(()=>{const c=(t==null?void 0:t.target)||hs;if(e!==null){const l=d=>{if(s.current=d.ctrlKey||d.metaKey||d.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Qn(d))return!1;const g=gs(d.code,a);i.current.add(d[g]),ps(o,i.current,!1)&&(d.preventDefault(),r(!0))},u=d=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Qn(d))return!1;const g=gs(d.code,a);ps(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(d[g]),d.key==="Meta"&&i.current.clear(),s.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",l),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",l),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function ps(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function gs(e,t){return t.includes(e)?"code":"key"}const gh=()=>{const e=te();return $.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},{duration:n==null?void 0:n.duration}),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>{const{nodeLookup:n,minZoom:r,maxZoom:s,panZoom:i,domNode:o}=e.getState();if(!i||!o)return Promise.resolve(!1);const a=Kn(n,t),{width:c,height:l}=pn(o);return Un({nodes:a,width:c,height:l,minZoom:r,maxZoom:s,panZoom:i},t)},setCenter:async(t,n,r)=>{const{width:s,height:i,maxZoom:o,panZoom:a}=e.getState(),c=typeof(r==null?void 0:r.zoom)<"u"?r.zoom:o,l=s/2-t*c,u=i/2-n*c;return a?(await a.setViewport({x:l,y:u,zoom:c},{duration:r==null?void 0:r.duration}),Promise.resolve(!0)):Promise.resolve(!1)},fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:o,panZoom:a}=e.getState(),c=hr(t,r,s,i,o,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:r,snapGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:o,y:a}=i.getBoundingClientRect(),c={x:t.x-o,y:t.y-a};return Mt(c,r,n.snapToGrid,s)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),o=Ei(t,n);return{x:o.x+s,y:o.y+i}}}),[])};function Qi(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const o=r.get(i.id);o?o.push(i):r.set(i.id,[i])}for(const i of t){const o=r.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const a={...i};for(const c of o)mh(c,a);n.push(a)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function mh(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??(t.measured={}),t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function xh(e,t){return Qi(e,t)}function yh(e,t){return Qi(e,t)}function Te(e,t){return{id:e,type:"select",selected:t}}function Ye(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const o=t.has(s);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),r.push(Te(i.id,o)))}return r}function ms({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),c=((s=a==null?void 0:a.internals)==null?void 0:s.userNode)??a;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function xs(e){return{id:e.id,type:"remove"}}const ys=e=>Ad(e),wh=e=>yi(e);function Ji(e){return $.forwardRef(e)}const vh=typeof window<"u"?$.useLayoutEffect:$.useEffect;function ws(e){const[t,n]=$.useState(BigInt(0)),[r]=$.useState(()=>bh(()=>n(s=>s+BigInt(1))));return vh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function bh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const eo=$.createContext(null);function Nh({children:e}){const t=te(),n=$.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:f,nodeLookup:d}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;u?l(p):f&&f(ms({items:p,lookup:d}))},[]),r=ws(n),s=$.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:d}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;u?l(p):f&&f(ms({items:p,lookup:d}))},[]),i=ws(s),o=$.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return h.jsx(eo.Provider,{value:o,children:e})}function _h(){const e=$.useContext(eo);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Eh=e=>!!e.panZoom;function wr(){const e=gh(),t=te(),n=_h(),r=Q(Eh),s=$.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),o=f=>{n.nodeQueue.push(f)},a=f=>{n.edgeQueue.push(f)},c=f=>{var y,E;const{nodeLookup:d,nodeOrigin:p}=t.getState(),g=ys(f)?f:d.get(f.id),m=g.parentId?ki(g.position,g.measured,g.parentId,d,p):g.position,N={...g,position:m,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((E=g.measured)==null?void 0:E.height)??g.height};return Je(N)},l=(f,d,p={replace:!1})=>{o(g=>g.map(m=>{if(m.id===f){const N=typeof d=="function"?d(m):d;return p.replace&&ys(N)?N:{...m,...N}}return m}))},u=(f,d,p={replace:!1})=>{a(g=>g.map(m=>{if(m.id===f){const N=typeof d=="function"?d(m):d;return p.replace&&wh(N)?N:{...m,...N}}return m}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var d;return(d=i(f))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:o,setEdges:a,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:p}=t.getState(),[g,m,N]=p;return{nodes:f.map(y=>({...y})),edges:d.map(y=>({...y})),viewport:{x:g,y:m,zoom:N}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:p,edges:g,onNodesDelete:m,onEdgesDelete:N,triggerNodeChanges:y,triggerEdgeChanges:E,onDelete:v,onBeforeDelete:w}=t.getState(),{nodes:C,edges:R}=await Dd({nodesToRemove:f,edgesToRemove:d,nodes:p,edges:g,onBeforeDelete:w}),j=R.length>0,z=C.length>0;if(j){const A=R.map(xs);N==null||N(R),E(A)}if(z){const A=C.map(xs);m==null||m(C),y(A)}return(z||j)&&(v==null||v({nodes:C,edges:R})),{deletedNodes:C,deletedEdges:R}},getIntersectingNodes:(f,d=!0,p)=>{const g=Zr(f),m=g?f:c(f),N=p!==void 0;return m?(p||t.getState().nodes).filter(y=>{const E=t.getState().nodeLookup.get(y.id);if(E&&!g&&(y.id===f.id||!E.internals.positionAbsolute))return!1;const v=Je(N?y:E),w=Nt(v,m);return d&&w>0||w>=m.width*m.height}):[]},isNodeIntersecting:(f,d,p=!0)=>{const m=Zr(f)?f:c(f);if(!m)return!1;const N=Nt(m,d);return p&&N>0||N>=m.width*m.height},updateNode:l,updateNodeData:(f,d,p={replace:!1})=>{l(f,g=>{const m=typeof d=="function"?d(g):d;return p.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},p)},updateEdge:u,updateEdgeData:(f,d,p={replace:!1})=>{u(f,g=>{const m=typeof d=="function"?d(g):d;return p.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},p)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:p}=t.getState();return Pd(f,{nodeLookup:d,nodeOrigin:p})},getHandleConnections:({type:f,id:d,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${f}-${d??null}`))==null?void 0:g.values())??[])}}},[]);return $.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const vs=e=>e.selected,Sh={actInsideInputWithModifier:!1},kh=typeof window<"u"?window:void 0;function jh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=te(),{deleteElements:r}=wr(),s=Et(e,Sh),i=Et(t,{target:kh});$.useEffect(()=>{if(s){const{edges:o,nodes:a}=n.getState();r({nodes:a.filter(vs),edges:o.filter(vs)}),n.setState({nodesSelectionActive:!1})}},[s]),$.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Ch(e){const t=te();$.useEffect(()=>{const n=()=>{var s,i;if(!e.current)return!1;const r=pn(e.current);(r.height===0||r.width===0)&&((i=(s=t.getState()).onError)==null||i.call(s,"004",Ee.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const yn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Mh=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function $h({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=He.Free,zoomOnDoubleClick:o=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:p=!0,children:g,noWheelClassName:m,noPanClassName:N,onViewportChange:y,isControlledViewport:E,paneClickDistance:v}){const w=te(),C=$.useRef(null),{userSelectionActive:R,lib:j}=Q(Mh,re),z=Et(d),A=$.useRef();Ch(C);const P=$.useCallback(L=>{y==null||y({x:L[0],y:L[1],zoom:L[2]}),E||w.setState({transform:L})},[y,E]);return $.useEffect(()=>{if(C.current){A.current=xf({domNode:C.current,minZoom:u,maxZoom:f,translateExtent:l,viewport:c,paneClickDistance:v,onDraggingChange:x=>w.setState({paneDragging:x}),onPanZoomStart:(x,k)=>{const{onViewportChangeStart:_,onMoveStart:I}=w.getState();I==null||I(x,k),_==null||_(k)},onPanZoom:(x,k)=>{const{onViewportChange:_,onMove:I}=w.getState();I==null||I(x,k),_==null||_(k)},onPanZoomEnd:(x,k)=>{const{onViewportChangeEnd:_,onMoveEnd:I}=w.getState();I==null||I(x,k),_==null||_(k)}});const{x:L,y:T,zoom:D}=A.current.getViewport();return w.setState({panZoom:A.current,transform:[L,T,D],domNode:C.current.closest(".react-flow")}),()=>{var x;(x=A.current)==null||x.destroy()}}},[]),$.useEffect(()=>{var L;(L=A.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:z,preventScrolling:p,noPanClassName:N,userSelectionActive:R,noWheelClassName:m,lib:j,onTransformChange:P})},[e,t,n,r,s,i,o,a,z,p,N,R,m,j,P]),h.jsx("div",{className:"react-flow__renderer",ref:C,style:yn,children:g})}const zh=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ih(){const{userSelectionActive:e,userSelectionRect:t}=Q(zh,re);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 Rn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Ah=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function Ph({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:r,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:o,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:l,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:d,children:p}){const g=$.useRef(null),m=te(),N=$.useRef(0),y=$.useRef(0),E=$.useRef(),v=$.useRef(new Map),{userSelectionActive:w,elementsSelectable:C,dragging:R}=Q(Ah,re),j=C&&(e||w),z=$.useRef(!1),A=$.useRef(!1),P=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,y.current=0},L=b=>{if(z.current){z.current=!1;return}a==null||a(b),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},T=b=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){b.preventDefault();return}c==null||c(b)},D=l?b=>l(b):void 0,x=b=>{var V,O,X,G;const{resetSelectedElements:S,domNode:M,edgeLookup:H}=m.getState();if(E.current=M==null?void 0:M.getBoundingClientRect(),!C||!e||b.button!==0||b.target!==g.current||!E.current)return;(O=(V=b.target)==null?void 0:V.setPointerCapture)==null||O.call(V,b.pointerId),A.current=!0,z.current=!1,v.current=new Map;for(const[B,W]of H)v.current.set(W.source,((X=v.current.get(W.source))==null?void 0:X.add(B))||new Set([B])),v.current.set(W.target,((G=v.current.get(W.target))==null?void 0:G.add(B))||new Set([B]));const{x:F,y:Y}=ve(b.nativeEvent,E.current);S(),m.setState({userSelectionRect:{width:0,height:0,startX:F,startY:Y,x:F,y:Y}}),i==null||i(b)},k=b=>{const{userSelectionRect:S,edgeLookup:M,transform:H,nodeLookup:F,triggerNodeChanges:Y,triggerEdgeChanges:V}=m.getState();if(!E.current||!S)return;z.current=!0;const{x:O,y:X}=ve(b.nativeEvent,E.current),{startX:G,startY:B}=S,W={startX:G,startY:B,x:O<G?O:G,y:X<B?X:B,width:Math.abs(O-G),height:Math.abs(X-B)},Z=wi(F,W,H,n===bt.Partial,!0),U=new Set,K=new Set;for(const J of Z){K.add(J.id);const ee=v.current.get(J.id);if(ee)for(const ie of ee)U.add(ie)}if(N.current!==K.size){N.current=K.size;const J=Ye(F,K,!0);Y(J)}if(y.current!==U.size){y.current=U.size;const J=Ye(M,U);V(J)}m.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},_=b=>{var M,H;if(b.button!==0||!A.current)return;(H=(M=b.target)==null?void 0:M.releasePointerCapture)==null||H.call(M,b.pointerId);const{userSelectionRect:S}=m.getState();!w&&S&&b.target===g.current&&(L==null||L(b)),N.current>0&&m.setState({nodesSelectionActive:!0}),P(),o==null||o(b),(t||s)&&(z.current=!1),A.current=!1},I=r===!0||Array.isArray(r)&&r.includes(0);return h.jsxs("div",{className:se(["react-flow__pane",{draggable:I,dragging:R,selection:e}]),onClick:j?void 0:Rn(L,g),onContextMenu:Rn(T,g),onWheel:Rn(D,g),onPointerEnter:j?void 0:u,onPointerDown:j?x:f,onPointerMove:j?k:f,onPointerUp:j?_:void 0,onPointerLeave:d,ref:g,style:yn,children:[p,h.jsx(Ih,{})]})}function rr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",Ee.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([e])}function to({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:o}){const a=te(),[c,l]=$.useState(!1),u=$.useRef();return $.useEffect(()=>{u.current=nf({getStoreItems:()=>a.getState(),onNodeMouseDown:f=>{rr({id:f,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),$.useEffect(()=>{var f,d;if(t)(f=u.current)==null||f.destroy();else if(e.current)return(d=u.current)==null||d.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:o}),()=>{var p;(p=u.current)==null||p.destroy()}},[n,r,t,i,e,s]),c}const Th=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function no(){const e=te();return $.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),f=new Map,d=Th(o),p=s?i[0]:5,g=s?i[1]:5,m=n.direction.x*p*n.factor,N=n.direction.y*g*n.factor;for(const[,y]of l){if(!d(y))continue;let E={x:y.internals.positionAbsolute.x+m,y:y.internals.positionAbsolute.y+N};s&&(E=hn(E,i));const{position:v,positionAbsolute:w}=vi({nodeId:y.id,nextPosition:E,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:a});y.position=v,y.internals.positionAbsolute=w,f.set(y.id,y)}c(f)},[])}const vr=$.createContext(null),Dh=vr.Provider;vr.Consumer;const ro=()=>$.useContext(vr),Rh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Hh=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=r,{fromHandle:a,toHandle:c,isValid:l}=o,u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:u,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Ze.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,valid:u&&l}};function Lh({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:f,...d},p){var x,k;const g=o||null,m=e==="target",N=te(),y=ro(),{connectOnClick:E,noPanClassName:v,rfId:w}=Q(Rh,re),{connectingFrom:C,connectingTo:R,clickConnecting:j,isPossibleEndHandle:z,connectionInProcess:A,valid:P}=Q(Hh(y,g,e),re);y||(k=(x=N.getState()).onError)==null||k.call(x,"010",Ee.error010());const L=_=>{const{defaultEdgeOptions:I,onConnect:b,hasDefaultEdges:S}=N.getState(),M={...I,..._};if(S){const{edges:H,setEdges:F}=N.getState();F(Od(M,H))}b==null||b(M),a==null||a(M)},T=_=>{if(!y)return;const I=Ci(_.nativeEvent);if(s&&(I&&_.button===0||!I)){const b=N.getState();nr.onPointerDown(_.nativeEvent,{autoPanOnConnect:b.autoPanOnConnect,connectionMode:b.connectionMode,connectionRadius:b.connectionRadius,domNode:b.domNode,nodeLookup:b.nodeLookup,lib:b.lib,isTarget:m,handleId:g,nodeId:y,flowId:b.rfId,panBy:b.panBy,cancelConnection:b.cancelConnection,onConnectStart:b.onConnectStart,onConnectEnd:b.onConnectEnd,updateConnection:b.updateConnection,onConnect:L,isValidConnection:n||b.isValidConnection,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:b.autoPanSpeed})}I?u==null||u(_):f==null||f(_)},D=_=>{const{onClickConnectStart:I,onClickConnectEnd:b,connectionClickStartHandle:S,connectionMode:M,isValidConnection:H,lib:F,rfId:Y,nodeLookup:V,connection:O}=N.getState();if(!y||!S&&!s)return;if(!S){I==null||I(_.nativeEvent,{nodeId:y,handleId:g,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const X=ji(_.target),G=n||H,{connection:B,isValid:W}=nr.isValid(_.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:M,fromNodeId:S.nodeId,fromHandleId:S.id||null,fromType:S.type,isValidConnection:G,flowId:Y,doc:X,lib:F,nodeLookup:V});W&&B&&L(B);const Z=structuredClone(O);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,b==null||b(_,Z),N.setState({connectionClickStartHandle:null})};return h.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,l,{source:!m,target:m,connectable:r,connectablestart:s,connectableend:i,clickconnecting:j,connectingfrom:C,connectingto:R,valid:P,connectionindicator:r&&(!A||z)&&(A?i:s)}]),onMouseDown:T,onTouchStart:T,onClick:E?D:void 0,ref:p,...d,children:c})}const Pe=$.memo(Ji(Lh));function Fh({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return h.jsxs(h.Fragment,{children:[e==null?void 0:e.label,h.jsx(Pe,{type:"source",position:n,isConnectable:t})]})}function Bh({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom}){return h.jsxs(h.Fragment,{children:[h.jsx(Pe,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,h.jsx(Pe,{type:"source",position:r,isConnectable:t})]})}function Vh(){return null}function Oh({data:e,isConnectable:t,targetPosition:n=q.Top}){return h.jsxs(h.Fragment,{children:[h.jsx(Pe,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const rn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},bs={input:Fh,default:Bh,output:Oh,group:Vh};function Xh(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const Yh=e=>{const{width:t,height:n,x:r,y:s}=Ct(e.nodeLookup,{filter:i=>!!i.selected});return{width:he(t)?t:null,height:he(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function qh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=te(),{width:s,height:i,transformString:o,userSelectionActive:a}=Q(Yh,re),c=no(),l=$.useRef(null);if($.useEffect(()=>{var d;n||(d=l.current)==null||d.focus({preventScroll:!0})},[n]),to({nodeRef:l}),a||!s||!i)return null;const u=e?d=>{const p=r.getState().nodes.filter(g=>g.selected);e(d,p)}:void 0,f=d=>{Object.prototype.hasOwnProperty.call(rn,d.key)&&(d.preventDefault(),c({direction:rn[d.key],factor:d.shiftKey?4:1}))};return h.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:h.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i}})})}const Ns=typeof window<"u"?window:void 0,Wh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function so({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:f,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:m,zoomActivationKeyCode:N,elementsSelectable:y,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:w,panOnScrollSpeed:C,panOnScrollMode:R,zoomOnDoubleClick:j,panOnDrag:z,defaultViewport:A,translateExtent:P,minZoom:L,maxZoom:T,preventScrolling:D,onSelectionContextMenu:x,noWheelClassName:k,noPanClassName:_,disableKeyboardA11y:I,onViewportChange:b,isControlledViewport:S}){const{nodesSelectionActive:M,userSelectionActive:H}=Q(Wh),F=Et(l,{target:Ns}),Y=Et(m,{target:Ns}),V=Y||z,O=Y||w,X=u&&V!==!0,G=F||H||X;return jh({deleteKeyCode:c,multiSelectionKeyCode:g}),h.jsx($h,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:O,panOnScrollSpeed:C,panOnScrollMode:R,zoomOnDoubleClick:j,panOnDrag:!F&&V,defaultViewport:A,translateExtent:P,minZoom:L,maxZoom:T,zoomActivationKeyCode:N,preventScrolling:D,noWheelClassName:k,noPanClassName:_,onViewportChange:b,isControlledViewport:S,paneClickDistance:a,children:h.jsxs(Ph,{onSelectionStart:d,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:V,isSelecting:!!G,selectionMode:f,selectionKeyPressed:F,selectionOnDrag:X,children:[e,M&&h.jsx(qh,{onSelectionContextMenu:x,noPanClassName:_,disableKeyboardA11y:I})]})})}so.displayName="FlowRenderer";const Gh=$.memo(so),Kh=e=>t=>e?wi(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 Uh(e){return Q($.useCallback(Kh(e),[e]),re)}const Zh=e=>e.updateNodeInternals;function Qh(){const e=Q(Zh),[t]=$.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return $.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Jh({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=te(),i=$.useRef(null),o=$.useRef(null),a=$.useRef(e.sourcePosition),c=$.useRef(e.targetPosition),l=$.useRef(t),u=n&&!!e.internals.handleBounds;return $.useEffect(()=>{i.current&&!e.hidden&&(!u||o.current!==i.current)&&(o.current&&(r==null||r.unobserve(o.current)),r==null||r.observe(i.current),o.current=i.current)},[u,e.hidden]),$.useEffect(()=>()=>{o.current&&(r==null||r.unobserve(o.current),o.current=null)},[]),$.useEffect(()=>{if(i.current){const f=l.current!==t,d=a.current!==e.sourcePosition,p=c.current!==e.targetPosition;(f||d||p)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function e0({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:f,noDragClassName:d,noPanClassName:p,disableKeyboardA11y:g,rfId:m,nodeTypes:N,nodeExtent:y,nodeClickDistance:E,onError:v}){const{node:w,internals:C,isParent:R}=Q(B=>{const W=B.nodeLookup.get(e),Z=B.parentLookup.has(e);return{node:W,internals:W.internals,isParent:Z}},re);let j=w.type||"default",z=(N==null?void 0:N[j])||bs[j];z===void 0&&(v==null||v("003",Ee.error003(j)),j="default",z=bs.default);const A=!!(w.draggable||a&&typeof w.draggable>"u"),P=!!(w.selectable||c&&typeof w.selectable>"u"),L=!!(w.connectable||l&&typeof w.connectable>"u"),T=!!(w.focusable||u&&typeof w.focusable>"u"),D=te(),x=Si(w),k=Jh({node:w,nodeType:j,hasDimensions:x,resizeObserver:f}),_=to({nodeRef:k,disabled:w.hidden||!A,noDragClassName:d,handleSelector:w.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:E}),I=no();if(w.hidden)return null;const b=Se(w),S=Xh(w),M=P||A||t||n||r||s,H=n?B=>n(B,{...C.userNode}):void 0,F=r?B=>r(B,{...C.userNode}):void 0,Y=s?B=>s(B,{...C.userNode}):void 0,V=i?B=>i(B,{...C.userNode}):void 0,O=o?B=>o(B,{...C.userNode}):void 0,X=B=>{const{selectNodesOnDrag:W,nodeDragThreshold:Z}=D.getState();P&&(!W||!A||Z>0)&&rr({id:e,store:D,nodeRef:k}),t&&t(B,{...C.userNode})},G=B=>{if(!(Qn(B.nativeEvent)||g))if(gi.includes(B.key)&&P){const W=B.key==="Escape";rr({id:e,store:D,unselect:W,nodeRef:k})}else A&&w.selected&&Object.prototype.hasOwnProperty.call(rn,B.key)&&(B.preventDefault(),D.setState({ariaLiveMessage:`Moved selected node ${B.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~C.positionAbsolute.x}, y: ${~~C.positionAbsolute.y}`}),I({direction:rn[B.key],factor:B.shiftKey?4:1}))};return h.jsx("div",{className:se(["react-flow__node",`react-flow__node-${j}`,{[p]:A},w.className,{selected:w.selected,selectable:P,parent:R,draggable:A,dragging:_}]),ref:k,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:x?"visible":"hidden",...w.style,...S},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:F,onMouseLeave:Y,onContextMenu:V,onClick:X,onDoubleClick:O,onKeyDown:T?G:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":g?void 0:`${Ki}-${m}`,"aria-label":w.ariaLabel,children:h.jsx(Dh,{value:e,children:h.jsx(z,{id:e,data:w.data,type:j,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:w.selected,selectable:P,draggable:A,deletable:w.deletable??!0,isConnectable:L,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:_,dragHandle:w.dragHandle,zIndex:C.z,parentId:w.parentId,...b})})})}const t0=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function io(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Q(t0,re),o=Uh(e.onlyRenderVisibleElements),a=Qh();return h.jsx("div",{className:"react-flow__nodes",style:yn,children:o.map(c=>h.jsx(e0,{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:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}io.displayName="NodeRenderer";const n0=$.memo(io);function r0(e){return Q($.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);i&&o&&Fd({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),re)}const s0=({color:e="none",strokeWidth:t=1})=>h.jsx("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),i0=({color:e="none",strokeWidth:t=1})=>h.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),_s={[en.Arrow]:s0,[en.ArrowClosed]:i0};function o0(e){const t=te();return $.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(_s,e)?_s[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Ee.error009(e)),null)},[e])}const a0=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const c=o0(t);return c?h.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:h.jsx(c,{color:n,strokeWidth:o})}):null},oo=({defaultColor:e,rfId:t})=>{const n=Q(i=>i.edges),r=Q(i=>i.defaultEdgeOptions),s=$.useMemo(()=>Gd(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?h.jsx("svg",{className:"react-flow__marker",children:h.jsx("defs",{children:s.map(i=>h.jsx(a0,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};oo.displayName="MarkerDefinitions";var c0=$.memo(oo);function ao({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[f,d]=$.useState({x:1,y:0,width:0,height:0}),p=se(["react-flow__edge-textwrapper",l]),g=$.useRef(null);return $.useEffect(()=>{if(g.current){const m=g.current.getBBox();d({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:h.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...u,children:[s&&h.jsx("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),h.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]})}ao.displayName="EdgeText";const l0=$.memo(ao);function wn({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return h.jsxs(h.Fragment,{children:[h.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l&&h.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}),r&&he(t)&&he(n)?h.jsx(l0,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Es({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function co({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:s,targetPosition:i=q.Top}){const[o,a]=Es({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,l]=Es({pos:i,x1:r,y1:s,x2:e,y2:t}),[u,f,d,p]=Mi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${a} ${c},${l} ${r},${s}`,u,f,d,p]}function lo(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=q.Bottom,targetPosition:a=q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:N,interactionWidth:y})=>{const[E,v,w]=co({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a}),C=e.isInternal?void 0:t;return h.jsx(wn,{id:C,path:E,labelX:v,labelY:w,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:N,interactionWidth:y})})}const u0=lo({isInternal:!1}),uo=lo({isInternal:!0});u0.displayName="SimpleBezierEdge";uo.displayName="SimpleBezierEdgeInternal";function fo(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,sourcePosition:p=q.Bottom,targetPosition:g=q.Top,markerEnd:m,markerStart:N,pathOptions:y,interactionWidth:E})=>{const[v,w,C]=Jn({sourceX:n,sourceY:r,sourcePosition:p,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset}),R=e.isInternal?void 0:t;return h.jsx(wn,{id:R,path:v,labelX:w,labelY:C,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:m,markerStart:N,interactionWidth:E})})}const ho=fo({isInternal:!1}),po=fo({isInternal:!0});ho.displayName="SmoothStepEdge";po.displayName="SmoothStepEdgeInternal";function go(e){return $.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return h.jsx(ho,{...n,id:r,pathOptions:$.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const d0=go({isInternal:!1}),mo=go({isInternal:!0});d0.displayName="StepEdge";mo.displayName="StepEdgeInternal";function xo(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:g,interactionWidth:m})=>{const[N,y,E]=Ii({sourceX:n,sourceY:r,targetX:s,targetY:i}),v=e.isInternal?void 0:t;return h.jsx(wn,{id:v,path:N,labelX:y,labelY:E,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:g,interactionWidth:m})})}const f0=xo({isInternal:!1}),yo=xo({isInternal:!0});f0.displayName="StraightEdge";yo.displayName="StraightEdgeInternal";function wo(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=q.Bottom,targetPosition:a=q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:N,pathOptions:y,interactionWidth:E})=>{const[v,w,C]=$i({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,curvature:y==null?void 0:y.curvature}),R=e.isInternal?void 0:t;return h.jsx(wn,{id:R,path:v,labelX:w,labelY:C,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:N,interactionWidth:E})})}const h0=wo({isInternal:!1}),vo=wo({isInternal:!0});h0.displayName="BezierEdge";vo.displayName="BezierEdgeInternal";const Ss={default:vo,straight:yo,step:mo,smoothstep:po,simplebezier:uo},ks={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},p0=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,g0=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,js="react-flow__edgeupdater";function Cs({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a}){return h.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:se([js,`${js}-${a}`]),cx:p0(t,r,e),cy:g0(n,r,e),r,stroke:"transparent",fill:"transparent"})}function m0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:o,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:f,setReconnecting:d,setUpdateHover:p}){const g=te(),m=(w,C)=>{if(w.button!==0)return;const{autoPanOnConnect:R,domNode:j,isValidConnection:z,connectionMode:A,connectionRadius:P,lib:L,onConnectStart:T,onConnectEnd:D,cancelConnection:x,nodeLookup:k,rfId:_,panBy:I,updateConnection:b}=g.getState(),S=C.type==="target";d(!0),u==null||u(w,n,C.type);const M=(F,Y)=>{d(!1),f==null||f(F,n,C.type,Y)},H=F=>l==null?void 0:l(n,F);nr.onPointerDown(w.nativeEvent,{autoPanOnConnect:R,connectionMode:A,connectionRadius:P,domNode:j,handleId:C.id,nodeId:C.nodeId,nodeLookup:k,isTarget:S,edgeUpdaterType:C.type,lib:L,flowId:_,cancelConnection:x,panBy:I,isValidConnection:z,onConnect:H,onConnectStart:T,onConnectEnd:D,onReconnectEnd:M,updateConnection:b,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle})},N=w=>m(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>m(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>p(!0),v=()=>p(!1);return h.jsxs(h.Fragment,{children:[(e===!0||e==="source")&&h.jsx(Cs,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:N,onMouseEnter:E,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&h.jsx(Cs,{position:c,centerX:i,centerY:o,radius:t,onMouseDown:y,onMouseEnter:E,onMouseOut:v,type:"target"})]})}function x0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,rfId:g,edgeTypes:m,noPanClassName:N,onError:y,disableKeyboardA11y:E}){let v=Q(K=>K.edgeLookup.get(e));const w=Q(K=>K.defaultEdgeOptions);v=w?{...w,...v}:v;let C=v.type||"default",R=(m==null?void 0:m[C])||Ss[C];R===void 0&&(y==null||y("011",Ee.error011(C)),C="default",R=Ss.default);const j=!!(v.focusable||t&&typeof v.focusable>"u"),z=typeof f<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),A=!!(v.selectable||r&&typeof v.selectable>"u"),P=$.useRef(null),[L,T]=$.useState(!1),[D,x]=$.useState(!1),k=te(),{zIndex:_,sourceX:I,sourceY:b,targetX:S,targetY:M,sourcePosition:H,targetPosition:F}=Q($.useCallback(K=>{const J=K.nodeLookup.get(v.source),ee=K.nodeLookup.get(v.target);if(!J||!ee)return{zIndex:v.zIndex,...ks};const ie=Wd({id:e,sourceNode:J,targetNode:ee,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:K.connectionMode,onError:y});return{zIndex:Ld({selected:v.selected,zIndex:v.zIndex,sourceNode:J,targetNode:ee,elevateOnSelect:K.elevateEdgesOnSelect}),...ie||ks}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),re),Y=$.useMemo(()=>v.markerStart?`url('#${er(v.markerStart,g)}')`:void 0,[v.markerStart,g]),V=$.useMemo(()=>v.markerEnd?`url('#${er(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||I===null||b===null||S===null||M===null)return null;const O=K=>{var ke;const{addSelectedEdges:J,unselectNodesAndEdges:ee,multiSelectionActive:ie}=k.getState();A&&(k.setState({nodesSelectionActive:!1}),v.selected&&ie?(ee({nodes:[],edges:[v]}),(ke=P.current)==null||ke.blur()):J([e])),s&&s(K,v)},X=i?K=>{i(K,{...v})}:void 0,G=o?K=>{o(K,{...v})}:void 0,B=a?K=>{a(K,{...v})}:void 0,W=c?K=>{c(K,{...v})}:void 0,Z=l?K=>{l(K,{...v})}:void 0,U=K=>{var J;if(!E&&gi.includes(K.key)&&A){const{unselectNodesAndEdges:ee,addSelectedEdges:ie}=k.getState();K.key==="Escape"?((J=P.current)==null||J.blur(),ee({edges:[v]})):ie([e])}};return h.jsx("svg",{style:{zIndex:_},children:h.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${C}`,v.className,N,{selected:v.selected,animated:v.animated,inactive:!A&&!s,updating:L,selectable:A}]),onClick:O,onDoubleClick:X,onContextMenu:G,onMouseEnter:B,onMouseMove:W,onMouseLeave:Z,onKeyDown:j?U:void 0,tabIndex:j?0:void 0,role:j?"button":"img","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":j?`${Ui}-${g}`:void 0,ref:P,children:[!D&&h.jsx(R,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:A,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:I,sourceY:b,targetX:S,targetY:M,sourcePosition:H,targetPosition:F,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:Y,markerEnd:V,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),z&&h.jsx(m0,{edge:v,isReconnectable:z,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,sourceX:I,sourceY:b,targetX:S,targetY:M,sourcePosition:H,targetPosition:F,setUpdateHover:T,setReconnecting:x})]})})}const y0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function bo({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:m}){const{edgesFocusable:N,edgesReconnectable:y,elementsSelectable:E,onError:v}=Q(y0,re),w=r0(t);return h.jsxs("div",{className:"react-flow__edges",children:[h.jsx(c0,{defaultColor:e,rfId:n}),w.map(C=>h.jsx(x0,{id:C,edgesFocusable:N,edgesReconnectable:y,elementsSelectable:E,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:f,onDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:r,disableKeyboardA11y:m},C))]})}bo.displayName="EdgeRenderer";const w0=$.memo(bo),v0=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function b0({children:e}){const t=Q(v0);return h.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function N0(e){const t=wr(),n=$.useRef(!1);$.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const _0=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function E0(e){const t=Q(_0),n=te();return $.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function S0(e){return e.connection.inProgress?{...e.connection,to:Mt(e.connection.to,e.transform)}:{...e.connection}}function k0(e){return S0}function j0(e){const t=k0();return Q(t,re)}const C0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function M0({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:o,isValid:a,inProgress:c}=Q(C0,re);return!(i&&s&&c)?null:h.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:h.jsx("g",{className:se(["react-flow__connection",xi(a)]),children:h.jsx(No,{style:t,type:n,CustomComponent:r,isValid:a})})})}const No=({style:e,type:t=ze.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:f,toPosition:d}=j0();if(!s)return;if(n)return h.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:d,connectionStatus:xi(r),toNode:u,toHandle:f});let p="";const g={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:d};switch(t){case ze.Bezier:[p]=$i(g);break;case ze.SimpleBezier:[p]=co(g);break;case ze.Step:[p]=Jn({...g,borderRadius:0});break;case ze.SmoothStep:[p]=Jn(g);break;default:[p]=Ii(g)}return h.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};No.displayName="ConnectionLine";const $0={};function Ms(e=$0){$.useRef(e),te(),$.useEffect(()=>{},[e])}function z0(){te(),$.useRef(!1),$.useEffect(()=>{},[])}function _o({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:m,connectionLineComponent:N,connectionLineContainerStyle:y,selectionKeyCode:E,selectionOnDrag:v,selectionMode:w,multiSelectionKeyCode:C,panActivationKeyCode:R,zoomActivationKeyCode:j,deleteKeyCode:z,onlyRenderVisibleElements:A,elementsSelectable:P,defaultViewport:L,translateExtent:T,minZoom:D,maxZoom:x,preventScrolling:k,defaultMarkerColor:_,zoomOnScroll:I,zoomOnPinch:b,panOnScroll:S,panOnScrollSpeed:M,panOnScrollMode:H,zoomOnDoubleClick:F,panOnDrag:Y,onPaneClick:V,onPaneMouseEnter:O,onPaneMouseMove:X,onPaneMouseLeave:G,onPaneScroll:B,onPaneContextMenu:W,paneClickDistance:Z,nodeClickDistance:U,onEdgeContextMenu:K,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,onReconnect:vn,onReconnectStart:bn,onReconnectEnd:Nn,noDragClassName:nt,noWheelClassName:_n,noPanClassName:rt,disableKeyboardA11y:st,nodeExtent:En,rfId:it,viewport:ot,onViewportChange:$t}){return Ms(e),Ms(t),z0(),N0(n),E0(ot),h.jsx(Gh,{onPaneClick:V,onPaneMouseEnter:O,onPaneMouseMove:X,onPaneMouseLeave:G,onPaneContextMenu:W,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:z,selectionKeyCode:E,selectionOnDrag:v,selectionMode:w,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:R,zoomActivationKeyCode:j,elementsSelectable:P,zoomOnScroll:I,zoomOnPinch:b,zoomOnDoubleClick:F,panOnScroll:S,panOnScrollSpeed:M,panOnScrollMode:H,panOnDrag:Y,defaultViewport:L,translateExtent:T,minZoom:D,maxZoom:x,onSelectionContextMenu:f,preventScrolling:k,noDragClassName:nt,noWheelClassName:_n,noPanClassName:rt,disableKeyboardA11y:st,onViewportChange:$t,isControlledViewport:!!ot,children:h.jsxs(b0,{children:[h.jsx(w0,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:vn,onReconnectStart:bn,onReconnectEnd:Nn,onlyRenderVisibleElements:A,onEdgeContextMenu:K,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,defaultMarkerColor:_,noPanClassName:rt,disableKeyboardA11y:st,rfId:it}),h.jsx(M0,{style:m,type:g,component:N,containerStyle:y}),h.jsx("div",{className:"react-flow__edgelabel-renderer"}),h.jsx(n0,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:U,onlyRenderVisibleElements:A,noPanClassName:rt,noDragClassName:nt,disableKeyboardA11y:st,nodeExtent:En,rfId:it}),h.jsx("div",{className:"react-flow__viewport-portal"})]})})}_o.displayName="GraphView";const I0=$.memo(_o),$s=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}={})=>{const l=new Map,u=new Map,f=new Map,d=new Map,p=r??t??[],g=n??e??[],m=a??[0,0],N=c??vt;Pi(f,d,p),tr(g,l,u,{nodeOrigin:m,nodeExtent:N,elevateNodesOnSelect:!1});let y=[0,0,1];if(o&&s&&i){const E=Ct(l,{filter:R=>!!((R.width||R.initialWidth)&&(R.height||R.initialHeight))}),{x:v,y:w,zoom:C}=hr(E,s,i,.5,2,.1);y=[v,w,C]}return{rfId:"1",width:0,height:0,transform:y,nodes:g,nodeLookup:l,parentLookup:u,edges:p,edgeLookup:d,connectionLookup:f,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:vt,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:m,nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connection:{...mi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanSpeed:15,connectionRadius:20,onError:Rd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},A0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c})=>Uf((l,u)=>({...$s({nodes:e,edges:t,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c,defaultNodes:n,defaultEdges:r}),setNodes:f=>{const{nodeLookup:d,parentLookup:p,nodeOrigin:g,elevateNodesOnSelect:m}=u();tr(f,d,p,{nodeOrigin:g,nodeExtent:c,elevateNodesOnSelect:m,checkEquality:!0}),l({nodes:f})},setEdges:f=>{const{connectionLookup:d,edgeLookup:p}=u();Pi(d,p,f),l({edges:f})},setDefaultNodesAndEdges:(f,d)=>{if(f){const{setNodes:p}=u();p(f),l({hasDefaultNodes:!0})}if(d){const{setEdges:p}=u();p(d),l({hasDefaultEdges:!0})}},updateNodeInternals:(f,d={triggerFitView:!0})=>{const{triggerNodeChanges:p,nodeLookup:g,parentLookup:m,fitViewOnInit:N,fitViewDone:y,fitViewOnInitOptions:E,domNode:v,nodeOrigin:w,nodeExtent:C,debug:R,fitViewSync:j}=u(),{changes:z,updatedInternals:A}=Jd(f,g,m,v,w,C);if(A){if(Ud(g,m,{nodeOrigin:w,nodeExtent:C}),d.triggerFitView){let P=y;!y&&N&&(P=j({...E,nodes:E==null?void 0:E.nodes})),l({fitViewDone:P})}else l({});(z==null?void 0:z.length)>0&&(R&&console.log("React Flow: trigger node changes",z),p==null||p(z))}},updateNodePositions:(f,d=!1)=>{const p=[],g=[];for(const[m,N]of f){const y=!!(N!=null&&N.expandParent&&(N!=null&&N.parentId)&&(N!=null&&N.position)),E={id:m,type:"position",position:y?{x:Math.max(0,N.position.x),y:Math.max(0,N.position.y)}:N.position,dragging:d};y&&p.push({id:m,parentId:N.parentId,rect:{...N.internals.positionAbsolute,width:N.measured.width,height:N.measured.height}}),g.push(E)}if(p.length>0){const{nodeLookup:m,parentLookup:N,nodeOrigin:y}=u(),E=xr(p,m,N,y);g.push(...E)}u().triggerNodeChanges(g)},triggerNodeChanges:f=>{const{onNodesChange:d,setNodes:p,nodes:g,hasDefaultNodes:m,debug:N}=u();if(f!=null&&f.length){if(m){const y=xh(f,g);p(y)}N&&console.log("React Flow: trigger node changes",f),d==null||d(f)}},triggerEdgeChanges:f=>{const{onEdgesChange:d,setEdges:p,edges:g,hasDefaultEdges:m,debug:N}=u();if(f!=null&&f.length){if(m){const y=yh(f,g);p(y)}N&&console.log("React Flow: trigger edge changes",f),d==null||d(f)}},addSelectedNodes:f=>{const{multiSelectionActive:d,edgeLookup:p,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:N}=u();if(d){const y=f.map(E=>Te(E,!0));m(y);return}m(Ye(g,new Set([...f]),!0)),N(Ye(p))},addSelectedEdges:f=>{const{multiSelectionActive:d,edgeLookup:p,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:N}=u();if(d){const y=f.map(E=>Te(E,!0));N(y);return}N(Ye(p,new Set([...f]))),m(Ye(g,new Set,!0))},unselectNodesAndEdges:({nodes:f,edges:d}={})=>{const{edges:p,nodes:g,nodeLookup:m,triggerNodeChanges:N,triggerEdgeChanges:y}=u(),E=f||g,v=d||p,w=E.map(R=>{const j=m.get(R.id);return j&&(j.selected=!1),Te(R.id,!1)}),C=v.map(R=>Te(R.id,!1));N(w),y(C)},setMinZoom:f=>{const{panZoom:d,maxZoom:p}=u();d==null||d.setScaleExtent([f,p]),l({minZoom:f})},setMaxZoom:f=>{const{panZoom:d,minZoom:p}=u();d==null||d.setScaleExtent([p,f]),l({maxZoom:f})},setTranslateExtent:f=>{var d;(d=u().panZoom)==null||d.setTranslateExtent(f),l({translateExtent:f})},setPaneClickDistance:f=>{var d;(d=u().panZoom)==null||d.setClickDistance(f)},resetSelectedElements:()=>{const{edges:f,nodes:d,triggerNodeChanges:p,triggerEdgeChanges:g}=u(),m=d.reduce((y,E)=>E.selected?[...y,Te(E.id,!1)]:y,[]),N=f.reduce((y,E)=>E.selected?[...y,Te(E.id,!1)]:y,[]);p(m),g(N)},setNodeExtent:f=>{const{nodes:d,nodeLookup:p,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:N,nodeExtent:y}=u();f[0][0]===y[0][0]&&f[0][1]===y[0][1]&&f[1][0]===y[1][0]&&f[1][1]===y[1][1]||(tr(d,p,g,{nodeOrigin:m,nodeExtent:f,elevateNodesOnSelect:N,checkEquality:!1}),l({nodeExtent:f}))},panBy:f=>{const{transform:d,width:p,height:g,panZoom:m,translateExtent:N}=u();return ef({delta:f,panZoom:m,transform:d,translateExtent:N,width:p,height:g})},fitView:f=>{const{panZoom:d,width:p,height:g,minZoom:m,maxZoom:N,nodeLookup:y}=u();if(!d)return Promise.resolve(!1);const E=Kn(y,f);return Un({nodes:E,width:p,height:g,panZoom:d,minZoom:m,maxZoom:N},f)},fitViewSync:f=>{const{panZoom:d,width:p,height:g,minZoom:m,maxZoom:N,nodeLookup:y}=u();if(!d)return!1;const E=Kn(y,f);return Un({nodes:E,width:p,height:g,panZoom:d,minZoom:m,maxZoom:N},f),E.size>0},cancelConnection:()=>{l({connection:{...mi}})},updateConnection:f=>{l({connection:f})},reset:()=>l({...$s()})}),Object.is);function P0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:o,nodeOrigin:a,nodeExtent:c,children:l}){const[u]=$.useState(()=>A0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}));return h.jsx(Zf,{value:u,children:h.jsx(Nh,{children:l})})}function T0({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:o,fitView:a,nodeOrigin:c,nodeExtent:l}){return $.useContext(xn)?h.jsx(h.Fragment,{children:e}):h.jsx(P0,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:a,nodeOrigin:c,nodeExtent:l,children:e})}const D0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function R0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onConnect:p,onConnectStart:g,onConnectEnd:m,onClickConnectStart:N,onClickConnectEnd:y,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:R,onNodeDragStart:j,onNodeDrag:z,onNodeDragStop:A,onNodesDelete:P,onEdgesDelete:L,onDelete:T,onSelectionChange:D,onSelectionDragStart:x,onSelectionDrag:k,onSelectionDragStop:_,onSelectionContextMenu:I,onSelectionStart:b,onSelectionEnd:S,onBeforeDelete:M,connectionMode:H,connectionLineType:F=ze.Bezier,connectionLineStyle:Y,connectionLineComponent:V,connectionLineContainerStyle:O,deleteKeyCode:X="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:B=!1,selectionMode:W=bt.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:U=nn()?"Meta":"Control",zoomActivationKeyCode:K=nn()?"Meta":"Control",snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ke,nodesDraggable:vn,nodesConnectable:bn,nodesFocusable:Nn,nodeOrigin:nt=Zi,edgesFocusable:_n,edgesReconnectable:rt,elementsSelectable:st=!0,defaultViewport:En=uh,minZoom:it=.5,maxZoom:ot=2,translateExtent:$t=vt,preventScrolling:$o=!0,nodeExtent:Sn,defaultMarkerColor:zo="#b1b1b7",zoomOnScroll:Io=!0,zoomOnPinch:Ao=!0,panOnScroll:Po=!1,panOnScrollSpeed:To=.5,panOnScrollMode:Do=He.Free,zoomOnDoubleClick:Ro=!0,panOnDrag:Ho=!0,onPaneClick:Lo,onPaneMouseEnter:Fo,onPaneMouseMove:Bo,onPaneMouseLeave:Vo,onPaneScroll:Oo,onPaneContextMenu:Xo,paneClickDistance:br=0,nodeClickDistance:Yo=0,children:qo,onReconnect:Wo,onReconnectStart:Go,onReconnectEnd:Ko,onEdgeContextMenu:Uo,onEdgeDoubleClick:Zo,onEdgeMouseEnter:Qo,onEdgeMouseMove:Jo,onEdgeMouseLeave:ea,reconnectRadius:ta=10,onNodesChange:na,onEdgesChange:ra,noDragClassName:sa="nodrag",noWheelClassName:ia="nowheel",noPanClassName:Nr="nopan",fitView:_r,fitViewOptions:oa,connectOnClick:aa,attributionPosition:ca,proOptions:la,defaultEdgeOptions:ua,elevateNodesOnSelect:da,elevateEdgesOnSelect:fa,disableKeyboardA11y:Er=!1,autoPanOnConnect:ha,autoPanOnNodeDrag:pa,autoPanSpeed:ga,connectionRadius:ma,isValidConnection:xa,onError:ya,style:wa,id:Sr,nodeDragThreshold:va,viewport:ba,onViewportChange:Na,width:_a,height:Ea,colorMode:Sa="light",debug:ka,...ja},Ca){const kn=Sr||"1",Ma=ph(Sa);return h.jsx("div",{"data-testid":"rf__wrapper",...ja,style:{...wa,...D0},ref:Ca,className:se(["react-flow",s,Ma]),id:Sr,children:h.jsxs(T0,{nodes:e,edges:t,width:_a,height:Ea,fitView:_r,nodeOrigin:nt,nodeExtent:Sn,children:[h.jsx(I0,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:R,nodeTypes:i,edgeTypes:o,connectionLineType:F,connectionLineStyle:Y,connectionLineComponent:V,connectionLineContainerStyle:O,selectionKeyCode:G,selectionOnDrag:B,selectionMode:W,deleteKeyCode:X,multiSelectionKeyCode:U,panActivationKeyCode:Z,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:En,translateExtent:$t,minZoom:it,maxZoom:ot,preventScrolling:$o,zoomOnScroll:Io,zoomOnPinch:Ao,zoomOnDoubleClick:Ro,panOnScroll:Po,panOnScrollSpeed:To,panOnScrollMode:Do,panOnDrag:Ho,onPaneClick:Lo,onPaneMouseEnter:Fo,onPaneMouseMove:Bo,onPaneMouseLeave:Vo,onPaneScroll:Oo,onPaneContextMenu:Xo,paneClickDistance:br,nodeClickDistance:Yo,onSelectionContextMenu:I,onSelectionStart:b,onSelectionEnd:S,onReconnect:Wo,onReconnectStart:Go,onReconnectEnd:Ko,onEdgeContextMenu:Uo,onEdgeDoubleClick:Zo,onEdgeMouseEnter:Qo,onEdgeMouseMove:Jo,onEdgeMouseLeave:ea,reconnectRadius:ta,defaultMarkerColor:zo,noDragClassName:sa,noWheelClassName:ia,noPanClassName:Nr,rfId:kn,disableKeyboardA11y:Er,nodeExtent:Sn,viewport:ba,onViewportChange:Na}),h.jsx(hh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:g,onConnectEnd:m,onClickConnectStart:N,onClickConnectEnd:y,nodesDraggable:vn,nodesConnectable:bn,nodesFocusable:Nn,edgesFocusable:_n,edgesReconnectable:rt,elementsSelectable:st,elevateNodesOnSelect:da,elevateEdgesOnSelect:fa,minZoom:it,maxZoom:ot,nodeExtent:Sn,onNodesChange:na,onEdgesChange:ra,snapToGrid:J,snapGrid:ee,connectionMode:H,translateExtent:$t,connectOnClick:aa,defaultEdgeOptions:ua,fitView:_r,fitViewOptions:oa,onNodesDelete:P,onEdgesDelete:L,onDelete:T,onNodeDragStart:j,onNodeDrag:z,onNodeDragStop:A,onSelectionDrag:k,onSelectionDragStart:x,onSelectionDragStop:_,onMove:u,onMoveStart:f,onMoveEnd:d,noPanClassName:Nr,nodeOrigin:nt,rfId:kn,autoPanOnConnect:ha,autoPanOnNodeDrag:pa,autoPanSpeed:ga,onError:ya,connectionRadius:ma,isValidConnection:xa,selectNodesOnDrag:ke,nodeDragThreshold:va,onBeforeDelete:M,paneClickDistance:br,debug:ka}),h.jsx(lh,{onSelectionChange:D}),qo,h.jsx(sh,{proOptions:la,position:ca}),h.jsx(nh,{rfId:kn,disableKeyboardA11y:Er})]})})}var H0=Ji(R0);function L0({dimensions:e,lineWidth:t,variant:n,className:r}){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,r])})}function F0({radius:e,className:t}){return h.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(be||(be={}));const B0={[be.Dots]:1,[be.Lines]:1,[be.Cross]:6},V0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Eo({id:e,variant:t=be.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:o,bgColor:a,style:c,className:l,patternClassName:u}){const f=$.useRef(null),{transform:d,patternId:p}=Q(V0,re),g=r||B0[t],m=t===be.Dots,N=t===be.Cross,y=Array.isArray(n)?n:[n,n],E=[y[0]*d[2]||1,y[1]*d[2]||1],v=g*d[2],w=Array.isArray(i)?i:[i,i],C=N?[v,v]:E,R=[w[0]*d[2]||1+C[0]/2,w[1]*d[2]||1+C[1]/2],j=`${p}${e||""}`;return h.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...yn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:f,"data-testid":"rf__background",children:[h.jsx("pattern",{id:j,x:d[0]%E[0],y:d[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${R[0]},-${R[1]})`,children:m?h.jsx(F0,{radius:v/2,className:u}):h.jsx(L0,{dimensions:C,lineWidth:s,variant:t,className:u})}),h.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}Eo.displayName="Background";const O0=$.memo(Eo);function X0(){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 Y0(){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 q0(){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 W0(){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 G0(){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 Lt({children:e,className:t,...n}){return h.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const K0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function So({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:c,className:l,children:u,position:f="bottom-left",orientation:d="vertical","aria-label":p="React Flow controls"}){const g=te(),{isInteractive:m,minZoomReached:N,maxZoomReached:y}=Q(K0,re),{zoomIn:E,zoomOut:v,fitView:w}=wr(),C=()=>{E(),i==null||i()},R=()=>{v(),o==null||o()},j=()=>{w(s),a==null||a()},z=()=>{g.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),c==null||c(!m)},A=d==="horizontal"?"horizontal":"vertical";return h.jsxs(yr,{className:se(["react-flow__controls",A,l]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[t&&h.jsxs(h.Fragment,{children:[h.jsx(Lt,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y,children:h.jsx(X0,{})}),h.jsx(Lt,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:N,children:h.jsx(Y0,{})})]}),n&&h.jsx(Lt,{className:"react-flow__controls-fitview",onClick:j,title:"fit view","aria-label":"fit view",children:h.jsx(q0,{})}),r&&h.jsx(Lt,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity",children:m?h.jsx(G0,{}):h.jsx(W0,{})}),u]})}So.displayName="Controls";const U0=$.memo(So);function Z0({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:f,selected:d,onClick:p}){const{background:g,backgroundColor:m}=i||{},N=o||g||m;return h.jsx("rect",{className:se(["react-flow__minimap-node",{selected:d},l]),x:t,y:n,rx:u,ry:u,width:r,height:s,style:{fill:N,stroke:a,strokeWidth:c},shapeRendering:f,onClick:p?y=>p(y,e):void 0})}const Q0=$.memo(Z0),J0=e=>e.nodes.map(t=>t.id),Hn=e=>e instanceof Function?e:()=>e;function ep({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=Q0,onClick:o}){const a=Q(J0,re),c=Hn(t),l=Hn(e),u=Hn(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return h.jsx(h.Fragment,{children:a.map(d=>h.jsx(np,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:f},d))})}function tp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:a,onClick:c}){const{node:l,x:u,y:f,width:d,height:p}=Q(g=>{const m=g.nodeLookup.get(e),{x:N,y}=m.internals.positionAbsolute,{width:E,height:v}=Se(m);return{node:m,x:N,y,width:E,height:v}},re);return!l||l.hidden||!Si(l)?null:h.jsx(a,{x:u,y:f,width:d,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:s,strokeColor:n(l),strokeWidth:i,shapeRendering:o,onClick:c,id:l.id})}const np=$.memo(tp);var rp=$.memo(ep);const sp=200,ip=150,op=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?_i(Ct(e.nodeLookup),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}},ap="react-flow__minimap-desc";function ko({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:f,position:d="bottom-right",onClick:p,onNodeClick:g,pannable:m=!1,zoomable:N=!1,ariaLabel:y="React Flow mini map",inversePan:E,zoomStep:v=10,offsetScale:w=5}){const C=te(),R=$.useRef(null),{boundingRect:j,viewBB:z,rfId:A,panZoom:P,translateExtent:L,flowWidth:T,flowHeight:D}=Q(op,re),x=(e==null?void 0:e.width)??sp,k=(e==null?void 0:e.height)??ip,_=j.width/x,I=j.height/k,b=Math.max(_,I),S=b*x,M=b*k,H=w*b,F=j.x-(S-j.width)/2-H,Y=j.y-(M-j.height)/2-H,V=S+H*2,O=M+H*2,X=`${ap}-${A}`,G=$.useRef(0),B=$.useRef();G.current=b,$.useEffect(()=>{if(R.current&&P)return B.current=lf({domNode:R.current,panZoom:P,getTransform:()=>C.getState().transform,getViewScale:()=>G.current}),()=>{var U;(U=B.current)==null||U.destroy()}},[P]),$.useEffect(()=>{var U;(U=B.current)==null||U.update({translateExtent:L,width:T,height:D,inversePan:E,pannable:m,zoomStep:v,zoomable:N})},[m,N,E,v,L,T,D]);const W=p?U=>{var ee;const[K,J]=((ee=B.current)==null?void 0:ee.pointer(U))||[0,0];p(U,{x:K,y:J})}:void 0,Z=g?$.useCallback((U,K)=>{const J=C.getState().nodeLookup.get(K);g(U,J)},[]):void 0;return h.jsx(yr,{position:d,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 u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*b:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="string"?o:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:h.jsxs("svg",{width:x,height:k,viewBox:`${F} ${Y} ${V} ${O}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:R,onClick:W,children:[y&&h.jsx("title",{id:X,children:y}),h.jsx(rp,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),h.jsx("path",{className:"react-flow__minimap-mask",d:`M${F-H},${Y-H}h${V+H*2}v${O+H*2}h${-V-H*2}z
23
- M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ko.displayName="MiniMap";$.memo(ko);function cp({nodeId:e,position:t,variant:n=ht.Handle,className:r,style:s={},children:i,color:o,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,shouldResize:d,onResizeStart:p,onResize:g,onResizeEnd:m}){const N=ro(),y=typeof e=="string"?e:N,E=te(),v=$.useRef(null),w=n===ht.Line?"right":"bottom-right",C=t??w,R=$.useRef(null);$.useEffect(()=>{if(!(!v.current||!y))return R.current||(R.current=Ef({domNode:v.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:x,domNode:k}=E.getState();return{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:x,paneDomNode:k}},onChange:(P,L)=>{const{triggerNodeChanges:T,nodeLookup:D,parentLookup:x,nodeOrigin:k}=E.getState(),_=[],I={x:P.x,y:P.y},b=D.get(y);if(b&&b.expandParent&&b.parentId){const S=b.origin??k,M=P.width??b.measured.width,H=P.height??b.measured.height,F={id:b.id,parentId:b.parentId,rect:{width:M,height:H,...ki({x:P.x??b.position.x,y:P.y??b.position.y},{width:M,height:H},b.parentId,D,S)}},Y=xr([F],D,x,k);_.push(...Y),I.x=P.x?Math.max(S[0]*M,P.x):void 0,I.y=P.y?Math.max(S[1]*H,P.y):void 0}if(I.x!==void 0&&I.y!==void 0){const S={id:y,type:"position",position:{...I}};_.push(S)}if(P.width!==void 0&&P.height!==void 0){const S={id:y,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:P.width,height:P.height}};_.push(S)}for(const S of L){const M={...S,type:"position"};_.push(M)}T(_)},onEnd:()=>{const P={id:y,type:"dimensions",resizing:!1};E.getState().triggerNodeChanges([P])}})),R.current.update({controlPosition:C,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:f,onResizeStart:p,onResize:g,onResizeEnd:m,shouldResize:d}),()=>{var P;(P=R.current)==null||P.destroy()}},[C,a,c,l,u,f,p,g,m,d]);const j=C.split("-"),z=n===ht.Line?"borderColor":"backgroundColor",A=o?{...s,[z]:o}:s;return h.jsx("div",{className:se(["react-flow__resize-control","nodrag",...j,n,r]),ref:v,style:A,children:i})}$.memo(cp);const lp=new Set;function up(e){return e.startsWith("signal:child:")}function dp(e){const t=sn(),n=(()=>{const i=new Set(e),o=[...e];for(;o.length>0;){const a=o.shift();if(a===void 0)continue;const c=t.getQueryData(["run",a]);if(c!==void 0)for(const l of c.timeline){const u=Yt(l);u!==void 0&&!i.has(u)&&(i.add(u),o.push(u))}}return[...i].sort()})(),r=Fa({queries:n.map(i=>({queryKey:["run",i],queryFn:()=>ue.run(i)}))}),s={};return n.forEach((i,o)=>{var c;const a=(c=r[o])==null?void 0:c.data;a&&(s[i]=a)}),s}function fp({data:e}){const t=e.status==="failed",n=e.status==="pending"||e.status==="running",r=!!e.childRunId,s=!!e.collapsed,i=r&&!s,o=i?Va:Ps(e.kind),a=t?{rail:"bg-red-400",badge:"bg-red-500/15 text-red-300",pill:"bg-red-500/20 text-red-300"}:n?{rail:"bg-amber-400",badge:"bg-amber-500/15 text-amber-300",pill:"bg-amber-500/20 text-amber-300"}:{rail:"bg-emerald-400",badge:"bg-emerald-500/15 text-emerald-300",pill:"bg-emerald-500/20 text-emerald-300"};return h.jsxs("div",{title:i?Ln.child:Ln[e.kind]??e.kind,className:`group relative w-[208px] cursor-pointer overflow-hidden rounded-xl border bg-[var(--panel)]/95 shadow-lg backdrop-blur transition-all duration-150 hover:-translate-y-0.5 ${e.selected?"border-emerald-400/60 ring-2 ring-emerald-400/30":t?"border-red-500/40 hover:border-red-400/60":i?"border-indigo-500/40 hover:border-indigo-400/60":"border-[var(--line)] hover:border-zinc-600"}`,children:[h.jsx("span",{className:`absolute inset-y-0 left-0 w-[3px] ${a.rail} ${n?"animate-pulse":""}`}),h.jsx(Pe,{type:"target",position:q.Left,className:"!border-0 !bg-zinc-600"}),h.jsxs("div",{className:"py-2.5 pl-3.5 pr-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`grid h-5 w-5 shrink-0 place-items-center rounded ${a.badge}`,children:h.jsx(o,{width:12,height:12})}),h.jsx("span",{className:"truncate text-[13px] font-medium text-zinc-100",children:e.name}),h.jsx("span",{className:`ml-auto grid h-4 w-4 shrink-0 place-items-center rounded-full ${a.pill} ${n?"animate-pulse":""}`,children:t?h.jsx(Ge,{width:9,height:9}):n?h.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}):h.jsx(Ds,{width:9,height:9})})]}),h.jsxs("div",{className:"mono mt-1.5 flex items-center gap-1.5 text-[10px] text-zinc-500",children:[r?h.jsxs("span",{className:"flex items-center gap-1",children:[!s&&h.jsx("button",{type:"button",onClick:c=>{var l;c.stopPropagation(),e.childRunId&&((l=e.onToggleChild)==null||l.call(e,e.childRunId))},title:e.childExpanded?"Collapse child flow":"Expand child flow inline",className:"grid h-4 w-4 place-items-center rounded border border-indigo-500/30 bg-indigo-500/10 text-indigo-300 transition-colors hover:border-indigo-400/60 hover:bg-indigo-500/20 hover:text-indigo-200",children:h.jsx("span",{className:"inline-block text-[9px] transition-transform",style:{transform:e.childExpanded?"rotate(90deg)":"rotate(0deg)"},children:"▸"})}),h.jsx("button",{type:"button",onClick:c=>{var l;c.stopPropagation(),e.childRunId&&((l=e.onOpenRun)==null||l.call(e,e.childRunId))},title:"Open the child run",className:"rounded border border-indigo-500/30 bg-indigo-500/10 px-1 text-indigo-300 transition-colors hover:border-indigo-400/60 hover:bg-indigo-500/20 hover:text-indigo-200",children:"child ↗"})]}):h.jsx("span",{className:"rounded border border-[var(--line)] px-1 text-zinc-400",children:e.kind}),e.attempts>1&&h.jsxs("span",{className:"flex items-center gap-0.5 text-amber-300",children:[h.jsx(Ts,{width:9,height:9}),e.attempts]}),e.workerGroup&&h.jsxs("span",{className:"truncate",children:["@",e.workerGroup]}),h.jsxs("span",{className:"tnum ml-auto text-zinc-400",children:["#",e.seq,e.duration&&h.jsxs("span",{className:"text-zinc-600",children:[" · ",e.duration]})]})]}),e.subs&&h.jsxs("div",{className:"mono mt-1.5 flex items-center gap-2 border-t border-[var(--line)] pt-1.5 text-[10px]",children:[e.subs.ok>0&&h.jsxs("span",{className:"text-emerald-300",children:[e.subs.ok," ok"]}),e.subs.failed>0&&h.jsxs("span",{className:"text-red-300",children:[e.subs.failed," failed"]}),e.subs.skipped>0&&h.jsxs("span",{className:"text-amber-300",children:[e.subs.skipped," skipped"]})]})]}),h.jsx(Pe,{type:"source",position:q.Right,className:"!border-0 !bg-zinc-600"})]})}function hp({data:e}){const t=e.status==="running"||e.status==="awaiting";return h.jsxs("div",{className:`s-${e.status} flex items-center gap-2 rounded-full border border-current/30 bg-[var(--panel)] px-3.5 py-1.5`,children:[h.jsx(Pe,{type:"target",position:q.Left,className:"!border-0 !bg-zinc-600"}),h.jsx("span",{className:`dot ${t?"pulse":""}`}),h.jsx("span",{className:"mono text-[11px] uppercase tracking-wider",children:e.label}),h.jsx(Pe,{type:"source",position:q.Right,className:"!border-0 !bg-zinc-600"})]})}const pp={step:fp,terminal:hp};function gp(e){var n;const t=(n=e.events)==null?void 0:n.filter(r=>r.status);if(!(!t||t.length===0))return{ok:t.filter(r=>r.status==="ok").length,failed:t.filter(r=>r.status==="failed").length,skipped:t.filter(r=>r.status==="skipped").length}}function mp({run:e,timeline:t,selectedKey:n,onSelect:r,onOpenRun:s,fmtDuration:i,expanded:o,onToggleChild:a}){const c=o??lp,l=$.useMemo(()=>{const g=new Set(c);for(const m of t){const N=Yt(m);N!==void 0&&g.add(N)}return g},[c,t]),u=dp(l),{nodes:f,edges:d}=(()=>{const y=[],E=[],v=e.status==="running"||e.status==="suspended",w=(T,D,x)=>({id:`${T}->${D}`,source:T,target:D,style:{stroke:x?"#f87171":"var(--line)",strokeWidth:1.5}}),C=(T,D)=>({id:`${T}=>${D}`,source:T,target:D,style:{stroke:"#818cf8",strokeWidth:1.5,strokeDasharray:"4 3"}});function R(T,D,x,k,_,I){const b=`${_}s${T.seq}`,S=Yt(T),M=S!==void 0?u[S]:void 0,H=M!==void 0&&M.timeline.length===1&&M.timeline[0]?{step:M.timeline[0],run:M.run}:void 0,F=H!==void 0,Y=!F&&S!==void 0&&c.has(S),V=H?H.step:T,O=H?H.run:I,X=H?H.step.name:S!==void 0?(M==null?void 0:M.run.workflow)??"child workflow":T.name,G=V.status==="failed";y.push({id:b,type:"step",draggable:!1,position:{x:D,y:x},data:{seq:V.seq,name:X,kind:V.kind,status:V.status,workerGroup:V.workerGroup,attempts:V.attempts,duration:i(V.startedAt,V.finishedAt),subs:gp(V),selected:n===`${V.runId}#${V.seq}`,childRunId:S,onOpenRun:s,childExpanded:Y,onToggleChild:a,collapsed:F,depth:k,step:V,laneRun:O}});const B=Y?M:void 0;if(B){const W=j(B.timeline,k+1,D+248,x+150,`${S}:`,B.run);for(const U of W.firstIds)E.push(C(b,U));const Z=up(T.name)&&W.connectors.length>0?W.connectors:[{id:b,failed:G}];return{id:b,exits:Z,nextX:Math.max(D+248,W.nextX),bottomY:Math.max(x,W.bottomY)}}return{id:b,exits:[{id:b,failed:G}],nextX:D+248,bottomY:x}}function j(T,D,x,k,_,I){let b=x;const S=[];let M=[],H=k;for(const F of Ba(T)){const Y=F.kind==="single"?[F.step]:F.steps,V=S.length===0,O=[];let X=k,G=b;for(const B of Y){const W=R(B,b,X,D,_,I);V&&S.push(W.id);for(const Z of M)E.push(w(Z.id,W.id,Z.failed));O.push(...W.exits),G=Math.max(G,W.nextX),X=W.bottomY+96}M=O,b=G,H=Math.max(H,X-96)}return{firstIds:S,connectors:M,nextX:b,bottomY:H}}const z=248;y.push({id:"start",type:"terminal",position:{x:0,y:0},draggable:!1,data:{status:"running",label:e.workflow}});const A=j(t,0,z,0,"",e);for(const T of A.firstIds)E.push({id:`start->${T}`,source:"start",target:T});const P=sr(e,t);y.push({id:"end",type:"terminal",position:{x:Math.max(A.nextX,z),y:0},draggable:!1,data:{status:P,label:P}});const L=A.connectors.length>0?A.connectors:[{id:"start",failed:!1}];for(const T of L)E.push({id:`${T.id}->end`,source:T.id,target:"end",animated:v,style:{stroke:v?"var(--accent)":"var(--line)",strokeWidth:v?2:1.5}});return{nodes:y,edges:E}})(),p=$.useCallback((g,m)=>{if(m.type!=="step")return;const N=m.data;N.step&&N.laneRun&&r(N.step,N.laneRun)},[r]);return h.jsxs(H0,{nodes:f,edges:d,nodeTypes:pp,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.3,maxZoom:1.1},proOptions:{hideAttribution:!0},nodesConnectable:!1,nodesDraggable:!1,panOnScroll:!0,minZoom:.3,children:[h.jsx(O0,{variant:be.Dots,gap:22,size:1,color:"#1c1c22"}),h.jsx(U0,{showInteractive:!1,position:"bottom-right"})]})}function jo({className:e}){return h.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img","aria-label":"durable",children:[h.jsx("title",{children:"durable"}),h.jsx("path",{d:"M12 2.5 21.5 12 12 21.5 2.5 12z",opacity:.35}),h.jsx("circle",{cx:"6.4",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("circle",{cx:"12",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("circle",{cx:"17.6",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("path",{d:"M8.1 12h2.2M13.7 12h2.2"})]})}const xp=["pending","running","suspended","completed","failed","cancelling","cancelled","dead"];function yp(e){const t=Date.now()-new Date(e).getTime(),n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function wp(e,t){const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${(n/6e4).toFixed(1)}m`}function Co({status:e}){const t=e==="running"||e==="awaiting"||e==="cancelling";return h.jsx("span",{className:`dot s-${e} ${t?"pulse":""}`,"aria-hidden":!0})}function Mo({status:e}){return h.jsxs("span",{className:`s-${e} inline-flex items-center gap-1.5 text-[11px] uppercase tracking-wider`,children:[h.jsx(Co,{status:e}),e]})}function vp({counts:e,filter:t,onFilter:n}){const r=Object.values(e).reduce((i,o)=>i+o,0),s=(i,o,a)=>h.jsxs("button",{type:"button",onClick:()=>n(i),className:`group flex items-center gap-2 rounded-md border px-2.5 py-1 text-xs transition-colors ${t===i?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:[i!=="all"&&h.jsx(Co,{status:i}),h.jsx("span",{className:"uppercase tracking-wide",children:o}),h.jsx("span",{className:"mono tnum text-zinc-600",children:a})]},i);return h.jsxs("header",{className:"z-10 flex items-center gap-4 border-b border-[var(--line)] px-5 py-3",children:[h.jsxs("div",{className:"flex items-center gap-2.5",children:[h.jsx("div",{className:"grid h-7 w-7 place-items-center rounded-md border border-emerald-500/30 bg-emerald-500/10",children:h.jsx(jo,{className:"h-4 w-4 text-emerald-400"})}),h.jsxs("div",{className:"leading-none",children:[h.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"durable"}),h.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"control plane"})]})]}),h.jsxs("div",{className:"ml-2 flex flex-wrap items-center gap-1",children:[s("all","all",r),xp.map(i=>s(i,i,e[i]??0))]}),h.jsx(_p,{}),h.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[h.jsx("span",{className:"dot s-completed pulse","aria-hidden":!0}),"live"]})]})}function bp(e){const t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;const n=Math.round(t/60);if(n<60)return`${n}m ago`;const r=Math.round(n/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function Np({workers:e}){return h.jsx("div",{className:"flex flex-col divide-y divide-[var(--line-soft)]",children:e.map(t=>{const n=t.status,r=n==null?void 0:n.concurrency,s=n&&r?`${n.inFlight}/${r.limit}`:"—",i=!!(n&&r&&r.limit>0&&n.inFlight>=r.limit*.8);return h.jsxs("div",{className:"flex flex-col gap-1 px-2.5 py-2",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"mono truncate text-[10px] text-zinc-400",children:t.instanceId}),r?h.jsx("span",{className:`mono shrink-0 rounded border px-1 text-[9px] uppercase tracking-wider ${r.mode==="adaptive"?"border-sky-500/40 bg-sky-500/10 text-sky-300":"border-zinc-600/50 bg-zinc-800/60 text-zinc-400"}`,children:r.mode==="adaptive"?`adaptive ${r.min??1}–${r.max??32}`:"fixed"}):h.jsx("span",{className:"mono shrink-0 text-[9px] text-zinc-600",children:"no status"})]}),n&&r&&h.jsxs("div",{className:"mono flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px] text-zinc-500",children:[h.jsxs("span",{className:i?"text-amber-300":"text-zinc-400",children:["in-flight ",h.jsx("span",{className:"tnum",children:s})]}),typeof n.rssPct=="number"&&h.jsxs("span",{className:n.rssPct>=85?"text-rose-300":"",children:["ram ",h.jsxs("span",{className:"tnum",children:[Math.round(n.rssPct),"%"]})]}),typeof n.cpuPct=="number"&&h.jsxs("span",{children:["cpu ",h.jsxs("span",{className:"tnum",children:[Math.round(n.cpuPct),"%"]})]}),typeof n.throughputPerMin=="number"&&h.jsxs("span",{children:[h.jsx("span",{className:"tnum",children:Math.round(n.throughputPerMin)}),"/min"]}),typeof n.p95Ms=="number"&&h.jsxs("span",{children:["p95 ",h.jsxs("span",{className:"tnum",children:[Math.round(n.p95Ms),"ms"]})]})]}),(n==null?void 0:n.lastAdjust)&&h.jsxs("div",{className:"mono text-[10px] text-zinc-500",children:[n.lastAdjust.reason," ",h.jsxs("span",{className:"tnum text-zinc-400",children:[n.lastAdjust.from,"→",n.lastAdjust.to]})," ",bp(n.lastAdjust.at)]})]},t.instanceId)})})}function _p(){const{data:e}=pt({queryKey:["workers"],queryFn:()=>ue.workers(),refetchInterval:1e4}),[t,n]=$.useState(void 0);return!e||e.length===0?null:h.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-1.5",children:e.map(r=>{const s=r.liveWorkers.length,i=r.depth>0&&s===0,o=t===r.group;return h.jsxs("div",{className:"relative",children:[h.jsxs("button",{type:"button",disabled:s===0,onClick:()=>n(o?void 0:r.group),title:`${r.group}: ${s} live worker(s), ${r.depth} queued${i?" — NO worker consuming":s>0?" — click for per-worker status":""}`,className:`mono flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${i?"border-rose-500/50 bg-rose-500/15 text-rose-300":o?"border-zinc-500 bg-zinc-800 text-zinc-200":"border-[var(--line)] bg-zinc-800/40 text-zinc-400"} ${s>0?"cursor-pointer hover:border-zinc-500":"cursor-default"}`,children:[h.jsx("span",{className:`dot ${i?"s-failed":s>0?"s-completed":""}`,"aria-hidden":!0}),r.group,h.jsxs("span",{className:"tnum text-zinc-500",children:[s,"w",r.depth>0?` ${r.depth}q`:""]})]}),o&&s>0&&h.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 w-72 rounded-md border border-[var(--line)] bg-zinc-950/95 shadow-xl backdrop-blur",children:[h.jsxs("div",{className:"mono flex items-center justify-between border-b border-[var(--line)] px-2.5 py-1.5 text-[10px] text-zinc-500",children:[h.jsx("span",{className:"text-zinc-300",children:r.group}),h.jsxs("span",{className:"tnum",children:[s," worker(s) · ",r.depth," queued"]})]}),h.jsx(Np,{workers:r.liveWorkers})]})]},r.group)})})}function Ep({runs:e,selected:t,onSelect:n,onSelectTag:r}){return e.length===0?h.jsx("div",{className:"p-6 text-sm text-zinc-600",children:"No runs yet."}):h.jsx("ul",{className:"divide-y divide-[var(--line-soft)]",children:e.map(s=>h.jsx("li",{children:h.jsxs("button",{type:"button",onClick:()=>n(s.id),className:`flex w-full flex-col gap-1 px-4 py-3 text-left transition-colors ${t===s.id?"bg-zinc-900":"hover:bg-zinc-900/50"}`,children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm font-medium text-zinc-200",children:s.workflow}),s.id.startsWith("dlq:")&&h.jsx("span",{className:"mono shrink-0 rounded border border-rose-500/40 bg-rose-500/10 px-1 text-[9px] uppercase tracking-wider text-rose-300",children:"dlq"})]}),h.jsx(Mo,{status:sr(s)})]}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"mono truncate text-[11px] text-zinc-600",children:s.id}),h.jsx("span",{className:"shrink-0 text-[11px] text-zinc-600",children:yp(s.updatedAt)})]}),s.tags&&s.tags.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map(i=>h.jsxs("span",{onClick:o=>{o.stopPropagation(),r(i)},className:"mono cursor-pointer rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400 hover:border-zinc-500 hover:text-zinc-200",children:["#",i]},i))})]})},s.id))})}function Sp({id:e,onOpenRun:t}){var _,I;const n=sn(),{data:r}=pt({queryKey:["run",e],queryFn:async()=>Ka(n.getQueryData(["run",e]),await ue.run(e)),refetchInterval:b=>{var M;const S=(M=b.state.data)==null?void 0:M.run.status;return S==="running"||S==="suspended"?1500:!1}}),s=(r==null?void 0:r.run.status)==="dead"?`dlq:${e}`:void 0,{data:i}=pt({queryKey:["run",s],queryFn:()=>ue.run(s),enabled:!!s,retry:!1}),o=()=>{n.invalidateQueries({queryKey:["run",e]}),n.invalidateQueries({queryKey:["runs"]})},a=r==null?void 0:r.run.status,c=a==="running"||a==="suspended";$.useEffect(()=>{if(c)return ue.streamRun(e,b=>{if(b.type==="step.progress"&&b.event&&b.seq!=null){const S=b.seq,M=b.event;n.setQueryData(["run",e],H=>H&&{...H,timeline:H.timeline.map(F=>F.seq===S?{...F,events:[...F.events??[],M]}:F)});return}n.invalidateQueries({queryKey:["run",e]})})},[e,c,n]);const l=lt({mutationFn:()=>ue.retry(e),onSuccess:o}),u=lt({mutationFn:b=>ue.cancel(e,b!==void 0?{compensate:b}:{}),onSuccess:o}),f=lt({mutationFn:()=>ue.continue(e),onSuccess:o}),d=lt({mutationFn:b=>ue.retryWithInput(e,b),onSuccess:b=>{n.invalidateQueries({queryKey:["runs"]}),t(b.runId)}}),p=()=>{const b=JSON.stringify((r==null?void 0:r.run.input)??{},null,2),S=window.prompt("Fix the input, then replay as a fresh run:",b);if(S!=null)try{d.mutate(JSON.parse(S))}catch{window.alert("Invalid JSON")}},[g,m]=$.useState(),[N,y]=$.useState(!1),[E,v]=$.useState(new Set),[w,C]=$.useState(240);function R(b){b.preventDefault(),b.currentTarget.setPointerCapture(b.pointerId);const S=H=>C(F=>Math.max(120,Math.min(720,F-H.movementY))),M=()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",M)};window.addEventListener("pointermove",S),window.addEventListener("pointerup",M)}function j(b){v(S=>{const M=new Set(S);return M.has(b)?M.delete(b):M.add(b),M})}if(!r)return h.jsx("div",{className:"p-8 text-sm text-zinc-600",children:"Loading run…"});const{run:z,timeline:A}=r,P=z.id.startsWith("dlq:"),L=P?{id:z.id.slice(4),title:"Dead-letter handler",subtitle:`started because run ${z.id.slice(4)} was dead-lettered`,cta:"open dead run →"}:i?{id:`dlq:${z.id}`,title:"Dead-lettered",subtitle:"this run exceeded recovery and was routed to a DLQ handler",cta:"open DLQ handler →"}:void 0,T=z.status==="failed"||z.status==="suspended",D=z.status==="running"||z.status==="suspended",x=A.some(b=>b.status==="pending"&&b.kind==="signal"&&b.name.startsWith("breakpoint")),k=g?`${g.step.runId}#${g.step.seq}`:void 0;return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--line)] px-7 py-5",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:z.workflow}),P&&h.jsx("span",{className:"mono rounded border border-rose-500/40 bg-rose-500/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-rose-300",children:"dlq"}),h.jsx(Mo,{status:sr(z,A)}),h.jsxs("span",{className:"mono rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] text-zinc-500",children:["v",z.workflowVersion]}),h.jsxs("span",{className:"mono tnum text-[11px] text-zinc-600",children:[A.length," ",A.length===1?"step":"steps"]})]}),h.jsx("div",{className:"mono mt-1 truncate text-[11px] text-zinc-600",children:z.id}),z.tags&&z.tags.length>0&&h.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:z.tags.map(b=>h.jsxs("span",{className:"mono rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400",children:["#",b]},b))}),z.searchAttributes&&Object.keys(z.searchAttributes).length>0&&h.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:Object.entries(z.searchAttributes).map(([b,S])=>h.jsxs("span",{className:"mono rounded border border-indigo-500/30 bg-indigo-500/10 px-1.5 text-[10px] text-indigo-300",title:"search attribute",children:[b,"=",String(S)]},b))}),(_=r==null?void 0:r.children)!=null&&_.length?h.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-zinc-600",children:"children:"}),(I=r.children)==null?void 0:I.map(b=>h.jsx("span",{onClick:()=>t(b),className:"mono cursor-pointer rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400 hover:border-zinc-500 hover:text-zinc-200",children:b},b))]}):null]}),h.jsxs("div",{className:"flex shrink-0 gap-2",children:[h.jsx("button",{type:"button",onClick:()=>y(!0),className:"mono rounded-md border border-[var(--line)] px-2.5 py-1.5 text-xs text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",title:"Run input / output",children:"{ }"}),x&&h.jsxs("button",{type:"button",disabled:f.isPending,onClick:()=>f.mutate(),className:"flex items-center gap-1.5 rounded-md border border-amber-500/40 bg-amber-500/15 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-amber-200 transition-colors enabled:hover:bg-amber-500/25 disabled:opacity-30",children:[h.jsx(Oa,{width:12,height:12}),"Continue"]}),h.jsxs("button",{type:"button",disabled:!T||l.isPending,onClick:()=>l.mutate(),className:"flex items-center gap-1.5 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-emerald-300 transition-colors enabled:hover:bg-emerald-500/20 disabled:opacity-30",children:[h.jsx(Cn,{width:12,height:12}),"Retry"]}),(z.status==="dead"||z.status==="failed")&&h.jsxs("button",{type:"button",disabled:d.isPending,onClick:p,title:"Edit the input and re-run as a fresh linked run",className:"flex items-center gap-1.5 rounded-md border border-indigo-500/30 bg-indigo-500/10 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-indigo-300 transition-colors enabled:hover:bg-indigo-500/20 disabled:opacity-30",children:[h.jsx(Cn,{width:12,height:12}),"Fix & replay"]}),D&&h.jsxs("button",{type:"button",disabled:u.isPending,onClick:()=>u.mutate(!0),title:"Cancel and run saga compensations (undo completed steps in reverse)",className:"flex items-center gap-1.5 rounded-md border border-amber-600/30 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-amber-300/90 transition-colors enabled:hover:bg-amber-900/20 disabled:opacity-30",children:[h.jsx(Cn,{width:12,height:12}),"Cancel + Undo"]}),h.jsxs("button",{type:"button",disabled:!D||u.isPending,onClick:()=>u.mutate(!1),className:"flex items-center gap-1.5 rounded-md border border-zinc-700 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-zinc-300 transition-colors enabled:hover:bg-zinc-800 disabled:opacity-30",children:[h.jsx(Ge,{width:12,height:12}),"Cancel"]})]})]}),L&&h.jsxs("div",{className:"flex items-center gap-3 border-b border-rose-500/30 bg-rose-500/10 px-7 py-3",children:[h.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-rose-500/40 bg-rose-500/15 text-sm text-rose-300","aria-hidden":!0,children:"⚠"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"text-[13px] font-medium text-rose-200",children:L.title}),h.jsx("div",{className:"mono truncate text-[11px] text-rose-300/70",children:L.subtitle})]}),h.jsx("button",{type:"button",onClick:()=>t(L.id),className:"mono shrink-0 rounded-md border border-rose-500/40 bg-rose-500/15 px-2.5 py-1.5 text-[11px] text-rose-200 transition-colors hover:bg-rose-500/25",children:L.cta})]}),h.jsxs("div",{className:"relative grid min-h-0 flex-1",style:{gridTemplateRows:A.length>0?`1fr ${w}px`:"1fr"},children:[h.jsxs("div",{className:"relative min-h-0",children:[A.length===0?h.jsx("div",{className:"grid h-full place-items-center text-sm text-zinc-600",children:"No steps recorded yet."}):h.jsx(mp,{run:z,timeline:A,selectedKey:k,onSelect:(b,S)=>m({step:b,run:S}),onOpenRun:t,fmtDuration:wp,expanded:E,onToggleChild:j}),(z.status==="failed"||z.status==="cancelled")&&z.error&&h.jsx("div",{className:"mono absolute inset-x-6 bottom-6 rounded-lg border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-300 backdrop-blur",children:z.error.message})]}),A.length>0&&h.jsxs("div",{className:"relative min-h-0 overflow-hidden border-t border-[var(--line)] bg-black/20",children:[h.jsx("div",{onPointerDown:R,className:"absolute inset-x-0 top-0 z-10 h-1.5 -translate-y-1/2 cursor-row-resize hover:bg-emerald-500/40",title:"Drag to resize"}),h.jsx(Xa,{run:z,timeline:A,selectedKey:k,onSelect:(b,S)=>m({step:b,run:S}),onOpenRun:t,expanded:E,onToggleChild:j})]}),g&&h.jsx(tc,{step:g.step,run:g.run,onClose:()=>m(void 0),onOpenRun:t}),N&&h.jsx(nc,{run:z,onClose:()=>y(!1)})]})]})}function zs(){if(typeof window>"u")return;const e=window.location.hash.match(/^#\/run\/(.+)$/),t=e==null?void 0:e[1];return t?decodeURIComponent(t):void 0}function kp(){const[e,t]=$.useState("all"),[n,r]=$.useState(""),[s,i]=$.useState(""),[o,a]=$.useState(()=>zs()),c=$.useCallback(m=>{if(a(m),typeof window>"u")return;const N=m?`#/run/${encodeURIComponent(m)}`:"",y=N||window.location.pathname+window.location.search;window.location.hash!==N&&window.history.pushState(null,"",y)},[]);$.useEffect(()=>{const m=()=>a(zs());return window.addEventListener("hashchange",m),window.addEventListener("popstate",m),()=>{window.removeEventListener("hashchange",m),window.removeEventListener("popstate",m)}},[]);const l=sn(),u=s.split(",").map(m=>m.trim()).filter(Boolean),{data:f=[]}=pt({queryKey:["runs",n,u.join("|")],queryFn:()=>ue.runs(void 0,n||void 0,u.length?u:void 0),refetchInterval:3e3}),d=lt({mutationFn:m=>ue.bulk(m,{status:e!=="all"?e:void 0,tag:n||void 0,attr:u.length?u:void 0}),onSuccess:()=>l.invalidateQueries({queryKey:["runs"]})}),p=f.reduce((m,N)=>(m[N.status]=(m[N.status]??0)+1,m),{}),g=e==="all"?f:f.filter(m=>m.status===e);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"app-bg"}),h.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[h.jsx(vp,{counts:p,filter:e,onFilter:t}),h.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(300px,360px)_1fr]",children:[h.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-[var(--line)]",children:[h.jsxs("div",{className:"border-b border-[var(--line)] p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[h.jsx("span",{className:"text-zinc-600",children:"#"}),h.jsx("input",{value:n,onChange:m=>r(m.target.value),placeholder:"filter by tag…",className:"mono w-full bg-transparent py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none"}),n&&h.jsx("button",{type:"button",onClick:()=>r(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear tag filter",children:h.jsx(Ge,{width:12,height:12})})]}),h.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[h.jsx("span",{className:"text-zinc-600",children:"⛃"}),h.jsx("input",{value:s,onChange:m=>i(m.target.value),placeholder:"attrs e.g. amount:gte:200, tier:eq:pro",title:"Typed search attributes: comma-separated key:op:value (ops eq ne gt gte lt lte)",className:"mono w-full bg-transparent py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none"}),s&&h.jsx("button",{type:"button",onClick:()=>i(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear attribute filter",children:h.jsx(Ge,{width:12,height:12})})]})]}),(e!=="all"||n||u.length>0)&&g.length>0&&h.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--line)] px-3 py-1.5",children:[h.jsxs("span",{className:"mono text-[10px] text-zinc-500",children:[g.length," ",e!=="all"?e:""," ",n&&`#${n}`,u.length>0&&` ⛃${u.length}`]}),h.jsx("button",{type:"button",disabled:d.isPending,onClick:()=>d.mutate("retry"),className:"mono ml-auto rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 text-[10px] text-emerald-300 transition-colors hover:bg-emerald-500/20 disabled:opacity-40",children:"retry all"}),h.jsx("button",{type:"button",disabled:d.isPending,onClick:()=>d.mutate("cancel"),className:"mono rounded border border-rose-500/30 bg-rose-500/10 px-1.5 py-0.5 text-[10px] text-rose-300 transition-colors hover:bg-rose-500/20 disabled:opacity-40",children:"cancel all"})]}),h.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:h.jsx(Ep,{runs:g,selected:o,onSelect:c,onSelectTag:r})})]}),h.jsx("main",{className:"min-h-0",children:o?h.jsx(Sp,{id:o,onOpenRun:c},o):h.jsx("div",{className:"grid h-full place-items-center text-center",children:h.jsxs("div",{className:"flex flex-col items-center",children:[h.jsx(jo,{className:"h-10 w-10 text-zinc-800"}),h.jsx("p",{className:"mt-3 text-sm text-zinc-600",children:"Select a run to see its timeline."})]})})})]})]})]})}const jp=new Ya({defaultOptions:{queries:{refetchInterval:2e3,refetchOnWindowFocus:!1}}});qa(document.getElementById("root")).render(h.jsx($.StrictMode,{children:h.jsx(Wa,{client:jp,children:h.jsx(kp,{})})}));