@opentrust/dashboard 7.3.8 → 7.3.9
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.
- package/dist/index.js +6 -2
- package/package.json +3 -3
- package/public/assets/{index-Cd3O1ECy.js → index-Bs89CfR5.js} +3 -3
- package/public/assets/index-Bs89CfR5.js.map +1 -0
- package/public/assets/{index-DXBIv7M-.css → index-COJhc2Tl.css} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-Cd3O1ECy.js.map +0 -1
|
@@ -153,7 +153,7 @@ Please change the parent <Route path="${m}"> to <Route path="${m==="/"?"*":`${m}
|
|
|
153
153
|
*
|
|
154
154
|
* This source code is licensed under the ISC license.
|
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const ok=Re("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),ik=[{label:"Discovery",items:[{to:"/inventory/agents",label:"Agents",icon:cg},{to:"/inventory/identities",label:"Identities",icon:dg},{to:"/inventory/permissions",label:"Permissions",icon:qS}]},{label:"Secure",items:[{to:"/secure/risk",label:"Risk",icon:hg},{to:"/secure/graph",label:"Graph",icon:tk}]}];function sk(){const e=It();return g.jsxs("aside",{className:"flex w-56 flex-col border-r border-border bg-card",children:[g.jsxs("div",{className:"flex h-14 items-center gap-2 border-b border-border px-4",children:[g.jsx("img",{src:"/dashboard/logo-512.png",alt:"OpenTrust",className:"h-6 w-6"}),g.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"OpenTrust"})]}),g.jsx("nav",{className:"flex-1 space-y-6 px-3 py-4",children:ik.map(t=>g.jsxs("div",{children:[g.jsx("p",{className:"mb-2 px-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t.label}),g.jsx("div",{className:"space-y-0.5",children:t.items.map(n=>g.jsxs(Jm,{to:n.to,className:Tt("flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm transition-colors",e.pathname.startsWith(n.to)?"bg-accent text-accent-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[g.jsx(n.icon,{className:"h-4 w-4 shrink-0"}),n.label]},n.to))})]},t.label))}),g.jsx("div",{className:"border-t border-border px-4 py-3",children:g.jsx("p",{className:"text-[11px] text-muted-foreground",children:"v7.0.0"})})]})}function lk(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ak(...e){return t=>e.forEach(n=>lk(n,t))}var pg=k.forwardRef((e,t)=>{const{children:n,...r}=e,o=k.Children.toArray(n),i=o.find(ck);if(i){const s=i.props.children,l=o.map(a=>a===i?k.Children.count(s)>1?k.Children.only(null):k.isValidElement(s)?s.props.children:null:a);return g.jsx(yu,{...r,ref:t,children:k.isValidElement(s)?k.cloneElement(s,void 0,l):null})}return g.jsx(yu,{...r,ref:t,children:n})});pg.displayName="Slot";var yu=k.forwardRef((e,t)=>{const{children:n,...r}=e;if(k.isValidElement(n)){const o=fk(n);return k.cloneElement(n,{...dk(r,n.props),ref:t?ak(t,o):o})}return k.Children.count(n)>1?k.Children.only(null):null});yu.displayName="SlotClone";var uk=({children:e})=>g.jsx(g.Fragment,{children:e});function ck(e){return k.isValidElement(e)&&e.type===uk}function dk(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{i(...l),o(...l)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function fk(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function mg(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=mg(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function hk(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=mg(e))&&(r&&(r+=" "),r+=t);return r}const Nf=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Cf=hk,pk=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Cf(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const f=n==null?void 0:n[u],c=i==null?void 0:i[u];if(f===null)return null;const d=Nf(f)||Nf(c);return o[u][d]}),l=n&&Object.entries(n).reduce((u,f)=>{let[c,d]=f;return d===void 0||(u[c]=d),u},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,f)=>{let{class:c,className:d,...y}=f;return Object.entries(y).every(v=>{let[x,S]=v;return Array.isArray(S)?S.includes({...i,...l}[x]):{...i,...l}[x]===S})?[...u,c,d]:u},[]);return Cf(e,s,a,n==null?void 0:n.class,n==null?void 0:n.className)},mk=pk("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-border bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Qo=k.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?pg:"button";return g.jsx(s,{className:Tt(mk({variant:t,size:n,className:e})),ref:i,...o})});Qo.displayName="Button";function gk(){const{user:e,logout:t}=Ic(),{theme:n,setTheme:r}=lS();return g.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-border bg-card px-6",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"h-2 w-2 rounded-full bg-success"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"Connected"})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(e==null?void 0:e.email)&&g.jsx("span",{className:"text-xs text-muted-foreground",children:e.email}),g.jsx(Qo,{variant:"ghost",size:"icon",onClick:()=>r(n==="dark"?"light":"dark"),className:"h-8 w-8",children:n==="dark"?g.jsx(rk,{className:"h-4 w-4"}):g.jsx(ek,{className:"h-4 w-4"})}),g.jsx(Qo,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8",children:g.jsx(JS,{className:"h-4 w-4"})})]})]})}function yk(){return g.jsxs("div",{className:"flex h-screen overflow-hidden bg-background",children:[g.jsx(sk,{}),g.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[g.jsx(gk,{}),g.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:g.jsx(E1,{})})]})]})}const Zo=k.forwardRef(({className:e,type:t,...n},r)=>g.jsx("input",{type:t,className:Tt("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Zo.displayName="Input";function vk(){const[e]=eS(),[t,n]=k.useState(e.get("email")??""),[r,o]=k.useState(e.get("key")??""),[i,s]=k.useState(""),[l,a]=k.useState(!1),{login:u,isAuthenticated:f,isLoading:c}=Ic(),d=ml();if(k.useEffect(()=>{f&&d("/inventory/agents",{replace:!0})},[f,d]),c)return g.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:g.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading..."})});const y=async v=>{v.preventDefault(),s(""),a(!0);try{await u(t,r),d("/inventory/agents",{replace:!0})}catch(x){s(x instanceof Error?x.message:"Login failed")}finally{a(!1)}};return g.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:g.jsxs("div",{className:"w-full max-w-sm space-y-8 px-4",children:[g.jsxs("div",{className:"flex flex-col items-center gap-3",children:[g.jsx("img",{src:"/dashboard/logo-512.png",alt:"OpenTrust",className:"h-12 w-12"}),g.jsxs("div",{className:"text-center",children:[g.jsx("h1",{className:"text-lg font-semibold tracking-tight text-foreground",children:"OpenTrust"}),g.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Sign in to your dashboard"})]})]}),g.jsxs("form",{onSubmit:y,className:"space-y-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium text-foreground",children:"Email"}),g.jsx(Zo,{type:"email",placeholder:"you@example.com",value:t,onChange:v=>n(v.target.value),required:!0})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Key"}),g.jsx(Zo,{type:"password",placeholder:"sk-og-...",value:r,onChange:v=>o(v.target.value),required:!0})]}),i&&g.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}),g.jsx(Qo,{type:"submit",className:"w-full",disabled:l,children:l?"Signing in...":"Sign in"})]}),g.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"API Key is generated when registering an agent with the Core API."})]})})}const xk="/api";async function Pe(e,t){const n=localStorage.getItem("opentrust_user"),r=n?JSON.parse(n).apiKey:null,o=await fetch(`${xk}${e}`,{...t,headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`},...t==null?void 0:t.headers}});if(!o.ok)throw new Error(`API ${o.status}: ${await o.text()}`);return o.json()}const bn={agents:{list:()=>Pe("/agents"),get:e=>Pe(`/agents/${e}`),create:e=>Pe("/agents",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Pe(`/agents/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Pe(`/agents/${e}`,{method:"DELETE"})},discovery:{agents:()=>Pe("/discovery/agents"),profile:e=>Pe(`/discovery/agents/${e}/profile`)},observations:{recent:(e=50)=>Pe(`/observations?limit=${e}`),permissions:()=>Pe("/observations/permissions"),anomalies:()=>Pe("/observations/anomalies"),summary:()=>Pe("/observations/summary"),agentPermissions:e=>Pe(`/observations/agents/${e}/permissions`)},detect:e=>Pe("/detect",{method:"POST",body:JSON.stringify(e)}),usage:{summary:(e=30)=>Pe(`/usage/summary?days=${e}`),daily:(e=30)=>Pe(`/usage/daily?days=${e}`)},settings:{get:()=>Pe("/settings"),update:e=>Pe("/settings",{method:"PUT",body:JSON.stringify(e)})}};function Ge({className:e,variant:t="default",...n}){return g.jsx("div",{className:Tt("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{"border-transparent bg-primary text-primary-foreground shadow":t==="default","border-transparent bg-secondary text-secondary-foreground":t==="secondary","border-transparent bg-destructive text-destructive-foreground shadow":t==="destructive","text-foreground":t==="outline","border-transparent bg-success/15 text-success":t==="success","border-transparent bg-warning/15 text-warning":t==="warning"},e),...n})}function wk(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[o,i]=k.useState(!0),s=async()=>{i(!0);try{const u=await bn.discovery.agents();t(u.data??[])}catch{}i(!1)};k.useEffect(()=>{s()},[]);const l=e.filter(u=>{var f;return!n||((f=u.name)==null?void 0:f.toLowerCase().includes(n.toLowerCase()))}),a=u=>u==="active"?"success":u==="inactive"?"secondary":"warning";return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Agents"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," agent",e.length!==1?"s":""," discovered"]})]}),g.jsxs(Qo,{variant:"outline",size:"sm",onClick:s,children:[g.jsx(nk,{className:"h-3.5 w-3.5"}),"Scan"]})]}),g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(fg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),g.jsx(Zo,{placeholder:"Search agents...",className:"pl-9",value:n,onChange:u=>r(u.target.value)})]}),o?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):l.length===0?g.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border",children:[g.jsx(cg,{className:"h-8 w-8 text-muted-foreground/50"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents found"})]}):g.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:l.map(u=>{var f;return g.jsxs(yl,{to:`/inventory/agents/${u.id}`,className:"group flex flex-col gap-3 rounded-lg border border-border bg-card p-4 transition-colors hover:border-muted-foreground/30",children:[g.jsxs("div",{className:"flex items-start justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2.5",children:[g.jsx("span",{className:"text-xl",children:u.emoji||"🤖"}),g.jsxs("div",{children:[g.jsx("p",{className:"text-sm font-medium text-foreground group-hover:text-foreground",children:u.name}),g.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.provider||"unknown",u.model?` · ${u.model}`:""]})]})]}),g.jsx(Ge,{variant:a(u.status??"inactive"),className:"text-[10px]",children:u.status??"inactive"})]}),((f=u.skills)==null?void 0:f.length)>0&&g.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.skills.slice(0,4).map(c=>g.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:typeof c=="string"?c:c.name},c.name??c)),u.skills.length>4&&g.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["+",u.skills.length-4]})]})]},u.id)})})]})}const hn=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("rounded-lg border border-border bg-card text-card-foreground shadow-sm",e),...t}));hn.displayName="Card";const On=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("flex flex-col space-y-1.5 p-6",e),...t}));On.displayName="CardHeader";const Fn=k.forwardRef(({className:e,...t},n)=>g.jsx("h3",{ref:n,className:Tt("font-semibold leading-none tracking-tight",e),...t}));Fn.displayName="CardTitle";const Sk=k.forwardRef(({className:e,...t},n)=>g.jsx("p",{ref:n,className:Tt("text-sm text-muted-foreground",e),...t}));Sk.displayName="CardDescription";const pn=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("p-6 pt-0",e),...t}));pn.displayName="CardContent";const kk=["Profile","Tasks","Identities","Permissions"];function Ek(){const{id:e}=u1(),[t,n]=k.useState(null),[r,o]=k.useState([]),[i,s]=k.useState("Profile"),[l,a]=k.useState(!0);return k.useEffect(()=>{e&&(a(!0),(async()=>{const u=await bn.discovery.profile(e).catch(()=>null),f=(u==null?void 0:u.data)??null;n(f);const c=(f==null?void 0:f.registeredAgentId)??e,d=await bn.observations.agentPermissions(c).catch(()=>({data:[]}));o((d==null?void 0:d.data)??[]),a(!1)})())},[e]),l?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):t?g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(yl,{to:"/inventory/agents",className:"rounded-md p-1.5 hover:bg-accent",children:g.jsx(YS,{className:"h-4 w-4"})}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("span",{className:"text-2xl",children:t.emoji||"🤖"}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-lg font-semibold",children:t.name||e}),g.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.provider||"unknown",t.model?` / ${t.model}`:""]})]})]})]}),g.jsx("div",{className:"flex gap-1 border-b border-border",children:kk.map(u=>g.jsx("button",{onClick:()=>s(u),className:Tt("border-b-2 px-4 py-2 text-sm font-medium transition-colors",i===u?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u},u))}),i==="Profile"&&g.jsx(Nk,{profile:t}),i==="Tasks"&&g.jsx(Ck,{profile:t}),i==="Identities"&&g.jsx(_k,{profile:t}),i==="Permissions"&&g.jsx(bk,{permissions:r})]}):g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Agent not found"})}function Nk({profile:e}){const t=e.skills??[];return g.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Info"})}),g.jsxs(pn,{className:"space-y-2 text-sm",children:[g.jsx(fo,{label:"Owner",value:e.ownerName||"—"}),g.jsx(fo,{label:"Creature",value:e.creature||"—"}),g.jsx(fo,{label:"Vibe",value:e.vibe||"—"}),g.jsx(fo,{label:"Sessions",value:String(e.sessionCount??0)}),g.jsx(fo,{label:"Last Active",value:e.lastActive??"never"})]})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(ok,{className:"h-4 w-4"})," Skills (",t.length,")"]})}),g.jsx(pn,{children:t.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No skills installed"}):g.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(n=>g.jsx(Ge,{variant:"secondary",className:"text-xs font-normal",children:n.name},n.name))})})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Plugins"})}),g.jsx(pn,{children:(e.plugins??[]).length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins"}):g.jsx("div",{className:"space-y-1.5",children:(e.plugins??[]).map(n=>g.jsxs("div",{className:"flex items-center justify-between text-sm",children:[g.jsx("span",{children:n.name}),g.jsx(Ge,{variant:n.enabled?"success":"secondary",className:"text-[10px]",children:n.enabled?"on":"off"})]},n.name))})})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Connected Systems"})}),g.jsx(pn,{children:(e.connectedSystems??[]).length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"None"}):g.jsx("div",{className:"flex flex-wrap gap-1.5",children:(e.connectedSystems??[]).map(n=>g.jsx(Ge,{variant:"outline",className:"text-xs",children:n},n))})})]})]})}function Ck({profile:e}){const t=e.cronJobs??[];return g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(QS,{className:"h-4 w-4"})," Scheduled Tasks (",t.length,")"]})}),g.jsx(pn,{children:t.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks"}):g.jsx("div",{className:"space-y-2",children:t.map((n,r)=>g.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2 text-sm",children:[g.jsxs("div",{children:[g.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:n.schedule}),g.jsx("span",{className:"ml-2",children:n.task??n.id})]}),g.jsx(Ge,{variant:n.enabled!==!1?"success":"secondary",className:"text-[10px]",children:n.enabled!==!1?"active":"paused"})]},r))})})]})}function _k({profile:e}){const t=e.workspaceFiles??{},n=[{label:"SOUL.md",content:t.soul},{label:"IDENTITY.md",content:t.identity},{label:"USER.md",content:t.user}].filter(r=>r.content);return g.jsx("div",{className:"space-y-4",children:n.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No identity files found"}):n.map(r=>g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(ZS,{className:"h-4 w-4"})," ",r.label]})}),g.jsx(pn,{children:g.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs text-muted-foreground",children:r.content})})]},r.label))})}function bk({permissions:e}){return e.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No observed permissions"}):g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Tool"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Access"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"Calls"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"Errors"})]})}),g.jsx("tbody",{children:e.map(t=>g.jsxs("tr",{className:"border-b border-border last:border-0",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:t.toolName}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:t.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:t.accessPattern==="write"?"warning":t.accessPattern==="admin"?"destructive":"secondary",className:"text-[10px]",children:t.accessPattern??"read"})}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs",children:t.callCount}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs text-destructive",children:t.errorCount||"—"})]},t.id))})]})})}function fo({label:e,value:t}){return g.jsxs("div",{className:"flex justify-between",children:[g.jsx("span",{className:"text-muted-foreground",children:e}),g.jsx("span",{className:"font-medium",children:t})]})}function Pk(){const[e,t]=k.useState([]),[n,r]=k.useState(!0),[o,i]=k.useState(new Set);k.useEffect(()=>{bn.discovery.agents().then(a=>{t(a.data??[]),r(!1)}).catch(()=>r(!1))},[]);const s=[{category:"Agents",items:e.map(a=>({id:a.id,name:a.name,emoji:a.emoji,provider:a.provider,status:a.status}))},{category:"Owners",items:[...new Set(e.map(a=>a.ownerName).filter(Boolean))].map(a=>({id:a,name:a,type:"owner"}))},{category:"Connected Systems",items:[...new Set(e.flatMap(a=>a.connectedSystems??[]))].map(a=>({id:a,name:a,type:"system"}))}],l=a=>{i(u=>{const f=new Set(u);return f.has(a)?f.delete(a):f.add(a),f})};return n?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Identities"}),g.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agents, owners, and connected systems"})]}),g.jsx("div",{className:"space-y-3",children:s.map(a=>g.jsxs(hn,{children:[g.jsxs("button",{onClick:()=>l(a.category),className:"flex w-full items-center justify-between p-4 text-left",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(dg,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("span",{className:"text-sm font-medium",children:a.category}),g.jsx(Ge,{variant:"secondary",className:"text-[10px]",children:a.items.length})]}),o.has(a.category)?g.jsx(GS,{className:"h-4 w-4 text-muted-foreground"}):g.jsx(KS,{className:"h-4 w-4 text-muted-foreground"})]}),o.has(a.category)&&g.jsx(pn,{className:"border-t border-border pt-3",children:a.items.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"None"}):g.jsx("div",{className:"space-y-1.5",children:a.items.map(u=>g.jsxs("div",{className:"flex items-center justify-between rounded-md px-3 py-2 text-sm hover:bg-muted/50",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[u.emoji&&g.jsx("span",{className:"text-base",children:u.emoji}),g.jsx("span",{children:u.name})]}),u.status&&g.jsx(Ge,{variant:u.status==="active"?"success":"secondary",className:"text-[10px]",children:u.status}),u.type&&g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:u.type})]},u.id))})})]},a.category))})]})}function Mk(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[o,i]=k.useState("callCount"),[s,l]=k.useState(!1),[a,u]=k.useState(!0);k.useEffect(()=>{bn.observations.permissions().then(d=>{t(d.data??[]),u(!1)}).catch(()=>u(!1))},[]);const f=k.useMemo(()=>{let d=e;if(n){const y=n.toLowerCase();d=d.filter(v=>{var x,S;return((x=v.toolName)==null?void 0:x.toLowerCase().includes(y))||((S=v.category)==null?void 0:S.toLowerCase().includes(y))})}return[...d].sort((y,v)=>{const x=y[o]??0,S=v[o]??0;return typeof x=="string"?s?x.localeCompare(S):S.localeCompare(x):s?x-S:S-x})},[e,n,o,s]),c=d=>{o===d?l(!s):(i(d),l(!1))};return a?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Permissions"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," observed tool permission",e.length!==1?"s":""]})]}),g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(fg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),g.jsx(Zo,{placeholder:"Filter by tool or category...",className:"pl-9",value:n,onChange:d=>r(d.target.value)})]}),g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx(aa,{label:"Tool",sortKey:"toolName",current:o,asc:s,onSort:c}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Access"}),g.jsx(aa,{label:"Calls",sortKey:"callCount",current:o,asc:s,onSort:c,align:"right"}),g.jsx(aa,{label:"Errors",sortKey:"errorCount",current:o,asc:s,onSort:c,align:"right"})]})}),g.jsx("tbody",{children:f.length===0?g.jsx("tr",{children:g.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-muted-foreground",children:"No permissions"})}):f.map(d=>g.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:d.toolName}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:d.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:d.accessPattern==="write"?"warning":d.accessPattern==="admin"?"destructive":"secondary",className:"text-[10px]",children:d.accessPattern??"read"})}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs",children:d.callCount}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs text-destructive",children:d.errorCount||"—"})]},d.id))})]})})]})}function aa({label:e,sortKey:t,current:n,asc:r,onSort:o,align:i="left"}){return g.jsx("th",{className:`cursor-pointer px-4 py-2.5 font-medium text-muted-foreground hover:text-foreground ${i==="right"?"text-right":"text-left"}`,onClick:()=>o(t),children:g.jsxs("span",{className:"inline-flex items-center gap-1",children:[e,n===t&&g.jsx(XS,{className:"h-3 w-3"})]})})}function jk(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);k.useEffect(()=>{bn.observations.anomalies().then(s=>{t(s.data??[]),r(!1)}).catch(()=>r(!1))},[]);const o=s=>s.blocked||s.errorCount>3?"high":s.callCount===1||s.errorCount>0?"medium":"low",i=s=>s==="high"?"destructive":s==="medium"?"warning":"secondary";return n?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Risk Overview"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," anomal",e.length!==1?"ies":"y"," detected"]})]}),e.length===0?g.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border",children:[g.jsx(hg,{className:"h-8 w-8 text-muted-foreground/50"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"No anomalies detected"})]}):g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Tool"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Agent"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Risk"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"First Seen"})]})}),g.jsx("tbody",{children:e.map(s=>{var a;const l=o(s);return g.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:s.toolName}),g.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground",children:((a=s.agentId)==null?void 0:a.slice(0,8))??"—"}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:i(l),className:"text-[10px]",children:l})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:s.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-muted-foreground",children:s.firstSeen?new Date(s.firstSeen).toLocaleDateString():"—"})]},s.id)})})]})})]})}function Ee(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=Ee(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Lk={value:()=>{}};function vl(){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 cs(n)}function cs(e){this._=e}function Rk(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}cs.prototype=vl.prototype={constructor:cs,on:function(e,t){var n=this._,r=Rk(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=Ik(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=_f(n[o],e.name,t);else if(t==null)for(o in n)n[o]=_f(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new cs(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++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],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function Ik(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function _f(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Lk,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var vu="http://www.w3.org/1999/xhtml";const bf={svg:"http://www.w3.org/2000/svg",xhtml:vu,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function xl(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),bf.hasOwnProperty(t)?{space:bf[t],local:e}:e}function Tk(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===vu&&t.documentElement.namespaceURI===vu?t.createElement(e):t.createElementNS(n,e)}}function zk(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function gg(e){var t=xl(e);return(t.local?zk:Tk)(t)}function Ak(){}function zc(e){return e==null?Ak:function(){return this.querySelector(e)}}function $k(e){typeof e!="function"&&(e=zc(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=new Array(s),a,u,f=0;f<s;++f)(a=i[f])&&(u=e.call(a,a.__data__,f,i))&&("__data__"in a&&(u.__data__=a.__data__),l[f]=u);return new et(r,this._parents)}function Dk(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ok(){return[]}function yg(e){return e==null?Ok:function(){return this.querySelectorAll(e)}}function Fk(e){return function(){return Dk(e.apply(this,arguments))}}function Hk(e){typeof e=="function"?e=Fk(e):e=yg(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],l=s.length,a,u=0;u<l;++u)(a=s[u])&&(r.push(e.call(a,a.__data__,u,s)),o.push(a));return new et(r,o)}function vg(e){return function(){return this.matches(e)}}function xg(e){return function(t){return t.matches(e)}}var Vk=Array.prototype.find;function Bk(e){return function(){return Vk.call(this.children,e)}}function Uk(){return this.firstElementChild}function Wk(e){return this.select(e==null?Uk:Bk(typeof e=="function"?e:xg(e)))}var Yk=Array.prototype.filter;function Xk(){return Array.from(this.children)}function Gk(e){return function(){return Yk.call(this.children,e)}}function Kk(e){return this.selectAll(e==null?Xk:Gk(typeof e=="function"?e:xg(e)))}function Qk(e){typeof e!="function"&&(e=vg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=[],a,u=0;u<s;++u)(a=i[u])&&e.call(a,a.__data__,u,i)&&l.push(a);return new et(r,this._parents)}function wg(e){return new Array(e.length)}function Zk(){return new et(this._enter||this._groups.map(wg),this._parents)}function Fs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fs.prototype={constructor:Fs,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 qk(e){return function(){return e}}function Jk(e,t,n,r,o,i){for(var s=0,l,a=t.length,u=i.length;s<u;++s)(l=t[s])?(l.__data__=i[s],r[s]=l):n[s]=new Fs(e,i[s]);for(;s<a;++s)(l=t[s])&&(o[s]=l)}function e2(e,t,n,r,o,i,s){var l,a,u=new Map,f=t.length,c=i.length,d=new Array(f),y;for(l=0;l<f;++l)(a=t[l])&&(d[l]=y=s.call(a,a.__data__,l,t)+"",u.has(y)?o[l]=a:u.set(y,a));for(l=0;l<c;++l)y=s.call(e,i[l],l,i)+"",(a=u.get(y))?(r[l]=a,a.__data__=i[l],u.delete(y)):n[l]=new Fs(e,i[l]);for(l=0;l<f;++l)(a=t[l])&&u.get(d[l])===a&&(o[l]=a)}function t2(e){return e.__data__}function n2(e,t){if(!arguments.length)return Array.from(this,t2);var n=t?e2:Jk,r=this._parents,o=this._groups;typeof e!="function"&&(e=qk(e));for(var i=o.length,s=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var f=r[u],c=o[u],d=c.length,y=r2(e.call(f,f&&f.__data__,u,r)),v=y.length,x=l[u]=new Array(v),S=s[u]=new Array(v),h=a[u]=new Array(d);n(f,c,x,S,h,y,t);for(var m=0,p=0,w,E;m<v;++m)if(w=x[m]){for(m>=p&&(p=m+1);!(E=S[p])&&++p<v;);w._next=E||null}}return s=new et(s,r),s._enter=l,s._exit=a,s}function r2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function o2(){return new et(this._exit||this._groups.map(wg),this._parents)}function i2(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function s2(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),l=new Array(o),a=0;a<s;++a)for(var u=n[a],f=r[a],c=u.length,d=l[a]=new Array(c),y,v=0;v<c;++v)(y=u[v]||f[v])&&(d[v]=y);for(;a<o;++a)l[a]=n[a];return new et(l,this._parents)}function l2(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function a2(e){e||(e=u2);function t(c,d){return c&&d?e(c.__data__,d.__data__):!c-!d}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],l=s.length,a=o[i]=new Array(l),u,f=0;f<l;++f)(u=s[f])&&(a[f]=u);a.sort(t)}return new et(o,this._parents).order()}function u2(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function c2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function d2(){return Array.from(this)}function f2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function h2(){let e=0;for(const t of this)++e;return e}function p2(){return!this.node()}function m2(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,l;i<s;++i)(l=o[i])&&e.call(l,l.__data__,i,o);return this}function g2(e){return function(){this.removeAttribute(e)}}function y2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function v2(e,t){return function(){this.setAttribute(e,t)}}function x2(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function w2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function S2(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 k2(e,t){var n=xl(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?y2:g2:typeof t=="function"?n.local?S2:w2:n.local?x2:v2)(n,t))}function Sg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function E2(e){return function(){this.style.removeProperty(e)}}function N2(e,t,n){return function(){this.style.setProperty(e,t,n)}}function C2(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _2(e,t,n){return arguments.length>1?this.each((t==null?E2:typeof t=="function"?C2:N2)(e,t,n??"")):zr(this.node(),e)}function zr(e,t){return e.style.getPropertyValue(t)||Sg(e).getComputedStyle(e,null).getPropertyValue(t)}function b2(e){return function(){delete this[e]}}function P2(e,t){return function(){this[e]=t}}function M2(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function j2(e,t){return arguments.length>1?this.each((t==null?b2:typeof t=="function"?M2:P2)(e,t)):this.node()[e]}function kg(e){return e.trim().split(/^|\s+/)}function Ac(e){return e.classList||new Eg(e)}function Eg(e){this._node=e,this._names=kg(e.getAttribute("class")||"")}Eg.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 Ng(e,t){for(var n=Ac(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Cg(e,t){for(var n=Ac(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function L2(e){return function(){Ng(this,e)}}function R2(e){return function(){Cg(this,e)}}function I2(e,t){return function(){(t.apply(this,arguments)?Ng:Cg)(this,e)}}function T2(e,t){var n=kg(e+"");if(arguments.length<2){for(var r=Ac(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?I2:t?L2:R2)(n,t))}function z2(){this.textContent=""}function A2(e){return function(){this.textContent=e}}function $2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function D2(e){return arguments.length?this.each(e==null?z2:(typeof e=="function"?$2:A2)(e)):this.node().textContent}function O2(){this.innerHTML=""}function F2(e){return function(){this.innerHTML=e}}function H2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function V2(e){return arguments.length?this.each(e==null?O2:(typeof e=="function"?H2:F2)(e)):this.node().innerHTML}function B2(){this.nextSibling&&this.parentNode.appendChild(this)}function U2(){return this.each(B2)}function W2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Y2(){return this.each(W2)}function X2(e){var t=typeof e=="function"?e:gg(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function G2(){return null}function K2(e,t){var n=typeof e=="function"?e:gg(e),r=t==null?G2:typeof t=="function"?t:zc(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Q2(){var e=this.parentNode;e&&e.removeChild(this)}function Z2(){return this.each(Q2)}function q2(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function J2(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eE(e){return this.select(e?J2:q2)}function tE(e){return arguments.length?this.property("__data__",e):this.node().__data__}function nE(e){return function(t){e.call(this,t,this.__data__)}}function rE(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 oE(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++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 iE(e,t,n){return function(){var r=this.__on,o,i=nE(t);if(r){for(var s=0,l=r.length;s<l;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function sE(e,t,n){var r=rE(e+""),o,i=r.length,s;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,f;a<u;++a)for(o=0,f=l[a];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(l=t?iE:oE,o=0;o<i;++o)this.each(l(r[o],t,n));return this}function _g(e,t,n){var r=Sg(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function lE(e,t){return function(){return _g(this,e,t)}}function aE(e,t){return function(){return _g(this,e,t.apply(this,arguments))}}function uE(e,t){return this.each((typeof t=="function"?aE:lE)(e,t))}function*cE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var bg=[null];function et(e,t){this._groups=e,this._parents=t}function pi(){return new et([[document.documentElement]],bg)}function dE(){return this}et.prototype=pi.prototype={constructor:et,select:$k,selectAll:Hk,selectChild:Wk,selectChildren:Kk,filter:Qk,data:n2,enter:Zk,exit:o2,join:i2,merge:s2,selection:dE,order:l2,sort:a2,call:c2,nodes:d2,node:f2,size:h2,empty:p2,each:m2,attr:k2,style:_2,property:j2,classed:T2,text:D2,html:V2,raise:U2,lower:Y2,append:X2,insert:K2,remove:Z2,clone:eE,datum:tE,on:sE,dispatch:uE,[Symbol.iterator]:cE};function Qe(e){return typeof e=="string"?new et([[document.querySelector(e)]],[document.documentElement]):new et([[e]],bg)}function fE(e){let t;for(;t=e.sourceEvent;)e=t;return e}function mt(e,t){if(e=fE(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 o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const hE={passive:!1},qo={capture:!0,passive:!1};function ua(e){e.stopImmediatePropagation()}function _r(e){e.preventDefault(),e.stopImmediatePropagation()}function Pg(e){var t=e.document.documentElement,n=Qe(e).on("dragstart.drag",_r,qo);"onselectstart"in t?n.on("selectstart.drag",_r,qo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Mg(e,t){var n=e.document.documentElement,r=Qe(e).on("dragstart.drag",null);t&&(r.on("click.drag",_r,qo),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 Hi=e=>()=>e;function xu(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:l,dx:a,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}xu.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pE(e){return!e.ctrlKey&&!e.button}function mE(){return this.parentNode}function gE(e,t){return t??{x:e.x,y:e.y}}function yE(){return navigator.maxTouchPoints||"ontouchstart"in this}function jg(){var e=pE,t=mE,n=gE,r=yE,o={},i=vl("start","drag","end"),s=0,l,a,u,f,c=0;function d(w){w.on("mousedown.drag",y).filter(r).on("touchstart.drag",S).on("touchmove.drag",h,hE).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(w,E){if(!(f||!e.call(this,w,E))){var N=p(this,t.call(this,w,E),w,E,"mouse");N&&(Qe(w.view).on("mousemove.drag",v,qo).on("mouseup.drag",x,qo),Pg(w.view),ua(w),u=!1,l=w.clientX,a=w.clientY,N("start",w))}}function v(w){if(_r(w),!u){var E=w.clientX-l,N=w.clientY-a;u=E*E+N*N>c}o.mouse("drag",w)}function x(w){Qe(w.view).on("mousemove.drag mouseup.drag",null),Mg(w.view,u),_r(w),o.mouse("end",w)}function S(w,E){if(e.call(this,w,E)){var N=w.changedTouches,_=t.call(this,w,E),M=N.length,R,$;for(R=0;R<M;++R)($=p(this,_,w,E,N[R].identifier,N[R]))&&(ua(w),$("start",w,N[R]))}}function h(w){var E=w.changedTouches,N=E.length,_,M;for(_=0;_<N;++_)(M=o[E[_].identifier])&&(_r(w),M("drag",w,E[_]))}function m(w){var E=w.changedTouches,N=E.length,_,M;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),_=0;_<N;++_)(M=o[E[_].identifier])&&(ua(w),M("end",w,E[_]))}function p(w,E,N,_,M,R){var $=i.copy(),I=mt(R||N,E),L,F,b;if((b=n.call(w,new xu("beforestart",{sourceEvent:N,target:d,identifier:M,active:s,x:I[0],y:I[1],dx:0,dy:0,dispatch:$}),_))!=null)return L=b.x-I[0]||0,F=b.y-I[1]||0,function z(j,A,C){var P=I,T;switch(j){case"start":o[M]=z,T=s++;break;case"end":delete o[M],--s;case"drag":I=mt(C||A,E),T=s;break}$.call(j,w,new xu(j,{sourceEvent:A,subject:b,target:d,identifier:M,active:T,x:I[0]+L,y:I[1]+F,dx:I[0]-P[0],dy:I[1]-P[1],dispatch:$}),_)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Hi(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:Hi(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Hi(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Hi(!!w),d):r},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(c=(w=+w)*w,d):Math.sqrt(c)},d}function $c(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Lg(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function mi(){}var Jo=.7,Hs=1/Jo,br="\\s*([+-]?\\d+)\\s*",ei="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vE=/^#([0-9a-f]{3,8})$/,xE=new RegExp(`^rgb\\(${br},${br},${br}\\)$`),wE=new RegExp(`^rgb\\(${Lt},${Lt},${Lt}\\)$`),SE=new RegExp(`^rgba\\(${br},${br},${br},${ei}\\)$`),kE=new RegExp(`^rgba\\(${Lt},${Lt},${Lt},${ei}\\)$`),EE=new RegExp(`^hsl\\(${ei},${Lt},${Lt}\\)$`),NE=new RegExp(`^hsla\\(${ei},${Lt},${Lt},${ei}\\)$`),Pf={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};$c(mi,Zn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mf,formatHex:Mf,formatHex8:CE,formatHsl:_E,formatRgb:jf,toString:jf});function Mf(){return this.rgb().formatHex()}function CE(){return this.rgb().formatHex8()}function _E(){return Rg(this).formatHsl()}function jf(){return this.rgb().formatRgb()}function Zn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=vE.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Lf(t):n===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Vi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Vi(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=xE.exec(e))?new Ue(t[1],t[2],t[3],1):(t=wE.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=SE.exec(e))?Vi(t[1],t[2],t[3],t[4]):(t=kE.exec(e))?Vi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=EE.exec(e))?Tf(t[1],t[2]/100,t[3]/100,1):(t=NE.exec(e))?Tf(t[1],t[2]/100,t[3]/100,t[4]):Pf.hasOwnProperty(e)?Lf(Pf[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function Lf(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function Vi(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ue(e,t,n,r)}function bE(e){return e instanceof mi||(e=Zn(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function wu(e,t,n,r){return arguments.length===1?bE(e):new Ue(e,t,n,r??1)}function Ue(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}$c(Ue,wu,Lg(mi,{brighter(e){return e=e==null?Hs:Math.pow(Hs,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jo:Math.pow(Jo,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(Un(this.r),Un(this.g),Un(this.b),Vs(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:Rf,formatHex:Rf,formatHex8:PE,formatRgb:If,toString:If}));function Rf(){return`#${Hn(this.r)}${Hn(this.g)}${Hn(this.b)}`}function PE(){return`#${Hn(this.r)}${Hn(this.g)}${Hn(this.b)}${Hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function If(){const e=Vs(this.opacity);return`${e===1?"rgb(":"rgba("}${Un(this.r)}, ${Un(this.g)}, ${Un(this.b)}${e===1?")":`, ${e})`}`}function Vs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Un(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Hn(e){return e=Un(e),(e<16?"0":"")+e.toString(16)}function Tf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yt(e,t,n,r)}function Rg(e){if(e instanceof yt)return new yt(e.h,e.s,e.l,e.opacity);if(e instanceof mi||(e=Zn(e)),!e)return new yt;if(e instanceof yt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,l=i-o,a=(i+o)/2;return l?(t===i?s=(n-r)/l+(n<r)*6:n===i?s=(r-t)/l+2:s=(t-n)/l+4,l/=a<.5?i+o:2-i-o,s*=60):l=a>0&&a<1?0:s,new yt(s,l,a,e.opacity)}function ME(e,t,n,r){return arguments.length===1?Rg(e):new yt(e,t,n,r??1)}function yt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}$c(yt,ME,Lg(mi,{brighter(e){return e=e==null?Hs:Math.pow(Hs,e),new yt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jo:Math.pow(Jo,e),new yt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Ue(ca(e>=240?e-240:e+120,o,r),ca(e,o,r),ca(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new yt(zf(this.h),Bi(this.s),Bi(this.l),Vs(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=Vs(this.opacity);return`${e===1?"hsl(":"hsla("}${zf(this.h)}, ${Bi(this.s)*100}%, ${Bi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function zf(e){return e=(e||0)%360,e<0?e+360:e}function Bi(e){return Math.max(0,Math.min(1,e||0))}function ca(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 Dc=e=>()=>e;function jE(e,t){return function(n){return e+n*t}}function LE(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 RE(e){return(e=+e)==1?Ig:function(t,n){return n-t?LE(t,n,e):Dc(isNaN(t)?n:t)}}function Ig(e,t){var n=t-e;return n?jE(e,n):Dc(isNaN(e)?t:e)}const Bs=function e(t){var n=RE(t);function r(o,i){var s=n((o=wu(o)).r,(i=wu(i)).r),l=n(o.g,i.g),a=n(o.b,i.b),u=Ig(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=l(f),o.b=a(f),o.opacity=u(f),o+""}}return r.gamma=e,r}(1);function IE(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function TE(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zE(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=jo(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(l){for(s=0;s<r;++s)i[s]=o[s](l);return i}}function AE(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $E(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=jo(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Su=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,da=new RegExp(Su.source,"g");function DE(e){return function(){return e}}function OE(e){return function(t){return e(t)+""}}function Tg(e,t){var n=Su.lastIndex=da.lastIndex=0,r,o,i,s=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Su.exec(e))&&(o=da.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(r=r[0])===(o=o[0])?l[s]?l[s]+=o:l[++s]=o:(l[++s]=null,a.push({i:s,x:bt(r,o)})),n=da.lastIndex;return n<t.length&&(i=t.slice(n),l[s]?l[s]+=i:l[++s]=i),l.length<2?a[0]?OE(a[0].x):DE(t):(t=a.length,function(u){for(var f=0,c;f<t;++f)l[(c=a[f]).i]=c.x(u);return l.join("")})}function jo(e,t){var n=typeof t,r;return t==null||n==="boolean"?Dc(t):(n==="number"?bt:n==="string"?(r=Zn(t))?(t=r,Bs):Tg:t instanceof Zn?Bs:t instanceof Date?AE:TE(t)?IE:Array.isArray(t)?zE:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?$E:bt)(e,t)}var Af=180/Math.PI,ku={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function zg(e,t,n,r,o,i){var s,l,a;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(a=e*n+t*r)&&(n-=e*a,r-=t*a),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,a/=l),e*r<t*n&&(e=-e,t=-t,a=-a,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Af,skewX:Math.atan(a)*Af,scaleX:s,scaleY:l}}var Ui;function FE(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ku:zg(t.a,t.b,t.c,t.d,t.e,t.f)}function HE(e){return e==null||(Ui||(Ui=document.createElementNS("http://www.w3.org/2000/svg","g")),Ui.setAttribute("transform",e),!(e=Ui.transform.baseVal.consolidate()))?ku:(e=e.matrix,zg(e.a,e.b,e.c,e.d,e.e,e.f))}function Ag(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,f,c,d,y,v){if(u!==c||f!==d){var x=y.push("translate(",null,t,null,n);v.push({i:x-4,x:bt(u,c)},{i:x-2,x:bt(f,d)})}else(c||d)&&y.push("translate("+c+t+d+n)}function s(u,f,c,d){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),d.push({i:c.push(o(c)+"rotate(",null,r)-2,x:bt(u,f)})):f&&c.push(o(c)+"rotate("+f+r)}function l(u,f,c,d){u!==f?d.push({i:c.push(o(c)+"skewX(",null,r)-2,x:bt(u,f)}):f&&c.push(o(c)+"skewX("+f+r)}function a(u,f,c,d,y,v){if(u!==c||f!==d){var x=y.push(o(y)+"scale(",null,",",null,")");v.push({i:x-4,x:bt(u,c)},{i:x-2,x:bt(f,d)})}else(c!==1||d!==1)&&y.push(o(y)+"scale("+c+","+d+")")}return function(u,f){var c=[],d=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,c,d),s(u.rotate,f.rotate,c,d),l(u.skewX,f.skewX,c,d),a(u.scaleX,u.scaleY,f.scaleX,f.scaleY,c,d),u=f=null,function(y){for(var v=-1,x=d.length,S;++v<x;)c[(S=d[v]).i]=S.x(y);return c.join("")}}}var VE=Ag(FE,"px, ","px)","deg)"),BE=Ag(HE,", ",")",")"),UE=1e-12;function $f(e){return((e=Math.exp(e))+1/e)/2}function WE(e){return((e=Math.exp(e))-1/e)/2}function YE(e){return((e=Math.exp(2*e))-1)/(e+1)}const ds=function e(t,n,r){function o(i,s){var l=i[0],a=i[1],u=i[2],f=s[0],c=s[1],d=s[2],y=f-l,v=c-a,x=y*y+v*v,S,h;if(x<UE)h=Math.log(d/u)/t,S=function(_){return[l+_*y,a+_*v,u*Math.exp(t*_*h)]};else{var m=Math.sqrt(x),p=(d*d-u*u+r*x)/(2*u*n*m),w=(d*d-u*u-r*x)/(2*d*n*m),E=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);h=(N-E)/t,S=function(_){var M=_*h,R=$f(E),$=u/(n*m)*(R*YE(t*M+E)-WE(E));return[l+$*y,a+$*v,u*R/$f(t*M+E)]}}return S.duration=h*1e3*t/Math.SQRT2,S}return o.rho=function(i){var s=Math.max(.001,+i),l=s*s,a=l*l;return e(s,l,a)},o}(Math.SQRT2,2,4);var Ar=0,xo=0,ho=0,$g=1e3,Us,wo,Ws=0,qn=0,wl=0,ti=typeof performance=="object"&&performance.now?performance:Date,Dg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Oc(){return qn||(Dg(XE),qn=ti.now()+wl)}function XE(){qn=0}function Ys(){this._call=this._time=this._next=null}Ys.prototype=Og.prototype={constructor:Ys,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Oc():+n)+(t==null?0:+t),!this._next&&wo!==this&&(wo?wo._next=this:Us=this,wo=this),this._call=e,this._time=n,Eu()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eu())}};function Og(e,t,n){var r=new Ys;return r.restart(e,t,n),r}function GE(){Oc(),++Ar;for(var e=Us,t;e;)(t=qn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ar}function Df(){qn=(Ws=ti.now())+wl,Ar=xo=0;try{GE()}finally{Ar=0,QE(),qn=0}}function KE(){var e=ti.now(),t=e-Ws;t>$g&&(wl-=t,Ws=e)}function QE(){for(var e,t=Us,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:Us=n);wo=e,Eu(r)}function Eu(e){if(!Ar){xo&&(xo=clearTimeout(xo));var t=e-qn;t>24?(e<1/0&&(xo=setTimeout(Df,e-ti.now()-wl)),ho&&(ho=clearInterval(ho))):(ho||(Ws=ti.now(),ho=setInterval(KE,$g)),Ar=1,Dg(Df))}}function Of(e,t,n){var r=new Ys;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var ZE=vl("start","end","cancel","interrupt"),qE=[],Fg=0,Ff=1,Nu=2,fs=3,Hf=4,Cu=5,hs=6;function Sl(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;JE(e,n,{name:t,index:r,group:o,on:ZE,tween:qE,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fg})}function Fc(e,t){var n=Nt(e,t);if(n.state>Fg)throw new Error("too late; already scheduled");return n}function zt(e,t){var n=Nt(e,t);if(n.state>fs)throw new Error("too late; already running");return n}function Nt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function JE(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Og(i,0,n.time);function i(u){n.state=Ff,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,c,d,y;if(n.state!==Ff)return a();for(f in r)if(y=r[f],y.name===n.name){if(y.state===fs)return Of(s);y.state===Hf?(y.state=hs,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[f]):+f<t&&(y.state=hs,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[f])}if(Of(function(){n.state===fs&&(n.state=Hf,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Nu,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Nu){for(n.state=fs,o=new Array(d=n.tween.length),f=0,c=-1;f<d;++f)(y=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++c]=y);o.length=c+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(a),n.state=Cu,1),c=-1,d=o.length;++c<d;)o[c].call(e,f);n.state===Cu&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=hs,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function ps(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Nu&&r.state<Cu,r.state=hs,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function eN(e){return this.each(function(){ps(this,e)})}function tN(e,t){var n,r;return function(){var o=zt(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,l=r.length;s<l;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function nN(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=zt(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var l={name:t,value:n},a=0,u=o.length;a<u;++a)if(o[a].name===t){o[a]=l;break}a===u&&o.push(l)}i.tween=o}}function rN(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Nt(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?tN:nN)(n,e,t))}function Hc(e,t,n){var r=e._id;return e.each(function(){var o=zt(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Nt(o,r).value[t]}}function Hg(e,t){var n;return(typeof t=="number"?bt:t instanceof Zn?Bs:(n=Zn(t))?(t=n,Bs):Tg)(e,t)}function oN(e){return function(){this.removeAttribute(e)}}function iN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sN(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function lN(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function aN(e,t,n){var r,o,i;return function(){var s,l=n(this),a;return l==null?void this.removeAttribute(e):(s=this.getAttribute(e),a=l+"",s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l)))}}function uN(e,t,n){var r,o,i;return function(){var s,l=n(this),a;return l==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),a=l+"",s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l)))}}function cN(e,t){var n=xl(e),r=n==="transform"?BE:Hg;return this.attrTween(e,typeof t=="function"?(n.local?uN:aN)(n,r,Hc(this,"attr."+e,t)):t==null?(n.local?iN:oN)(n):(n.local?lN:sN)(n,r,t))}function dN(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fN(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hN(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&fN(e,i)),n}return o._value=t,o}function pN(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&dN(e,i)),n}return o._value=t,o}function mN(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=xl(e);return this.tween(n,(r.local?hN:pN)(r,t))}function gN(e,t){return function(){Fc(this,e).delay=+t.apply(this,arguments)}}function yN(e,t){return t=+t,function(){Fc(this,e).delay=t}}function vN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?gN:yN)(t,e)):Nt(this.node(),t).delay}function xN(e,t){return function(){zt(this,e).duration=+t.apply(this,arguments)}}function wN(e,t){return t=+t,function(){zt(this,e).duration=t}}function SN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xN:wN)(t,e)):Nt(this.node(),t).duration}function kN(e,t){if(typeof t!="function")throw new Error;return function(){zt(this,e).ease=t}}function EN(e){var t=this._id;return arguments.length?this.each(kN(t,e)):Nt(this.node(),t).ease}function NN(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;zt(this,e).ease=n}}function CN(e){if(typeof e!="function")throw new Error;return this.each(NN(this._id,e))}function _N(e){typeof e!="function"&&(e=vg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=[],a,u=0;u<s;++u)(a=i[u])&&e.call(a,a.__data__,u,i)&&l.push(a);return new Qt(r,this._parents,this._name,this._id)}function bN(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),l=0;l<i;++l)for(var a=t[l],u=n[l],f=a.length,c=s[l]=new Array(f),d,y=0;y<f;++y)(d=a[y]||u[y])&&(c[y]=d);for(;l<r;++l)s[l]=t[l];return new Qt(s,this._parents,this._name,this._id)}function PN(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 MN(e,t,n){var r,o,i=PN(t)?Fc:zt;return function(){var s=i(this,e),l=s.on;l!==r&&(o=(r=l).copy()).on(t,n),s.on=o}}function jN(e,t){var n=this._id;return arguments.length<2?Nt(this.node(),n).on.on(e):this.each(MN(n,e,t))}function LN(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RN(){return this.on("end.remove",LN(this._id))}function IN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zc(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var l=r[s],a=l.length,u=i[s]=new Array(a),f,c,d=0;d<a;++d)(f=l[d])&&(c=e.call(f,f.__data__,d,l))&&("__data__"in f&&(c.__data__=f.__data__),u[d]=c,Sl(u[d],t,n,d,u,Nt(f,n)));return new Qt(i,this._parents,t,n)}function TN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=yg(e));for(var r=this._groups,o=r.length,i=[],s=[],l=0;l<o;++l)for(var a=r[l],u=a.length,f,c=0;c<u;++c)if(f=a[c]){for(var d=e.call(f,f.__data__,c,a),y,v=Nt(f,n),x=0,S=d.length;x<S;++x)(y=d[x])&&Sl(y,t,n,x,d,v);i.push(d),s.push(f)}return new Qt(i,s,t,n)}var zN=pi.prototype.constructor;function AN(){return new zN(this._groups,this._parents)}function $N(e,t){var n,r,o;return function(){var i=zr(this,e),s=(this.style.removeProperty(e),zr(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Vg(e){return function(){this.style.removeProperty(e)}}function DN(e,t,n){var r,o=n+"",i;return function(){var s=zr(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function ON(e,t,n){var r,o,i;return function(){var s=zr(this,e),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(e),zr(this,e))),s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l))}}function FN(e,t){var n,r,o,i="style."+t,s="end."+i,l;return function(){var a=zt(this,e),u=a.on,f=a.value[i]==null?l||(l=Vg(t)):void 0;(u!==n||o!==f)&&(r=(n=u).copy()).on(s,o=f),a.on=r}}function HN(e,t,n){var r=(e+="")=="transform"?VE:Hg;return t==null?this.styleTween(e,$N(e,r)).on("end.style."+e,Vg(e)):typeof t=="function"?this.styleTween(e,ON(e,r,Hc(this,"style."+e,t))).each(FN(this._id,e)):this.styleTween(e,DN(e,r,t),n).on("end.style."+e,null)}function VN(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function BN(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&VN(e,s,n)),r}return i._value=t,i}function UN(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,BN(e,t,n??""))}function WN(e){return function(){this.textContent=e}}function YN(e){return function(){var t=e(this);this.textContent=t??""}}function XN(e){return this.tween("text",typeof e=="function"?YN(Hc(this,"text",e)):WN(e==null?"":e+""))}function GN(e){return function(t){this.textContent=e.call(this,t)}}function KN(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&GN(o)),t}return r._value=e,r}function QN(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,KN(e))}function ZN(){for(var e=this._name,t=this._id,n=Bg(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],l=s.length,a,u=0;u<l;++u)if(a=s[u]){var f=Nt(a,t);Sl(a,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Qt(r,this._parents,e,n)}function qN(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var l={value:s},a={value:function(){--o===0&&i()}};n.each(function(){var u=zt(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(a)),u.on=t}),o===0&&i()})}var JN=0;function Qt(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Bg(){return++JN}var Dt=pi.prototype;Qt.prototype={constructor:Qt,select:IN,selectAll:TN,selectChild:Dt.selectChild,selectChildren:Dt.selectChildren,filter:_N,merge:bN,selection:AN,transition:ZN,call:Dt.call,nodes:Dt.nodes,node:Dt.node,size:Dt.size,empty:Dt.empty,each:Dt.each,on:jN,attr:cN,attrTween:mN,style:HN,styleTween:UN,text:XN,textTween:QN,remove:RN,tween:rN,delay:vN,duration:SN,ease:EN,easeVarying:CN,end:qN,[Symbol.iterator]:Dt[Symbol.iterator]};function eC(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tC={time:null,delay:0,duration:250,ease:eC};function nC(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 rC(e){var t,n;e instanceof Qt?(t=e._id,e=e._name):(t=Bg(),(n=tC).time=Oc(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],l=s.length,a,u=0;u<l;++u)(a=s[u])&&Sl(a,e,t,u,s,n||nC(a,t));return new Qt(r,this._parents,e,t)}pi.prototype.interrupt=eN;pi.prototype.transition=rC;const Wi=e=>()=>e;function oC(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Bt(e,t,n){this.k=e,this.x=t,this.y=n}Bt.prototype={constructor:Bt,scale:function(e){return e===1?this:new Bt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Bt(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 kl=new Bt(1,0,0);Ug.prototype=Bt.prototype;function Ug(e){for(;!e.__zoom;)if(!(e=e.parentNode))return kl;return e.__zoom}function fa(e){e.stopImmediatePropagation()}function po(e){e.preventDefault(),e.stopImmediatePropagation()}function iC(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sC(){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 Vf(){return this.__zoom||kl}function lC(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aC(){return navigator.maxTouchPoints||"ontouchstart"in this}function uC(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Wg(){var e=iC,t=sC,n=uC,r=lC,o=aC,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,a=ds,u=vl("start","zoom","end"),f,c,d,y=500,v=150,x=0,S=10;function h(b){b.property("__zoom",Vf).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",$).filter(o).on("touchstart.zoom",I).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}h.transform=function(b,z,j,A){var C=b.selection?b.selection():b;C.property("__zoom",Vf),b!==C?E(b,z,j,A):C.interrupt().each(function(){N(this,arguments).event(A).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},h.scaleBy=function(b,z,j,A){h.scaleTo(b,function(){var C=this.__zoom.k,P=typeof z=="function"?z.apply(this,arguments):z;return C*P},j,A)},h.scaleTo=function(b,z,j,A){h.transform(b,function(){var C=t.apply(this,arguments),P=this.__zoom,T=j==null?w(C):typeof j=="function"?j.apply(this,arguments):j,O=P.invert(T),D=typeof z=="function"?z.apply(this,arguments):z;return n(p(m(P,D),T,O),C,s)},j,A)},h.translateBy=function(b,z,j,A){h.transform(b,function(){return n(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),s)},null,A)},h.translateTo=function(b,z,j,A,C){h.transform(b,function(){var P=t.apply(this,arguments),T=this.__zoom,O=A==null?w(P):typeof A=="function"?A.apply(this,arguments):A;return n(kl.translate(O[0],O[1]).scale(T.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof j=="function"?-j.apply(this,arguments):-j),P,s)},A,C)};function m(b,z){return z=Math.max(i[0],Math.min(i[1],z)),z===b.k?b:new Bt(z,b.x,b.y)}function p(b,z,j){var A=z[0]-j[0]*b.k,C=z[1]-j[1]*b.k;return A===b.x&&C===b.y?b:new Bt(b.k,A,C)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function E(b,z,j,A){b.on("start.zoom",function(){N(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(A).end()}).tween("zoom",function(){var C=this,P=arguments,T=N(C,P).event(A),O=t.apply(C,P),D=j==null?w(O):typeof j=="function"?j.apply(C,P):j,U=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),B=C.__zoom,Y=typeof z=="function"?z.apply(C,P):z,X=a(B.invert(D).concat(U/B.k),Y.invert(D).concat(U/Y.k));return function(G){if(G===1)G=Y;else{var V=X(G),Q=U/V[2];G=new Bt(Q,D[0]-V[0]*Q,D[1]-V[1]*Q)}T.zoom(null,G)}})}function N(b,z,j){return!j&&b.__zooming||new _(b,z)}function _(b,z){this.that=b,this.args=z,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,z),this.taps=0}_.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,z){return this.mouse&&b!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var z=Qe(this.that).datum();u.call(b,this.that,new oC(b,{sourceEvent:this.sourceEvent,target:h,transform:this.that.__zoom,dispatch:u}),z)}};function M(b,...z){if(!e.apply(this,arguments))return;var j=N(this,z).event(b),A=this.__zoom,C=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),P=mt(b);if(j.wheel)(j.mouse[0][0]!==P[0]||j.mouse[0][1]!==P[1])&&(j.mouse[1]=A.invert(j.mouse[0]=P)),clearTimeout(j.wheel);else{if(A.k===C)return;j.mouse=[P,A.invert(P)],ps(this),j.start()}po(b),j.wheel=setTimeout(T,v),j.zoom("mouse",n(p(m(A,C),j.mouse[0],j.mouse[1]),j.extent,s));function T(){j.wheel=null,j.end()}}function R(b,...z){if(d||!e.apply(this,arguments))return;var j=b.currentTarget,A=N(this,z,!0).event(b),C=Qe(b.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",U,!0),P=mt(b,j),T=b.clientX,O=b.clientY;Pg(b.view),fa(b),A.mouse=[P,this.__zoom.invert(P)],ps(this),A.start();function D(B){if(po(B),!A.moved){var Y=B.clientX-T,X=B.clientY-O;A.moved=Y*Y+X*X>x}A.event(B).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=mt(B,j),A.mouse[1]),A.extent,s))}function U(B){C.on("mousemove.zoom mouseup.zoom",null),Mg(B.view,A.moved),po(B),A.event(B).end()}}function $(b,...z){if(e.apply(this,arguments)){var j=this.__zoom,A=mt(b.changedTouches?b.changedTouches[0]:b,this),C=j.invert(A),P=j.k*(b.shiftKey?.5:2),T=n(p(m(j,P),A,C),t.apply(this,z),s);po(b),l>0?Qe(this).transition().duration(l).call(E,T,A,b):Qe(this).call(h.transform,T,A,b)}}function I(b,...z){if(e.apply(this,arguments)){var j=b.touches,A=j.length,C=N(this,z,b.changedTouches.length===A).event(b),P,T,O,D;for(fa(b),T=0;T<A;++T)O=j[T],D=mt(O,this),D=[D,this.__zoom.invert(D),O.identifier],C.touch0?!C.touch1&&C.touch0[2]!==D[2]&&(C.touch1=D,C.taps=0):(C.touch0=D,P=!0,C.taps=1+!!f);f&&(f=clearTimeout(f)),P&&(C.taps<2&&(c=D[0],f=setTimeout(function(){f=null},y)),ps(this),C.start())}}function L(b,...z){if(this.__zooming){var j=N(this,z).event(b),A=b.changedTouches,C=A.length,P,T,O,D;for(po(b),P=0;P<C;++P)T=A[P],O=mt(T,this),j.touch0&&j.touch0[2]===T.identifier?j.touch0[0]=O:j.touch1&&j.touch1[2]===T.identifier&&(j.touch1[0]=O);if(T=j.that.__zoom,j.touch1){var U=j.touch0[0],B=j.touch0[1],Y=j.touch1[0],X=j.touch1[1],G=(G=Y[0]-U[0])*G+(G=Y[1]-U[1])*G,V=(V=X[0]-B[0])*V+(V=X[1]-B[1])*V;T=m(T,Math.sqrt(G/V)),O=[(U[0]+Y[0])/2,(U[1]+Y[1])/2],D=[(B[0]+X[0])/2,(B[1]+X[1])/2]}else if(j.touch0)O=j.touch0[0],D=j.touch0[1];else return;j.zoom("touch",n(p(T,O,D),j.extent,s))}}function F(b,...z){if(this.__zooming){var j=N(this,z).event(b),A=b.changedTouches,C=A.length,P,T;for(fa(b),d&&clearTimeout(d),d=setTimeout(function(){d=null},y),P=0;P<C;++P)T=A[P],j.touch0&&j.touch0[2]===T.identifier?delete j.touch0:j.touch1&&j.touch1[2]===T.identifier&&delete j.touch1;if(j.touch1&&!j.touch0&&(j.touch0=j.touch1,delete j.touch1),j.touch0)j.touch0[1]=this.__zoom.invert(j.touch0[0]);else if(j.end(),j.taps===2&&(T=mt(T,this),Math.hypot(c[0]-T[0],c[1]-T[1])<S)){var O=Qe(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return h.wheelDelta=function(b){return arguments.length?(r=typeof b=="function"?b:Wi(+b),h):r},h.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Wi(!!b),h):e},h.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Wi(!!b),h):o},h.extent=function(b){return arguments.length?(t=typeof b=="function"?b:Wi([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),h):t},h.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],h):[i[0],i[1]]},h.translateExtent=function(b){return arguments.length?(s[0][0]=+b[0][0],s[1][0]=+b[1][0],s[0][1]=+b[0][1],s[1][1]=+b[1][1],h):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},h.constrain=function(b){return arguments.length?(n=b,h):n},h.duration=function(b){return arguments.length?(l=+b,h):l},h.interpolate=function(b){return arguments.length?(a=b,h):a},h.on=function(){var b=u.on.apply(u,arguments);return b===u?h:b},h.clickDistance=function(b){return arguments.length?(x=(b=+b)*b,h):Math.sqrt(x)},h.tapDistance=function(b){return arguments.length?(S=+b,h):S},h}const Rt={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.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ni=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yg=["Enter"," ","Escape"],Xg={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var $r;(function(e){e.Strict="strict",e.Loose="loose"})($r||($r={}));var Wn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wn||(Wn={}));var ri;(function(e){e.Partial="partial",e.Full="full"})(ri||(ri={}));const Gg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var cn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(cn||(cn={}));var Xs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xs||(Xs={}));var K;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(K||(K={}));const Bf={[K.Left]:K.Right,[K.Right]:K.Left,[K.Top]:K.Bottom,[K.Bottom]:K.Top};function Kg(e){return e===null?null:e?"valid":"invalid"}const Qg=e=>"id"in e&&"source"in e&&"target"in e,cC=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Vc=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gi=(e,t=[0,0])=>{const{width:n,height:r}=qt(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},dC=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):Vc(o)?o:t.nodeLookup.get(o.id));const l=s?Gs(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return El(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nl(n)},yi=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=El(n,Gs(o)),r=!0)}),r?Nl(n):{x:0,y:0,width:0,height:0}},Bc=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const l={...xi(t,[n,r,o]),width:t.width/o,height:t.height/o},a=[];for(const u of e.values()){const{measured:f,selectable:c=!0,hidden:d=!1}=u;if(s&&!c||d)continue;const y=f.width??u.width??u.initialWidth??null,v=f.height??u.height??u.initialHeight??null,x=oi(l,Or(u)),S=(y??0)*(v??0),h=i&&x>0;(!u.internals.handleBounds||h||x>=S||u.dragging)&&a.push(u)}return a},fC=(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 hC(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function pC({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=hC(e,s),a=yi(l),u=Uc(a,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Zg({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:a,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let c=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!l)i==null||i("005",Rt.error005());else{const y=l.measured.width,v=l.measured.height;y&&v&&(c=[[a,u],[a+y,u+v]])}else l&&Fr(s.extent)&&(c=[[s.extent[0][0]+a,s.extent[0][1]+u],[s.extent[1][0]+a,s.extent[1][1]+u]]);const d=Fr(c)?Jn(t,c,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",Rt.error015())),{position:{x:d.x-a+(s.measured.width??0)*f[0],y:d.y-u+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function mC({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const y=i.has(d.id),v=!y&&d.parentId&&s.find(x=>x.id===d.parentId);(y||v)&&s.push(d)}const l=new Set(t.map(d=>d.id)),a=r.filter(d=>d.deletable!==!1),f=fC(s,a);for(const d of a)l.has(d.id)&&!f.find(v=>v.id===d.id)&&f.push(d);if(!o)return{edges:f,nodes:s};const c=await o({nodes:s,edges:f});return typeof c=="boolean"?c?{edges:f,nodes:s}:{edges:[],nodes:[]}:c}const Dr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Jn=(e={x:0,y:0},t,n)=>({x:Dr(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Dr(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function qg(e,t,n){const{width:r,height:o}=qt(n),{x:i,y:s}=n.internals.positionAbsolute;return Jn(e,[[i,s],[i+r,s+o]],t)}const Uf=(e,t,n)=>e<t?Dr(Math.abs(e-t),1,t)/t:e>n?-Dr(Math.abs(e-n),1,t)/t:0,Jg=(e,t,n=15,r=40)=>{const o=Uf(e.x,r,t.width-r)*n,i=Uf(e.y,r,t.height-r)*n;return[o,i]},El=(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)}),_u=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Nl=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Or=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Vc(e)?e.internals.positionAbsolute:gi(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Gs=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Vc(e)?e.internals.positionAbsolute:gi(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},ey=(e,t)=>Nl(El(_u(e),_u(t))),oi=(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)},Wf=e=>vt(e.width)&&vt(e.height)&&vt(e.x)&&vt(e.y),vt=e=>!isNaN(e)&&isFinite(e),gC=(e,t)=>{},vi=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),xi=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?vi(l,s):l},Ks=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function ir(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function yC(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ir(e,n),o=ir(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=ir(e.top??e.y??0,n),o=ir(e.bottom??e.y??0,n),i=ir(e.left??e.x??0,t),s=ir(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function vC(e,t,n,r,o,i){const{x:s,y:l}=Ks(e,[t,n,r]),{x:a,y:u}=Ks({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-a,c=i-u;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(c)}}const Uc=(e,t,n,r,o,i)=>{const s=yC(i,t,n),l=(t-s.x)/e.width,a=(n-s.y)/e.height,u=Math.min(l,a),f=Dr(u,r,o),c=e.x+e.width/2,d=e.y+e.height/2,y=t/2-c*f,v=n/2-d*f,x=vC(e,y,v,f,t,n),S={left:Math.min(x.left-s.left,0),top:Math.min(x.top-s.top,0),right:Math.min(x.right-s.right,0),bottom:Math.min(x.bottom-s.bottom,0)};return{x:y-S.left+S.right,y:v-S.top+S.bottom,zoom:f}},ii=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Fr(e){return e!=null&&e!=="parent"}function qt(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 ty(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 ny(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const l=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function Yf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xC(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function wC(e){return{...Xg,...e||{}}}function Lo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=xt(e),l=xi({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:a,y:u}=n?vi(l,t):l;return{xSnapped:a,ySnapped:u,...l}}const Wc=e=>({width:e.offsetWidth,height:e.offsetHeight}),ry=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},SC=["INPUT","SELECT","TEXTAREA"];function oy(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:SC.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const iy=e=>"clientX"in e,xt=(e,t)=>{var i,s;const n=iy(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Xf=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...Wc(s)}})};function sy({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:l}){const a=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+l*.375+r*.125,f=Math.abs(a-e),c=Math.abs(u-t);return[a,u,f,c]}function Yi(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Gf({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case K.Left:return[t-Yi(t-r,i),n];case K.Right:return[t+Yi(r-t,i),n];case K.Top:return[t,n-Yi(n-o,i)];case K.Bottom:return[t,n+Yi(o-n,i)]}}function ly({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:i=K.Top,curvature:s=.25}){const[l,a]=Gf({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,f]=Gf({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[c,d,y,v]=sy({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${a} ${u},${f} ${r},${o}`,c,d,y,v]}function ay({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,l=r<t?r+s:r-s;return[i,l,o,s]}function kC({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,l=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+l}function EC({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=El(Gs(e),Gs(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return oi(s,Nl(i))>0}const NC=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,CC=(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)),_C=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||NC;let o;return Qg(e)?o={...e}:o={...e,id:r(e)},CC(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function uy({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,l]=ay({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,l]}const Kf={[K.Left]:{x:-1,y:0},[K.Right]:{x:1,y:0},[K.Top]:{x:0,y:-1},[K.Bottom]:{x:0,y:1}},bC=({source:e,sourcePosition:t=K.Bottom,target:n})=>t===K.Left||t===K.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},Qf=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function PC({source:e,sourcePosition:t=K.Bottom,target:n,targetPosition:r=K.Top,center:o,offset:i,stepPosition:s}){const l=Kf[t],a=Kf[r],u={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+a.x*i,y:n.y+a.y*i},c=bC({source:u,sourcePosition:t,target:f}),d=c.x!==0?"x":"y",y=c[d];let v=[],x,S;const h={x:0,y:0},m={x:0,y:0},[,,p,w]=ay({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*a[d]===-1){d==="x"?(x=o.x??u.x+(f.x-u.x)*s,S=o.y??(u.y+f.y)/2):(x=o.x??(u.x+f.x)/2,S=o.y??u.y+(f.y-u.y)*s);const N=[{x,y:u.y},{x,y:f.y}],_=[{x:u.x,y:S},{x:f.x,y:S}];l[d]===y?v=d==="x"?N:_:v=d==="x"?_:N}else{const N=[{x:u.x,y:f.y}],_=[{x:f.x,y:u.y}];if(d==="x"?v=l.x===y?_:N:v=l.y===y?N:_,t===r){const L=Math.abs(e[d]-n[d]);if(L<=i){const F=Math.min(i-1,i-L);l[d]===y?h[d]=(u[d]>e[d]?-1:1)*F:m[d]=(f[d]>n[d]?-1:1)*F}}if(t!==r){const L=d==="x"?"y":"x",F=l[d]===a[L],b=u[L]>f[L],z=u[L]<f[L];(l[d]===1&&(!F&&b||F&&z)||l[d]!==1&&(!F&&z||F&&b))&&(v=d==="x"?N:_)}const M={x:u.x+h.x,y:u.y+h.y},R={x:f.x+m.x,y:f.y+m.y},$=Math.max(Math.abs(M.x-v[0].x),Math.abs(R.x-v[0].x)),I=Math.max(Math.abs(M.y-v[0].y),Math.abs(R.y-v[0].y));$>=I?(x=(M.x+R.x)/2,S=v[0].y):(x=v[0].x,S=(M.y+R.y)/2)}return[[e,{x:u.x+h.x,y:u.y+h.y},...v,{x:f.x+m.x,y:f.y+m.y},n],x,S,p,w]}function MC(e,t,n,r){const o=Math.min(Qf(e,t)/2,Qf(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*f}`}const l=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${s+o*a}Q ${i},${s} ${i+o*l},${s}`}function bu({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:i=K.Top,borderRadius:s=5,centerX:l,centerY:a,offset:u=20,stepPosition:f=.5}){const[c,d,y,v,x]=PC({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:l,y:a},offset:u,stepPosition:f});return[c.reduce((h,m,p)=>{let w="";return p>0&&p<c.length-1?w=MC(c[p-1],m,c[p+1],s):w=`${p===0?"M":"L"}${m.x} ${m.y}`,h+=w,h},""),d,y,v,x]}function Zf(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function jC(e){var c;const{sourceNode:t,targetNode:n}=e;if(!Zf(t)||!Zf(n))return null;const r=t.internals.handleBounds||qf(t.handles),o=n.internals.handleBounds||qf(n.handles),i=Jf((r==null?void 0:r.source)??[],e.sourceHandle),s=Jf(e.connectionMode===$r.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(c=e.onError)==null||c.call(e,"008",Rt.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||K.Bottom,a=(s==null?void 0:s.position)||K.Top,u=er(t,i,l),f=er(n,s,a);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:a}}function qf(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 er(e,t,n=K.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:l}=t??qt(e);if(r)return{x:o+s/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case K.Top:return{x:o+s/2,y:i};case K.Right:return{x:o+s,y:i+l/2};case K.Bottom:return{x:o+s/2,y:i+l};case K.Left:return{x:o,y:i+l/2}}}function Jf(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Pu(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function LC(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||r,l.markerEnd||o].forEach(a=>{if(a&&typeof a=="object"){const u=Pu(a,t);i.has(u)||(s.push({id:u,color:a.color||n,...a}),i.add(u))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const cy=1e3,RC=10,Yc={nodeOrigin:[0,0],nodeExtent:ni,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},IC={...Yc,checkEquality:!0};function Xc(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function TC(e,t,n){const r=Xc(Yc,n);for(const o of e.values())if(o.parentId)Kc(o,e,t,r);else{const i=gi(o,r.nodeOrigin),s=Fr(o.extent)?o.extent:r.nodeExtent,l=Jn(i,s,qt(o));o.internals.positionAbsolute=l}}function zC(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function Gc(e){return e==="manual"}function Mu(e,t,n,r={}){var u,f;const o=Xc(IC,r),i={i:0},s=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!Gc(o.zIndexMode)?cy:0;let a=e.length>0;t.clear(),n.clear();for(const c of e){let d=s.get(c.id);if(o.checkEquality&&c===(d==null?void 0:d.internals.userNode))t.set(c.id,d);else{const y=gi(c,o.nodeOrigin),v=Fr(c.extent)?c.extent:o.nodeExtent,x=Jn(y,v,qt(c));d={...o.defaults,...c,measured:{width:(u=c.measured)==null?void 0:u.width,height:(f=c.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:zC(c,d),z:dy(c,l,o.zIndexMode),userNode:c}},t.set(c.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(a=!1),c.parentId&&Kc(d,t,n,r,i)}return a}function AC(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 Kc(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:a}=Xc(Yc,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}AC(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&a==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*RC),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const c=i&&!Gc(a)?cy:0,{x:d,y,z:v}=$C(e,f,s,l,c,a),{positionAbsolute:x}=e.internals,S=d!==x.x||y!==x.y;(S||v!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:d,y}:x,z:v}})}function dy(e,t,n){const r=vt(e.zIndex)?e.zIndex:0;return Gc(n)?r:r+(e.selected?t:0)}function $C(e,t,n,r,o,i){const{x:s,y:l}=t.internals.positionAbsolute,a=qt(e),u=gi(e,n),f=Fr(e.extent)?Jn(u,e.extent,a):u;let c=Jn({x:s+f.x,y:l+f.y},r,a);e.extent==="parent"&&(c=qg(c,a,t));const d=dy(e,o,i),y=t.internals.z??0;return{x:c.x,y:c.y,z:y>=d?y+1:d}}function Qc(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const u=((s=i.get(l.parentId))==null?void 0:s.expandedRect)??Or(a),f=ey(u,l.rect);i.set(l.parentId,{expandedRect:f,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},u)=>{var p;const f=a.internals.positionAbsolute,c=qt(a),d=a.origin??r,y=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,v=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,x=Math.max(c.width,Math.round(l.width)),S=Math.max(c.height,Math.round(l.height)),h=(x-c.width)*d[0],m=(S-c.height)*d[1];(y>0||v>0||h||m)&&(o.push({id:u,type:"position",position:{x:a.position.x-y+h,y:a.position.y-v+m}}),(p=n.get(u))==null||p.forEach(w=>{e.some(E=>E.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+y,y:w.position.y+v}})})),(c.width<l.width||c.height<l.height||y||v)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(y?d[0]*y-h:0),height:S+(v?d[1]*v-m:0)}})}),o}function DC(e,t,n,r,o,i,s){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let a=!1;if(!l)return{changes:[],updatedInternals:a};const u=[],f=window.getComputedStyle(l),{m22:c}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const y of e.values()){const v=t.get(y.id);if(!v)continue;if(v.hidden){t.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),a=!0;continue}const x=Wc(y.nodeElement),S=v.measured.width!==x.width||v.measured.height!==x.height;if(!!(x.width&&x.height&&(S||!v.internals.handleBounds||y.force))){const m=y.nodeElement.getBoundingClientRect(),p=Fr(v.extent)?v.extent:i;let{positionAbsolute:w}=v.internals;v.parentId&&v.extent==="parent"?w=qg(w,x,t.get(v.parentId)):p&&(w=Jn(w,p,x));const E={...v,measured:x,internals:{...v.internals,positionAbsolute:w,handleBounds:{source:Xf("source",y.nodeElement,m,c,v.id),target:Xf("target",y.nodeElement,m,c,v.id)}}};t.set(v.id,E),v.parentId&&Kc(E,t,n,{nodeOrigin:o,zIndexMode:s}),a=!0,S&&(u.push({id:v.id,type:"dimensions",dimensions:x}),v.expandParent&&v.parentId&&d.push({id:v.id,parentId:v.parentId,rect:Or(E,o)}))}}if(d.length>0){const y=Qc(d,t,n,o);u.push(...y)}return{changes:u,updatedInternals:a}}async function OC({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function eh(e,t,n,r,o,i){let s=o;const l=r.get(s)||new Map;r.set(s,l.set(n,t)),s=`${o}-${e}`;const a=r.get(s)||new Map;if(r.set(s,a.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function fy(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:l=null}=r,a={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:l},u=`${o}-${s}--${i}-${l}`,f=`${i}-${l}--${o}-${s}`;eh("source",a,f,e,o,s),eh("target",a,u,e,i,l),t.set(r.id,r)}}function hy(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:hy(n,t):!1}function th(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function FC(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!hy(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return o}function ha({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,l,a;const o=[];for(const[u,f]of t){const c=(s=n.get(u))==null?void 0:s.internals.userNode;c&&o.push({...c,position:f.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:r}:o[0],o]}function HC({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=vi(i,t);return{x:s.x-i.x,y:s.y-i.y}}function VC({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,l=new Map,a=!1,u={x:0,y:0},f=null,c=!1,d=null,y=!1,v=!1,x=null;function S({noDragClassName:m,handleSelector:p,domNode:w,isSelectable:E,nodeId:N,nodeClickDistance:_=0}){d=Qe(w);function M({x:L,y:F}){const{nodeLookup:b,nodeExtent:z,snapGrid:j,snapToGrid:A,nodeOrigin:C,onNodeDrag:P,onSelectionDrag:T,onError:O,updateNodePositions:D}=t();i={x:L,y:F};let U=!1;const B=l.size>1,Y=B&&z?_u(yi(l)):null,X=B&&A?HC({dragItems:l,snapGrid:j,x:L,y:F}):null;for(const[G,V]of l){if(!b.has(G))continue;let Q={x:L-V.distance.x,y:F-V.distance.y};A&&(Q=X?{x:Math.round(Q.x+X.x),y:Math.round(Q.y+X.y)}:vi(Q,j));let te=null;if(B&&z&&!V.extent&&Y){const{positionAbsolute:Z}=V.internals,se=Z.x-Y.x+z[0][0],ue=Z.x+V.measured.width-Y.x2+z[1][0],ie=Z.y-Y.y+z[0][1],Ie=Z.y+V.measured.height-Y.y2+z[1][1];te=[[se,ie],[ue,Ie]]}const{position:J,positionAbsolute:q}=Zg({nodeId:G,nextPosition:Q,nodeLookup:b,nodeExtent:te||z,nodeOrigin:C,onError:O});U=U||V.position.x!==J.x||V.position.y!==J.y,V.position=J,V.internals.positionAbsolute=q}if(v=v||U,!!U&&(D(l,!0),x&&(r||P||!N&&T))){const[G,V]=ha({nodeId:N,dragItems:l,nodeLookup:b});r==null||r(x,l,G,V),P==null||P(x,G,V),N||T==null||T(x,V)}}async function R(){if(!f)return;const{transform:L,panBy:F,autoPanSpeed:b,autoPanOnNodeDrag:z}=t();if(!z){a=!1,cancelAnimationFrame(s);return}const[j,A]=Jg(u,f,b);(j!==0||A!==0)&&(i.x=(i.x??0)-j/L[2],i.y=(i.y??0)-A/L[2],await F({x:j,y:A})&&M(i)),s=requestAnimationFrame(R)}function $(L){var B;const{nodeLookup:F,multiSelectionActive:b,nodesDraggable:z,transform:j,snapGrid:A,snapToGrid:C,selectNodesOnDrag:P,onNodeDragStart:T,onSelectionDragStart:O,unselectNodesAndEdges:D}=t();c=!0,(!P||!E)&&!b&&N&&((B=F.get(N))!=null&&B.selected||D()),E&&P&&N&&(e==null||e(N));const U=Lo(L.sourceEvent,{transform:j,snapGrid:A,snapToGrid:C,containerBounds:f});if(i=U,l=FC(F,z,U,N),l.size>0&&(n||T||!N&&O)){const[Y,X]=ha({nodeId:N,dragItems:l,nodeLookup:F});n==null||n(L.sourceEvent,l,Y,X),T==null||T(L.sourceEvent,Y,X),N||O==null||O(L.sourceEvent,X)}}const I=jg().clickDistance(_).on("start",L=>{const{domNode:F,nodeDragThreshold:b,transform:z,snapGrid:j,snapToGrid:A}=t();f=(F==null?void 0:F.getBoundingClientRect())||null,y=!1,v=!1,x=L.sourceEvent,b===0&&$(L),i=Lo(L.sourceEvent,{transform:z,snapGrid:j,snapToGrid:A,containerBounds:f}),u=xt(L.sourceEvent,f)}).on("drag",L=>{const{autoPanOnNodeDrag:F,transform:b,snapGrid:z,snapToGrid:j,nodeDragThreshold:A,nodeLookup:C}=t(),P=Lo(L.sourceEvent,{transform:b,snapGrid:z,snapToGrid:j,containerBounds:f});if(x=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!C.has(N))&&(y=!0),!y){if(!a&&F&&c&&(a=!0,R()),!c){const T=xt(L.sourceEvent,f),O=T.x-u.x,D=T.y-u.y;Math.sqrt(O*O+D*D)>A&&$(L)}(i.x!==P.xSnapped||i.y!==P.ySnapped)&&l&&c&&(u=xt(L.sourceEvent,f),M(P))}}).on("end",L=>{if(!(!c||y)&&(a=!1,c=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:F,updateNodePositions:b,onNodeDragStop:z,onSelectionDragStop:j}=t();if(v&&(b(l,!1),v=!1),o||z||!N&&j){const[A,C]=ha({nodeId:N,dragItems:l,nodeLookup:F,dragging:!1});o==null||o(L.sourceEvent,l,A,C),z==null||z(L.sourceEvent,A,C),N||j==null||j(L.sourceEvent,C)}}}).filter(L=>{const F=L.target;return!L.button&&(!m||!th(F,`.${m}`,w))&&(!p||th(F,p,w))});d.call(I)}function h(){d==null||d.on(".drag",null)}return{update:S,destroy:h}}function BC(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())oi(o,Or(i))>0&&r.push(i);return r}const UC=250;function WC(e,t,n,r){var l,a;let o=[],i=1/0;const s=BC(e,n,t+UC);for(const u of s){const f=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((a=u.internals.handleBounds)==null?void 0:a.target)??[]];for(const c of f){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:d,y}=er(u,c,c.position,!0),v=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(y-e.y,2));v>t||(v<i?(o=[{...c,x:d,y}],i=v):v===i&&o.push({...c,x:d,y}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(f=>f.type===u)??o[0]}return o[0]}function py(e,t,n,r,o,i=!1){var u,f,c;const s=r.get(e);if(!s)return null;const l=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((c=s.internals.handleBounds)==null?void 0:c.target)??[]],a=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return a&&i?{...a,...er(s,a,a.position,!0)}:a}function my(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function YC(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const gy=()=>!0;function XC(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:a,lib:u,autoPanOnConnect:f,flowId:c,panBy:d,cancelConnection:y,onConnectStart:v,onConnect:x,onConnectEnd:S,isValidConnection:h=gy,onReconnectEnd:m,updateConnection:p,getTransform:w,getFromHandle:E,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:M}){const R=ry(e.target);let $=0,I;const{x:L,y:F}=xt(e),b=my(i,M),z=l==null?void 0:l.getBoundingClientRect();let j=!1;if(!z||!b)return;const A=py(o,b,r,a,t);if(!A)return;let C=xt(e,z),P=!1,T=null,O=!1,D=null;function U(){if(!f||!z)return;const[J,q]=Jg(C,z,N);d({x:J,y:q}),$=requestAnimationFrame(U)}const B={...A,nodeId:o,type:b,position:A.position},Y=a.get(o);let G={inProgress:!0,isValid:null,from:er(Y,B,K.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:C,toHandle:null,toPosition:Bf[B.position],toNode:null,pointer:C};function V(){j=!0,p(G),v==null||v(e,{nodeId:o,handleId:r,handleType:b})}_===0&&V();function Q(J){if(!j){const{x:Ie,y:Jt}=xt(J),At=Ie-L,Ln=Jt-F;if(!(At*At+Ln*Ln>_*_))return;V()}if(!E()||!B){te(J);return}const q=w();C=xt(J,z),I=WC(xi(C,q,!1,[1,1]),n,a,B),P||(U(),P=!0);const Z=yy(J,{handle:I,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:h,doc:R,lib:u,flowId:c,nodeLookup:a});D=Z.handleDomNode,T=Z.connection,O=YC(!!I,Z.isValid);const se=a.get(o),ue=se?er(se,B,K.Left,!0):G.from,ie={...G,from:ue,isValid:O,to:Z.toHandle&&O?Ks({x:Z.toHandle.x,y:Z.toHandle.y},q):C,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:Bf[B.position],toNode:Z.toHandle?a.get(Z.toHandle.nodeId):null,pointer:C};p(ie),G=ie}function te(J){if(!("touches"in J&&J.touches.length>0)){if(j){(I||D)&&T&&O&&(x==null||x(T));const{inProgress:q,...Z}=G,se={...Z,toPosition:G.toHandle?G.toPosition:null};S==null||S(J,se),i&&(m==null||m(J,se))}y(),cancelAnimationFrame($),P=!1,O=!1,T=null,D=null,R.removeEventListener("mousemove",Q),R.removeEventListener("mouseup",te),R.removeEventListener("touchmove",Q),R.removeEventListener("touchend",te)}}R.addEventListener("mousemove",Q),R.addEventListener("mouseup",te),R.addEventListener("touchmove",Q),R.addEventListener("touchend",te)}function yy(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:l,flowId:a,isValidConnection:u=gy,nodeLookup:f}){const c=i==="target",d=t?s.querySelector(`.${l}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:y,y:v}=xt(e),x=s.elementFromPoint(y,v),S=x!=null&&x.classList.contains(`${l}-flow__handle`)?x:d,h={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const m=my(void 0,S),p=S.getAttribute("data-nodeid"),w=S.getAttribute("data-handleid"),E=S.classList.contains("connectable"),N=S.classList.contains("connectableend");if(!p||!m)return h;const _={source:c?p:r,sourceHandle:c?w:o,target:c?r:p,targetHandle:c?o:w};h.connection=_;const R=E&&N&&(n===$r.Strict?c&&m==="source"||!c&&m==="target":p!==r||w!==o);h.isValid=R&&u(_),h.toHandle=py(p,m,w,f,n,!0)}return h}const ju={onPointerDown:XC,isValid:yy};function GC({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Qe(e);function i({translateExtent:l,width:a,height:u,zoomStep:f=1,pannable:c=!0,zoomable:d=!0,inversePan:y=!1}){const v=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),E=p.sourceEvent.ctrlKey&&ii()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,_=w[2]*Math.pow(2,N*E);t.scaleTo(_)};let x=[0,0];const S=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(x=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},h=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[E[0]-x[0],E[1]-x[1]];x=E;const _=r()*Math.max(w[2],Math.log(w[2]))*(y?-1:1),M={x:w[0]-N[0]*_,y:w[1]-N[1]*_},R=[[0,0],[a,u]];t.setViewportConstrained({x:M.x,y:M.y,zoom:w[2]},R,l)},m=Wg().on("start",S).on("zoom",c?h:null).on("zoom.wheel",d?v:null);o.call(m,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:mt}}const Cl=e=>({x:e.x,y:e.y,zoom:e.k}),pa=({x:e,y:t,zoom:n})=>kl.translate(e,t).scale(n),vr=(e,t)=>e.target.closest(`.${t}`),vy=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),KC=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ma=(e,t=0,n=KC,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},xy=e=>{const t=e.ctrlKey&&ii()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QC({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:u}){return f=>{if(vr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(f.ctrlKey&&s){const S=mt(f),h=xy(f),m=c*Math.pow(2,h);r.scaleTo(n,m,S,f);return}const d=f.deltaMode===1?20:1;let y=o===Wn.Vertical?0:f.deltaX*d,v=o===Wn.Horizontal?0:f.deltaY*d;!ii()&&f.shiftKey&&o!==Wn.Vertical&&(y=f.deltaY*d,v=0),r.translateBy(n,-(y/c)*i,-(v/c)*i,{internal:!0});const x=Cl(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(a==null||a(f,x),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,x))}}function ZC({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,l=vr(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),s||l)return null;r.preventDefault(),n.call(this,r,o)}}function qC({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Cl(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function JC({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,l;e.usedRightMouseButton=!!(n&&vy(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Cl(i.transform)))}}function e_({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var l;if(!((l=s.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&vy(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const a=Cl(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,a)},n?150:0)}}}function t_({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:a,lib:u,connectionInProgress:f}){return c=>{var S;const d=e||t,y=n&&c.ctrlKey,v=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(vr(c,`${u}-flow__node`)||vr(c,`${u}-flow__edge`)))return!0;if(!r&&!d&&!o&&!i&&!n||s||f&&!v||vr(c,l)&&v||vr(c,a)&&(!v||o&&v&&!e)||!n&&c.ctrlKey&&v)return!1;if(!n&&c.type==="touchstart"&&((S=c.touches)==null?void 0:S.length)>1)return c.preventDefault(),!1;if(!d&&!o&&!y&&v||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||v)&&x}}function n_({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:a}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),c=Wg().scaleExtent([t,n]).translateExtent(r),d=Qe(e).call(c);m({x:o.x,y:o.y,zoom:Dr(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const y=d.on("wheel.zoom"),v=d.on("dblclick.zoom");c.wheelDelta(xy);function x(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).transform(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function S({noWheelClassName:I,noPanClassName:L,onPaneContextMenu:F,userSelectionActive:b,panOnScroll:z,panOnDrag:j,panOnScrollMode:A,panOnScrollSpeed:C,preventScrolling:P,zoomOnPinch:T,zoomOnScroll:O,zoomOnDoubleClick:D,zoomActivationKeyPressed:U,lib:B,onTransformChange:Y,connectionInProgress:X,paneClickDistance:G,selectionOnDrag:V}){b&&!u.isZoomingOrPanning&&h();const Q=z&&!U&&!b;c.clickDistance(V?1/0:!vt(G)||G<0?0:G);const te=Q?QC({zoomPanValues:u,noWheelClassName:I,d3Selection:d,d3Zoom:c,panOnScrollMode:A,panOnScrollSpeed:C,zoomOnPinch:T,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):ZC({noWheelClassName:I,preventScrolling:P,d3ZoomHandler:y});if(d.on("wheel.zoom",te,{passive:!1}),!b){const q=qC({zoomPanValues:u,onDraggingChange:a,onPanZoomStart:s});c.on("start",q);const Z=JC({zoomPanValues:u,panOnDrag:j,onPaneContextMenu:!!F,onPanZoom:i,onTransformChange:Y});c.on("zoom",Z);const se=e_({zoomPanValues:u,panOnDrag:j,panOnScroll:z,onPaneContextMenu:F,onPanZoomEnd:l,onDraggingChange:a});c.on("end",se)}const J=t_({zoomActivationKeyPressed:U,panOnDrag:j,zoomOnScroll:O,panOnScroll:z,zoomOnDoubleClick:D,zoomOnPinch:T,userSelectionActive:b,noPanClassName:L,noWheelClassName:I,lib:B,connectionInProgress:X});c.filter(J),D?d.on("dblclick.zoom",v):d.on("dblclick.zoom",null)}function h(){c.on("zoom",null)}async function m(I,L,F){const b=pa(I),z=c==null?void 0:c.constrain()(b,L,F);return z&&await x(z),new Promise(j=>j(z))}async function p(I,L){const F=pa(I);return await x(F,L),new Promise(b=>b(F))}function w(I){if(d){const L=pa(I),F=d.property("__zoom");(F.k!==I.zoom||F.x!==I.x||F.y!==I.y)&&(c==null||c.transform(d,L,null,{sync:!0}))}}function E(){const I=d?Ug(d.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}function N(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).scaleTo(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function _(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).scaleBy(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function M(I){c==null||c.scaleExtent(I)}function R(I){c==null||c.translateExtent(I)}function $(I){const L=!vt(I)||I<0?0:I;c==null||c.clickDistance(L)}return{update:S,destroy:h,setViewport:p,setViewportConstrained:m,getViewport:E,scaleTo:N,scaleBy:_,setScaleExtent:M,setTranslateExtent:R,syncViewport:w,setClickDistance:$}}var Hr;(function(e){e.Line="line",e.Handle="handle"})(Hr||(Hr={}));function r_({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,l=n-r,a=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&o&&(a[0]=a[0]*-1),l&&i&&(a[1]=a[1]*-1),a}function nh(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function rn(e,t){return Math.max(0,t-e)}function on(e,t){return Math.max(0,e-t)}function Xi(e,t,n){return Math.max(0,t-e,e-n)}function rh(e,t){return e?!t:t}function o_(e,t,n,r,o,i,s,l){let{affectsX:a,affectsY:u}=t;const{isHorizontal:f,isVertical:c}=t,d=f&&c,{xSnapped:y,ySnapped:v}=n,{minWidth:x,maxWidth:S,minHeight:h,maxHeight:m}=r,{x:p,y:w,width:E,height:N,aspectRatio:_}=e;let M=Math.floor(f?y-e.pointerX:0),R=Math.floor(c?v-e.pointerY:0);const $=E+(a?-M:M),I=N+(u?-R:R),L=-i[0]*E,F=-i[1]*N;let b=Xi($,x,S),z=Xi(I,h,m);if(s){let C=0,P=0;a&&M<0?C=rn(p+M+L,s[0][0]):!a&&M>0&&(C=on(p+$+L,s[1][0])),u&&R<0?P=rn(w+R+F,s[0][1]):!u&&R>0&&(P=on(w+I+F,s[1][1])),b=Math.max(b,C),z=Math.max(z,P)}if(l){let C=0,P=0;a&&M>0?C=on(p+M,l[0][0]):!a&&M<0&&(C=rn(p+$,l[1][0])),u&&R>0?P=on(w+R,l[0][1]):!u&&R<0&&(P=rn(w+I,l[1][1])),b=Math.max(b,C),z=Math.max(z,P)}if(o){if(f){const C=Xi($/_,h,m)*_;if(b=Math.max(b,C),s){let P=0;!a&&!u||a&&!u&&d?P=on(w+F+$/_,s[1][1])*_:P=rn(w+F+(a?M:-M)/_,s[0][1])*_,b=Math.max(b,P)}if(l){let P=0;!a&&!u||a&&!u&&d?P=rn(w+$/_,l[1][1])*_:P=on(w+(a?M:-M)/_,l[0][1])*_,b=Math.max(b,P)}}if(c){const C=Xi(I*_,x,S)/_;if(z=Math.max(z,C),s){let P=0;!a&&!u||u&&!a&&d?P=on(p+I*_+L,s[1][0])/_:P=rn(p+(u?R:-R)*_+L,s[0][0])/_,z=Math.max(z,P)}if(l){let P=0;!a&&!u||u&&!a&&d?P=rn(p+I*_,l[1][0])/_:P=on(p+(u?R:-R)*_,l[0][0])/_,z=Math.max(z,P)}}}R=R+(R<0?z:-z),M=M+(M<0?b:-b),o&&(d?$>I*_?R=(rh(a,u)?-M:M)/_:M=(rh(a,u)?-R:R)*_:f?(R=M/_,u=a):(M=R*_,a=u));const j=a?p+M:p,A=u?w+R:w;return{width:E+(a?-M:M),height:N+(u?-R:R),x:i[0]*M*(a?-1:1)+j,y:i[1]*R*(u?-1:1)+A}}const wy={width:0,height:0,x:0,y:0},i_={...wy,pointerX:0,pointerY:0,aspectRatio:1};function s_(e){return[[0,0],[e.measured.width,e.measured.height]]}function l_(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,a=n[1]*s;return[[r-l,o-a],[r+i-l,o+s-a]]}function a_({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Qe(e);let s={controlDirection:nh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:f,keepAspectRatio:c,resizeDirection:d,onResizeStart:y,onResize:v,onResizeEnd:x,shouldResize:S}){let h={...wy},m={...i_};s={boundaries:f,resizeDirection:d,keepAspectRatio:c,controlDirection:nh(u)};let p,w=null,E=[],N,_,M,R=!1;const $=jg().on("start",I=>{const{nodeLookup:L,transform:F,snapGrid:b,snapToGrid:z,nodeOrigin:j,paneDomNode:A}=n();if(p=L.get(t),!p)return;w=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:P}=Lo(I.sourceEvent,{transform:F,snapGrid:b,snapToGrid:z,containerBounds:w});h={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},m={...h,pointerX:C,pointerY:P,aspectRatio:h.width/h.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=L.get(p.parentId),_=N&&p.extent==="parent"?s_(N):void 0),E=[],M=void 0;for(const[T,O]of L)if(O.parentId===t&&(E.push({id:T,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const D=l_(O,p,O.origin??j);M?M=[[Math.min(D[0][0],M[0][0]),Math.min(D[0][1],M[0][1])],[Math.max(D[1][0],M[1][0]),Math.max(D[1][1],M[1][1])]]:M=D}y==null||y(I,{...h})}).on("drag",I=>{const{transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z}=n(),j=Lo(I.sourceEvent,{transform:L,snapGrid:F,snapToGrid:b,containerBounds:w}),A=[];if(!p)return;const{x:C,y:P,width:T,height:O}=h,D={},U=p.origin??z,{width:B,height:Y,x:X,y:G}=o_(m,s.controlDirection,j,s.boundaries,s.keepAspectRatio,U,_,M),V=B!==T,Q=Y!==O,te=X!==C&&V,J=G!==P&&Q;if(!te&&!J&&!V&&!Q)return;if((te||J||U[0]===1||U[1]===1)&&(D.x=te?X:h.x,D.y=J?G:h.y,h.x=D.x,h.y=D.y,E.length>0)){const ue=X-C,ie=G-P;for(const Ie of E)Ie.position={x:Ie.position.x-ue+U[0]*(B-T),y:Ie.position.y-ie+U[1]*(Y-O)},A.push(Ie)}if((V||Q)&&(D.width=V&&(!s.resizeDirection||s.resizeDirection==="horizontal")?B:h.width,D.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:h.height,h.width=D.width,h.height=D.height),N&&p.expandParent){const ue=U[0]*(D.width??0);D.x&&D.x<ue&&(h.x=ue,m.x=m.x-(D.x-ue));const ie=U[1]*(D.height??0);D.y&&D.y<ie&&(h.y=ie,m.y=m.y-(D.y-ie))}const q=r_({width:h.width,prevWidth:T,height:h.height,prevHeight:O,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...h,direction:q};(S==null?void 0:S(I,Z))!==!1&&(R=!0,v==null||v(I,Z),r(D,A))}).on("end",I=>{R&&(x==null||x(I,{...h}),o==null||o({...h}),R=!1)});i.call($)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var Sy={exports:{}},ky={},Ey={exports:{}},Ny={};/**
|
|
156
|
+
*/const ok=Re("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),ik=[{label:"Discovery",items:[{to:"/inventory/agents",label:"Agents",icon:cg},{to:"/inventory/identities",label:"Identities",icon:dg},{to:"/inventory/permissions",label:"Permissions",icon:qS}]},{label:"Secure",items:[{to:"/secure/risk",label:"Risk",icon:hg},{to:"/secure/graph",label:"Graph",icon:tk}]}];function sk(){const e=It(),[t,n]=k.useState("");return k.useEffect(()=>{fetch("/health").then(r=>r.json()).then(r=>n(r.version??"")).catch(()=>{})},[]),g.jsxs("aside",{className:"flex w-56 flex-col border-r border-border bg-card",children:[g.jsxs("div",{className:"flex h-14 items-center gap-2 border-b border-border px-4",children:[g.jsx("img",{src:"/dashboard/logo-512.png",alt:"OpenTrust",className:"h-6 w-6 dark:brightness-[1.8] dark:contrast-125"}),g.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"OpenTrust"})]}),g.jsx("nav",{className:"flex-1 space-y-6 px-3 py-4",children:ik.map(r=>g.jsxs("div",{children:[g.jsx("p",{className:"mb-2 px-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:r.label}),g.jsx("div",{className:"space-y-0.5",children:r.items.map(o=>g.jsxs(Jm,{to:o.to,className:Tt("flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm transition-colors",e.pathname.startsWith(o.to)?"bg-accent text-accent-foreground font-medium":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[g.jsx(o.icon,{className:"h-4 w-4 shrink-0"}),o.label]},o.to))})]},r.label))}),g.jsx("div",{className:"border-t border-border px-4 py-3",children:g.jsx("p",{className:"text-[11px] text-muted-foreground",children:t?`v${t}`:""})})]})}function lk(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ak(...e){return t=>e.forEach(n=>lk(n,t))}var pg=k.forwardRef((e,t)=>{const{children:n,...r}=e,o=k.Children.toArray(n),i=o.find(ck);if(i){const s=i.props.children,l=o.map(a=>a===i?k.Children.count(s)>1?k.Children.only(null):k.isValidElement(s)?s.props.children:null:a);return g.jsx(yu,{...r,ref:t,children:k.isValidElement(s)?k.cloneElement(s,void 0,l):null})}return g.jsx(yu,{...r,ref:t,children:n})});pg.displayName="Slot";var yu=k.forwardRef((e,t)=>{const{children:n,...r}=e;if(k.isValidElement(n)){const o=fk(n);return k.cloneElement(n,{...dk(r,n.props),ref:t?ak(t,o):o})}return k.Children.count(n)>1?k.Children.only(null):null});yu.displayName="SlotClone";var uk=({children:e})=>g.jsx(g.Fragment,{children:e});function ck(e){return k.isValidElement(e)&&e.type===uk}function dk(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{i(...l),o(...l)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function fk(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function mg(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=mg(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function hk(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=mg(e))&&(r&&(r+=" "),r+=t);return r}const Nf=e=>typeof e=="boolean"?"".concat(e):e===0?"0":e,Cf=hk,pk=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Cf(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const f=n==null?void 0:n[u],c=i==null?void 0:i[u];if(f===null)return null;const d=Nf(f)||Nf(c);return o[u][d]}),l=n&&Object.entries(n).reduce((u,f)=>{let[c,d]=f;return d===void 0||(u[c]=d),u},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,f)=>{let{class:c,className:d,...y}=f;return Object.entries(y).every(v=>{let[x,S]=v;return Array.isArray(S)?S.includes({...i,...l}[x]):{...i,...l}[x]===S})?[...u,c,d]:u},[]);return Cf(e,s,a,n==null?void 0:n.class,n==null?void 0:n.className)},mk=pk("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-border bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Qo=k.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?pg:"button";return g.jsx(s,{className:Tt(mk({variant:t,size:n,className:e})),ref:i,...o})});Qo.displayName="Button";function gk(){const{user:e,logout:t}=Ic(),{theme:n,setTheme:r}=lS();return g.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-border bg-card px-6",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"h-2 w-2 rounded-full bg-success"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"Connected"})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(e==null?void 0:e.email)&&g.jsx("span",{className:"text-xs text-muted-foreground",children:e.email}),g.jsx(Qo,{variant:"ghost",size:"icon",onClick:()=>r(n==="dark"?"light":"dark"),className:"h-8 w-8",children:n==="dark"?g.jsx(rk,{className:"h-4 w-4"}):g.jsx(ek,{className:"h-4 w-4"})}),g.jsx(Qo,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8",children:g.jsx(JS,{className:"h-4 w-4"})})]})]})}function yk(){return g.jsxs("div",{className:"flex h-screen overflow-hidden bg-background",children:[g.jsx(sk,{}),g.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[g.jsx(gk,{}),g.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:g.jsx(E1,{})})]})]})}const Zo=k.forwardRef(({className:e,type:t,...n},r)=>g.jsx("input",{type:t,className:Tt("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors","file:border-0 file:bg-transparent file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Zo.displayName="Input";function vk(){const[e]=eS(),[t,n]=k.useState(e.get("email")??""),[r,o]=k.useState(e.get("key")??""),[i,s]=k.useState(""),[l,a]=k.useState(!1),{login:u,isAuthenticated:f,isLoading:c}=Ic(),d=ml();if(k.useEffect(()=>{f&&d("/inventory/agents",{replace:!0})},[f,d]),c)return g.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:g.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading..."})});const y=async v=>{v.preventDefault(),s(""),a(!0);try{await u(t,r),d("/inventory/agents",{replace:!0})}catch(x){s(x instanceof Error?x.message:"Login failed")}finally{a(!1)}};return g.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:g.jsxs("div",{className:"w-full max-w-sm space-y-8 px-4",children:[g.jsxs("div",{className:"flex flex-col items-center gap-3",children:[g.jsx("img",{src:"/dashboard/logo-512.png",alt:"OpenTrust",className:"h-12 w-12 dark:brightness-[1.8] dark:contrast-125"}),g.jsxs("div",{className:"text-center",children:[g.jsx("h1",{className:"text-lg font-semibold tracking-tight text-foreground",children:"OpenTrust"}),g.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Sign in to your dashboard"})]})]}),g.jsxs("form",{onSubmit:y,className:"space-y-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium text-foreground",children:"Email"}),g.jsx(Zo,{type:"email",placeholder:"you@example.com",value:t,onChange:v=>n(v.target.value),required:!0})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Key"}),g.jsx(Zo,{type:"password",placeholder:"sk-og-...",value:r,onChange:v=>o(v.target.value),required:!0})]}),i&&g.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}),g.jsx(Qo,{type:"submit",className:"w-full",disabled:l,children:l?"Signing in...":"Sign in"})]}),g.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"API Key is generated when registering an agent with the Core API."})]})})}const xk="/api";async function Pe(e,t){const n=localStorage.getItem("opentrust_user"),r=n?JSON.parse(n).apiKey:null,o=await fetch(`${xk}${e}`,{...t,headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`},...t==null?void 0:t.headers}});if(!o.ok)throw new Error(`API ${o.status}: ${await o.text()}`);return o.json()}const bn={agents:{list:()=>Pe("/agents"),get:e=>Pe(`/agents/${e}`),create:e=>Pe("/agents",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Pe(`/agents/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Pe(`/agents/${e}`,{method:"DELETE"})},discovery:{agents:()=>Pe("/discovery/agents"),profile:e=>Pe(`/discovery/agents/${e}/profile`)},observations:{recent:(e=50)=>Pe(`/observations?limit=${e}`),permissions:()=>Pe("/observations/permissions"),anomalies:()=>Pe("/observations/anomalies"),summary:()=>Pe("/observations/summary"),agentPermissions:e=>Pe(`/observations/agents/${e}/permissions`)},detect:e=>Pe("/detect",{method:"POST",body:JSON.stringify(e)}),usage:{summary:(e=30)=>Pe(`/usage/summary?days=${e}`),daily:(e=30)=>Pe(`/usage/daily?days=${e}`)},settings:{get:()=>Pe("/settings"),update:e=>Pe("/settings",{method:"PUT",body:JSON.stringify(e)})}};function Ge({className:e,variant:t="default",...n}){return g.jsx("div",{className:Tt("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{"border-transparent bg-primary text-primary-foreground shadow":t==="default","border-transparent bg-secondary text-secondary-foreground":t==="secondary","border-transparent bg-destructive text-destructive-foreground shadow":t==="destructive","text-foreground":t==="outline","border-transparent bg-success/15 text-success":t==="success","border-transparent bg-warning/15 text-warning":t==="warning"},e),...n})}function wk(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[o,i]=k.useState(!0),s=async()=>{i(!0);try{const u=await bn.discovery.agents();t(u.data??[])}catch{}i(!1)};k.useEffect(()=>{s()},[]);const l=e.filter(u=>{var f;return!n||((f=u.name)==null?void 0:f.toLowerCase().includes(n.toLowerCase()))}),a=u=>u==="active"?"success":u==="inactive"?"secondary":"warning";return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Agents"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," agent",e.length!==1?"s":""," discovered"]})]}),g.jsxs(Qo,{variant:"outline",size:"sm",onClick:s,children:[g.jsx(nk,{className:"h-3.5 w-3.5"}),"Scan"]})]}),g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(fg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),g.jsx(Zo,{placeholder:"Search agents...",className:"pl-9",value:n,onChange:u=>r(u.target.value)})]}),o?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):l.length===0?g.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border",children:[g.jsx(cg,{className:"h-8 w-8 text-muted-foreground/50"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents found"})]}):g.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:l.map(u=>{var f;return g.jsxs(yl,{to:`/inventory/agents/${u.id}`,className:"group flex flex-col gap-3 rounded-lg border border-border bg-card p-4 transition-colors hover:border-muted-foreground/30",children:[g.jsxs("div",{className:"flex items-start justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2.5",children:[g.jsx("span",{className:"text-xl",children:u.emoji||"🤖"}),g.jsxs("div",{children:[g.jsx("p",{className:"text-sm font-medium text-foreground group-hover:text-foreground",children:u.name}),g.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.provider||"unknown",u.model?` · ${u.model}`:""]})]})]}),g.jsx(Ge,{variant:a(u.status??"inactive"),className:"text-[10px]",children:u.status??"inactive"})]}),((f=u.skills)==null?void 0:f.length)>0&&g.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.skills.slice(0,4).map(c=>g.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:typeof c=="string"?c:c.name},c.name??c)),u.skills.length>4&&g.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["+",u.skills.length-4]})]})]},u.id)})})]})}const hn=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("rounded-lg border border-border bg-card text-card-foreground shadow-sm",e),...t}));hn.displayName="Card";const On=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("flex flex-col space-y-1.5 p-6",e),...t}));On.displayName="CardHeader";const Fn=k.forwardRef(({className:e,...t},n)=>g.jsx("h3",{ref:n,className:Tt("font-semibold leading-none tracking-tight",e),...t}));Fn.displayName="CardTitle";const Sk=k.forwardRef(({className:e,...t},n)=>g.jsx("p",{ref:n,className:Tt("text-sm text-muted-foreground",e),...t}));Sk.displayName="CardDescription";const pn=k.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:Tt("p-6 pt-0",e),...t}));pn.displayName="CardContent";const kk=["Profile","Tasks","Identities","Permissions"];function Ek(){const{id:e}=u1(),[t,n]=k.useState(null),[r,o]=k.useState([]),[i,s]=k.useState("Profile"),[l,a]=k.useState(!0);return k.useEffect(()=>{e&&(a(!0),(async()=>{const u=await bn.discovery.profile(e).catch(()=>null),f=(u==null?void 0:u.data)??null;n(f);const c=(f==null?void 0:f.registeredAgentId)??e,d=await bn.observations.agentPermissions(c).catch(()=>({data:[]}));o((d==null?void 0:d.data)??[]),a(!1)})())},[e]),l?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):t?g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(yl,{to:"/inventory/agents",className:"rounded-md p-1.5 hover:bg-accent",children:g.jsx(YS,{className:"h-4 w-4"})}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("span",{className:"text-2xl",children:t.emoji||"🤖"}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-lg font-semibold",children:t.name||e}),g.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.provider||"unknown",t.model?` / ${t.model}`:""]})]})]})]}),g.jsx("div",{className:"flex gap-1 border-b border-border",children:kk.map(u=>g.jsx("button",{onClick:()=>s(u),className:Tt("border-b-2 px-4 py-2 text-sm font-medium transition-colors",i===u?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u},u))}),i==="Profile"&&g.jsx(Nk,{profile:t}),i==="Tasks"&&g.jsx(Ck,{profile:t}),i==="Identities"&&g.jsx(_k,{profile:t}),i==="Permissions"&&g.jsx(bk,{permissions:r})]}):g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Agent not found"})}function Nk({profile:e}){const t=e.skills??[];return g.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Info"})}),g.jsxs(pn,{className:"space-y-2 text-sm",children:[g.jsx(fo,{label:"Owner",value:e.ownerName||"—"}),g.jsx(fo,{label:"Creature",value:e.creature||"—"}),g.jsx(fo,{label:"Vibe",value:e.vibe||"—"}),g.jsx(fo,{label:"Sessions",value:String(e.sessionCount??0)}),g.jsx(fo,{label:"Last Active",value:e.lastActive??"never"})]})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(ok,{className:"h-4 w-4"})," Skills (",t.length,")"]})}),g.jsx(pn,{children:t.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No skills installed"}):g.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(n=>g.jsx(Ge,{variant:"secondary",className:"text-xs font-normal",children:n.name},n.name))})})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Plugins"})}),g.jsx(pn,{children:(e.plugins??[]).length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins"}):g.jsx("div",{className:"space-y-1.5",children:(e.plugins??[]).map(n=>g.jsxs("div",{className:"flex items-center justify-between text-sm",children:[g.jsx("span",{children:n.name}),g.jsx(Ge,{variant:n.enabled?"success":"secondary",className:"text-[10px]",children:n.enabled?"on":"off"})]},n.name))})})]}),g.jsxs(hn,{children:[g.jsx(On,{children:g.jsx(Fn,{className:"text-sm",children:"Connected Systems"})}),g.jsx(pn,{children:(e.connectedSystems??[]).length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"None"}):g.jsx("div",{className:"flex flex-wrap gap-1.5",children:(e.connectedSystems??[]).map(n=>g.jsx(Ge,{variant:"outline",className:"text-xs",children:n},n))})})]})]})}function Ck({profile:e}){const t=e.cronJobs??[];return g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(QS,{className:"h-4 w-4"})," Scheduled Tasks (",t.length,")"]})}),g.jsx(pn,{children:t.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks"}):g.jsx("div",{className:"space-y-2",children:t.map((n,r)=>g.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2 text-sm",children:[g.jsxs("div",{children:[g.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:n.schedule}),g.jsx("span",{className:"ml-2",children:n.task??n.id})]}),g.jsx(Ge,{variant:n.enabled!==!1?"success":"secondary",className:"text-[10px]",children:n.enabled!==!1?"active":"paused"})]},r))})})]})}function _k({profile:e}){const t=e.workspaceFiles??{},n=[{label:"SOUL.md",content:t.soul},{label:"IDENTITY.md",content:t.identity},{label:"USER.md",content:t.user}].filter(r=>r.content);return g.jsx("div",{className:"space-y-4",children:n.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No identity files found"}):n.map(r=>g.jsxs(hn,{children:[g.jsx(On,{children:g.jsxs(Fn,{className:"flex items-center gap-2 text-sm",children:[g.jsx(ZS,{className:"h-4 w-4"})," ",r.label]})}),g.jsx(pn,{children:g.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs text-muted-foreground",children:r.content})})]},r.label))})}function bk({permissions:e}){return e.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"No observed permissions"}):g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Tool"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Access"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"Calls"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"Errors"})]})}),g.jsx("tbody",{children:e.map(t=>g.jsxs("tr",{className:"border-b border-border last:border-0",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:t.toolName}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:t.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:t.accessPattern==="write"?"warning":t.accessPattern==="admin"?"destructive":"secondary",className:"text-[10px]",children:t.accessPattern??"read"})}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs",children:t.callCount}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs text-destructive",children:t.errorCount||"—"})]},t.id))})]})})}function fo({label:e,value:t}){return g.jsxs("div",{className:"flex justify-between",children:[g.jsx("span",{className:"text-muted-foreground",children:e}),g.jsx("span",{className:"font-medium",children:t})]})}function Pk(){const[e,t]=k.useState([]),[n,r]=k.useState(!0),[o,i]=k.useState(new Set);k.useEffect(()=>{bn.discovery.agents().then(a=>{t(a.data??[]),r(!1)}).catch(()=>r(!1))},[]);const s=[{category:"Agents",items:e.map(a=>({id:a.id,name:a.name,emoji:a.emoji,provider:a.provider,status:a.status}))},{category:"Owners",items:[...new Set(e.map(a=>a.ownerName).filter(Boolean))].map(a=>({id:a,name:a,type:"owner"}))},{category:"Connected Systems",items:[...new Set(e.flatMap(a=>a.connectedSystems??[]))].map(a=>({id:a,name:a,type:"system"}))}],l=a=>{i(u=>{const f=new Set(u);return f.has(a)?f.delete(a):f.add(a),f})};return n?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Identities"}),g.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agents, owners, and connected systems"})]}),g.jsx("div",{className:"space-y-3",children:s.map(a=>g.jsxs(hn,{children:[g.jsxs("button",{onClick:()=>l(a.category),className:"flex w-full items-center justify-between p-4 text-left",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(dg,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("span",{className:"text-sm font-medium",children:a.category}),g.jsx(Ge,{variant:"secondary",className:"text-[10px]",children:a.items.length})]}),o.has(a.category)?g.jsx(GS,{className:"h-4 w-4 text-muted-foreground"}):g.jsx(KS,{className:"h-4 w-4 text-muted-foreground"})]}),o.has(a.category)&&g.jsx(pn,{className:"border-t border-border pt-3",children:a.items.length===0?g.jsx("p",{className:"text-sm text-muted-foreground",children:"None"}):g.jsx("div",{className:"space-y-1.5",children:a.items.map(u=>g.jsxs("div",{className:"flex items-center justify-between rounded-md px-3 py-2 text-sm hover:bg-muted/50",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[u.emoji&&g.jsx("span",{className:"text-base",children:u.emoji}),g.jsx("span",{children:u.name})]}),u.status&&g.jsx(Ge,{variant:u.status==="active"?"success":"secondary",className:"text-[10px]",children:u.status}),u.type&&g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:u.type})]},u.id))})})]},a.category))})]})}function Mk(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[o,i]=k.useState("callCount"),[s,l]=k.useState(!1),[a,u]=k.useState(!0);k.useEffect(()=>{bn.observations.permissions().then(d=>{t(d.data??[]),u(!1)}).catch(()=>u(!1))},[]);const f=k.useMemo(()=>{let d=e;if(n){const y=n.toLowerCase();d=d.filter(v=>{var x,S;return((x=v.toolName)==null?void 0:x.toLowerCase().includes(y))||((S=v.category)==null?void 0:S.toLowerCase().includes(y))})}return[...d].sort((y,v)=>{const x=y[o]??0,S=v[o]??0;return typeof x=="string"?s?x.localeCompare(S):S.localeCompare(x):s?x-S:S-x})},[e,n,o,s]),c=d=>{o===d?l(!s):(i(d),l(!1))};return a?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Permissions"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," observed tool permission",e.length!==1?"s":""]})]}),g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(fg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),g.jsx(Zo,{placeholder:"Filter by tool or category...",className:"pl-9",value:n,onChange:d=>r(d.target.value)})]}),g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx(aa,{label:"Tool",sortKey:"toolName",current:o,asc:s,onSort:c}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Access"}),g.jsx(aa,{label:"Calls",sortKey:"callCount",current:o,asc:s,onSort:c,align:"right"}),g.jsx(aa,{label:"Errors",sortKey:"errorCount",current:o,asc:s,onSort:c,align:"right"})]})}),g.jsx("tbody",{children:f.length===0?g.jsx("tr",{children:g.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-muted-foreground",children:"No permissions"})}):f.map(d=>g.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:d.toolName}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:d.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:d.accessPattern==="write"?"warning":d.accessPattern==="admin"?"destructive":"secondary",className:"text-[10px]",children:d.accessPattern??"read"})}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs",children:d.callCount}),g.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs text-destructive",children:d.errorCount||"—"})]},d.id))})]})})]})}function aa({label:e,sortKey:t,current:n,asc:r,onSort:o,align:i="left"}){return g.jsx("th",{className:`cursor-pointer px-4 py-2.5 font-medium text-muted-foreground hover:text-foreground ${i==="right"?"text-right":"text-left"}`,onClick:()=>o(t),children:g.jsxs("span",{className:"inline-flex items-center gap-1",children:[e,n===t&&g.jsx(XS,{className:"h-3 w-3"})]})})}function jk(){const[e,t]=k.useState([]),[n,r]=k.useState(!0);k.useEffect(()=>{bn.observations.anomalies().then(s=>{t(s.data??[]),r(!1)}).catch(()=>r(!1))},[]);const o=s=>s.blocked||s.errorCount>3?"high":s.callCount===1||s.errorCount>0?"medium":"low",i=s=>s==="high"?"destructive":s==="medium"?"warning":"secondary";return n?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Risk Overview"}),g.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[e.length," anomal",e.length!==1?"ies":"y"," detected"]})]}),e.length===0?g.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border",children:[g.jsx(hg,{className:"h-8 w-8 text-muted-foreground/50"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"No anomalies detected"})]}):g.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Tool"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Agent"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Risk"}),g.jsx("th",{className:"px-4 py-2.5 text-left font-medium text-muted-foreground",children:"Category"}),g.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-muted-foreground",children:"First Seen"})]})}),g.jsx("tbody",{children:e.map(s=>{var a;const l=o(s);return g.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30",children:[g.jsx("td",{className:"px-4 py-2.5 font-mono text-xs",children:s.toolName}),g.jsx("td",{className:"px-4 py-2.5 text-xs text-muted-foreground",children:((a=s.agentId)==null?void 0:a.slice(0,8))??"—"}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:i(l),className:"text-[10px]",children:l})}),g.jsx("td",{className:"px-4 py-2.5",children:g.jsx(Ge,{variant:"outline",className:"text-[10px]",children:s.category??"—"})}),g.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-muted-foreground",children:s.firstSeen?new Date(s.firstSeen).toLocaleDateString():"—"})]},s.id)})})]})})]})}function Ee(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=Ee(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Lk={value:()=>{}};function vl(){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 cs(n)}function cs(e){this._=e}function Rk(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}cs.prototype=vl.prototype={constructor:cs,on:function(e,t){var n=this._,r=Rk(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=Ik(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=_f(n[o],e.name,t);else if(t==null)for(o in n)n[o]=_f(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new cs(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++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],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function Ik(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function _f(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Lk,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var vu="http://www.w3.org/1999/xhtml";const bf={svg:"http://www.w3.org/2000/svg",xhtml:vu,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function xl(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),bf.hasOwnProperty(t)?{space:bf[t],local:e}:e}function Tk(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===vu&&t.documentElement.namespaceURI===vu?t.createElement(e):t.createElementNS(n,e)}}function zk(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function gg(e){var t=xl(e);return(t.local?zk:Tk)(t)}function Ak(){}function zc(e){return e==null?Ak:function(){return this.querySelector(e)}}function $k(e){typeof e!="function"&&(e=zc(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=new Array(s),a,u,f=0;f<s;++f)(a=i[f])&&(u=e.call(a,a.__data__,f,i))&&("__data__"in a&&(u.__data__=a.__data__),l[f]=u);return new et(r,this._parents)}function Dk(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ok(){return[]}function yg(e){return e==null?Ok:function(){return this.querySelectorAll(e)}}function Fk(e){return function(){return Dk(e.apply(this,arguments))}}function Hk(e){typeof e=="function"?e=Fk(e):e=yg(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],l=s.length,a,u=0;u<l;++u)(a=s[u])&&(r.push(e.call(a,a.__data__,u,s)),o.push(a));return new et(r,o)}function vg(e){return function(){return this.matches(e)}}function xg(e){return function(t){return t.matches(e)}}var Vk=Array.prototype.find;function Bk(e){return function(){return Vk.call(this.children,e)}}function Uk(){return this.firstElementChild}function Wk(e){return this.select(e==null?Uk:Bk(typeof e=="function"?e:xg(e)))}var Yk=Array.prototype.filter;function Xk(){return Array.from(this.children)}function Gk(e){return function(){return Yk.call(this.children,e)}}function Kk(e){return this.selectAll(e==null?Xk:Gk(typeof e=="function"?e:xg(e)))}function Qk(e){typeof e!="function"&&(e=vg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=[],a,u=0;u<s;++u)(a=i[u])&&e.call(a,a.__data__,u,i)&&l.push(a);return new et(r,this._parents)}function wg(e){return new Array(e.length)}function Zk(){return new et(this._enter||this._groups.map(wg),this._parents)}function Fs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fs.prototype={constructor:Fs,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 qk(e){return function(){return e}}function Jk(e,t,n,r,o,i){for(var s=0,l,a=t.length,u=i.length;s<u;++s)(l=t[s])?(l.__data__=i[s],r[s]=l):n[s]=new Fs(e,i[s]);for(;s<a;++s)(l=t[s])&&(o[s]=l)}function e2(e,t,n,r,o,i,s){var l,a,u=new Map,f=t.length,c=i.length,d=new Array(f),y;for(l=0;l<f;++l)(a=t[l])&&(d[l]=y=s.call(a,a.__data__,l,t)+"",u.has(y)?o[l]=a:u.set(y,a));for(l=0;l<c;++l)y=s.call(e,i[l],l,i)+"",(a=u.get(y))?(r[l]=a,a.__data__=i[l],u.delete(y)):n[l]=new Fs(e,i[l]);for(l=0;l<f;++l)(a=t[l])&&u.get(d[l])===a&&(o[l]=a)}function t2(e){return e.__data__}function n2(e,t){if(!arguments.length)return Array.from(this,t2);var n=t?e2:Jk,r=this._parents,o=this._groups;typeof e!="function"&&(e=qk(e));for(var i=o.length,s=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var f=r[u],c=o[u],d=c.length,y=r2(e.call(f,f&&f.__data__,u,r)),v=y.length,x=l[u]=new Array(v),S=s[u]=new Array(v),h=a[u]=new Array(d);n(f,c,x,S,h,y,t);for(var m=0,p=0,w,E;m<v;++m)if(w=x[m]){for(m>=p&&(p=m+1);!(E=S[p])&&++p<v;);w._next=E||null}}return s=new et(s,r),s._enter=l,s._exit=a,s}function r2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function o2(){return new et(this._exit||this._groups.map(wg),this._parents)}function i2(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function s2(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),l=new Array(o),a=0;a<s;++a)for(var u=n[a],f=r[a],c=u.length,d=l[a]=new Array(c),y,v=0;v<c;++v)(y=u[v]||f[v])&&(d[v]=y);for(;a<o;++a)l[a]=n[a];return new et(l,this._parents)}function l2(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function a2(e){e||(e=u2);function t(c,d){return c&&d?e(c.__data__,d.__data__):!c-!d}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],l=s.length,a=o[i]=new Array(l),u,f=0;f<l;++f)(u=s[f])&&(a[f]=u);a.sort(t)}return new et(o,this._parents).order()}function u2(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function c2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function d2(){return Array.from(this)}function f2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function h2(){let e=0;for(const t of this)++e;return e}function p2(){return!this.node()}function m2(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,l;i<s;++i)(l=o[i])&&e.call(l,l.__data__,i,o);return this}function g2(e){return function(){this.removeAttribute(e)}}function y2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function v2(e,t){return function(){this.setAttribute(e,t)}}function x2(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function w2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function S2(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 k2(e,t){var n=xl(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?y2:g2:typeof t=="function"?n.local?S2:w2:n.local?x2:v2)(n,t))}function Sg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function E2(e){return function(){this.style.removeProperty(e)}}function N2(e,t,n){return function(){this.style.setProperty(e,t,n)}}function C2(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _2(e,t,n){return arguments.length>1?this.each((t==null?E2:typeof t=="function"?C2:N2)(e,t,n??"")):zr(this.node(),e)}function zr(e,t){return e.style.getPropertyValue(t)||Sg(e).getComputedStyle(e,null).getPropertyValue(t)}function b2(e){return function(){delete this[e]}}function P2(e,t){return function(){this[e]=t}}function M2(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function j2(e,t){return arguments.length>1?this.each((t==null?b2:typeof t=="function"?M2:P2)(e,t)):this.node()[e]}function kg(e){return e.trim().split(/^|\s+/)}function Ac(e){return e.classList||new Eg(e)}function Eg(e){this._node=e,this._names=kg(e.getAttribute("class")||"")}Eg.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 Ng(e,t){for(var n=Ac(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Cg(e,t){for(var n=Ac(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function L2(e){return function(){Ng(this,e)}}function R2(e){return function(){Cg(this,e)}}function I2(e,t){return function(){(t.apply(this,arguments)?Ng:Cg)(this,e)}}function T2(e,t){var n=kg(e+"");if(arguments.length<2){for(var r=Ac(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?I2:t?L2:R2)(n,t))}function z2(){this.textContent=""}function A2(e){return function(){this.textContent=e}}function $2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function D2(e){return arguments.length?this.each(e==null?z2:(typeof e=="function"?$2:A2)(e)):this.node().textContent}function O2(){this.innerHTML=""}function F2(e){return function(){this.innerHTML=e}}function H2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function V2(e){return arguments.length?this.each(e==null?O2:(typeof e=="function"?H2:F2)(e)):this.node().innerHTML}function B2(){this.nextSibling&&this.parentNode.appendChild(this)}function U2(){return this.each(B2)}function W2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Y2(){return this.each(W2)}function X2(e){var t=typeof e=="function"?e:gg(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function G2(){return null}function K2(e,t){var n=typeof e=="function"?e:gg(e),r=t==null?G2:typeof t=="function"?t:zc(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Q2(){var e=this.parentNode;e&&e.removeChild(this)}function Z2(){return this.each(Q2)}function q2(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function J2(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eE(e){return this.select(e?J2:q2)}function tE(e){return arguments.length?this.property("__data__",e):this.node().__data__}function nE(e){return function(t){e.call(this,t,this.__data__)}}function rE(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 oE(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++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 iE(e,t,n){return function(){var r=this.__on,o,i=nE(t);if(r){for(var s=0,l=r.length;s<l;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function sE(e,t,n){var r=rE(e+""),o,i=r.length,s;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,f;a<u;++a)for(o=0,f=l[a];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(l=t?iE:oE,o=0;o<i;++o)this.each(l(r[o],t,n));return this}function _g(e,t,n){var r=Sg(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function lE(e,t){return function(){return _g(this,e,t)}}function aE(e,t){return function(){return _g(this,e,t.apply(this,arguments))}}function uE(e,t){return this.each((typeof t=="function"?aE:lE)(e,t))}function*cE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var bg=[null];function et(e,t){this._groups=e,this._parents=t}function pi(){return new et([[document.documentElement]],bg)}function dE(){return this}et.prototype=pi.prototype={constructor:et,select:$k,selectAll:Hk,selectChild:Wk,selectChildren:Kk,filter:Qk,data:n2,enter:Zk,exit:o2,join:i2,merge:s2,selection:dE,order:l2,sort:a2,call:c2,nodes:d2,node:f2,size:h2,empty:p2,each:m2,attr:k2,style:_2,property:j2,classed:T2,text:D2,html:V2,raise:U2,lower:Y2,append:X2,insert:K2,remove:Z2,clone:eE,datum:tE,on:sE,dispatch:uE,[Symbol.iterator]:cE};function Qe(e){return typeof e=="string"?new et([[document.querySelector(e)]],[document.documentElement]):new et([[e]],bg)}function fE(e){let t;for(;t=e.sourceEvent;)e=t;return e}function mt(e,t){if(e=fE(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 o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const hE={passive:!1},qo={capture:!0,passive:!1};function ua(e){e.stopImmediatePropagation()}function _r(e){e.preventDefault(),e.stopImmediatePropagation()}function Pg(e){var t=e.document.documentElement,n=Qe(e).on("dragstart.drag",_r,qo);"onselectstart"in t?n.on("selectstart.drag",_r,qo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Mg(e,t){var n=e.document.documentElement,r=Qe(e).on("dragstart.drag",null);t&&(r.on("click.drag",_r,qo),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 Hi=e=>()=>e;function xu(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:l,dx:a,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}xu.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pE(e){return!e.ctrlKey&&!e.button}function mE(){return this.parentNode}function gE(e,t){return t??{x:e.x,y:e.y}}function yE(){return navigator.maxTouchPoints||"ontouchstart"in this}function jg(){var e=pE,t=mE,n=gE,r=yE,o={},i=vl("start","drag","end"),s=0,l,a,u,f,c=0;function d(w){w.on("mousedown.drag",y).filter(r).on("touchstart.drag",S).on("touchmove.drag",h,hE).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(w,E){if(!(f||!e.call(this,w,E))){var N=p(this,t.call(this,w,E),w,E,"mouse");N&&(Qe(w.view).on("mousemove.drag",v,qo).on("mouseup.drag",x,qo),Pg(w.view),ua(w),u=!1,l=w.clientX,a=w.clientY,N("start",w))}}function v(w){if(_r(w),!u){var E=w.clientX-l,N=w.clientY-a;u=E*E+N*N>c}o.mouse("drag",w)}function x(w){Qe(w.view).on("mousemove.drag mouseup.drag",null),Mg(w.view,u),_r(w),o.mouse("end",w)}function S(w,E){if(e.call(this,w,E)){var N=w.changedTouches,_=t.call(this,w,E),M=N.length,R,$;for(R=0;R<M;++R)($=p(this,_,w,E,N[R].identifier,N[R]))&&(ua(w),$("start",w,N[R]))}}function h(w){var E=w.changedTouches,N=E.length,_,M;for(_=0;_<N;++_)(M=o[E[_].identifier])&&(_r(w),M("drag",w,E[_]))}function m(w){var E=w.changedTouches,N=E.length,_,M;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),_=0;_<N;++_)(M=o[E[_].identifier])&&(ua(w),M("end",w,E[_]))}function p(w,E,N,_,M,R){var $=i.copy(),I=mt(R||N,E),L,F,b;if((b=n.call(w,new xu("beforestart",{sourceEvent:N,target:d,identifier:M,active:s,x:I[0],y:I[1],dx:0,dy:0,dispatch:$}),_))!=null)return L=b.x-I[0]||0,F=b.y-I[1]||0,function z(j,A,C){var P=I,T;switch(j){case"start":o[M]=z,T=s++;break;case"end":delete o[M],--s;case"drag":I=mt(C||A,E),T=s;break}$.call(j,w,new xu(j,{sourceEvent:A,subject:b,target:d,identifier:M,active:T,x:I[0]+L,y:I[1]+F,dx:I[0]-P[0],dy:I[1]-P[1],dispatch:$}),_)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Hi(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:Hi(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Hi(w),d):n},d.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Hi(!!w),d):r},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(c=(w=+w)*w,d):Math.sqrt(c)},d}function $c(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Lg(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function mi(){}var Jo=.7,Hs=1/Jo,br="\\s*([+-]?\\d+)\\s*",ei="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vE=/^#([0-9a-f]{3,8})$/,xE=new RegExp(`^rgb\\(${br},${br},${br}\\)$`),wE=new RegExp(`^rgb\\(${Lt},${Lt},${Lt}\\)$`),SE=new RegExp(`^rgba\\(${br},${br},${br},${ei}\\)$`),kE=new RegExp(`^rgba\\(${Lt},${Lt},${Lt},${ei}\\)$`),EE=new RegExp(`^hsl\\(${ei},${Lt},${Lt}\\)$`),NE=new RegExp(`^hsla\\(${ei},${Lt},${Lt},${ei}\\)$`),Pf={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};$c(mi,Zn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Mf,formatHex:Mf,formatHex8:CE,formatHsl:_E,formatRgb:jf,toString:jf});function Mf(){return this.rgb().formatHex()}function CE(){return this.rgb().formatHex8()}function _E(){return Rg(this).formatHsl()}function jf(){return this.rgb().formatRgb()}function Zn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=vE.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Lf(t):n===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Vi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Vi(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=xE.exec(e))?new Ue(t[1],t[2],t[3],1):(t=wE.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=SE.exec(e))?Vi(t[1],t[2],t[3],t[4]):(t=kE.exec(e))?Vi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=EE.exec(e))?Tf(t[1],t[2]/100,t[3]/100,1):(t=NE.exec(e))?Tf(t[1],t[2]/100,t[3]/100,t[4]):Pf.hasOwnProperty(e)?Lf(Pf[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function Lf(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function Vi(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ue(e,t,n,r)}function bE(e){return e instanceof mi||(e=Zn(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function wu(e,t,n,r){return arguments.length===1?bE(e):new Ue(e,t,n,r??1)}function Ue(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}$c(Ue,wu,Lg(mi,{brighter(e){return e=e==null?Hs:Math.pow(Hs,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jo:Math.pow(Jo,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(Un(this.r),Un(this.g),Un(this.b),Vs(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:Rf,formatHex:Rf,formatHex8:PE,formatRgb:If,toString:If}));function Rf(){return`#${Hn(this.r)}${Hn(this.g)}${Hn(this.b)}`}function PE(){return`#${Hn(this.r)}${Hn(this.g)}${Hn(this.b)}${Hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function If(){const e=Vs(this.opacity);return`${e===1?"rgb(":"rgba("}${Un(this.r)}, ${Un(this.g)}, ${Un(this.b)}${e===1?")":`, ${e})`}`}function Vs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Un(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Hn(e){return e=Un(e),(e<16?"0":"")+e.toString(16)}function Tf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yt(e,t,n,r)}function Rg(e){if(e instanceof yt)return new yt(e.h,e.s,e.l,e.opacity);if(e instanceof mi||(e=Zn(e)),!e)return new yt;if(e instanceof yt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,l=i-o,a=(i+o)/2;return l?(t===i?s=(n-r)/l+(n<r)*6:n===i?s=(r-t)/l+2:s=(t-n)/l+4,l/=a<.5?i+o:2-i-o,s*=60):l=a>0&&a<1?0:s,new yt(s,l,a,e.opacity)}function ME(e,t,n,r){return arguments.length===1?Rg(e):new yt(e,t,n,r??1)}function yt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}$c(yt,ME,Lg(mi,{brighter(e){return e=e==null?Hs:Math.pow(Hs,e),new yt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jo:Math.pow(Jo,e),new yt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Ue(ca(e>=240?e-240:e+120,o,r),ca(e,o,r),ca(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new yt(zf(this.h),Bi(this.s),Bi(this.l),Vs(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=Vs(this.opacity);return`${e===1?"hsl(":"hsla("}${zf(this.h)}, ${Bi(this.s)*100}%, ${Bi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function zf(e){return e=(e||0)%360,e<0?e+360:e}function Bi(e){return Math.max(0,Math.min(1,e||0))}function ca(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 Dc=e=>()=>e;function jE(e,t){return function(n){return e+n*t}}function LE(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 RE(e){return(e=+e)==1?Ig:function(t,n){return n-t?LE(t,n,e):Dc(isNaN(t)?n:t)}}function Ig(e,t){var n=t-e;return n?jE(e,n):Dc(isNaN(e)?t:e)}const Bs=function e(t){var n=RE(t);function r(o,i){var s=n((o=wu(o)).r,(i=wu(i)).r),l=n(o.g,i.g),a=n(o.b,i.b),u=Ig(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=l(f),o.b=a(f),o.opacity=u(f),o+""}}return r.gamma=e,r}(1);function IE(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function TE(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zE(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=jo(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(l){for(s=0;s<r;++s)i[s]=o[s](l);return i}}function AE(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $E(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=jo(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Su=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,da=new RegExp(Su.source,"g");function DE(e){return function(){return e}}function OE(e){return function(t){return e(t)+""}}function Tg(e,t){var n=Su.lastIndex=da.lastIndex=0,r,o,i,s=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Su.exec(e))&&(o=da.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(r=r[0])===(o=o[0])?l[s]?l[s]+=o:l[++s]=o:(l[++s]=null,a.push({i:s,x:bt(r,o)})),n=da.lastIndex;return n<t.length&&(i=t.slice(n),l[s]?l[s]+=i:l[++s]=i),l.length<2?a[0]?OE(a[0].x):DE(t):(t=a.length,function(u){for(var f=0,c;f<t;++f)l[(c=a[f]).i]=c.x(u);return l.join("")})}function jo(e,t){var n=typeof t,r;return t==null||n==="boolean"?Dc(t):(n==="number"?bt:n==="string"?(r=Zn(t))?(t=r,Bs):Tg:t instanceof Zn?Bs:t instanceof Date?AE:TE(t)?IE:Array.isArray(t)?zE:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?$E:bt)(e,t)}var Af=180/Math.PI,ku={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function zg(e,t,n,r,o,i){var s,l,a;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(a=e*n+t*r)&&(n-=e*a,r-=t*a),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,a/=l),e*r<t*n&&(e=-e,t=-t,a=-a,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Af,skewX:Math.atan(a)*Af,scaleX:s,scaleY:l}}var Ui;function FE(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ku:zg(t.a,t.b,t.c,t.d,t.e,t.f)}function HE(e){return e==null||(Ui||(Ui=document.createElementNS("http://www.w3.org/2000/svg","g")),Ui.setAttribute("transform",e),!(e=Ui.transform.baseVal.consolidate()))?ku:(e=e.matrix,zg(e.a,e.b,e.c,e.d,e.e,e.f))}function Ag(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,f,c,d,y,v){if(u!==c||f!==d){var x=y.push("translate(",null,t,null,n);v.push({i:x-4,x:bt(u,c)},{i:x-2,x:bt(f,d)})}else(c||d)&&y.push("translate("+c+t+d+n)}function s(u,f,c,d){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),d.push({i:c.push(o(c)+"rotate(",null,r)-2,x:bt(u,f)})):f&&c.push(o(c)+"rotate("+f+r)}function l(u,f,c,d){u!==f?d.push({i:c.push(o(c)+"skewX(",null,r)-2,x:bt(u,f)}):f&&c.push(o(c)+"skewX("+f+r)}function a(u,f,c,d,y,v){if(u!==c||f!==d){var x=y.push(o(y)+"scale(",null,",",null,")");v.push({i:x-4,x:bt(u,c)},{i:x-2,x:bt(f,d)})}else(c!==1||d!==1)&&y.push(o(y)+"scale("+c+","+d+")")}return function(u,f){var c=[],d=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,c,d),s(u.rotate,f.rotate,c,d),l(u.skewX,f.skewX,c,d),a(u.scaleX,u.scaleY,f.scaleX,f.scaleY,c,d),u=f=null,function(y){for(var v=-1,x=d.length,S;++v<x;)c[(S=d[v]).i]=S.x(y);return c.join("")}}}var VE=Ag(FE,"px, ","px)","deg)"),BE=Ag(HE,", ",")",")"),UE=1e-12;function $f(e){return((e=Math.exp(e))+1/e)/2}function WE(e){return((e=Math.exp(e))-1/e)/2}function YE(e){return((e=Math.exp(2*e))-1)/(e+1)}const ds=function e(t,n,r){function o(i,s){var l=i[0],a=i[1],u=i[2],f=s[0],c=s[1],d=s[2],y=f-l,v=c-a,x=y*y+v*v,S,h;if(x<UE)h=Math.log(d/u)/t,S=function(_){return[l+_*y,a+_*v,u*Math.exp(t*_*h)]};else{var m=Math.sqrt(x),p=(d*d-u*u+r*x)/(2*u*n*m),w=(d*d-u*u-r*x)/(2*d*n*m),E=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);h=(N-E)/t,S=function(_){var M=_*h,R=$f(E),$=u/(n*m)*(R*YE(t*M+E)-WE(E));return[l+$*y,a+$*v,u*R/$f(t*M+E)]}}return S.duration=h*1e3*t/Math.SQRT2,S}return o.rho=function(i){var s=Math.max(.001,+i),l=s*s,a=l*l;return e(s,l,a)},o}(Math.SQRT2,2,4);var Ar=0,xo=0,ho=0,$g=1e3,Us,wo,Ws=0,qn=0,wl=0,ti=typeof performance=="object"&&performance.now?performance:Date,Dg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Oc(){return qn||(Dg(XE),qn=ti.now()+wl)}function XE(){qn=0}function Ys(){this._call=this._time=this._next=null}Ys.prototype=Og.prototype={constructor:Ys,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Oc():+n)+(t==null?0:+t),!this._next&&wo!==this&&(wo?wo._next=this:Us=this,wo=this),this._call=e,this._time=n,Eu()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eu())}};function Og(e,t,n){var r=new Ys;return r.restart(e,t,n),r}function GE(){Oc(),++Ar;for(var e=Us,t;e;)(t=qn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ar}function Df(){qn=(Ws=ti.now())+wl,Ar=xo=0;try{GE()}finally{Ar=0,QE(),qn=0}}function KE(){var e=ti.now(),t=e-Ws;t>$g&&(wl-=t,Ws=e)}function QE(){for(var e,t=Us,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:Us=n);wo=e,Eu(r)}function Eu(e){if(!Ar){xo&&(xo=clearTimeout(xo));var t=e-qn;t>24?(e<1/0&&(xo=setTimeout(Df,e-ti.now()-wl)),ho&&(ho=clearInterval(ho))):(ho||(Ws=ti.now(),ho=setInterval(KE,$g)),Ar=1,Dg(Df))}}function Of(e,t,n){var r=new Ys;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var ZE=vl("start","end","cancel","interrupt"),qE=[],Fg=0,Ff=1,Nu=2,fs=3,Hf=4,Cu=5,hs=6;function Sl(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;JE(e,n,{name:t,index:r,group:o,on:ZE,tween:qE,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fg})}function Fc(e,t){var n=Nt(e,t);if(n.state>Fg)throw new Error("too late; already scheduled");return n}function zt(e,t){var n=Nt(e,t);if(n.state>fs)throw new Error("too late; already running");return n}function Nt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function JE(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Og(i,0,n.time);function i(u){n.state=Ff,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,c,d,y;if(n.state!==Ff)return a();for(f in r)if(y=r[f],y.name===n.name){if(y.state===fs)return Of(s);y.state===Hf?(y.state=hs,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[f]):+f<t&&(y.state=hs,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[f])}if(Of(function(){n.state===fs&&(n.state=Hf,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Nu,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Nu){for(n.state=fs,o=new Array(d=n.tween.length),f=0,c=-1;f<d;++f)(y=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++c]=y);o.length=c+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(a),n.state=Cu,1),c=-1,d=o.length;++c<d;)o[c].call(e,f);n.state===Cu&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=hs,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function ps(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Nu&&r.state<Cu,r.state=hs,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function eN(e){return this.each(function(){ps(this,e)})}function tN(e,t){var n,r;return function(){var o=zt(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,l=r.length;s<l;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function nN(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=zt(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var l={name:t,value:n},a=0,u=o.length;a<u;++a)if(o[a].name===t){o[a]=l;break}a===u&&o.push(l)}i.tween=o}}function rN(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Nt(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?tN:nN)(n,e,t))}function Hc(e,t,n){var r=e._id;return e.each(function(){var o=zt(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Nt(o,r).value[t]}}function Hg(e,t){var n;return(typeof t=="number"?bt:t instanceof Zn?Bs:(n=Zn(t))?(t=n,Bs):Tg)(e,t)}function oN(e){return function(){this.removeAttribute(e)}}function iN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sN(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function lN(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function aN(e,t,n){var r,o,i;return function(){var s,l=n(this),a;return l==null?void this.removeAttribute(e):(s=this.getAttribute(e),a=l+"",s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l)))}}function uN(e,t,n){var r,o,i;return function(){var s,l=n(this),a;return l==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),a=l+"",s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l)))}}function cN(e,t){var n=xl(e),r=n==="transform"?BE:Hg;return this.attrTween(e,typeof t=="function"?(n.local?uN:aN)(n,r,Hc(this,"attr."+e,t)):t==null?(n.local?iN:oN)(n):(n.local?lN:sN)(n,r,t))}function dN(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fN(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hN(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&fN(e,i)),n}return o._value=t,o}function pN(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&dN(e,i)),n}return o._value=t,o}function mN(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=xl(e);return this.tween(n,(r.local?hN:pN)(r,t))}function gN(e,t){return function(){Fc(this,e).delay=+t.apply(this,arguments)}}function yN(e,t){return t=+t,function(){Fc(this,e).delay=t}}function vN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?gN:yN)(t,e)):Nt(this.node(),t).delay}function xN(e,t){return function(){zt(this,e).duration=+t.apply(this,arguments)}}function wN(e,t){return t=+t,function(){zt(this,e).duration=t}}function SN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xN:wN)(t,e)):Nt(this.node(),t).duration}function kN(e,t){if(typeof t!="function")throw new Error;return function(){zt(this,e).ease=t}}function EN(e){var t=this._id;return arguments.length?this.each(kN(t,e)):Nt(this.node(),t).ease}function NN(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;zt(this,e).ease=n}}function CN(e){if(typeof e!="function")throw new Error;return this.each(NN(this._id,e))}function _N(e){typeof e!="function"&&(e=vg(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,l=r[o]=[],a,u=0;u<s;++u)(a=i[u])&&e.call(a,a.__data__,u,i)&&l.push(a);return new Qt(r,this._parents,this._name,this._id)}function bN(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),l=0;l<i;++l)for(var a=t[l],u=n[l],f=a.length,c=s[l]=new Array(f),d,y=0;y<f;++y)(d=a[y]||u[y])&&(c[y]=d);for(;l<r;++l)s[l]=t[l];return new Qt(s,this._parents,this._name,this._id)}function PN(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 MN(e,t,n){var r,o,i=PN(t)?Fc:zt;return function(){var s=i(this,e),l=s.on;l!==r&&(o=(r=l).copy()).on(t,n),s.on=o}}function jN(e,t){var n=this._id;return arguments.length<2?Nt(this.node(),n).on.on(e):this.each(MN(n,e,t))}function LN(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RN(){return this.on("end.remove",LN(this._id))}function IN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zc(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var l=r[s],a=l.length,u=i[s]=new Array(a),f,c,d=0;d<a;++d)(f=l[d])&&(c=e.call(f,f.__data__,d,l))&&("__data__"in f&&(c.__data__=f.__data__),u[d]=c,Sl(u[d],t,n,d,u,Nt(f,n)));return new Qt(i,this._parents,t,n)}function TN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=yg(e));for(var r=this._groups,o=r.length,i=[],s=[],l=0;l<o;++l)for(var a=r[l],u=a.length,f,c=0;c<u;++c)if(f=a[c]){for(var d=e.call(f,f.__data__,c,a),y,v=Nt(f,n),x=0,S=d.length;x<S;++x)(y=d[x])&&Sl(y,t,n,x,d,v);i.push(d),s.push(f)}return new Qt(i,s,t,n)}var zN=pi.prototype.constructor;function AN(){return new zN(this._groups,this._parents)}function $N(e,t){var n,r,o;return function(){var i=zr(this,e),s=(this.style.removeProperty(e),zr(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Vg(e){return function(){this.style.removeProperty(e)}}function DN(e,t,n){var r,o=n+"",i;return function(){var s=zr(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function ON(e,t,n){var r,o,i;return function(){var s=zr(this,e),l=n(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(e),zr(this,e))),s===a?null:s===r&&a===o?i:(o=a,i=t(r=s,l))}}function FN(e,t){var n,r,o,i="style."+t,s="end."+i,l;return function(){var a=zt(this,e),u=a.on,f=a.value[i]==null?l||(l=Vg(t)):void 0;(u!==n||o!==f)&&(r=(n=u).copy()).on(s,o=f),a.on=r}}function HN(e,t,n){var r=(e+="")=="transform"?VE:Hg;return t==null?this.styleTween(e,$N(e,r)).on("end.style."+e,Vg(e)):typeof t=="function"?this.styleTween(e,ON(e,r,Hc(this,"style."+e,t))).each(FN(this._id,e)):this.styleTween(e,DN(e,r,t),n).on("end.style."+e,null)}function VN(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function BN(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&VN(e,s,n)),r}return i._value=t,i}function UN(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,BN(e,t,n??""))}function WN(e){return function(){this.textContent=e}}function YN(e){return function(){var t=e(this);this.textContent=t??""}}function XN(e){return this.tween("text",typeof e=="function"?YN(Hc(this,"text",e)):WN(e==null?"":e+""))}function GN(e){return function(t){this.textContent=e.call(this,t)}}function KN(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&GN(o)),t}return r._value=e,r}function QN(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,KN(e))}function ZN(){for(var e=this._name,t=this._id,n=Bg(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],l=s.length,a,u=0;u<l;++u)if(a=s[u]){var f=Nt(a,t);Sl(a,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Qt(r,this._parents,e,n)}function qN(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var l={value:s},a={value:function(){--o===0&&i()}};n.each(function(){var u=zt(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(a)),u.on=t}),o===0&&i()})}var JN=0;function Qt(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Bg(){return++JN}var Dt=pi.prototype;Qt.prototype={constructor:Qt,select:IN,selectAll:TN,selectChild:Dt.selectChild,selectChildren:Dt.selectChildren,filter:_N,merge:bN,selection:AN,transition:ZN,call:Dt.call,nodes:Dt.nodes,node:Dt.node,size:Dt.size,empty:Dt.empty,each:Dt.each,on:jN,attr:cN,attrTween:mN,style:HN,styleTween:UN,text:XN,textTween:QN,remove:RN,tween:rN,delay:vN,duration:SN,ease:EN,easeVarying:CN,end:qN,[Symbol.iterator]:Dt[Symbol.iterator]};function eC(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tC={time:null,delay:0,duration:250,ease:eC};function nC(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 rC(e){var t,n;e instanceof Qt?(t=e._id,e=e._name):(t=Bg(),(n=tC).time=Oc(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],l=s.length,a,u=0;u<l;++u)(a=s[u])&&Sl(a,e,t,u,s,n||nC(a,t));return new Qt(r,this._parents,e,t)}pi.prototype.interrupt=eN;pi.prototype.transition=rC;const Wi=e=>()=>e;function oC(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Bt(e,t,n){this.k=e,this.x=t,this.y=n}Bt.prototype={constructor:Bt,scale:function(e){return e===1?this:new Bt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Bt(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 kl=new Bt(1,0,0);Ug.prototype=Bt.prototype;function Ug(e){for(;!e.__zoom;)if(!(e=e.parentNode))return kl;return e.__zoom}function fa(e){e.stopImmediatePropagation()}function po(e){e.preventDefault(),e.stopImmediatePropagation()}function iC(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sC(){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 Vf(){return this.__zoom||kl}function lC(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aC(){return navigator.maxTouchPoints||"ontouchstart"in this}function uC(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Wg(){var e=iC,t=sC,n=uC,r=lC,o=aC,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,a=ds,u=vl("start","zoom","end"),f,c,d,y=500,v=150,x=0,S=10;function h(b){b.property("__zoom",Vf).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",$).filter(o).on("touchstart.zoom",I).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}h.transform=function(b,z,j,A){var C=b.selection?b.selection():b;C.property("__zoom",Vf),b!==C?E(b,z,j,A):C.interrupt().each(function(){N(this,arguments).event(A).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},h.scaleBy=function(b,z,j,A){h.scaleTo(b,function(){var C=this.__zoom.k,P=typeof z=="function"?z.apply(this,arguments):z;return C*P},j,A)},h.scaleTo=function(b,z,j,A){h.transform(b,function(){var C=t.apply(this,arguments),P=this.__zoom,T=j==null?w(C):typeof j=="function"?j.apply(this,arguments):j,O=P.invert(T),D=typeof z=="function"?z.apply(this,arguments):z;return n(p(m(P,D),T,O),C,s)},j,A)},h.translateBy=function(b,z,j,A){h.transform(b,function(){return n(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof j=="function"?j.apply(this,arguments):j),t.apply(this,arguments),s)},null,A)},h.translateTo=function(b,z,j,A,C){h.transform(b,function(){var P=t.apply(this,arguments),T=this.__zoom,O=A==null?w(P):typeof A=="function"?A.apply(this,arguments):A;return n(kl.translate(O[0],O[1]).scale(T.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof j=="function"?-j.apply(this,arguments):-j),P,s)},A,C)};function m(b,z){return z=Math.max(i[0],Math.min(i[1],z)),z===b.k?b:new Bt(z,b.x,b.y)}function p(b,z,j){var A=z[0]-j[0]*b.k,C=z[1]-j[1]*b.k;return A===b.x&&C===b.y?b:new Bt(b.k,A,C)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function E(b,z,j,A){b.on("start.zoom",function(){N(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(A).end()}).tween("zoom",function(){var C=this,P=arguments,T=N(C,P).event(A),O=t.apply(C,P),D=j==null?w(O):typeof j=="function"?j.apply(C,P):j,U=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),B=C.__zoom,Y=typeof z=="function"?z.apply(C,P):z,X=a(B.invert(D).concat(U/B.k),Y.invert(D).concat(U/Y.k));return function(G){if(G===1)G=Y;else{var V=X(G),Q=U/V[2];G=new Bt(Q,D[0]-V[0]*Q,D[1]-V[1]*Q)}T.zoom(null,G)}})}function N(b,z,j){return!j&&b.__zooming||new _(b,z)}function _(b,z){this.that=b,this.args=z,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,z),this.taps=0}_.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,z){return this.mouse&&b!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var z=Qe(this.that).datum();u.call(b,this.that,new oC(b,{sourceEvent:this.sourceEvent,target:h,transform:this.that.__zoom,dispatch:u}),z)}};function M(b,...z){if(!e.apply(this,arguments))return;var j=N(this,z).event(b),A=this.__zoom,C=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),P=mt(b);if(j.wheel)(j.mouse[0][0]!==P[0]||j.mouse[0][1]!==P[1])&&(j.mouse[1]=A.invert(j.mouse[0]=P)),clearTimeout(j.wheel);else{if(A.k===C)return;j.mouse=[P,A.invert(P)],ps(this),j.start()}po(b),j.wheel=setTimeout(T,v),j.zoom("mouse",n(p(m(A,C),j.mouse[0],j.mouse[1]),j.extent,s));function T(){j.wheel=null,j.end()}}function R(b,...z){if(d||!e.apply(this,arguments))return;var j=b.currentTarget,A=N(this,z,!0).event(b),C=Qe(b.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",U,!0),P=mt(b,j),T=b.clientX,O=b.clientY;Pg(b.view),fa(b),A.mouse=[P,this.__zoom.invert(P)],ps(this),A.start();function D(B){if(po(B),!A.moved){var Y=B.clientX-T,X=B.clientY-O;A.moved=Y*Y+X*X>x}A.event(B).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=mt(B,j),A.mouse[1]),A.extent,s))}function U(B){C.on("mousemove.zoom mouseup.zoom",null),Mg(B.view,A.moved),po(B),A.event(B).end()}}function $(b,...z){if(e.apply(this,arguments)){var j=this.__zoom,A=mt(b.changedTouches?b.changedTouches[0]:b,this),C=j.invert(A),P=j.k*(b.shiftKey?.5:2),T=n(p(m(j,P),A,C),t.apply(this,z),s);po(b),l>0?Qe(this).transition().duration(l).call(E,T,A,b):Qe(this).call(h.transform,T,A,b)}}function I(b,...z){if(e.apply(this,arguments)){var j=b.touches,A=j.length,C=N(this,z,b.changedTouches.length===A).event(b),P,T,O,D;for(fa(b),T=0;T<A;++T)O=j[T],D=mt(O,this),D=[D,this.__zoom.invert(D),O.identifier],C.touch0?!C.touch1&&C.touch0[2]!==D[2]&&(C.touch1=D,C.taps=0):(C.touch0=D,P=!0,C.taps=1+!!f);f&&(f=clearTimeout(f)),P&&(C.taps<2&&(c=D[0],f=setTimeout(function(){f=null},y)),ps(this),C.start())}}function L(b,...z){if(this.__zooming){var j=N(this,z).event(b),A=b.changedTouches,C=A.length,P,T,O,D;for(po(b),P=0;P<C;++P)T=A[P],O=mt(T,this),j.touch0&&j.touch0[2]===T.identifier?j.touch0[0]=O:j.touch1&&j.touch1[2]===T.identifier&&(j.touch1[0]=O);if(T=j.that.__zoom,j.touch1){var U=j.touch0[0],B=j.touch0[1],Y=j.touch1[0],X=j.touch1[1],G=(G=Y[0]-U[0])*G+(G=Y[1]-U[1])*G,V=(V=X[0]-B[0])*V+(V=X[1]-B[1])*V;T=m(T,Math.sqrt(G/V)),O=[(U[0]+Y[0])/2,(U[1]+Y[1])/2],D=[(B[0]+X[0])/2,(B[1]+X[1])/2]}else if(j.touch0)O=j.touch0[0],D=j.touch0[1];else return;j.zoom("touch",n(p(T,O,D),j.extent,s))}}function F(b,...z){if(this.__zooming){var j=N(this,z).event(b),A=b.changedTouches,C=A.length,P,T;for(fa(b),d&&clearTimeout(d),d=setTimeout(function(){d=null},y),P=0;P<C;++P)T=A[P],j.touch0&&j.touch0[2]===T.identifier?delete j.touch0:j.touch1&&j.touch1[2]===T.identifier&&delete j.touch1;if(j.touch1&&!j.touch0&&(j.touch0=j.touch1,delete j.touch1),j.touch0)j.touch0[1]=this.__zoom.invert(j.touch0[0]);else if(j.end(),j.taps===2&&(T=mt(T,this),Math.hypot(c[0]-T[0],c[1]-T[1])<S)){var O=Qe(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return h.wheelDelta=function(b){return arguments.length?(r=typeof b=="function"?b:Wi(+b),h):r},h.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Wi(!!b),h):e},h.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Wi(!!b),h):o},h.extent=function(b){return arguments.length?(t=typeof b=="function"?b:Wi([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),h):t},h.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],h):[i[0],i[1]]},h.translateExtent=function(b){return arguments.length?(s[0][0]=+b[0][0],s[1][0]=+b[1][0],s[0][1]=+b[0][1],s[1][1]=+b[1][1],h):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},h.constrain=function(b){return arguments.length?(n=b,h):n},h.duration=function(b){return arguments.length?(l=+b,h):l},h.interpolate=function(b){return arguments.length?(a=b,h):a},h.on=function(){var b=u.on.apply(u,arguments);return b===u?h:b},h.clickDistance=function(b){return arguments.length?(x=(b=+b)*b,h):Math.sqrt(x)},h.tapDistance=function(b){return arguments.length?(S=+b,h):S},h}const Rt={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.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ni=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yg=["Enter"," ","Escape"],Xg={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var $r;(function(e){e.Strict="strict",e.Loose="loose"})($r||($r={}));var Wn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wn||(Wn={}));var ri;(function(e){e.Partial="partial",e.Full="full"})(ri||(ri={}));const Gg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var cn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(cn||(cn={}));var Xs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xs||(Xs={}));var K;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(K||(K={}));const Bf={[K.Left]:K.Right,[K.Right]:K.Left,[K.Top]:K.Bottom,[K.Bottom]:K.Top};function Kg(e){return e===null?null:e?"valid":"invalid"}const Qg=e=>"id"in e&&"source"in e&&"target"in e,cC=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Vc=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gi=(e,t=[0,0])=>{const{width:n,height:r}=qt(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},dC=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):Vc(o)?o:t.nodeLookup.get(o.id));const l=s?Gs(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return El(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nl(n)},yi=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=El(n,Gs(o)),r=!0)}),r?Nl(n):{x:0,y:0,width:0,height:0}},Bc=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const l={...xi(t,[n,r,o]),width:t.width/o,height:t.height/o},a=[];for(const u of e.values()){const{measured:f,selectable:c=!0,hidden:d=!1}=u;if(s&&!c||d)continue;const y=f.width??u.width??u.initialWidth??null,v=f.height??u.height??u.initialHeight??null,x=oi(l,Or(u)),S=(y??0)*(v??0),h=i&&x>0;(!u.internals.handleBounds||h||x>=S||u.dragging)&&a.push(u)}return a},fC=(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 hC(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function pC({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=hC(e,s),a=yi(l),u=Uc(a,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Zg({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:a,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let c=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!l)i==null||i("005",Rt.error005());else{const y=l.measured.width,v=l.measured.height;y&&v&&(c=[[a,u],[a+y,u+v]])}else l&&Fr(s.extent)&&(c=[[s.extent[0][0]+a,s.extent[0][1]+u],[s.extent[1][0]+a,s.extent[1][1]+u]]);const d=Fr(c)?Jn(t,c,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",Rt.error015())),{position:{x:d.x-a+(s.measured.width??0)*f[0],y:d.y-u+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function mC({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const y=i.has(d.id),v=!y&&d.parentId&&s.find(x=>x.id===d.parentId);(y||v)&&s.push(d)}const l=new Set(t.map(d=>d.id)),a=r.filter(d=>d.deletable!==!1),f=fC(s,a);for(const d of a)l.has(d.id)&&!f.find(v=>v.id===d.id)&&f.push(d);if(!o)return{edges:f,nodes:s};const c=await o({nodes:s,edges:f});return typeof c=="boolean"?c?{edges:f,nodes:s}:{edges:[],nodes:[]}:c}const Dr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Jn=(e={x:0,y:0},t,n)=>({x:Dr(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Dr(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function qg(e,t,n){const{width:r,height:o}=qt(n),{x:i,y:s}=n.internals.positionAbsolute;return Jn(e,[[i,s],[i+r,s+o]],t)}const Uf=(e,t,n)=>e<t?Dr(Math.abs(e-t),1,t)/t:e>n?-Dr(Math.abs(e-n),1,t)/t:0,Jg=(e,t,n=15,r=40)=>{const o=Uf(e.x,r,t.width-r)*n,i=Uf(e.y,r,t.height-r)*n;return[o,i]},El=(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)}),_u=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Nl=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Or=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Vc(e)?e.internals.positionAbsolute:gi(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Gs=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Vc(e)?e.internals.positionAbsolute:gi(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},ey=(e,t)=>Nl(El(_u(e),_u(t))),oi=(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)},Wf=e=>vt(e.width)&&vt(e.height)&&vt(e.x)&&vt(e.y),vt=e=>!isNaN(e)&&isFinite(e),gC=(e,t)=>{},vi=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),xi=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?vi(l,s):l},Ks=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function ir(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function yC(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ir(e,n),o=ir(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=ir(e.top??e.y??0,n),o=ir(e.bottom??e.y??0,n),i=ir(e.left??e.x??0,t),s=ir(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function vC(e,t,n,r,o,i){const{x:s,y:l}=Ks(e,[t,n,r]),{x:a,y:u}=Ks({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-a,c=i-u;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(c)}}const Uc=(e,t,n,r,o,i)=>{const s=yC(i,t,n),l=(t-s.x)/e.width,a=(n-s.y)/e.height,u=Math.min(l,a),f=Dr(u,r,o),c=e.x+e.width/2,d=e.y+e.height/2,y=t/2-c*f,v=n/2-d*f,x=vC(e,y,v,f,t,n),S={left:Math.min(x.left-s.left,0),top:Math.min(x.top-s.top,0),right:Math.min(x.right-s.right,0),bottom:Math.min(x.bottom-s.bottom,0)};return{x:y-S.left+S.right,y:v-S.top+S.bottom,zoom:f}},ii=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Fr(e){return e!=null&&e!=="parent"}function qt(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 ty(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 ny(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const l=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function Yf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xC(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function wC(e){return{...Xg,...e||{}}}function Lo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=xt(e),l=xi({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:a,y:u}=n?vi(l,t):l;return{xSnapped:a,ySnapped:u,...l}}const Wc=e=>({width:e.offsetWidth,height:e.offsetHeight}),ry=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},SC=["INPUT","SELECT","TEXTAREA"];function oy(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:SC.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const iy=e=>"clientX"in e,xt=(e,t)=>{var i,s;const n=iy(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Xf=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...Wc(s)}})};function sy({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:l}){const a=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+l*.375+r*.125,f=Math.abs(a-e),c=Math.abs(u-t);return[a,u,f,c]}function Yi(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Gf({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case K.Left:return[t-Yi(t-r,i),n];case K.Right:return[t+Yi(r-t,i),n];case K.Top:return[t,n-Yi(n-o,i)];case K.Bottom:return[t,n+Yi(o-n,i)]}}function ly({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:i=K.Top,curvature:s=.25}){const[l,a]=Gf({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,f]=Gf({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[c,d,y,v]=sy({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${a} ${u},${f} ${r},${o}`,c,d,y,v]}function ay({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,l=r<t?r+s:r-s;return[i,l,o,s]}function kC({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,l=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+l}function EC({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=El(Gs(e),Gs(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return oi(s,Nl(i))>0}const NC=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,CC=(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)),_C=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||NC;let o;return Qg(e)?o={...e}:o={...e,id:r(e)},CC(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function uy({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,l]=ay({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,l]}const Kf={[K.Left]:{x:-1,y:0},[K.Right]:{x:1,y:0},[K.Top]:{x:0,y:-1},[K.Bottom]:{x:0,y:1}},bC=({source:e,sourcePosition:t=K.Bottom,target:n})=>t===K.Left||t===K.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},Qf=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function PC({source:e,sourcePosition:t=K.Bottom,target:n,targetPosition:r=K.Top,center:o,offset:i,stepPosition:s}){const l=Kf[t],a=Kf[r],u={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+a.x*i,y:n.y+a.y*i},c=bC({source:u,sourcePosition:t,target:f}),d=c.x!==0?"x":"y",y=c[d];let v=[],x,S;const h={x:0,y:0},m={x:0,y:0},[,,p,w]=ay({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*a[d]===-1){d==="x"?(x=o.x??u.x+(f.x-u.x)*s,S=o.y??(u.y+f.y)/2):(x=o.x??(u.x+f.x)/2,S=o.y??u.y+(f.y-u.y)*s);const N=[{x,y:u.y},{x,y:f.y}],_=[{x:u.x,y:S},{x:f.x,y:S}];l[d]===y?v=d==="x"?N:_:v=d==="x"?_:N}else{const N=[{x:u.x,y:f.y}],_=[{x:f.x,y:u.y}];if(d==="x"?v=l.x===y?_:N:v=l.y===y?N:_,t===r){const L=Math.abs(e[d]-n[d]);if(L<=i){const F=Math.min(i-1,i-L);l[d]===y?h[d]=(u[d]>e[d]?-1:1)*F:m[d]=(f[d]>n[d]?-1:1)*F}}if(t!==r){const L=d==="x"?"y":"x",F=l[d]===a[L],b=u[L]>f[L],z=u[L]<f[L];(l[d]===1&&(!F&&b||F&&z)||l[d]!==1&&(!F&&z||F&&b))&&(v=d==="x"?N:_)}const M={x:u.x+h.x,y:u.y+h.y},R={x:f.x+m.x,y:f.y+m.y},$=Math.max(Math.abs(M.x-v[0].x),Math.abs(R.x-v[0].x)),I=Math.max(Math.abs(M.y-v[0].y),Math.abs(R.y-v[0].y));$>=I?(x=(M.x+R.x)/2,S=v[0].y):(x=v[0].x,S=(M.y+R.y)/2)}return[[e,{x:u.x+h.x,y:u.y+h.y},...v,{x:f.x+m.x,y:f.y+m.y},n],x,S,p,w]}function MC(e,t,n,r){const o=Math.min(Qf(e,t)/2,Qf(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*f}`}const l=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${s+o*a}Q ${i},${s} ${i+o*l},${s}`}function bu({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:i=K.Top,borderRadius:s=5,centerX:l,centerY:a,offset:u=20,stepPosition:f=.5}){const[c,d,y,v,x]=PC({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:l,y:a},offset:u,stepPosition:f});return[c.reduce((h,m,p)=>{let w="";return p>0&&p<c.length-1?w=MC(c[p-1],m,c[p+1],s):w=`${p===0?"M":"L"}${m.x} ${m.y}`,h+=w,h},""),d,y,v,x]}function Zf(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function jC(e){var c;const{sourceNode:t,targetNode:n}=e;if(!Zf(t)||!Zf(n))return null;const r=t.internals.handleBounds||qf(t.handles),o=n.internals.handleBounds||qf(n.handles),i=Jf((r==null?void 0:r.source)??[],e.sourceHandle),s=Jf(e.connectionMode===$r.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(c=e.onError)==null||c.call(e,"008",Rt.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||K.Bottom,a=(s==null?void 0:s.position)||K.Top,u=er(t,i,l),f=er(n,s,a);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:a}}function qf(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 er(e,t,n=K.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:l}=t??qt(e);if(r)return{x:o+s/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case K.Top:return{x:o+s/2,y:i};case K.Right:return{x:o+s,y:i+l/2};case K.Bottom:return{x:o+s/2,y:i+l};case K.Left:return{x:o,y:i+l/2}}}function Jf(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Pu(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function LC(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||r,l.markerEnd||o].forEach(a=>{if(a&&typeof a=="object"){const u=Pu(a,t);i.has(u)||(s.push({id:u,color:a.color||n,...a}),i.add(u))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const cy=1e3,RC=10,Yc={nodeOrigin:[0,0],nodeExtent:ni,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},IC={...Yc,checkEquality:!0};function Xc(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function TC(e,t,n){const r=Xc(Yc,n);for(const o of e.values())if(o.parentId)Kc(o,e,t,r);else{const i=gi(o,r.nodeOrigin),s=Fr(o.extent)?o.extent:r.nodeExtent,l=Jn(i,s,qt(o));o.internals.positionAbsolute=l}}function zC(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function Gc(e){return e==="manual"}function Mu(e,t,n,r={}){var u,f;const o=Xc(IC,r),i={i:0},s=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!Gc(o.zIndexMode)?cy:0;let a=e.length>0;t.clear(),n.clear();for(const c of e){let d=s.get(c.id);if(o.checkEquality&&c===(d==null?void 0:d.internals.userNode))t.set(c.id,d);else{const y=gi(c,o.nodeOrigin),v=Fr(c.extent)?c.extent:o.nodeExtent,x=Jn(y,v,qt(c));d={...o.defaults,...c,measured:{width:(u=c.measured)==null?void 0:u.width,height:(f=c.measured)==null?void 0:f.height},internals:{positionAbsolute:x,handleBounds:zC(c,d),z:dy(c,l,o.zIndexMode),userNode:c}},t.set(c.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(a=!1),c.parentId&&Kc(d,t,n,r,i)}return a}function AC(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 Kc(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:a}=Xc(Yc,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}AC(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&a==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*RC),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const c=i&&!Gc(a)?cy:0,{x:d,y,z:v}=$C(e,f,s,l,c,a),{positionAbsolute:x}=e.internals,S=d!==x.x||y!==x.y;(S||v!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:d,y}:x,z:v}})}function dy(e,t,n){const r=vt(e.zIndex)?e.zIndex:0;return Gc(n)?r:r+(e.selected?t:0)}function $C(e,t,n,r,o,i){const{x:s,y:l}=t.internals.positionAbsolute,a=qt(e),u=gi(e,n),f=Fr(e.extent)?Jn(u,e.extent,a):u;let c=Jn({x:s+f.x,y:l+f.y},r,a);e.extent==="parent"&&(c=qg(c,a,t));const d=dy(e,o,i),y=t.internals.z??0;return{x:c.x,y:c.y,z:y>=d?y+1:d}}function Qc(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const u=((s=i.get(l.parentId))==null?void 0:s.expandedRect)??Or(a),f=ey(u,l.rect);i.set(l.parentId,{expandedRect:f,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},u)=>{var p;const f=a.internals.positionAbsolute,c=qt(a),d=a.origin??r,y=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,v=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,x=Math.max(c.width,Math.round(l.width)),S=Math.max(c.height,Math.round(l.height)),h=(x-c.width)*d[0],m=(S-c.height)*d[1];(y>0||v>0||h||m)&&(o.push({id:u,type:"position",position:{x:a.position.x-y+h,y:a.position.y-v+m}}),(p=n.get(u))==null||p.forEach(w=>{e.some(E=>E.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+y,y:w.position.y+v}})})),(c.width<l.width||c.height<l.height||y||v)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(y?d[0]*y-h:0),height:S+(v?d[1]*v-m:0)}})}),o}function DC(e,t,n,r,o,i,s){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let a=!1;if(!l)return{changes:[],updatedInternals:a};const u=[],f=window.getComputedStyle(l),{m22:c}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const y of e.values()){const v=t.get(y.id);if(!v)continue;if(v.hidden){t.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),a=!0;continue}const x=Wc(y.nodeElement),S=v.measured.width!==x.width||v.measured.height!==x.height;if(!!(x.width&&x.height&&(S||!v.internals.handleBounds||y.force))){const m=y.nodeElement.getBoundingClientRect(),p=Fr(v.extent)?v.extent:i;let{positionAbsolute:w}=v.internals;v.parentId&&v.extent==="parent"?w=qg(w,x,t.get(v.parentId)):p&&(w=Jn(w,p,x));const E={...v,measured:x,internals:{...v.internals,positionAbsolute:w,handleBounds:{source:Xf("source",y.nodeElement,m,c,v.id),target:Xf("target",y.nodeElement,m,c,v.id)}}};t.set(v.id,E),v.parentId&&Kc(E,t,n,{nodeOrigin:o,zIndexMode:s}),a=!0,S&&(u.push({id:v.id,type:"dimensions",dimensions:x}),v.expandParent&&v.parentId&&d.push({id:v.id,parentId:v.parentId,rect:Or(E,o)}))}}if(d.length>0){const y=Qc(d,t,n,o);u.push(...y)}return{changes:u,updatedInternals:a}}async function OC({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function eh(e,t,n,r,o,i){let s=o;const l=r.get(s)||new Map;r.set(s,l.set(n,t)),s=`${o}-${e}`;const a=r.get(s)||new Map;if(r.set(s,a.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function fy(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:l=null}=r,a={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:l},u=`${o}-${s}--${i}-${l}`,f=`${i}-${l}--${o}-${s}`;eh("source",a,f,e,o,s),eh("target",a,u,e,i,l),t.set(r.id,r)}}function hy(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:hy(n,t):!1}function th(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function FC(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!hy(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return o}function ha({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,l,a;const o=[];for(const[u,f]of t){const c=(s=n.get(u))==null?void 0:s.internals.userNode;c&&o.push({...c,position:f.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:r}:o[0],o]}function HC({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=vi(i,t);return{x:s.x-i.x,y:s.y-i.y}}function VC({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,l=new Map,a=!1,u={x:0,y:0},f=null,c=!1,d=null,y=!1,v=!1,x=null;function S({noDragClassName:m,handleSelector:p,domNode:w,isSelectable:E,nodeId:N,nodeClickDistance:_=0}){d=Qe(w);function M({x:L,y:F}){const{nodeLookup:b,nodeExtent:z,snapGrid:j,snapToGrid:A,nodeOrigin:C,onNodeDrag:P,onSelectionDrag:T,onError:O,updateNodePositions:D}=t();i={x:L,y:F};let U=!1;const B=l.size>1,Y=B&&z?_u(yi(l)):null,X=B&&A?HC({dragItems:l,snapGrid:j,x:L,y:F}):null;for(const[G,V]of l){if(!b.has(G))continue;let Q={x:L-V.distance.x,y:F-V.distance.y};A&&(Q=X?{x:Math.round(Q.x+X.x),y:Math.round(Q.y+X.y)}:vi(Q,j));let te=null;if(B&&z&&!V.extent&&Y){const{positionAbsolute:Z}=V.internals,se=Z.x-Y.x+z[0][0],ue=Z.x+V.measured.width-Y.x2+z[1][0],ie=Z.y-Y.y+z[0][1],Ie=Z.y+V.measured.height-Y.y2+z[1][1];te=[[se,ie],[ue,Ie]]}const{position:J,positionAbsolute:q}=Zg({nodeId:G,nextPosition:Q,nodeLookup:b,nodeExtent:te||z,nodeOrigin:C,onError:O});U=U||V.position.x!==J.x||V.position.y!==J.y,V.position=J,V.internals.positionAbsolute=q}if(v=v||U,!!U&&(D(l,!0),x&&(r||P||!N&&T))){const[G,V]=ha({nodeId:N,dragItems:l,nodeLookup:b});r==null||r(x,l,G,V),P==null||P(x,G,V),N||T==null||T(x,V)}}async function R(){if(!f)return;const{transform:L,panBy:F,autoPanSpeed:b,autoPanOnNodeDrag:z}=t();if(!z){a=!1,cancelAnimationFrame(s);return}const[j,A]=Jg(u,f,b);(j!==0||A!==0)&&(i.x=(i.x??0)-j/L[2],i.y=(i.y??0)-A/L[2],await F({x:j,y:A})&&M(i)),s=requestAnimationFrame(R)}function $(L){var B;const{nodeLookup:F,multiSelectionActive:b,nodesDraggable:z,transform:j,snapGrid:A,snapToGrid:C,selectNodesOnDrag:P,onNodeDragStart:T,onSelectionDragStart:O,unselectNodesAndEdges:D}=t();c=!0,(!P||!E)&&!b&&N&&((B=F.get(N))!=null&&B.selected||D()),E&&P&&N&&(e==null||e(N));const U=Lo(L.sourceEvent,{transform:j,snapGrid:A,snapToGrid:C,containerBounds:f});if(i=U,l=FC(F,z,U,N),l.size>0&&(n||T||!N&&O)){const[Y,X]=ha({nodeId:N,dragItems:l,nodeLookup:F});n==null||n(L.sourceEvent,l,Y,X),T==null||T(L.sourceEvent,Y,X),N||O==null||O(L.sourceEvent,X)}}const I=jg().clickDistance(_).on("start",L=>{const{domNode:F,nodeDragThreshold:b,transform:z,snapGrid:j,snapToGrid:A}=t();f=(F==null?void 0:F.getBoundingClientRect())||null,y=!1,v=!1,x=L.sourceEvent,b===0&&$(L),i=Lo(L.sourceEvent,{transform:z,snapGrid:j,snapToGrid:A,containerBounds:f}),u=xt(L.sourceEvent,f)}).on("drag",L=>{const{autoPanOnNodeDrag:F,transform:b,snapGrid:z,snapToGrid:j,nodeDragThreshold:A,nodeLookup:C}=t(),P=Lo(L.sourceEvent,{transform:b,snapGrid:z,snapToGrid:j,containerBounds:f});if(x=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!C.has(N))&&(y=!0),!y){if(!a&&F&&c&&(a=!0,R()),!c){const T=xt(L.sourceEvent,f),O=T.x-u.x,D=T.y-u.y;Math.sqrt(O*O+D*D)>A&&$(L)}(i.x!==P.xSnapped||i.y!==P.ySnapped)&&l&&c&&(u=xt(L.sourceEvent,f),M(P))}}).on("end",L=>{if(!(!c||y)&&(a=!1,c=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:F,updateNodePositions:b,onNodeDragStop:z,onSelectionDragStop:j}=t();if(v&&(b(l,!1),v=!1),o||z||!N&&j){const[A,C]=ha({nodeId:N,dragItems:l,nodeLookup:F,dragging:!1});o==null||o(L.sourceEvent,l,A,C),z==null||z(L.sourceEvent,A,C),N||j==null||j(L.sourceEvent,C)}}}).filter(L=>{const F=L.target;return!L.button&&(!m||!th(F,`.${m}`,w))&&(!p||th(F,p,w))});d.call(I)}function h(){d==null||d.on(".drag",null)}return{update:S,destroy:h}}function BC(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())oi(o,Or(i))>0&&r.push(i);return r}const UC=250;function WC(e,t,n,r){var l,a;let o=[],i=1/0;const s=BC(e,n,t+UC);for(const u of s){const f=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((a=u.internals.handleBounds)==null?void 0:a.target)??[]];for(const c of f){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:d,y}=er(u,c,c.position,!0),v=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(y-e.y,2));v>t||(v<i?(o=[{...c,x:d,y}],i=v):v===i&&o.push({...c,x:d,y}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(f=>f.type===u)??o[0]}return o[0]}function py(e,t,n,r,o,i=!1){var u,f,c;const s=r.get(e);if(!s)return null;const l=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((c=s.internals.handleBounds)==null?void 0:c.target)??[]],a=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return a&&i?{...a,...er(s,a,a.position,!0)}:a}function my(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function YC(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const gy=()=>!0;function XC(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:a,lib:u,autoPanOnConnect:f,flowId:c,panBy:d,cancelConnection:y,onConnectStart:v,onConnect:x,onConnectEnd:S,isValidConnection:h=gy,onReconnectEnd:m,updateConnection:p,getTransform:w,getFromHandle:E,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:M}){const R=ry(e.target);let $=0,I;const{x:L,y:F}=xt(e),b=my(i,M),z=l==null?void 0:l.getBoundingClientRect();let j=!1;if(!z||!b)return;const A=py(o,b,r,a,t);if(!A)return;let C=xt(e,z),P=!1,T=null,O=!1,D=null;function U(){if(!f||!z)return;const[J,q]=Jg(C,z,N);d({x:J,y:q}),$=requestAnimationFrame(U)}const B={...A,nodeId:o,type:b,position:A.position},Y=a.get(o);let G={inProgress:!0,isValid:null,from:er(Y,B,K.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:C,toHandle:null,toPosition:Bf[B.position],toNode:null,pointer:C};function V(){j=!0,p(G),v==null||v(e,{nodeId:o,handleId:r,handleType:b})}_===0&&V();function Q(J){if(!j){const{x:Ie,y:Jt}=xt(J),At=Ie-L,Ln=Jt-F;if(!(At*At+Ln*Ln>_*_))return;V()}if(!E()||!B){te(J);return}const q=w();C=xt(J,z),I=WC(xi(C,q,!1,[1,1]),n,a,B),P||(U(),P=!0);const Z=yy(J,{handle:I,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:h,doc:R,lib:u,flowId:c,nodeLookup:a});D=Z.handleDomNode,T=Z.connection,O=YC(!!I,Z.isValid);const se=a.get(o),ue=se?er(se,B,K.Left,!0):G.from,ie={...G,from:ue,isValid:O,to:Z.toHandle&&O?Ks({x:Z.toHandle.x,y:Z.toHandle.y},q):C,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:Bf[B.position],toNode:Z.toHandle?a.get(Z.toHandle.nodeId):null,pointer:C};p(ie),G=ie}function te(J){if(!("touches"in J&&J.touches.length>0)){if(j){(I||D)&&T&&O&&(x==null||x(T));const{inProgress:q,...Z}=G,se={...Z,toPosition:G.toHandle?G.toPosition:null};S==null||S(J,se),i&&(m==null||m(J,se))}y(),cancelAnimationFrame($),P=!1,O=!1,T=null,D=null,R.removeEventListener("mousemove",Q),R.removeEventListener("mouseup",te),R.removeEventListener("touchmove",Q),R.removeEventListener("touchend",te)}}R.addEventListener("mousemove",Q),R.addEventListener("mouseup",te),R.addEventListener("touchmove",Q),R.addEventListener("touchend",te)}function yy(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:l,flowId:a,isValidConnection:u=gy,nodeLookup:f}){const c=i==="target",d=t?s.querySelector(`.${l}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:y,y:v}=xt(e),x=s.elementFromPoint(y,v),S=x!=null&&x.classList.contains(`${l}-flow__handle`)?x:d,h={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const m=my(void 0,S),p=S.getAttribute("data-nodeid"),w=S.getAttribute("data-handleid"),E=S.classList.contains("connectable"),N=S.classList.contains("connectableend");if(!p||!m)return h;const _={source:c?p:r,sourceHandle:c?w:o,target:c?r:p,targetHandle:c?o:w};h.connection=_;const R=E&&N&&(n===$r.Strict?c&&m==="source"||!c&&m==="target":p!==r||w!==o);h.isValid=R&&u(_),h.toHandle=py(p,m,w,f,n,!0)}return h}const ju={onPointerDown:XC,isValid:yy};function GC({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Qe(e);function i({translateExtent:l,width:a,height:u,zoomStep:f=1,pannable:c=!0,zoomable:d=!0,inversePan:y=!1}){const v=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),E=p.sourceEvent.ctrlKey&&ii()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,_=w[2]*Math.pow(2,N*E);t.scaleTo(_)};let x=[0,0];const S=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(x=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},h=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[E[0]-x[0],E[1]-x[1]];x=E;const _=r()*Math.max(w[2],Math.log(w[2]))*(y?-1:1),M={x:w[0]-N[0]*_,y:w[1]-N[1]*_},R=[[0,0],[a,u]];t.setViewportConstrained({x:M.x,y:M.y,zoom:w[2]},R,l)},m=Wg().on("start",S).on("zoom",c?h:null).on("zoom.wheel",d?v:null);o.call(m,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:mt}}const Cl=e=>({x:e.x,y:e.y,zoom:e.k}),pa=({x:e,y:t,zoom:n})=>kl.translate(e,t).scale(n),vr=(e,t)=>e.target.closest(`.${t}`),vy=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),KC=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ma=(e,t=0,n=KC,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},xy=e=>{const t=e.ctrlKey&&ii()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QC({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:u}){return f=>{if(vr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(f.ctrlKey&&s){const S=mt(f),h=xy(f),m=c*Math.pow(2,h);r.scaleTo(n,m,S,f);return}const d=f.deltaMode===1?20:1;let y=o===Wn.Vertical?0:f.deltaX*d,v=o===Wn.Horizontal?0:f.deltaY*d;!ii()&&f.shiftKey&&o!==Wn.Vertical&&(y=f.deltaY*d,v=0),r.translateBy(n,-(y/c)*i,-(v/c)*i,{internal:!0});const x=Cl(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(a==null||a(f,x),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,x))}}function ZC({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,l=vr(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),s||l)return null;r.preventDefault(),n.call(this,r,o)}}function qC({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Cl(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function JC({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,l;e.usedRightMouseButton=!!(n&&vy(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Cl(i.transform)))}}function e_({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var l;if(!((l=s.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&vy(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const a=Cl(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,a)},n?150:0)}}}function t_({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:a,lib:u,connectionInProgress:f}){return c=>{var S;const d=e||t,y=n&&c.ctrlKey,v=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(vr(c,`${u}-flow__node`)||vr(c,`${u}-flow__edge`)))return!0;if(!r&&!d&&!o&&!i&&!n||s||f&&!v||vr(c,l)&&v||vr(c,a)&&(!v||o&&v&&!e)||!n&&c.ctrlKey&&v)return!1;if(!n&&c.type==="touchstart"&&((S=c.touches)==null?void 0:S.length)>1)return c.preventDefault(),!1;if(!d&&!o&&!y&&v||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||v)&&x}}function n_({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:a}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),c=Wg().scaleExtent([t,n]).translateExtent(r),d=Qe(e).call(c);m({x:o.x,y:o.y,zoom:Dr(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const y=d.on("wheel.zoom"),v=d.on("dblclick.zoom");c.wheelDelta(xy);function x(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).transform(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function S({noWheelClassName:I,noPanClassName:L,onPaneContextMenu:F,userSelectionActive:b,panOnScroll:z,panOnDrag:j,panOnScrollMode:A,panOnScrollSpeed:C,preventScrolling:P,zoomOnPinch:T,zoomOnScroll:O,zoomOnDoubleClick:D,zoomActivationKeyPressed:U,lib:B,onTransformChange:Y,connectionInProgress:X,paneClickDistance:G,selectionOnDrag:V}){b&&!u.isZoomingOrPanning&&h();const Q=z&&!U&&!b;c.clickDistance(V?1/0:!vt(G)||G<0?0:G);const te=Q?QC({zoomPanValues:u,noWheelClassName:I,d3Selection:d,d3Zoom:c,panOnScrollMode:A,panOnScrollSpeed:C,zoomOnPinch:T,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):ZC({noWheelClassName:I,preventScrolling:P,d3ZoomHandler:y});if(d.on("wheel.zoom",te,{passive:!1}),!b){const q=qC({zoomPanValues:u,onDraggingChange:a,onPanZoomStart:s});c.on("start",q);const Z=JC({zoomPanValues:u,panOnDrag:j,onPaneContextMenu:!!F,onPanZoom:i,onTransformChange:Y});c.on("zoom",Z);const se=e_({zoomPanValues:u,panOnDrag:j,panOnScroll:z,onPaneContextMenu:F,onPanZoomEnd:l,onDraggingChange:a});c.on("end",se)}const J=t_({zoomActivationKeyPressed:U,panOnDrag:j,zoomOnScroll:O,panOnScroll:z,zoomOnDoubleClick:D,zoomOnPinch:T,userSelectionActive:b,noPanClassName:L,noWheelClassName:I,lib:B,connectionInProgress:X});c.filter(J),D?d.on("dblclick.zoom",v):d.on("dblclick.zoom",null)}function h(){c.on("zoom",null)}async function m(I,L,F){const b=pa(I),z=c==null?void 0:c.constrain()(b,L,F);return z&&await x(z),new Promise(j=>j(z))}async function p(I,L){const F=pa(I);return await x(F,L),new Promise(b=>b(F))}function w(I){if(d){const L=pa(I),F=d.property("__zoom");(F.k!==I.zoom||F.x!==I.x||F.y!==I.y)&&(c==null||c.transform(d,L,null,{sync:!0}))}}function E(){const I=d?Ug(d.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}function N(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).scaleTo(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function _(I,L){return d?new Promise(F=>{c==null||c.interpolate((L==null?void 0:L.interpolate)==="linear"?jo:ds).scaleBy(ma(d,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>F(!0)),I)}):Promise.resolve(!1)}function M(I){c==null||c.scaleExtent(I)}function R(I){c==null||c.translateExtent(I)}function $(I){const L=!vt(I)||I<0?0:I;c==null||c.clickDistance(L)}return{update:S,destroy:h,setViewport:p,setViewportConstrained:m,getViewport:E,scaleTo:N,scaleBy:_,setScaleExtent:M,setTranslateExtent:R,syncViewport:w,setClickDistance:$}}var Hr;(function(e){e.Line="line",e.Handle="handle"})(Hr||(Hr={}));function r_({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,l=n-r,a=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&o&&(a[0]=a[0]*-1),l&&i&&(a[1]=a[1]*-1),a}function nh(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function rn(e,t){return Math.max(0,t-e)}function on(e,t){return Math.max(0,e-t)}function Xi(e,t,n){return Math.max(0,t-e,e-n)}function rh(e,t){return e?!t:t}function o_(e,t,n,r,o,i,s,l){let{affectsX:a,affectsY:u}=t;const{isHorizontal:f,isVertical:c}=t,d=f&&c,{xSnapped:y,ySnapped:v}=n,{minWidth:x,maxWidth:S,minHeight:h,maxHeight:m}=r,{x:p,y:w,width:E,height:N,aspectRatio:_}=e;let M=Math.floor(f?y-e.pointerX:0),R=Math.floor(c?v-e.pointerY:0);const $=E+(a?-M:M),I=N+(u?-R:R),L=-i[0]*E,F=-i[1]*N;let b=Xi($,x,S),z=Xi(I,h,m);if(s){let C=0,P=0;a&&M<0?C=rn(p+M+L,s[0][0]):!a&&M>0&&(C=on(p+$+L,s[1][0])),u&&R<0?P=rn(w+R+F,s[0][1]):!u&&R>0&&(P=on(w+I+F,s[1][1])),b=Math.max(b,C),z=Math.max(z,P)}if(l){let C=0,P=0;a&&M>0?C=on(p+M,l[0][0]):!a&&M<0&&(C=rn(p+$,l[1][0])),u&&R>0?P=on(w+R,l[0][1]):!u&&R<0&&(P=rn(w+I,l[1][1])),b=Math.max(b,C),z=Math.max(z,P)}if(o){if(f){const C=Xi($/_,h,m)*_;if(b=Math.max(b,C),s){let P=0;!a&&!u||a&&!u&&d?P=on(w+F+$/_,s[1][1])*_:P=rn(w+F+(a?M:-M)/_,s[0][1])*_,b=Math.max(b,P)}if(l){let P=0;!a&&!u||a&&!u&&d?P=rn(w+$/_,l[1][1])*_:P=on(w+(a?M:-M)/_,l[0][1])*_,b=Math.max(b,P)}}if(c){const C=Xi(I*_,x,S)/_;if(z=Math.max(z,C),s){let P=0;!a&&!u||u&&!a&&d?P=on(p+I*_+L,s[1][0])/_:P=rn(p+(u?R:-R)*_+L,s[0][0])/_,z=Math.max(z,P)}if(l){let P=0;!a&&!u||u&&!a&&d?P=rn(p+I*_,l[1][0])/_:P=on(p+(u?R:-R)*_,l[0][0])/_,z=Math.max(z,P)}}}R=R+(R<0?z:-z),M=M+(M<0?b:-b),o&&(d?$>I*_?R=(rh(a,u)?-M:M)/_:M=(rh(a,u)?-R:R)*_:f?(R=M/_,u=a):(M=R*_,a=u));const j=a?p+M:p,A=u?w+R:w;return{width:E+(a?-M:M),height:N+(u?-R:R),x:i[0]*M*(a?-1:1)+j,y:i[1]*R*(u?-1:1)+A}}const wy={width:0,height:0,x:0,y:0},i_={...wy,pointerX:0,pointerY:0,aspectRatio:1};function s_(e){return[[0,0],[e.measured.width,e.measured.height]]}function l_(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,a=n[1]*s;return[[r-l,o-a],[r+i-l,o+s-a]]}function a_({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Qe(e);let s={controlDirection:nh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:f,keepAspectRatio:c,resizeDirection:d,onResizeStart:y,onResize:v,onResizeEnd:x,shouldResize:S}){let h={...wy},m={...i_};s={boundaries:f,resizeDirection:d,keepAspectRatio:c,controlDirection:nh(u)};let p,w=null,E=[],N,_,M,R=!1;const $=jg().on("start",I=>{const{nodeLookup:L,transform:F,snapGrid:b,snapToGrid:z,nodeOrigin:j,paneDomNode:A}=n();if(p=L.get(t),!p)return;w=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:P}=Lo(I.sourceEvent,{transform:F,snapGrid:b,snapToGrid:z,containerBounds:w});h={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},m={...h,pointerX:C,pointerY:P,aspectRatio:h.width/h.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=L.get(p.parentId),_=N&&p.extent==="parent"?s_(N):void 0),E=[],M=void 0;for(const[T,O]of L)if(O.parentId===t&&(E.push({id:T,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const D=l_(O,p,O.origin??j);M?M=[[Math.min(D[0][0],M[0][0]),Math.min(D[0][1],M[0][1])],[Math.max(D[1][0],M[1][0]),Math.max(D[1][1],M[1][1])]]:M=D}y==null||y(I,{...h})}).on("drag",I=>{const{transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z}=n(),j=Lo(I.sourceEvent,{transform:L,snapGrid:F,snapToGrid:b,containerBounds:w}),A=[];if(!p)return;const{x:C,y:P,width:T,height:O}=h,D={},U=p.origin??z,{width:B,height:Y,x:X,y:G}=o_(m,s.controlDirection,j,s.boundaries,s.keepAspectRatio,U,_,M),V=B!==T,Q=Y!==O,te=X!==C&&V,J=G!==P&&Q;if(!te&&!J&&!V&&!Q)return;if((te||J||U[0]===1||U[1]===1)&&(D.x=te?X:h.x,D.y=J?G:h.y,h.x=D.x,h.y=D.y,E.length>0)){const ue=X-C,ie=G-P;for(const Ie of E)Ie.position={x:Ie.position.x-ue+U[0]*(B-T),y:Ie.position.y-ie+U[1]*(Y-O)},A.push(Ie)}if((V||Q)&&(D.width=V&&(!s.resizeDirection||s.resizeDirection==="horizontal")?B:h.width,D.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:h.height,h.width=D.width,h.height=D.height),N&&p.expandParent){const ue=U[0]*(D.width??0);D.x&&D.x<ue&&(h.x=ue,m.x=m.x-(D.x-ue));const ie=U[1]*(D.height??0);D.y&&D.y<ie&&(h.y=ie,m.y=m.y-(D.y-ie))}const q=r_({width:h.width,prevWidth:T,height:h.height,prevHeight:O,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...h,direction:q};(S==null?void 0:S(I,Z))!==!1&&(R=!0,v==null||v(I,Z),r(D,A))}).on("end",I=>{R&&(x==null||x(I,{...h}),o==null||o({...h}),R=!1)});i.call($)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var Sy={exports:{}},ky={},Ey={exports:{}},Ny={};/**
|
|
157
157
|
* @license React
|
|
158
158
|
* use-sync-external-store-shim.production.js
|
|
159
159
|
*
|
|
@@ -175,5 +175,5 @@ Please change the parent <Route path="${m}"> to <Route path="${m==="/"?"*":`${m}
|
|
|
175
175
|
`,`
|
|
176
176
|
+`).split(`
|
|
177
177
|
`)),f=u.reduce((c,d)=>c.concat(...d),[]);return[u,f]}return[[],[]]},[e]);return k.useEffect(()=>{const a=(t==null?void 0:t.target)??ch,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=y=>{var S,h;if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!u)&&oy(y))return!1;const x=fh(y.code,l);if(i.current.add(y[x]),dh(s,i.current,!1)){const m=((h=(S=y.composedPath)==null?void 0:S.call(y))==null?void 0:h[0])||y.target,p=(m==null?void 0:m.nodeName)==="BUTTON"||(m==null?void 0:m.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&y.preventDefault(),r(!0)}},c=y=>{const v=fh(y.code,l);dh(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(y[v]),y.key==="Meta"&&i.current.clear(),o.current=!1},d=()=>{i.current.clear(),r(!1)};return a==null||a.addEventListener("keydown",f),a==null||a.addEventListener("keyup",c),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{a==null||a.removeEventListener("keydown",f),a==null||a.removeEventListener("keyup",c),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function dh(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function fh(e,t){return t.includes(e)?"code":"key"}const J_=()=>{const e=ge();return k.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,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:l}=e.getState(),a=Uc(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(a,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:l,y:a}=s.getBoundingClientRect(),u={x:t.x-l,y:t.y-a},f=n.snapGrid??o,c=n.snapToGrid??i;return xi(u,r,c,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=Ks(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function jy(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const l={...i};for(const a of s)eb(a,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function eb(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function tb(e,t){return jy(e,t)}function nb(e,t){return jy(e,t)}function Tn(e,t){return{id:e,type:"select",selected:t}}function xr(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(Tn(i.id,s)))}return r}function hh({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const l=t.get(s.id),a=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;a!==void 0&&a!==s&&n.push({id:s.id,item:s,type:"replace"}),a===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function ph(e){return{id:e.id,type:"remove"}}const mh=e=>cC(e),rb=e=>Qg(e);function Ly(e){return k.forwardRef(e)}const ob=typeof window<"u"?k.useLayoutEffect:k.useEffect;function gh(e){const[t,n]=k.useState(BigInt(0)),[r]=k.useState(()=>ib(()=>n(o=>o+BigInt(1))));return ob(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function ib(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ry=k.createContext(null);function sb({children:e}){const t=ge(),n=k.useCallback(l=>{const{nodes:a=[],setNodes:u,hasDefaultNodes:f,onNodesChange:c,nodeLookup:d,fitViewQueued:y,onNodesChangeMiddlewareMap:v}=t.getState();let x=a;for(const h of l)x=typeof h=="function"?h(x):h;let S=hh({items:x,lookup:d});for(const h of v.values())S=h(S);f&&u(x),S.length>0?c==null||c(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:h,nodes:m,setNodes:p}=t.getState();h&&p(m)})},[]),r=gh(n),o=k.useCallback(l=>{const{edges:a=[],setEdges:u,hasDefaultEdges:f,onEdgesChange:c,edgeLookup:d}=t.getState();let y=a;for(const v of l)y=typeof v=="function"?v(y):v;f?u(y):c&&c(hh({items:y,lookup:d}))},[]),i=gh(o),s=k.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return g.jsx(Ry.Provider,{value:s,children:e})}function lb(){const e=k.useContext(Ry);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const ab=e=>!!e.panZoom;function Zc(){const e=J_(),t=ge(),n=lb(),r=re(ab),o=k.useMemo(()=>{const i=c=>t.getState().nodeLookup.get(c),s=c=>{n.nodeQueue.push(c)},l=c=>{n.edgeQueue.push(c)},a=c=>{var h,m;const{nodeLookup:d,nodeOrigin:y}=t.getState(),v=mh(c)?c:d.get(c.id),x=v.parentId?ny(v.position,v.measured,v.parentId,d,y):v.position,S={...v,position:x,width:((h=v.measured)==null?void 0:h.width)??v.width,height:((m=v.measured)==null?void 0:m.height)??v.height};return Or(S)},u=(c,d,y={replace:!1})=>{s(v=>v.map(x=>{if(x.id===c){const S=typeof d=="function"?d(x):d;return y.replace&&mh(S)?S:{...x,...S}}return x}))},f=(c,d,y={replace:!1})=>{l(v=>v.map(x=>{if(x.id===c){const S=typeof d=="function"?d(x):d;return y.replace&&rb(S)?S:{...x,...S}}return x}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var d;return(d=i(c))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(d=>({...d}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:s,setEdges:l,addNodes:c=>{const d=Array.isArray(c)?c:[c];n.nodeQueue.push(y=>[...y,...d])},addEdges:c=>{const d=Array.isArray(c)?c:[c];n.edgeQueue.push(y=>[...y,...d])},toObject:()=>{const{nodes:c=[],edges:d=[],transform:y}=t.getState(),[v,x,S]=y;return{nodes:c.map(h=>({...h})),edges:d.map(h=>({...h})),viewport:{x:v,y:x,zoom:S}}},deleteElements:async({nodes:c=[],edges:d=[]})=>{const{nodes:y,edges:v,onNodesDelete:x,onEdgesDelete:S,triggerNodeChanges:h,triggerEdgeChanges:m,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:E,edges:N}=await mC({nodesToRemove:c,edgesToRemove:d,nodes:y,edges:v,onBeforeDelete:w}),_=N.length>0,M=E.length>0;if(_){const R=N.map(ph);S==null||S(N),m(R)}if(M){const R=E.map(ph);x==null||x(E),h(R)}return(M||_)&&(p==null||p({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(c,d=!0,y)=>{const v=Wf(c),x=v?c:a(c),S=y!==void 0;return x?(y||t.getState().nodes).filter(h=>{const m=t.getState().nodeLookup.get(h.id);if(m&&!v&&(h.id===c.id||!m.internals.positionAbsolute))return!1;const p=Or(S?h:m),w=oi(p,x);return d&&w>0||w>=p.width*p.height||w>=x.width*x.height}):[]},isNodeIntersecting:(c,d,y=!0)=>{const x=Wf(c)?c:a(c);if(!x)return!1;const S=oi(x,d);return y&&S>0||S>=d.width*d.height||S>=x.width*x.height},updateNode:u,updateNodeData:(c,d,y={replace:!1})=>{u(c,v=>{const x=typeof d=="function"?d(v):d;return y.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},y)},updateEdge:f,updateEdgeData:(c,d,y={replace:!1})=>{f(c,v=>{const x=typeof d=="function"?d(v):d;return y.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},y)},getNodesBounds:c=>{const{nodeLookup:d,nodeOrigin:y}=t.getState();return dC(c,{nodeLookup:d,nodeOrigin:y})},getHandleConnections:({type:c,id:d,nodeId:y})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${y}-${c}${d?`-${d}`:""}`))==null?void 0:v.values())??[])},getNodeConnections:({type:c,handleId:d,nodeId:y})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${y}${c?d?`-${c}-${d}`:`-${c}`:""}`))==null?void 0:v.values())??[])},fitView:async c=>{const d=t.getState().fitViewResolver??xC();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:d}),n.nodeQueue.push(y=>[...y]),d.promise}}},[]);return k.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const yh=e=>e.selected,ub=typeof window<"u"?window:void 0;function cb({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ge(),{deleteElements:r}=Zc(),o=si(e,{actInsideInputWithModifier:!1}),i=si(t,{target:ub});k.useEffect(()=>{if(o){const{edges:s,nodes:l}=n.getState();r({nodes:l.filter(yh),edges:s.filter(yh)}),n.setState({nodesSelectionActive:!1})}},[o]),k.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function db(e){const t=ge();k.useEffect(()=>{const n=()=>{var o,i,s,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=Wc(e.current);(r.height===0||r.width===0)&&((l=(s=t.getState()).onError)==null||l.call(s,"004",Rt.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},fb=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function hb({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Wn.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:a,translateExtent:u,minZoom:f,maxZoom:c,zoomActivationKeyCode:d,preventScrolling:y=!0,children:v,noWheelClassName:x,noPanClassName:S,onViewportChange:h,isControlledViewport:m,paneClickDistance:p,selectionOnDrag:w}){const E=ge(),N=k.useRef(null),{userSelectionActive:_,lib:M,connectionInProgress:R}=re(fb,me),$=si(d),I=k.useRef();db(N);const L=k.useCallback(F=>{h==null||h({x:F[0],y:F[1],zoom:F[2]}),m||E.setState({transform:F})},[h,m]);return k.useEffect(()=>{if(N.current){I.current=n_({domNode:N.current,minZoom:f,maxZoom:c,translateExtent:u,viewport:a,onDraggingChange:j=>E.setState({paneDragging:j}),onPanZoomStart:(j,A)=>{const{onViewportChangeStart:C,onMoveStart:P}=E.getState();P==null||P(j,A),C==null||C(A)},onPanZoom:(j,A)=>{const{onViewportChange:C,onMove:P}=E.getState();P==null||P(j,A),C==null||C(A)},onPanZoomEnd:(j,A)=>{const{onViewportChangeEnd:C,onMoveEnd:P}=E.getState();P==null||P(j,A),C==null||C(A)}});const{x:F,y:b,zoom:z}=I.current.getViewport();return E.setState({panZoom:I.current,transform:[F,b,z],domNode:N.current.closest(".react-flow")}),()=>{var j;(j=I.current)==null||j.destroy()}}},[]),k.useEffect(()=>{var F;(F=I.current)==null||F.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:$,preventScrolling:y,noPanClassName:S,userSelectionActive:_,noWheelClassName:x,lib:M,onTransformChange:L,connectionInProgress:R,selectionOnDrag:w,paneClickDistance:p})},[e,t,n,r,o,i,s,l,$,y,S,_,x,M,L,R,w,p]),g.jsx("div",{className:"react-flow__renderer",ref:N,style:Ml,children:v})}const pb=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function mb(){const{userSelectionActive:e,userSelectionRect:t}=re(pb,me);return e&&t?g.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 ya=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},gb=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function yb({isSelecting:e,selectionKeyPressed:t,selectionMode:n=ri.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:l,onPaneClick:a,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:y,children:v}){const x=ge(),{userSelectionActive:S,elementsSelectable:h,dragging:m,connectionInProgress:p}=re(gb,me),w=h&&(e||S),E=k.useRef(null),N=k.useRef(),_=k.useRef(new Set),M=k.useRef(new Set),R=k.useRef(!1),$=C=>{if(R.current||p){R.current=!1;return}a==null||a(C),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},I=C=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){C.preventDefault();return}u==null||u(C)},L=f?C=>f(C):void 0,F=C=>{R.current&&(C.stopPropagation(),R.current=!1)},b=C=>{var Y,X;const{domNode:P}=x.getState();if(N.current=P==null?void 0:P.getBoundingClientRect(),!N.current)return;const T=C.target===E.current;if(!T&&!!C.target.closest(".nokey")||!e||!(i&&T||t)||C.button!==0||!C.isPrimary)return;(X=(Y=C.target)==null?void 0:Y.setPointerCapture)==null||X.call(Y,C.pointerId),R.current=!1;const{x:U,y:B}=xt(C.nativeEvent,N.current);x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:B,x:U,y:B}}),T||(C.stopPropagation(),C.preventDefault())},z=C=>{const{userSelectionRect:P,transform:T,nodeLookup:O,edgeLookup:D,connectionLookup:U,triggerNodeChanges:B,triggerEdgeChanges:Y,defaultEdgeOptions:X,resetSelectedElements:G}=x.getState();if(!N.current||!P)return;const{x:V,y:Q}=xt(C.nativeEvent,N.current),{startX:te,startY:J}=P;if(!R.current){const ie=t?0:o;if(Math.hypot(V-te,Q-J)<=ie)return;G(),s==null||s(C)}R.current=!0;const q={startX:te,startY:J,x:V<te?V:te,y:Q<J?Q:J,width:Math.abs(V-te),height:Math.abs(Q-J)},Z=_.current,se=M.current;_.current=new Set(Bc(O,q,T,n===ri.Partial,!0).map(ie=>ie.id)),M.current=new Set;const ue=(X==null?void 0:X.selectable)??!0;for(const ie of _.current){const Ie=U.get(ie);if(Ie)for(const{edgeId:Jt}of Ie.values()){const At=D.get(Jt);At&&(At.selectable??ue)&&M.current.add(Jt)}}if(!Yf(Z,_.current)){const ie=xr(O,_.current,!0);B(ie)}if(!Yf(se,M.current)){const ie=xr(D,M.current);Y(ie)}x.setState({userSelectionRect:q,userSelectionActive:!0,nodesSelectionActive:!1})},j=C=>{var P,T;C.button===0&&((T=(P=C.target)==null?void 0:P.releasePointerCapture)==null||T.call(P,C.pointerId),!S&&C.target===E.current&&x.getState().userSelectionRect&&($==null||$(C)),x.setState({userSelectionActive:!1,userSelectionRect:null}),R.current&&(l==null||l(C),x.setState({nodesSelectionActive:_.current.size>0})))},A=r===!0||Array.isArray(r)&&r.includes(0);return g.jsxs("div",{className:Ee(["react-flow__pane",{draggable:A,dragging:m,selection:e}]),onClick:w?void 0:ya($,E),onContextMenu:ya(I,E),onWheel:ya(L,E),onPointerEnter:w?void 0:c,onPointerMove:w?z:d,onPointerUp:w?j:void 0,onPointerDownCapture:w?b:void 0,onClickCapture:w?F:void 0,onPointerLeave:y,ref:E,style:Ml,children:[v,g.jsx(mb,{})]})}function Lu({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:a}=t.getState(),u=l.get(e);if(!u){a==null||a("012",Rt.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):o([e])}function Iy({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const l=ge(),[a,u]=k.useState(!1),f=k.useRef();return k.useEffect(()=>{f.current=VC({getStoreItems:()=>l.getState(),onNodeMouseDown:c=>{Lu({id:c,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),k.useEffect(()=>{var c,d;if(t)(c=f.current)==null||c.destroy();else if(e.current)return(d=f.current)==null||d.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var y;(y=f.current)==null||y.destroy()}},[n,r,t,i,e,o]),a}const vb=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ty(){const e=ge();return k.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:l,updateNodePositions:a,nodeLookup:u,nodeOrigin:f}=e.getState(),c=new Map,d=vb(s),y=o?i[0]:5,v=o?i[1]:5,x=n.direction.x*y*n.factor,S=n.direction.y*v*n.factor;for(const[,h]of u){if(!d(h))continue;let m={x:h.internals.positionAbsolute.x+x,y:h.internals.positionAbsolute.y+S};o&&(m=vi(m,i));const{position:p,positionAbsolute:w}=Zg({nodeId:h.id,nextPosition:m,nodeLookup:u,nodeExtent:r,nodeOrigin:f,onError:l});h.position=p,h.internals.positionAbsolute=w,c.set(h.id,h)}a(c)},[])}const qc=k.createContext(null),xb=qc.Provider;qc.Consumer;const zy=()=>k.useContext(qc),wb=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Sb=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:l,toHandle:a,isValid:u}=s,f=(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===$r.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:f&&u}};function kb({type:e="source",position:t=K.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:a,className:u,onMouseDown:f,onTouchStart:c,...d},y){var z,j;const v=s||null,x=e==="target",S=ge(),h=zy(),{connectOnClick:m,noPanClassName:p,rfId:w}=re(wb,me),{connectingFrom:E,connectingTo:N,clickConnecting:_,isPossibleEndHandle:M,connectionInProcess:R,clickConnectionInProcess:$,valid:I}=re(Sb(h,v,e),me);h||(j=(z=S.getState()).onError)==null||j.call(z,"010",Rt.error010());const L=A=>{const{defaultEdgeOptions:C,onConnect:P,hasDefaultEdges:T}=S.getState(),O={...C,...A};if(T){const{edges:D,setEdges:U}=S.getState();U(_C(O,D))}P==null||P(O),l==null||l(O)},F=A=>{if(!h)return;const C=iy(A.nativeEvent);if(o&&(C&&A.button===0||!C)){const P=S.getState();ju.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:P.autoPanOnConnect,connectionMode:P.connectionMode,connectionRadius:P.connectionRadius,domNode:P.domNode,nodeLookup:P.nodeLookup,lib:P.lib,isTarget:x,handleId:v,nodeId:h,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:P.onConnectEnd,updateConnection:P.updateConnection,onConnect:L,isValidConnection:n||P.isValidConnection,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}C?f==null||f(A):c==null||c(A)},b=A=>{const{onClickConnectStart:C,onClickConnectEnd:P,connectionClickStartHandle:T,connectionMode:O,isValidConnection:D,lib:U,rfId:B,nodeLookup:Y,connection:X}=S.getState();if(!h||!T&&!o)return;if(!T){C==null||C(A.nativeEvent,{nodeId:h,handleId:v,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:h,type:e,id:v}});return}const G=ry(A.target),V=n||D,{connection:Q,isValid:te}=ju.isValid(A.nativeEvent,{handle:{nodeId:h,id:v,type:e},connectionMode:O,fromNodeId:T.nodeId,fromHandleId:T.id||null,fromType:T.type,isValidConnection:V,flowId:B,doc:G,lib:U,nodeLookup:Y});te&&Q&&L(Q);const J=structuredClone(X);delete J.inProgress,J.toPosition=J.toHandle?J.toHandle.position:null,P==null||P(A,J),S.setState({connectionClickStartHandle:null})};return g.jsx("div",{"data-handleid":v,"data-nodeid":h,"data-handlepos":t,"data-id":`${w}-${h}-${v}-${e}`,className:Ee(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!x,target:x,connectable:r,connectablestart:o,connectableend:i,clickconnecting:_,connectingfrom:E,connectingto:N,valid:I,connectionindicator:r&&(!R||M)&&(R||$?i:o)}]),onMouseDown:F,onTouchStart:F,onClick:m?b:void 0,ref:y,...d,children:a})}const Qs=k.memo(Ly(kb));function Eb({data:e,isConnectable:t,sourcePosition:n=K.Bottom}){return g.jsxs(g.Fragment,{children:[e==null?void 0:e.label,g.jsx(Qs,{type:"source",position:n,isConnectable:t})]})}function Nb({data:e,isConnectable:t,targetPosition:n=K.Top,sourcePosition:r=K.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(Qs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,g.jsx(Qs,{type:"source",position:r,isConnectable:t})]})}function Cb(){return null}function _b({data:e,isConnectable:t,targetPosition:n=K.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(Qs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Zs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},vh={input:Eb,default:Nb,output:_b,group:Cb};function bb(e){var t,n,r,o;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??((o=e.style)==null?void 0:o.height)}}const Pb=e=>{const{width:t,height:n,x:r,y:o}=yi(e.nodeLookup,{filter:i=>!!i.selected});return{width:vt(t)?t:null,height:vt(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function Mb({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ge(),{width:o,height:i,transformString:s,userSelectionActive:l}=re(Pb,me),a=Ty(),u=k.useRef(null);if(k.useEffect(()=>{var d;n||(d=u.current)==null||d.focus({preventScroll:!0})},[n]),Iy({nodeRef:u}),l||!o||!i)return null;const f=e?d=>{const y=r.getState().nodes.filter(v=>v.selected);e(d,y)}:void 0,c=d=>{Object.prototype.hasOwnProperty.call(Zs,d.key)&&(d.preventDefault(),a({direction:Zs[d.key],factor:d.shiftKey?4:1}))};return g.jsx("div",{className:Ee(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:g.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:c,style:{width:o,height:i}})})}const xh=typeof window<"u"?window:void 0,jb=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ay({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:l,deleteKeyCode:a,selectionKeyCode:u,selectionOnDrag:f,selectionMode:c,onSelectionStart:d,onSelectionEnd:y,multiSelectionKeyCode:v,panActivationKeyCode:x,zoomActivationKeyCode:S,elementsSelectable:h,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:_,panOnDrag:M,defaultViewport:R,translateExtent:$,minZoom:I,maxZoom:L,preventScrolling:F,onSelectionContextMenu:b,noWheelClassName:z,noPanClassName:j,disableKeyboardA11y:A,onViewportChange:C,isControlledViewport:P}){const{nodesSelectionActive:T,userSelectionActive:O}=re(jb,me),D=si(u,{target:xh}),U=si(x,{target:xh}),B=U||M,Y=U||w,X=f&&B!==!0,G=D||O||X;return cb({deleteKeyCode:a,multiSelectionKeyCode:v}),g.jsx(hb,{onPaneContextMenu:i,elementsSelectable:h,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:Y,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:_,panOnDrag:!D&&B,defaultViewport:R,translateExtent:$,minZoom:I,maxZoom:L,zoomActivationKeyCode:S,preventScrolling:F,noWheelClassName:z,noPanClassName:j,onViewportChange:C,isControlledViewport:P,paneClickDistance:l,selectionOnDrag:X,children:g.jsxs(yb,{onSelectionStart:d,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:B,isSelecting:!!G,selectionMode:c,selectionKeyPressed:D,paneClickDistance:l,selectionOnDrag:X,children:[e,T&&g.jsx(Mb,{onSelectionContextMenu:b,noPanClassName:j,disableKeyboardA11y:A})]})})}Ay.displayName="FlowRenderer";const Lb=k.memo(Ay),Rb=e=>t=>e?Bc(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 Ib(e){return re(k.useCallback(Rb(e),[e]),me)}const Tb=e=>e.updateNodeInternals;function zb(){const e=re(Tb),[t]=k.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return k.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Ab({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=ge(),i=k.useRef(null),s=k.useRef(null),l=k.useRef(e.sourcePosition),a=k.useRef(e.targetPosition),u=k.useRef(t),f=n&&!!e.internals.handleBounds;return k.useEffect(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[f,e.hidden]),k.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),k.useEffect(()=>{if(i.current){const c=u.current!==t,d=l.current!==e.sourcePosition,y=a.current!==e.targetPosition;(c||d||y)&&(u.current=t,l.current=e.sourcePosition,a.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function $b({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:l,elementsSelectable:a,nodesConnectable:u,nodesFocusable:f,resizeObserver:c,noDragClassName:d,noPanClassName:y,disableKeyboardA11y:v,rfId:x,nodeTypes:S,nodeClickDistance:h,onError:m}){const{node:p,internals:w,isParent:E}=re(V=>{const Q=V.nodeLookup.get(e),te=V.parentLookup.has(e);return{node:Q,internals:Q.internals,isParent:te}},me);let N=p.type||"default",_=(S==null?void 0:S[N])||vh[N];_===void 0&&(m==null||m("003",Rt.error003(N)),N="default",_=(S==null?void 0:S.default)||vh.default);const M=!!(p.draggable||l&&typeof p.draggable>"u"),R=!!(p.selectable||a&&typeof p.selectable>"u"),$=!!(p.connectable||u&&typeof p.connectable>"u"),I=!!(p.focusable||f&&typeof p.focusable>"u"),L=ge(),F=ty(p),b=Ab({node:p,nodeType:N,hasDimensions:F,resizeObserver:c}),z=Iy({nodeRef:b,disabled:p.hidden||!M,noDragClassName:d,handleSelector:p.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:h}),j=Ty();if(p.hidden)return null;const A=qt(p),C=bb(p),P=R||M||t||n||r||o,T=n?V=>n(V,{...w.userNode}):void 0,O=r?V=>r(V,{...w.userNode}):void 0,D=o?V=>o(V,{...w.userNode}):void 0,U=i?V=>i(V,{...w.userNode}):void 0,B=s?V=>s(V,{...w.userNode}):void 0,Y=V=>{const{selectNodesOnDrag:Q,nodeDragThreshold:te}=L.getState();R&&(!Q||!M||te>0)&&Lu({id:e,store:L,nodeRef:b}),t&&t(V,{...w.userNode})},X=V=>{if(!(oy(V.nativeEvent)||v)){if(Yg.includes(V.key)&&R){const Q=V.key==="Escape";Lu({id:e,store:L,unselect:Q,nodeRef:b})}else if(M&&p.selected&&Object.prototype.hasOwnProperty.call(Zs,V.key)){V.preventDefault();const{ariaLabelConfig:Q}=L.getState();L.setState({ariaLiveMessage:Q["node.a11yDescription.ariaLiveMessage"]({direction:V.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),j({direction:Zs[V.key],factor:V.shiftKey?4:1})}}},G=()=>{var se;if(v||!((se=b.current)!=null&&se.matches(":focus-visible")))return;const{transform:V,width:Q,height:te,autoPanOnNodeFocus:J,setCenter:q}=L.getState();if(!J)return;Bc(new Map([[e,p]]),{x:0,y:0,width:Q,height:te},V,!0).length>0||q(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:V[2]})};return g.jsx("div",{className:Ee(["react-flow__node",`react-flow__node-${N}`,{[y]:M},p.className,{selected:p.selected,selectable:R,parent:E,draggable:M,dragging:z}]),ref:b,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:F?"visible":"hidden",...p.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:T,onMouseMove:O,onMouseLeave:D,onContextMenu:U,onClick:Y,onDoubleClick:B,onKeyDown:I?X:void 0,tabIndex:I?0:void 0,onFocus:I?G:void 0,role:p.ariaRole??(I?"group":void 0),"aria-roledescription":"node","aria-describedby":v?void 0:`${by}-${x}`,"aria-label":p.ariaLabel,...p.domAttributes,children:g.jsx(xb,{value:e,children:g.jsx(_,{id:e,data:p.data,type:N,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:R,draggable:M,deletable:p.deletable??!0,isConnectable:$,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:z,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...A})})})}var Db=k.memo($b);const Ob=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function $y(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=re(Ob,me),s=Ib(e.onlyRenderVisibleElements),l=zb();return g.jsx("div",{className:"react-flow__nodes",style:Ml,children:s.map(a=>g.jsx(Db,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}$y.displayName="NodeRenderer";const Fb=k.memo($y);function Hb(e){return re(k.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&EC({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),me)}const Vb=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return g.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Bb=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return g.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},wh={[Xs.Arrow]:Vb,[Xs.ArrowClosed]:Bb};function Ub(e){const t=ge();return k.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(wh,e)?wh[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",Rt.error009(e)),null)},[e])}const Wb=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const a=Ub(t);return a?g.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:g.jsx(a,{color:n,strokeWidth:s})}):null},Dy=({defaultColor:e,rfId:t})=>{const n=re(i=>i.edges),r=re(i=>i.defaultEdgeOptions),o=k.useMemo(()=>LC(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?g.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:g.jsx("defs",{children:o.map(i=>g.jsx(Wb,{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};Dy.displayName="MarkerDefinitions";var Yb=k.memo(Dy);function Oy({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...f}){const[c,d]=k.useState({x:1,y:0,width:0,height:0}),y=Ee(["react-flow__edge-textwrapper",u]),v=k.useRef(null);return k.useEffect(()=>{if(v.current){const x=v.current.getBBox();d({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?g.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:y,visibility:c.width?"visible":"hidden",...f,children:[o&&g.jsx("rect",{width:c.width+2*s[0],x:-s[0],y:-s[1],height:c.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),g.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:v,style:r,children:n}),a]}):null}Oy.displayName="EdgeText";const Xb=k.memo(Oy);function jl({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a,interactionWidth:u=20,...f}){return g.jsxs(g.Fragment,{children:[g.jsx("path",{...f,d:e,fill:"none",className:Ee(["react-flow__edge-path",f.className])}),u?g.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&vt(t)&&vt(n)?g.jsx(Xb,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a}):null]})}function Sh({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===K.Left||e===K.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Fy({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:i=K.Top}){const[s,l]=Sh({pos:n,x1:e,y1:t,x2:r,y2:o}),[a,u]=Sh({pos:i,x1:r,y1:o,x2:e,y2:t}),[f,c,d,y]=sy({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:a,targetControlY:u});return[`M${e},${t} C${s},${l} ${a},${u} ${r},${o}`,f,c,d,y]}function Hy(e){return k.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:l,label:a,labelStyle:u,labelShowBg:f,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:y,style:v,markerEnd:x,markerStart:S,interactionWidth:h})=>{const[m,p,w]=Fy({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l}),E=e.isInternal?void 0:t;return g.jsx(jl,{id:E,path:m,labelX:p,labelY:w,label:a,labelStyle:u,labelShowBg:f,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:y,style:v,markerEnd:x,markerStart:S,interactionWidth:h})})}const Gb=Hy({isInternal:!1}),Vy=Hy({isInternal:!0});Gb.displayName="SimpleBezierEdge";Vy.displayName="SimpleBezierEdgeInternal";function By(e){return k.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:c,style:d,sourcePosition:y=K.Bottom,targetPosition:v=K.Top,markerEnd:x,markerStart:S,pathOptions:h,interactionWidth:m})=>{const[p,w,E]=bu({sourceX:n,sourceY:r,sourcePosition:y,targetX:o,targetY:i,targetPosition:v,borderRadius:h==null?void 0:h.borderRadius,offset:h==null?void 0:h.offset,stepPosition:h==null?void 0:h.stepPosition}),N=e.isInternal?void 0:t;return g.jsx(jl,{id:N,path:p,labelX:w,labelY:E,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:c,style:d,markerEnd:x,markerStart:S,interactionWidth:m})})}const Uy=By({isInternal:!1}),Wy=By({isInternal:!0});Uy.displayName="SmoothStepEdge";Wy.displayName="SmoothStepEdgeInternal";function Yy(e){return k.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return g.jsx(Uy,{...n,id:r,pathOptions:k.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const Kb=Yy({isInternal:!1}),Xy=Yy({isInternal:!0});Kb.displayName="StepEdge";Xy.displayName="StepEdgeInternal";function Gy(e){return k.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:c,style:d,markerEnd:y,markerStart:v,interactionWidth:x})=>{const[S,h,m]=uy({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return g.jsx(jl,{id:p,path:S,labelX:h,labelY:m,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:c,style:d,markerEnd:y,markerStart:v,interactionWidth:x})})}const Qb=Gy({isInternal:!1}),Ky=Gy({isInternal:!0});Qb.displayName="StraightEdge";Ky.displayName="StraightEdgeInternal";function Qy(e){return k.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=K.Bottom,targetPosition:l=K.Top,label:a,labelStyle:u,labelShowBg:f,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:y,style:v,markerEnd:x,markerStart:S,pathOptions:h,interactionWidth:m})=>{const[p,w,E]=ly({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l,curvature:h==null?void 0:h.curvature}),N=e.isInternal?void 0:t;return g.jsx(jl,{id:N,path:p,labelX:w,labelY:E,label:a,labelStyle:u,labelShowBg:f,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:y,style:v,markerEnd:x,markerStart:S,interactionWidth:m})})}const Zb=Qy({isInternal:!1}),Zy=Qy({isInternal:!0});Zb.displayName="BezierEdge";Zy.displayName="BezierEdgeInternal";const kh={default:Zy,straight:Ky,step:Xy,smoothstep:Wy,simplebezier:Vy},Eh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},qb=(e,t,n)=>n===K.Left?e-t:n===K.Right?e+t:e,Jb=(e,t,n)=>n===K.Top?e-t:n===K.Bottom?e+t:e,Nh="react-flow__edgeupdater";function Ch({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:l}){return g.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:Ee([Nh,`${Nh}-${l}`]),cx:qb(t,r,e),cy:Jb(n,r,e),r,stroke:"transparent",fill:"transparent"})}function eP({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:l,targetPosition:a,onReconnect:u,onReconnectStart:f,onReconnectEnd:c,setReconnecting:d,setUpdateHover:y}){const v=ge(),x=(w,E)=>{if(w.button!==0)return;const{autoPanOnConnect:N,domNode:_,isValidConnection:M,connectionMode:R,connectionRadius:$,lib:I,onConnectStart:L,onConnectEnd:F,cancelConnection:b,nodeLookup:z,rfId:j,panBy:A,updateConnection:C}=v.getState(),P=E.type==="target",T=(U,B)=>{d(!1),c==null||c(U,n,E.type,B)},O=U=>u==null?void 0:u(n,U),D=(U,B)=>{d(!0),f==null||f(w,n,E.type),L==null||L(U,B)};ju.onPointerDown(w.nativeEvent,{autoPanOnConnect:N,connectionMode:R,connectionRadius:$,domNode:_,handleId:E.id,nodeId:E.nodeId,nodeLookup:z,isTarget:P,edgeUpdaterType:E.type,lib:I,flowId:j,cancelConnection:b,panBy:A,isValidConnection:M,onConnect:O,onConnectStart:D,onConnectEnd:F,onReconnectEnd:T,updateConnection:C,getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,dragThreshold:v.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},S=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),h=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),m=()=>y(!0),p=()=>y(!1);return g.jsxs(g.Fragment,{children:[(e===!0||e==="source")&&g.jsx(Ch,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:S,onMouseEnter:m,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&g.jsx(Ch,{position:a,centerX:i,centerY:s,radius:t,onMouseDown:h,onMouseEnter:m,onMouseOut:p,type:"target"})]})}function tP({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,reconnectRadius:f,onReconnect:c,onReconnectStart:d,onReconnectEnd:y,rfId:v,edgeTypes:x,noPanClassName:S,onError:h,disableKeyboardA11y:m}){let p=re(q=>q.edgeLookup.get(e));const w=re(q=>q.defaultEdgeOptions);p=w?{...w,...p}:p;let E=p.type||"default",N=(x==null?void 0:x[E])||kh[E];N===void 0&&(h==null||h("011",Rt.error011(E)),E="default",N=(x==null?void 0:x.default)||kh.default);const _=!!(p.focusable||t&&typeof p.focusable>"u"),M=typeof c<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),R=!!(p.selectable||r&&typeof p.selectable>"u"),$=k.useRef(null),[I,L]=k.useState(!1),[F,b]=k.useState(!1),z=ge(),{zIndex:j,sourceX:A,sourceY:C,targetX:P,targetY:T,sourcePosition:O,targetPosition:D}=re(k.useCallback(q=>{const Z=q.nodeLookup.get(p.source),se=q.nodeLookup.get(p.target);if(!Z||!se)return{zIndex:p.zIndex,...Eh};const ue=jC({id:e,sourceNode:Z,targetNode:se,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:q.connectionMode,onError:h});return{zIndex:kC({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:se,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...ue||Eh}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),me),U=k.useMemo(()=>p.markerStart?`url('#${Pu(p.markerStart,v)}')`:void 0,[p.markerStart,v]),B=k.useMemo(()=>p.markerEnd?`url('#${Pu(p.markerEnd,v)}')`:void 0,[p.markerEnd,v]);if(p.hidden||A===null||C===null||P===null||T===null)return null;const Y=q=>{var ie;const{addSelectedEdges:Z,unselectNodesAndEdges:se,multiSelectionActive:ue}=z.getState();R&&(z.setState({nodesSelectionActive:!1}),p.selected&&ue?(se({nodes:[],edges:[p]}),(ie=$.current)==null||ie.blur()):Z([e])),o&&o(q,p)},X=i?q=>{i(q,{...p})}:void 0,G=s?q=>{s(q,{...p})}:void 0,V=l?q=>{l(q,{...p})}:void 0,Q=a?q=>{a(q,{...p})}:void 0,te=u?q=>{u(q,{...p})}:void 0,J=q=>{var Z;if(!m&&Yg.includes(q.key)&&R){const{unselectNodesAndEdges:se,addSelectedEdges:ue}=z.getState();q.key==="Escape"?((Z=$.current)==null||Z.blur(),se({edges:[p]})):ue([e])}};return g.jsx("svg",{style:{zIndex:j},children:g.jsxs("g",{className:Ee(["react-flow__edge",`react-flow__edge-${E}`,p.className,S,{selected:p.selected,animated:p.animated,inactive:!R&&!o,updating:I,selectable:R}]),onClick:Y,onDoubleClick:X,onContextMenu:G,onMouseEnter:V,onMouseMove:Q,onMouseLeave:te,onKeyDown:_?J:void 0,tabIndex:_?0:void 0,role:p.ariaRole??(_?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":_?`${Py}-${v}`:void 0,ref:$,...p.domAttributes,children:[!F&&g.jsx(N,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:R,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:C,targetX:P,targetY:T,sourcePosition:O,targetPosition:D,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:U,markerEnd:B,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),M&&g.jsx(eP,{edge:p,isReconnectable:M,reconnectRadius:f,onReconnect:c,onReconnectStart:d,onReconnectEnd:y,sourceX:A,sourceY:C,targetX:P,targetY:T,sourcePosition:O,targetPosition:D,setUpdateHover:L,setReconnecting:b})]})})}var nP=k.memo(tP);const rP=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function qy({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:f,reconnectRadius:c,onEdgeDoubleClick:d,onReconnectStart:y,onReconnectEnd:v,disableKeyboardA11y:x}){const{edgesFocusable:S,edgesReconnectable:h,elementsSelectable:m,onError:p}=re(rP,me),w=Hb(t);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(Yb,{defaultColor:e,rfId:n}),w.map(E=>g.jsx(nP,{id:E,edgesFocusable:S,edgesReconnectable:h,elementsSelectable:m,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:f,reconnectRadius:c,onDoubleClick:d,onReconnectStart:y,onReconnectEnd:v,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:x},E))]})}qy.displayName="EdgeRenderer";const oP=k.memo(qy),iP=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function sP({children:e}){const t=re(iP);return g.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function lP(e){const t=Zc(),n=k.useRef(!1);k.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const aP=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function uP(e){const t=re(aP),n=ge();return k.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function cP(e){return e.connection.inProgress?{...e.connection,to:xi(e.connection.to,e.transform)}:{...e.connection}}function dP(e){return cP}function fP(e){const t=dP();return re(t,me)}const hP=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function pP({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:l,inProgress:a}=re(hP,me);return!(i&&o&&a)?null:g.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:g.jsx("g",{className:Ee(["react-flow__connection",Kg(l)]),children:g.jsx(Jy,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Jy=({style:e,type:t=cn.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:l,fromPosition:a,to:u,toNode:f,toHandle:c,toPosition:d,pointer:y}=fP();if(!o)return;if(n)return g.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:a,toPosition:d,connectionStatus:Kg(r),toNode:f,toHandle:c,pointer:y});let v="";const x={sourceX:i.x,sourceY:i.y,sourcePosition:a,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case cn.Bezier:[v]=ly(x);break;case cn.SimpleBezier:[v]=Fy(x);break;case cn.Step:[v]=bu({...x,borderRadius:0});break;case cn.SmoothStep:[v]=bu(x);break;default:[v]=uy(x)}return g.jsx("path",{d:v,fill:"none",className:"react-flow__connection-path",style:e})};Jy.displayName="ConnectionLine";const mP={};function _h(e=mP){k.useRef(e),ge(),k.useEffect(()=>{},[e])}function gP(){ge(),k.useRef(!1),k.useEffect(()=>{},[])}function e0({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:u,onNodeContextMenu:f,onSelectionContextMenu:c,onSelectionStart:d,onSelectionEnd:y,connectionLineType:v,connectionLineStyle:x,connectionLineComponent:S,connectionLineContainerStyle:h,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:_,deleteKeyCode:M,onlyRenderVisibleElements:R,elementsSelectable:$,defaultViewport:I,translateExtent:L,minZoom:F,maxZoom:b,preventScrolling:z,defaultMarkerColor:j,zoomOnScroll:A,zoomOnPinch:C,panOnScroll:P,panOnScrollSpeed:T,panOnScrollMode:O,zoomOnDoubleClick:D,panOnDrag:U,onPaneClick:B,onPaneMouseEnter:Y,onPaneMouseMove:X,onPaneMouseLeave:G,onPaneScroll:V,onPaneContextMenu:Q,paneClickDistance:te,nodeClickDistance:J,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ue,reconnectRadius:ie,onReconnect:Ie,onReconnectStart:Jt,onReconnectEnd:At,noDragClassName:Ln,noWheelClassName:Qr,noPanClassName:Zr,disableKeyboardA11y:qr,nodeExtent:Ll,rfId:wi,viewport:rr,onViewportChange:Jr}){return _h(e),_h(t),gP(),lP(n),uP(rr),g.jsx(Lb,{onPaneClick:B,onPaneMouseEnter:Y,onPaneMouseMove:X,onPaneMouseLeave:G,onPaneContextMenu:Q,onPaneScroll:V,paneClickDistance:te,deleteKeyCode:M,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,onSelectionStart:d,onSelectionEnd:y,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:_,elementsSelectable:$,zoomOnScroll:A,zoomOnPinch:C,zoomOnDoubleClick:D,panOnScroll:P,panOnScrollSpeed:T,panOnScrollMode:O,panOnDrag:U,defaultViewport:I,translateExtent:L,minZoom:F,maxZoom:b,onSelectionContextMenu:c,preventScrolling:z,noDragClassName:Ln,noWheelClassName:Qr,noPanClassName:Zr,disableKeyboardA11y:qr,onViewportChange:Jr,isControlledViewport:!!rr,children:g.jsxs(sP,{children:[g.jsx(oP,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:Ie,onReconnectStart:Jt,onReconnectEnd:At,onlyRenderVisibleElements:R,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ue,reconnectRadius:ie,defaultMarkerColor:j,noPanClassName:Zr,disableKeyboardA11y:qr,rfId:wi}),g.jsx(pP,{style:x,type:v,component:S,containerStyle:h}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx(Fb,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:u,onNodeContextMenu:f,nodeClickDistance:J,onlyRenderVisibleElements:R,noPanClassName:Zr,noDragClassName:Ln,disableKeyboardA11y:qr,nodeExtent:Ll,rfId:wi}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}e0.displayName="GraphView";const yP=k.memo(e0),bh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a=.5,maxZoom:u=2,nodeOrigin:f,nodeExtent:c,zIndexMode:d="basic"}={})=>{const y=new Map,v=new Map,x=new Map,S=new Map,h=r??t??[],m=n??e??[],p=f??[0,0],w=c??ni;fy(x,S,h);const E=Mu(m,y,v,{nodeOrigin:p,nodeExtent:w,zIndexMode:d});let N=[0,0,1];if(s&&o&&i){const _=yi(y,{filter:I=>!!((I.width||I.initialWidth)&&(I.height||I.initialHeight))}),{x:M,y:R,zoom:$}=Uc(_,o,i,a,u,(l==null?void 0:l.padding)??.1);N=[M,R,$]}return{rfId:"1",width:o??0,height:i??0,transform:N,nodes:m,nodesInitialized:E,nodeLookup:y,parentLookup:v,edges:h,edgeLookup:S,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:a,maxZoom:u,translateExtent:ni,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:$r.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Gg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:gC,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Xg,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},vP=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:u,nodeOrigin:f,nodeExtent:c,zIndexMode:d})=>T_((y,v)=>{async function x(){const{nodeLookup:S,panZoom:h,fitViewOptions:m,fitViewResolver:p,width:w,height:E,minZoom:N,maxZoom:_}=v();h&&(await pC({nodes:S,width:w,height:E,panZoom:h,minZoom:N,maxZoom:_},m),p==null||p.resolve(!0),y({fitViewResolver:null}))}return{...bh({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:u,nodeOrigin:f,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:S=>{const{nodeLookup:h,parentLookup:m,nodeOrigin:p,elevateNodesOnSelect:w,fitViewQueued:E,zIndexMode:N}=v(),_=Mu(S,h,m,{nodeOrigin:p,nodeExtent:c,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:N});E&&_?(x(),y({nodes:S,nodesInitialized:_,fitViewQueued:!1,fitViewOptions:void 0})):y({nodes:S,nodesInitialized:_})},setEdges:S=>{const{connectionLookup:h,edgeLookup:m}=v();fy(h,m,S),y({edges:S})},setDefaultNodesAndEdges:(S,h)=>{if(S){const{setNodes:m}=v();m(S),y({hasDefaultNodes:!0})}if(h){const{setEdges:m}=v();m(h),y({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:h,nodeLookup:m,parentLookup:p,domNode:w,nodeOrigin:E,nodeExtent:N,debug:_,fitViewQueued:M,zIndexMode:R}=v(),{changes:$,updatedInternals:I}=DC(S,m,p,w,E,N,R);I&&(TC(m,p,{nodeOrigin:E,nodeExtent:N,zIndexMode:R}),M?(x(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),($==null?void 0:$.length)>0&&(_&&console.log("React Flow: trigger node changes",$),h==null||h($)))},updateNodePositions:(S,h=!1)=>{const m=[];let p=[];const{nodeLookup:w,triggerNodeChanges:E,connection:N,updateConnection:_,onNodesChangeMiddlewareMap:M}=v();for(const[R,$]of S){const I=w.get(R),L=!!(I!=null&&I.expandParent&&(I!=null&&I.parentId)&&($!=null&&$.position)),F={id:R,type:"position",position:L?{x:Math.max(0,$.position.x),y:Math.max(0,$.position.y)}:$.position,dragging:h};if(I&&N.inProgress&&N.fromNode.id===I.id){const b=er(I,N.fromHandle,K.Left,!0);_({...N,from:b})}L&&I.parentId&&m.push({id:R,parentId:I.parentId,rect:{...$.internals.positionAbsolute,width:$.measured.width??0,height:$.measured.height??0}}),p.push(F)}if(m.length>0){const{parentLookup:R,nodeOrigin:$}=v(),I=Qc(m,w,R,$);p.push(...I)}for(const R of M.values())p=R(p);E(p)},triggerNodeChanges:S=>{const{onNodesChange:h,setNodes:m,nodes:p,hasDefaultNodes:w,debug:E}=v();if(S!=null&&S.length){if(w){const N=tb(S,p);m(N)}E&&console.log("React Flow: trigger node changes",S),h==null||h(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:h,setEdges:m,edges:p,hasDefaultEdges:w,debug:E}=v();if(S!=null&&S.length){if(w){const N=nb(S,p);m(N)}E&&console.log("React Flow: trigger edge changes",S),h==null||h(S)}},addSelectedNodes:S=>{const{multiSelectionActive:h,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:E}=v();if(h){const N=S.map(_=>Tn(_,!0));w(N);return}w(xr(p,new Set([...S]),!0)),E(xr(m))},addSelectedEdges:S=>{const{multiSelectionActive:h,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:E}=v();if(h){const N=S.map(_=>Tn(_,!0));E(N);return}E(xr(m,new Set([...S]))),w(xr(p,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:h}={})=>{const{edges:m,nodes:p,nodeLookup:w,triggerNodeChanges:E,triggerEdgeChanges:N}=v(),_=S||p,M=h||m,R=_.map(I=>{const L=w.get(I.id);return L&&(L.selected=!1),Tn(I.id,!1)}),$=M.map(I=>Tn(I.id,!1));E(R),N($)},setMinZoom:S=>{const{panZoom:h,maxZoom:m}=v();h==null||h.setScaleExtent([S,m]),y({minZoom:S})},setMaxZoom:S=>{const{panZoom:h,minZoom:m}=v();h==null||h.setScaleExtent([m,S]),y({maxZoom:S})},setTranslateExtent:S=>{var h;(h=v().panZoom)==null||h.setTranslateExtent(S),y({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:h,triggerNodeChanges:m,triggerEdgeChanges:p,elementsSelectable:w}=v();if(!w)return;const E=h.reduce((_,M)=>M.selected?[..._,Tn(M.id,!1)]:_,[]),N=S.reduce((_,M)=>M.selected?[..._,Tn(M.id,!1)]:_,[]);m(E),p(N)},setNodeExtent:S=>{const{nodes:h,nodeLookup:m,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:_}=v();S[0][0]===N[0][0]&&S[0][1]===N[0][1]&&S[1][0]===N[1][0]&&S[1][1]===N[1][1]||(Mu(h,m,p,{nodeOrigin:w,nodeExtent:S,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:_}),y({nodeExtent:S}))},panBy:S=>{const{transform:h,width:m,height:p,panZoom:w,translateExtent:E}=v();return OC({delta:S,panZoom:w,transform:h,translateExtent:E,width:m,height:p})},setCenter:async(S,h,m)=>{const{width:p,height:w,maxZoom:E,panZoom:N}=v();if(!N)return Promise.resolve(!1);const _=typeof(m==null?void 0:m.zoom)<"u"?m.zoom:E;return await N.setViewport({x:p/2-S*_,y:w/2-h*_,zoom:_},{duration:m==null?void 0:m.duration,ease:m==null?void 0:m.ease,interpolate:m==null?void 0:m.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...Gg}})},updateConnection:S=>{y({connection:S})},reset:()=>y({...bh()})}},Object.is);function xP({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:l,initialFitViewOptions:a,fitView:u,nodeOrigin:f,nodeExtent:c,zIndexMode:d,children:y}){const[v]=k.useState(()=>vP({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:u,minZoom:s,maxZoom:l,fitViewOptions:a,nodeOrigin:f,nodeExtent:c,zIndexMode:d}));return g.jsx(z_,{value:v,children:g.jsx(sb,{children:y})})}function wP({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:l,fitViewOptions:a,minZoom:u,maxZoom:f,nodeOrigin:c,nodeExtent:d,zIndexMode:y}){return k.useContext(bl)?g.jsx(g.Fragment,{children:e}):g.jsx(xP,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:l,initialFitViewOptions:a,initialMinZoom:u,initialMaxZoom:f,nodeOrigin:c,nodeExtent:d,zIndexMode:y,children:e})}const SP={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function kP({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:f,onMoveStart:c,onMoveEnd:d,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:h,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:_,onNodeDrag:M,onNodeDragStop:R,onNodesDelete:$,onEdgesDelete:I,onDelete:L,onSelectionChange:F,onSelectionDragStart:b,onSelectionDrag:z,onSelectionDragStop:j,onSelectionContextMenu:A,onSelectionStart:C,onSelectionEnd:P,onBeforeDelete:T,connectionMode:O,connectionLineType:D=cn.Bezier,connectionLineStyle:U,connectionLineComponent:B,connectionLineContainerStyle:Y,deleteKeyCode:X="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:V=!1,selectionMode:Q=ri.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:J=ii()?"Meta":"Control",zoomActivationKeyCode:q=ii()?"Meta":"Control",snapToGrid:Z,snapGrid:se,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:ie,nodesDraggable:Ie,autoPanOnNodeFocus:Jt,nodesConnectable:At,nodesFocusable:Ln,nodeOrigin:Qr=My,edgesFocusable:Zr,edgesReconnectable:qr,elementsSelectable:Ll=!0,defaultViewport:wi=G_,minZoom:rr=.5,maxZoom:Jr=2,translateExtent:Jc=ni,preventScrolling:o0=!0,nodeExtent:Rl,defaultMarkerColor:i0="#b1b1b7",zoomOnScroll:s0=!0,zoomOnPinch:l0=!0,panOnScroll:a0=!1,panOnScrollSpeed:u0=.5,panOnScrollMode:c0=Wn.Free,zoomOnDoubleClick:d0=!0,panOnDrag:f0=!0,onPaneClick:h0,onPaneMouseEnter:p0,onPaneMouseMove:m0,onPaneMouseLeave:g0,onPaneScroll:y0,onPaneContextMenu:v0,paneClickDistance:x0=1,nodeClickDistance:w0=0,children:S0,onReconnect:k0,onReconnectStart:E0,onReconnectEnd:N0,onEdgeContextMenu:C0,onEdgeDoubleClick:_0,onEdgeMouseEnter:b0,onEdgeMouseMove:P0,onEdgeMouseLeave:M0,reconnectRadius:j0=10,onNodesChange:L0,onEdgesChange:R0,noDragClassName:I0="nodrag",noWheelClassName:T0="nowheel",noPanClassName:ed="nopan",fitView:td,fitViewOptions:nd,connectOnClick:z0,attributionPosition:A0,proOptions:$0,defaultEdgeOptions:D0,elevateNodesOnSelect:O0=!0,elevateEdgesOnSelect:F0=!1,disableKeyboardA11y:rd=!1,autoPanOnConnect:H0,autoPanOnNodeDrag:V0,autoPanSpeed:B0,connectionRadius:U0,isValidConnection:W0,onError:Y0,style:X0,id:od,nodeDragThreshold:G0,connectionDragThreshold:K0,viewport:Q0,onViewportChange:Z0,width:q0,height:J0,colorMode:ev="light",debug:tv,onScroll:Si,ariaLabelConfig:nv,zIndexMode:id="basic",...rv},ov){const Il=od||"1",iv=q_(ev),sv=k.useCallback(sd=>{sd.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Si==null||Si(sd)},[Si]);return g.jsx("div",{"data-testid":"rf__wrapper",...rv,onScroll:sv,style:{...X0,...SP},ref:ov,className:Ee(["react-flow",o,iv]),id:od,role:"application",children:g.jsxs(wP,{nodes:e,edges:t,width:q0,height:J0,fitView:td,fitViewOptions:nd,minZoom:rr,maxZoom:Jr,nodeOrigin:Qr,nodeExtent:Rl,zIndexMode:id,children:[g.jsx(yP,{onInit:u,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:D,connectionLineStyle:U,connectionLineComponent:B,connectionLineContainerStyle:Y,selectionKeyCode:G,selectionOnDrag:V,selectionMode:Q,deleteKeyCode:X,multiSelectionKeyCode:J,panActivationKeyCode:te,zoomActivationKeyCode:q,onlyRenderVisibleElements:ue,defaultViewport:wi,translateExtent:Jc,minZoom:rr,maxZoom:Jr,preventScrolling:o0,zoomOnScroll:s0,zoomOnPinch:l0,zoomOnDoubleClick:d0,panOnScroll:a0,panOnScrollSpeed:u0,panOnScrollMode:c0,panOnDrag:f0,onPaneClick:h0,onPaneMouseEnter:p0,onPaneMouseMove:m0,onPaneMouseLeave:g0,onPaneScroll:y0,onPaneContextMenu:v0,paneClickDistance:x0,nodeClickDistance:w0,onSelectionContextMenu:A,onSelectionStart:C,onSelectionEnd:P,onReconnect:k0,onReconnectStart:E0,onReconnectEnd:N0,onEdgeContextMenu:C0,onEdgeDoubleClick:_0,onEdgeMouseEnter:b0,onEdgeMouseMove:P0,onEdgeMouseLeave:M0,reconnectRadius:j0,defaultMarkerColor:i0,noDragClassName:I0,noWheelClassName:T0,noPanClassName:ed,rfId:Il,disableKeyboardA11y:rd,nodeExtent:Rl,viewport:Q0,onViewportChange:Z0}),g.jsx(Z_,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:h,nodesDraggable:Ie,autoPanOnNodeFocus:Jt,nodesConnectable:At,nodesFocusable:Ln,edgesFocusable:Zr,edgesReconnectable:qr,elementsSelectable:Ll,elevateNodesOnSelect:O0,elevateEdgesOnSelect:F0,minZoom:rr,maxZoom:Jr,nodeExtent:Rl,onNodesChange:L0,onEdgesChange:R0,snapToGrid:Z,snapGrid:se,connectionMode:O,translateExtent:Jc,connectOnClick:z0,defaultEdgeOptions:D0,fitView:td,fitViewOptions:nd,onNodesDelete:$,onEdgesDelete:I,onDelete:L,onNodeDragStart:_,onNodeDrag:M,onNodeDragStop:R,onSelectionDrag:z,onSelectionDragStart:b,onSelectionDragStop:j,onMove:f,onMoveStart:c,onMoveEnd:d,noPanClassName:ed,nodeOrigin:Qr,rfId:Il,autoPanOnConnect:H0,autoPanOnNodeDrag:V0,autoPanSpeed:B0,onError:Y0,connectionRadius:U0,isValidConnection:W0,selectNodesOnDrag:ie,nodeDragThreshold:G0,connectionDragThreshold:K0,onBeforeDelete:T,debug:tv,ariaLabelConfig:nv,zIndexMode:id}),g.jsx(X_,{onSelectionChange:F}),S0,g.jsx(V_,{proOptions:$0,position:A0}),g.jsx(H_,{rfId:Il,disableKeyboardA11y:rd})]})})}var EP=Ly(kP);function NP({dimensions:e,lineWidth:t,variant:n,className:r}){return g.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Ee(["react-flow__background-pattern",n,r])})}function CP({radius:e,className:t}){return g.jsx("circle",{cx:e,cy:e,r:e,className:Ee(["react-flow__background-pattern","dots",t])})}var En;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(En||(En={}));const _P={[En.Dots]:1,[En.Lines]:1,[En.Cross]:6},bP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function t0({id:e,variant:t=En.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:l,style:a,className:u,patternClassName:f}){const c=k.useRef(null),{transform:d,patternId:y}=re(bP,me),v=r||_P[t],x=t===En.Dots,S=t===En.Cross,h=Array.isArray(n)?n:[n,n],m=[h[0]*d[2]||1,h[1]*d[2]||1],p=v*d[2],w=Array.isArray(i)?i:[i,i],E=S?[p,p]:m,N=[w[0]*d[2]||1+E[0]/2,w[1]*d[2]||1+E[1]/2],_=`${y}${e||""}`;return g.jsxs("svg",{className:Ee(["react-flow__background",u]),style:{...a,...Ml,"--xy-background-color-props":l,"--xy-background-pattern-color-props":s},ref:c,"data-testid":"rf__background",children:[g.jsx("pattern",{id:_,x:d[0]%m[0],y:d[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:x?g.jsx(CP,{radius:p/2,className:f}):g.jsx(NP,{dimensions:E,lineWidth:o,variant:t,className:f})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${_})`})]})}t0.displayName="Background";const PP=k.memo(t0);function MP(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:g.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function jP(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:g.jsx("path",{d:"M0 0h32v4.2H0z"})})}function LP(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:g.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 g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 IP(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 Ki({children:e,className:t,...n}){return g.jsx("button",{type:"button",className:Ee(["react-flow__controls-button",t]),...n,children:e})}const TP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function n0({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:a,className:u,children:f,position:c="bottom-left",orientation:d="vertical","aria-label":y}){const v=ge(),{isInteractive:x,minZoomReached:S,maxZoomReached:h,ariaLabelConfig:m}=re(TP,me),{zoomIn:p,zoomOut:w,fitView:E}=Zc(),N=()=>{p(),i==null||i()},_=()=>{w(),s==null||s()},M=()=>{E(o),l==null||l()},R=()=>{v.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),a==null||a(!x)},$=d==="horizontal"?"horizontal":"vertical";return g.jsxs(Pl,{className:Ee(["react-flow__controls",$,u]),position:c,style:e,"data-testid":"rf__controls","aria-label":y??m["controls.ariaLabel"],children:[t&&g.jsxs(g.Fragment,{children:[g.jsx(Ki,{onClick:N,className:"react-flow__controls-zoomin",title:m["controls.zoomIn.ariaLabel"],"aria-label":m["controls.zoomIn.ariaLabel"],disabled:h,children:g.jsx(MP,{})}),g.jsx(Ki,{onClick:_,className:"react-flow__controls-zoomout",title:m["controls.zoomOut.ariaLabel"],"aria-label":m["controls.zoomOut.ariaLabel"],disabled:S,children:g.jsx(jP,{})})]}),n&&g.jsx(Ki,{className:"react-flow__controls-fitview",onClick:M,title:m["controls.fitView.ariaLabel"],"aria-label":m["controls.fitView.ariaLabel"],children:g.jsx(LP,{})}),r&&g.jsx(Ki,{className:"react-flow__controls-interactive",onClick:R,title:m["controls.interactive.ariaLabel"],"aria-label":m["controls.interactive.ariaLabel"],children:x?g.jsx(IP,{}):g.jsx(RP,{})}),f]})}n0.displayName="Controls";const zP=k.memo(n0);function AP({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:l,strokeWidth:a,className:u,borderRadius:f,shapeRendering:c,selected:d,onClick:y}){const{background:v,backgroundColor:x}=i||{},S=s||v||x;return g.jsx("rect",{className:Ee(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:f,ry:f,width:r,height:o,style:{fill:S,stroke:l,strokeWidth:a},shapeRendering:c,onClick:y?h=>y(h,e):void 0})}const $P=k.memo(AP),DP=e=>e.nodes.map(t=>t.id),va=e=>e instanceof Function?e:()=>e;function OP({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=$P,onClick:s}){const l=re(DP,me),a=va(t),u=va(e),f=va(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:l.map(d=>g.jsx(HP,{id:d,nodeColorFunc:a,nodeStrokeColorFunc:u,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:c},d))})}function FP({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:l,onClick:a}){const{node:u,x:f,y:c,width:d,height:y}=re(v=>{const{internals:x}=v.nodeLookup.get(e),S=x.userNode,{x:h,y:m}=x.positionAbsolute,{width:p,height:w}=qt(S);return{node:S,x:h,y:m,width:p,height:w}},me);return!u||u.hidden||!ty(u)?null:g.jsx(l,{x:f,y:c,width:d,height:y,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:a,id:u.id})}const HP=k.memo(FP);var VP=k.memo(OP);const BP=200,UP=150,WP=e=>!e.hidden,YP=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?ey(yi(e.nodeLookup,{filter:WP}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},XP="react-flow__minimap-desc";function r0({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:l,bgColor:a,maskColor:u,maskStrokeColor:f,maskStrokeWidth:c,position:d="bottom-right",onClick:y,onNodeClick:v,pannable:x=!1,zoomable:S=!1,ariaLabel:h,inversePan:m,zoomStep:p=1,offsetScale:w=5}){const E=ge(),N=k.useRef(null),{boundingRect:_,viewBB:M,rfId:R,panZoom:$,translateExtent:I,flowWidth:L,flowHeight:F,ariaLabelConfig:b}=re(YP,me),z=(e==null?void 0:e.width)??BP,j=(e==null?void 0:e.height)??UP,A=_.width/z,C=_.height/j,P=Math.max(A,C),T=P*z,O=P*j,D=w*P,U=_.x-(T-_.width)/2-D,B=_.y-(O-_.height)/2-D,Y=T+D*2,X=O+D*2,G=`${XP}-${R}`,V=k.useRef(0),Q=k.useRef();V.current=P,k.useEffect(()=>{if(N.current&&$)return Q.current=GC({domNode:N.current,panZoom:$,getTransform:()=>E.getState().transform,getViewScale:()=>V.current}),()=>{var Z;(Z=Q.current)==null||Z.destroy()}},[$]),k.useEffect(()=>{var Z;(Z=Q.current)==null||Z.update({translateExtent:I,width:L,height:F,inversePan:m,pannable:x,zoomStep:p,zoomable:S})},[x,S,m,p,I,L,F]);const te=y?Z=>{var ie;const[se,ue]=((ie=Q.current)==null?void 0:ie.pointer(Z))||[0,0];y(Z,{x:se,y:ue})}:void 0,J=v?k.useCallback((Z,se)=>{const ue=E.getState().nodeLookup.get(se).internals.userNode;v(Z,ue)},[]):void 0,q=h??b["minimap.ariaLabel"];return g.jsx(Pl,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*P: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 s=="number"?s:void 0},className:Ee(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:g.jsxs("svg",{width:z,height:j,viewBox:`${U} ${B} ${Y} ${X}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:N,onClick:te,children:[q&&g.jsx("title",{id:G,children:q}),g.jsx(VP,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:l}),g.jsx("path",{className:"react-flow__minimap-mask",d:`M${U-D},${B-D}h${Y+D*2}v${X+D*2}h${-Y-D*2}z
|
|
178
|
-
M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}r0.displayName="MiniMap";k.memo(r0);const GP=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,KP={[Hr.Line]:"right",[Hr.Handle]:"bottom-right"};function QP({nodeId:e,position:t,variant:n=Hr.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:d,autoScale:y=!0,shouldResize:v,onResizeStart:x,onResize:S,onResizeEnd:h}){const m=zy(),p=typeof e=="string"?e:m,w=ge(),E=k.useRef(null),N=n===Hr.Handle,_=re(k.useCallback(GP(N&&y),[N,y]),me),M=k.useRef(null),R=t??KP[n];k.useEffect(()=>{if(!(!E.current||!p))return M.current||(M.current=a_({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:I,transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z,domNode:j}=w.getState();return{nodeLookup:I,transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z,paneDomNode:j}},onChange:(I,L)=>{const{triggerNodeChanges:F,nodeLookup:b,parentLookup:z,nodeOrigin:j}=w.getState(),A=[],C={x:I.x,y:I.y},P=b.get(p);if(P&&P.expandParent&&P.parentId){const T=P.origin??j,O=I.width??P.measured.width??0,D=I.height??P.measured.height??0,U={id:P.id,parentId:P.parentId,rect:{width:O,height:D,...ny({x:I.x??P.position.x,y:I.y??P.position.y},{width:O,height:D},P.parentId,b,T)}},B=Qc([U],b,z,j);A.push(...B),C.x=I.x?Math.max(T[0]*O,I.x):void 0,C.y=I.y?Math.max(T[1]*D,I.y):void 0}if(C.x!==void 0&&C.y!==void 0){const T={id:p,type:"position",position:{...C}};A.push(T)}if(I.width!==void 0&&I.height!==void 0){const O={id:p,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:I.width,height:I.height}};A.push(O)}for(const T of L){const O={...T,type:"position"};A.push(O)}F(A)},onEnd:({width:I,height:L})=>{const F={id:p,type:"dimensions",resizing:!1,dimensions:{width:I,height:L}};w.getState().triggerNodeChanges([F])}})),M.current.update({controlPosition:R,boundaries:{minWidth:l,minHeight:a,maxWidth:u,maxHeight:f},keepAspectRatio:c,resizeDirection:d,onResizeStart:x,onResize:S,onResizeEnd:h,shouldResize:v}),()=>{var I;(I=M.current)==null||I.destroy()}},[R,l,a,u,f,c,x,S,h,v]);const $=R.split("-");return g.jsx("div",{className:Ee(["react-flow__resize-control","nodrag",...$,n,r]),ref:E,style:{...o,scale:_,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}k.memo(QP);function ZP(){const[e,t]=k.useState([]),[n,r]=k.useState([]),[o,i]=k.useState(!0);k.useEffect(()=>{Promise.all([bn.discovery.agents(),bn.observations.permissions()]).then(([
|
|
179
|
-
//# sourceMappingURL=index-
|
|
178
|
+
M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}r0.displayName="MiniMap";k.memo(r0);const GP=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,KP={[Hr.Line]:"right",[Hr.Handle]:"bottom-right"};function QP({nodeId:e,position:t,variant:n=Hr.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:d,autoScale:y=!0,shouldResize:v,onResizeStart:x,onResize:S,onResizeEnd:h}){const m=zy(),p=typeof e=="string"?e:m,w=ge(),E=k.useRef(null),N=n===Hr.Handle,_=re(k.useCallback(GP(N&&y),[N,y]),me),M=k.useRef(null),R=t??KP[n];k.useEffect(()=>{if(!(!E.current||!p))return M.current||(M.current=a_({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:I,transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z,domNode:j}=w.getState();return{nodeLookup:I,transform:L,snapGrid:F,snapToGrid:b,nodeOrigin:z,paneDomNode:j}},onChange:(I,L)=>{const{triggerNodeChanges:F,nodeLookup:b,parentLookup:z,nodeOrigin:j}=w.getState(),A=[],C={x:I.x,y:I.y},P=b.get(p);if(P&&P.expandParent&&P.parentId){const T=P.origin??j,O=I.width??P.measured.width??0,D=I.height??P.measured.height??0,U={id:P.id,parentId:P.parentId,rect:{width:O,height:D,...ny({x:I.x??P.position.x,y:I.y??P.position.y},{width:O,height:D},P.parentId,b,T)}},B=Qc([U],b,z,j);A.push(...B),C.x=I.x?Math.max(T[0]*O,I.x):void 0,C.y=I.y?Math.max(T[1]*D,I.y):void 0}if(C.x!==void 0&&C.y!==void 0){const T={id:p,type:"position",position:{...C}};A.push(T)}if(I.width!==void 0&&I.height!==void 0){const O={id:p,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:I.width,height:I.height}};A.push(O)}for(const T of L){const O={...T,type:"position"};A.push(O)}F(A)},onEnd:({width:I,height:L})=>{const F={id:p,type:"dimensions",resizing:!1,dimensions:{width:I,height:L}};w.getState().triggerNodeChanges([F])}})),M.current.update({controlPosition:R,boundaries:{minWidth:l,minHeight:a,maxWidth:u,maxHeight:f},keepAspectRatio:c,resizeDirection:d,onResizeStart:x,onResize:S,onResizeEnd:h,shouldResize:v}),()=>{var I;(I=M.current)==null||I.destroy()}},[R,l,a,u,f,c,x,S,h,v]);const $=R.split("-");return g.jsx("div",{className:Ee(["react-flow__resize-control","nodrag",...$,n,r]),ref:E,style:{...o,scale:_,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}k.memo(QP);function ZP(){const[e,t]=k.useState(()=>document.documentElement.classList.contains("dark"));return k.useEffect(()=>{const n=new MutationObserver(()=>t(document.documentElement.classList.contains("dark")));return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),e}function qP(){const[e,t]=k.useState([]),[n,r]=k.useState([]),[o,i]=k.useState(!0),s=ZP();k.useEffect(()=>{Promise.all([bn.discovery.agents(),bn.observations.permissions()]).then(([u,f])=>{t(u.data??[]),r(f.data??[]),i(!1)}).catch(()=>i(!1))},[]);const{nodes:l,edges:a}=k.useMemo(()=>{const u=[],f=[],c=new Set,d=new Map,y=s?{background:"#18181b",color:"#fafafa",border:"1px solid #3f3f46"}:{background:"#ffffff",color:"#09090b",border:"1px solid #e4e4e7"},v=s?{background:"#09090b",color:"#a1a1aa",border:"1px solid #3f3f46"}:{background:"#f4f4f5",color:"#52525b",border:"1px solid #d4d4d8"},x=s?"#52525b":"#a1a1aa",S=s?"#27272a":"#e4e4e7";return e.forEach((h,m)=>{const p=`agent-${h.id}`;h.registeredAgentId&&d.set(h.registeredAgentId,p),d.set(h.id,p),u.push({id:p,position:{x:100,y:m*120},data:{label:`${h.emoji||"🤖"} ${h.name}`},style:{...y,borderRadius:"8px",padding:"8px 16px",fontSize:"13px"}})}),n.forEach(h=>{const m=`tool-${h.toolName}`;c.has(h.toolName)||(c.add(h.toolName),u.push({id:m,position:{x:400,y:c.size*80},data:{label:`🔧 ${h.toolName}`},style:{...v,borderRadius:"8px",padding:"6px 12px",fontSize:"12px"}}));const p=d.get(h.agentId)??`agent-${h.agentId}`;f.push({id:`e-${h.agentId}-${h.toolName}`,source:p,target:m,animated:h.accessPattern==="write",style:{stroke:h.accessPattern==="write"?"#eab308":x}})}),{nodes:u,edges:f,bgColor:S}},[e,n,s]);return o?g.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading..."}):g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Identity Graph"}),g.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agent-to-tool relationship visualization"})]}),g.jsx("div",{className:"h-[600px] rounded-lg border border-border bg-card",children:g.jsxs(EP,{nodes:l,edges:a,fitView:!0,proOptions:{hideAttribution:!0},children:[g.jsx(PP,{color:s?"#27272a":"#e4e4e7",gap:20}),g.jsx(zP,{})]})})]})}function JP({children:e}){const{isAuthenticated:t,isLoading:n}=Ic();return n?g.jsx("div",{className:"flex min-h-screen items-center justify-center",children:g.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading..."})}):t?g.jsx(g.Fragment,{children:e}):g.jsx(hu,{to:"/login",replace:!0})}function e4(){return g.jsxs(C1,{children:[g.jsx(ft,{path:"/login",element:g.jsx(vk,{})}),g.jsxs(ft,{element:g.jsx(JP,{children:g.jsx(yk,{})}),children:[g.jsx(ft,{index:!0,element:g.jsx(hu,{to:"/inventory/agents",replace:!0})}),g.jsx(ft,{path:"/inventory/agents",element:g.jsx(wk,{})}),g.jsx(ft,{path:"/inventory/agents/:id",element:g.jsx(Ek,{})}),g.jsx(ft,{path:"/inventory/identities",element:g.jsx(Pk,{})}),g.jsx(ft,{path:"/inventory/permissions",element:g.jsx(Mk,{})}),g.jsx(ft,{path:"/secure/risk",element:g.jsx(jk,{})}),g.jsx(ft,{path:"/secure/graph",element:g.jsx(qP,{})})]}),g.jsx(ft,{path:"*",element:g.jsx(hu,{to:"/inventory/agents",replace:!0})})]})}xa.createRoot(document.getElementById("root")).render(g.jsx(Dh.StrictMode,{children:g.jsx(Q1,{basename:"/dashboard",children:g.jsx(sS,{children:g.jsx(uS,{children:g.jsx(e4,{})})})})}));
|
|
179
|
+
//# sourceMappingURL=index-Bs89CfR5.js.map
|