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