ima2-gen 3.12.2 → 3.12.3

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.
Files changed (45) hide show
  1. package/bin/commands/vectorize.js +108 -0
  2. package/bin/ima2.js +5 -1
  3. package/docs/API.md +1 -1
  4. package/docs/API.zh-CN.md +1 -1
  5. package/docs/API.zh-TW.md +1 -1
  6. package/docs/CLI.md +1 -0
  7. package/docs/migration/runtime-test-inventory.md +6 -1
  8. package/lib/agentImageVideoGen.js +15 -1
  9. package/lib/agentQueueStore.js +11 -3
  10. package/lib/agentQueueWorker.js +6 -1
  11. package/lib/agentRuntime.js +4 -0
  12. package/lib/db.js +3 -0
  13. package/lib/imageThumb.js +9 -2
  14. package/lib/vectorizeImage.js +132 -0
  15. package/package.json +4 -3
  16. package/routes/assetDerived.js +79 -2
  17. package/server.js +8 -0
  18. package/skills/ima2/SKILL.md +37 -0
  19. package/ui/dist/.vite/manifest.json +33 -33
  20. package/ui/dist/assets/{AgentWorkspace-CW1x4uOl.js → AgentWorkspace-AJkVTaU5.js} +2 -2
  21. package/ui/dist/assets/AssetGenWorkspace-Cguej69V.js +2 -0
  22. package/ui/dist/assets/AssetsWorkspace-DIQ9wBuD.js +1 -0
  23. package/ui/dist/assets/{CardNewsWorkspace-nBKX5TXr.js → CardNewsWorkspace-C_Eb2g7d.js} +1 -1
  24. package/ui/dist/assets/{GenerationRequestLogPanel-CWqbfNis.js → GenerationRequestLogPanel-giH1e4hp.js} +1 -1
  25. package/ui/dist/assets/{HomeWorkspace-CxqIGhb9.js → HomeWorkspace-DHmXGtqC.js} +1 -1
  26. package/ui/dist/assets/{NodeCanvas-m41ECrFJ.js → NodeCanvas-CF_NHudI.js} +1 -1
  27. package/ui/dist/assets/{PromptBuilderPanel-ChOoMAVA.js → PromptBuilderPanel-D7NJto-1.js} +2 -2
  28. package/ui/dist/assets/{PromptImportDialog-8hDG8MeK.js → PromptImportDialog-B40X9UAa.js} +2 -2
  29. package/ui/dist/assets/{PromptImportDiscoverySection-D2_TAuLm.js → PromptImportDiscoverySection-BWoUDHj1.js} +1 -1
  30. package/ui/dist/assets/{PromptImportFolderSection-qv0qhTwq.js → PromptImportFolderSection-DBSEyJb-.js} +1 -1
  31. package/ui/dist/assets/{PromptLibraryPanel-BPOD61FZ.js → PromptLibraryPanel-DLywJBpt.js} +2 -2
  32. package/ui/dist/assets/{SettingsWorkspace-BKgXN2l9.js → SettingsWorkspace-BawWId1t.js} +1 -1
  33. package/ui/dist/assets/SpriteRecipeWorkspace-Biy2yRAk.js +1 -0
  34. package/ui/dist/assets/VectorizePanel-DdlVvwV1.js +1 -0
  35. package/ui/dist/assets/{index-Bzt4YWub.js → index-D05Ong5g.js} +3 -3
  36. package/ui/dist/assets/{index-DB9EfKr6.css → index-DGRIdnsL.css} +1 -1
  37. package/ui/dist/assets/{index-DTEhasVd.js → index-Sch70vBs.js} +17 -17
  38. package/ui/dist/assets/{pptxgen.es-BEVsR2-i.js → pptxgen.es-CSd_gCsx.js} +1 -1
  39. package/ui/dist/assets/useAgentDialogFocus-DcWwFfYd.js +1 -0
  40. package/ui/dist/index.html +2 -2
  41. package/ui/dist/assets/AssetGenWorkspace-BQkdilsH.js +0 -2
  42. package/ui/dist/assets/AssetsWorkspace-CYSkmYU-.js +0 -1
  43. package/ui/dist/assets/KeyingPanel-CtGvO6-u.js +0 -1
  44. package/ui/dist/assets/SpriteRecipeWorkspace-D8gHgnt8.js +0 -1
  45. package/ui/dist/assets/useAgentDialogFocus-Dyj_bA5Q.js +0 -1
@@ -1 +1 @@
1
- import{b as i,u as m,al as I,j as e,am as A,an as k,ao as P,v as E,ap as M,a as x,aq as w,ar as R,as as T,at as C,au as L,av as O,aw as H,ax as S}from"./index-DTEhasVd.js";const G={oauth:"GPT OAuth",api:"GPT API",grok:"Grok OAuth","grok-api":"Grok API",agy:"Antigravity","gemini-api":"Gemini API",atlascloud:"Atlas Cloud",minimax:"MiniMax",nai:"NovelAI",comfy:"ComfyUI"};function U(s){if(s.kind==="attachment")return s.source.dataUrl;if(s.source.thumbnailUrl)return s.source.thumbnailUrl;const t=s.source.referenceFilenames[0];if(t)return t.startsWith("/generated/")?t:`/generated/${t.split("/").map(encodeURIComponent).join("/")}`}function D({providerAvailability:s}){const t=i(o=>o.prompt),r=i(o=>o.setPrompt),n=i(o=>o.provider),a=i(o=>o.setProvider),c=i(o=>o.selectedPresetIds),p=i(o=>o.removePreset),d=i(o=>o.generate),v=i(o=>o.activeGenerations),h=i(o=>o.trayItems),{t:l}=m(),f=new Set(c),j=I().filter(o=>f.has(o.id)),b=v>0,y=Object.entries(G).map(([o,u])=>{const g=o,_=s[g];return{value:g,label:u,sub:_.ok?l("readiness.ready"):_.reason,disabled:!_.ok}});return e.jsxs("div",{className:"home-prompt",children:[j.length>0?e.jsx(A,{className:"home-prompt__chips",ariaLabel:l("home.selectedPresets"),children:j.map(o=>e.jsx(k,{selected:!0,onRemove:()=>p(o.id),removeLabel:l("common.removeNamed",{name:o.name}),title:o.category,children:o.name},o.id))}):null,h.length>0?e.jsxs("div",{className:"home-prompt__reference-strip",role:"group","aria-label":l("home.referenceTrayAria",{count:h.length}),children:[e.jsx("span",{className:"home-prompt__reference-thumbs","aria-hidden":"true",children:h.map(o=>{const u=U(o);return e.jsx("span",{className:"home-prompt__reference-thumb",children:u?e.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}):"@"},o.tokenId)})}),e.jsx("span",{className:"home-prompt__reference-count",children:l("home.referenceTrayCount",{count:h.length})})]}):null,e.jsx("label",{className:"home-prompt__label",htmlFor:"home-prompt-input",children:l("prompt.label")}),e.jsx("textarea",{id:"home-prompt-input",className:"home-prompt__textarea",rows:5,value:t,placeholder:l("prompt.placeholder"),onChange:o=>r(o.target.value)}),e.jsx(P,{variant:"home"}),e.jsxs("div",{className:"home-prompt__footer",children:[e.jsx(E,{className:"home-prompt__provider",items:y,value:n,onChange:a,ariaLabel:l("readiness.provider")}),e.jsx("button",{type:"button",className:"home-prompt__generate",disabled:b||t.trim().length===0,onClick:()=>{d();const o=i.getState().setUIMode;o("classic")},children:b?l("generate.buttonLoading",{n:v}):l("generate.button")})]})]})}const N=/\.(mp4|webm|mov)(?:$|[?#])/i;function V(s){return s.mediaType==="video"||N.test(s.filename??"")||N.test(s.url??s.image)?s.thumb:s.thumb||s.url||s.image||void 0}function B({item:s,featured:t}){const{t:r}=m(),[n,a]=x.useState(!1),c=V(s),p=(s.userPrompt?.trim()||s.prompt?.trim()||r("home.untitledResult")).slice(0,60),d=r("home.recentResultAlt",{prompt:p});return!c||n?e.jsx("div",{className:"home-recent-card__fallback",role:"img","aria-label":d,children:r("home.mediaUnavailable")}):e.jsx("img",{src:c,alt:d,loading:t?"eager":"lazy",decoding:"async",onError:()=>a(!0)})}function F(){const s=i(n=>n.history),{t}=m(),r=s.slice(0,5);return r.length===0?e.jsx("p",{className:"home-recent-empty",role:"status",children:t("history.emptyRecent")}):e.jsx("div",{className:"home-recent-row",role:"list","aria-label":t("home.recentTitle"),children:r.map((n,a)=>{const c=a===0;return e.jsx("figure",{className:`home-recent-card${c?" is-featured":""}`,role:"listitem",children:e.jsx(B,{item:n,featured:c})},M(n))})})}function $(){return e.jsxs("svg",{className:"home-hero__mode-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]})}function W(){const{t:s}=m(),t=w(),r=x.useMemo(()=>Object.values(t).filter(a=>a?.ok).length,[t]),n=x.useMemo(()=>Object.keys(t).length,[t]);return e.jsxs("div",{className:"home-hero",children:[e.jsx("div",{className:"home-hero__mark","aria-hidden":"true",children:"IMA2"}),e.jsxs("header",{className:"home-hero__intro",children:[e.jsx("h1",{className:"home-hero__title",children:s("home.heroTitle")}),e.jsx("p",{className:"home-hero__lede",children:s("home.heroLede")})]}),e.jsxs("p",{className:"home-hero__readiness",role:"status",children:[e.jsx("span",{className:`home-hero__dot${r>0?" is-ready":""}`,"aria-hidden":"true"}),r>0?s("home.lanesReady",{ready:r,total:n}):s("home.lanesNone")]}),e.jsx("div",{className:"home-workspace__composer",children:e.jsx(D,{providerAvailability:t})}),e.jsxs("section",{className:"home-workspace__recent","aria-labelledby":"home-recent-title",children:[e.jsx("h2",{id:"home-recent-title",children:s("home.recentTitle")}),e.jsx(F,{})]}),e.jsx(z,{})]})}function z(){const{t:s}=m(),t=i(a=>a.setUIMode),r=[{mode:"classic",label:s("nav.create"),hint:s("home.modeCreateHint"),enabled:!0,icon:R},{mode:"node",label:s("nav.node"),hint:s("home.modeNodeHint"),enabled:C,icon:T},{mode:"agent",label:s("nav.agent"),hint:s("home.modeAgentHint"),enabled:O,icon:L},{mode:"assets",label:s("nav.assets"),hint:s("home.modeAssetsHint"),enabled:!0,icon:H}];function n(a){t(a),history.replaceState(null,"",S[a]??"#create")}return e.jsxs("nav",{className:"home-modes","aria-label":s("home.modesTitle"),children:[e.jsx("h2",{className:"home-modes__title",children:s("home.modesTitle")}),r.filter(a=>a.enabled).map(a=>e.jsxs("button",{type:"button",className:"home-modes__item",onClick:()=>n(a.mode),children:[e.jsx("span",{className:"home-modes__icon",children:e.jsx(a.icon,{})}),e.jsx("span",{className:"home-modes__label",children:a.label}),e.jsx("span",{className:"home-modes__hint",children:a.hint}),e.jsx($,{})]},a.mode))]})}function K(){const{t:s}=m();return e.jsx("section",{className:"home-workspace","aria-label":s("nav.home"),children:e.jsx("div",{className:"home-workspace__inner",children:e.jsx(W,{})})})}export{K as HomeWorkspace};
1
+ import{b as i,u as m,am as I,j as e,an as A,ao as k,ap as P,v as E,aq as M,a as x,ar as w,as as R,at as T,au as C,av as L,aw as O,ax as H,ay as S}from"./index-Sch70vBs.js";const G={oauth:"GPT OAuth",api:"GPT API",grok:"Grok OAuth","grok-api":"Grok API",agy:"Antigravity","gemini-api":"Gemini API",atlascloud:"Atlas Cloud",minimax:"MiniMax",nai:"NovelAI",comfy:"ComfyUI"};function U(s){if(s.kind==="attachment")return s.source.dataUrl;if(s.source.thumbnailUrl)return s.source.thumbnailUrl;const t=s.source.referenceFilenames[0];if(t)return t.startsWith("/generated/")?t:`/generated/${t.split("/").map(encodeURIComponent).join("/")}`}function D({providerAvailability:s}){const t=i(o=>o.prompt),r=i(o=>o.setPrompt),n=i(o=>o.provider),a=i(o=>o.setProvider),c=i(o=>o.selectedPresetIds),p=i(o=>o.removePreset),d=i(o=>o.generate),v=i(o=>o.activeGenerations),h=i(o=>o.trayItems),{t:l}=m(),f=new Set(c),j=I().filter(o=>f.has(o.id)),b=v>0,y=Object.entries(G).map(([o,u])=>{const g=o,_=s[g];return{value:g,label:u,sub:_.ok?l("readiness.ready"):_.reason,disabled:!_.ok}});return e.jsxs("div",{className:"home-prompt",children:[j.length>0?e.jsx(A,{className:"home-prompt__chips",ariaLabel:l("home.selectedPresets"),children:j.map(o=>e.jsx(k,{selected:!0,onRemove:()=>p(o.id),removeLabel:l("common.removeNamed",{name:o.name}),title:o.category,children:o.name},o.id))}):null,h.length>0?e.jsxs("div",{className:"home-prompt__reference-strip",role:"group","aria-label":l("home.referenceTrayAria",{count:h.length}),children:[e.jsx("span",{className:"home-prompt__reference-thumbs","aria-hidden":"true",children:h.map(o=>{const u=U(o);return e.jsx("span",{className:"home-prompt__reference-thumb",children:u?e.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}):"@"},o.tokenId)})}),e.jsx("span",{className:"home-prompt__reference-count",children:l("home.referenceTrayCount",{count:h.length})})]}):null,e.jsx("label",{className:"home-prompt__label",htmlFor:"home-prompt-input",children:l("prompt.label")}),e.jsx("textarea",{id:"home-prompt-input",className:"home-prompt__textarea",rows:5,value:t,placeholder:l("prompt.placeholder"),onChange:o=>r(o.target.value)}),e.jsx(P,{variant:"home"}),e.jsxs("div",{className:"home-prompt__footer",children:[e.jsx(E,{className:"home-prompt__provider",items:y,value:n,onChange:a,ariaLabel:l("readiness.provider")}),e.jsx("button",{type:"button",className:"home-prompt__generate",disabled:b||t.trim().length===0,onClick:()=>{d();const o=i.getState().setUIMode;o("classic")},children:b?l("generate.buttonLoading",{n:v}):l("generate.button")})]})]})}const N=/\.(mp4|webm|mov)(?:$|[?#])/i;function V(s){return s.mediaType==="video"||N.test(s.filename??"")||N.test(s.url??s.image)?s.thumb:s.thumb||s.url||s.image||void 0}function B({item:s,featured:t}){const{t:r}=m(),[n,a]=x.useState(!1),c=V(s),p=(s.userPrompt?.trim()||s.prompt?.trim()||r("home.untitledResult")).slice(0,60),d=r("home.recentResultAlt",{prompt:p});return!c||n?e.jsx("div",{className:"home-recent-card__fallback",role:"img","aria-label":d,children:r("home.mediaUnavailable")}):e.jsx("img",{src:c,alt:d,loading:t?"eager":"lazy",decoding:"async",onError:()=>a(!0)})}function F(){const s=i(n=>n.history),{t}=m(),r=s.slice(0,5);return r.length===0?e.jsx("p",{className:"home-recent-empty",role:"status",children:t("history.emptyRecent")}):e.jsx("div",{className:"home-recent-row",role:"list","aria-label":t("home.recentTitle"),children:r.map((n,a)=>{const c=a===0;return e.jsx("figure",{className:`home-recent-card${c?" is-featured":""}`,role:"listitem",children:e.jsx(B,{item:n,featured:c})},M(n))})})}function $(){return e.jsxs("svg",{className:"home-hero__mode-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]})}function W(){const{t:s}=m(),t=w(),r=x.useMemo(()=>Object.values(t).filter(a=>a?.ok).length,[t]),n=x.useMemo(()=>Object.keys(t).length,[t]);return e.jsxs("div",{className:"home-hero",children:[e.jsx("div",{className:"home-hero__mark","aria-hidden":"true",children:"IMA2"}),e.jsxs("header",{className:"home-hero__intro",children:[e.jsx("h1",{className:"home-hero__title",children:s("home.heroTitle")}),e.jsx("p",{className:"home-hero__lede",children:s("home.heroLede")})]}),e.jsxs("p",{className:"home-hero__readiness",role:"status",children:[e.jsx("span",{className:`home-hero__dot${r>0?" is-ready":""}`,"aria-hidden":"true"}),r>0?s("home.lanesReady",{ready:r,total:n}):s("home.lanesNone")]}),e.jsx("div",{className:"home-workspace__composer",children:e.jsx(D,{providerAvailability:t})}),e.jsxs("section",{className:"home-workspace__recent","aria-labelledby":"home-recent-title",children:[e.jsx("h2",{id:"home-recent-title",children:s("home.recentTitle")}),e.jsx(F,{})]}),e.jsx(z,{})]})}function z(){const{t:s}=m(),t=i(a=>a.setUIMode),r=[{mode:"classic",label:s("nav.create"),hint:s("home.modeCreateHint"),enabled:!0,icon:R},{mode:"node",label:s("nav.node"),hint:s("home.modeNodeHint"),enabled:C,icon:T},{mode:"agent",label:s("nav.agent"),hint:s("home.modeAgentHint"),enabled:O,icon:L},{mode:"assets",label:s("nav.assets"),hint:s("home.modeAssetsHint"),enabled:!0,icon:H}];function n(a){t(a),history.replaceState(null,"",S[a]??"#create")}return e.jsxs("nav",{className:"home-modes","aria-label":s("home.modesTitle"),children:[e.jsx("h2",{className:"home-modes__title",children:s("home.modesTitle")}),r.filter(a=>a.enabled).map(a=>e.jsxs("button",{type:"button",className:"home-modes__item",onClick:()=>n(a.mode),children:[e.jsx("span",{className:"home-modes__icon",children:e.jsx(a.icon,{})}),e.jsx("span",{className:"home-modes__label",children:a.label}),e.jsx("span",{className:"home-modes__hint",children:a.hint}),e.jsx($,{})]},a.mode))]})}function K(){const{t:s}=m();return e.jsx("section",{className:"home-workspace","aria-label":s("nav.home"),children:e.jsx("div",{className:"home-workspace__inner",children:e.jsx(W,{})})})}export{K as HomeWorkspace};
@@ -1,4 +1,4 @@
1
- import{r as Gr,g as qa,R as Ua,a as E,j as p,u as ce,b as Q,i as Vt,S as Ka,f as Qa,c as Ja,d as ec,n as tc,e as nc,w as oc,h as rc,k as qr,l as ic,m as sc,o as ac,p as cc,q as lc,s as Ct,t as uc}from"./index-DTEhasVd.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var dc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function fc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=fc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=hc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Ao(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ao(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function hc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Ao(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=dc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zn="http://www.w3.org/1999/xhtml";const Po={svg:"http://www.w3.org/2000/svg",xhtml:zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Po.hasOwnProperty(t)?{space:Po[t],local:e}:e}function pc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function gc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=cn(e);return(t.local?gc:pc)(t)}function mc(){}function oo(e){return e==null?mc:function(){return this.querySelector(e)}}function yc(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function xc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wc(){return[]}function Kr(e){return e==null?wc:function(){return this.querySelectorAll(e)}}function vc(e){return function(){return xc(e.apply(this,arguments))}}function bc(e){typeof e=="function"?e=vc(e):e=Kr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function Qr(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var _c=Array.prototype.find;function Sc(e){return function(){return _c.call(this.children,e)}}function Nc(){return this.firstElementChild}function Ec(e){return this.select(e==null?Nc:Sc(typeof e=="function"?e:Jr(e)))}var Cc=Array.prototype.filter;function Ic(){return Array.from(this.children)}function Mc(e){return function(){return Cc.call(this.children,e)}}function kc(e){return this.selectAll(e==null?Ic:Mc(typeof e=="function"?e:Jr(e)))}function Tc(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function ei(e){return new Array(e.length)}function Ac(){return new de(this._enter||this._groups.map(ei),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Pc(e){return function(){return e}}function Dc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function $c(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(d[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?r[a]=c:l.set(h,c));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(o[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new qt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function jc(e){return e.__data__}function Rc(e,t){if(!arguments.length)return Array.from(this,jc);var n=t?$c:Dc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Pc(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],f=r[l],d=f.length,h=Hc(e.call(u,u&&u.__data__,l,o)),m=h.length,v=a[l]=new Array(m),x=s[l]=new Array(m),y=c[l]=new Array(d);n(u,f,v,x,y,h,t);for(var w=0,g=0,b,C;w<m;++w)if(b=v[w]){for(w>=g&&(g=w+1);!(C=x[g])&&++g<m;);b._next=C||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Hc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Oc(){return new de(this._exit||this._groups.map(ei),this._parents)}function zc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Lc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],f=l.length,d=a[c]=new Array(f),h,m=0;m<f;++m)(h=l[m]||u[m])&&(d[m]=h);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Bc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Vc(e){e||(e=Fc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function Fc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Yc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Xc(){return Array.from(this)}function Wc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function Zc(){let e=0;for(const t of this)++e;return e}function Gc(){return!this.node()}function qc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Uc(e){return function(){this.removeAttribute(e)}}function Kc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qc(e,t){return function(){this.setAttribute(e,t)}}function Jc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tl(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 nl(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Kc:Uc:typeof t=="function"?n.local?tl:el:n.local?Jc:Qc)(n,t))}function ti(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ol(e){return function(){this.style.removeProperty(e)}}function rl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function il(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function sl(e,t,n){return arguments.length>1?this.each((t==null?ol:typeof t=="function"?il:rl)(e,t,n??"")):ot(this.node(),e)}function ot(e,t){return e.style.getPropertyValue(t)||ti(e).getComputedStyle(e,null).getPropertyValue(t)}function al(e){return function(){delete this[e]}}function cl(e,t){return function(){this[e]=t}}function ll(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ul(e,t){return arguments.length>1?this.each((t==null?al:typeof t=="function"?ll:cl)(e,t)):this.node()[e]}function ni(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new oi(e)}function oi(e){this._node=e,this._names=ni(e.getAttribute("class")||"")}oi.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 ri(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ii(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function dl(e){return function(){ri(this,e)}}function fl(e){return function(){ii(this,e)}}function hl(e,t){return function(){(t.apply(this,arguments)?ri:ii)(this,e)}}function pl(e,t){var n=ni(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?hl:t?dl:fl)(n,t))}function gl(){this.textContent=""}function ml(e){return function(){this.textContent=e}}function yl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xl(e){return arguments.length?this.each(e==null?gl:(typeof e=="function"?yl:ml)(e)):this.node().textContent}function wl(){this.innerHTML=""}function vl(e){return function(){this.innerHTML=e}}function bl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _l(e){return arguments.length?this.each(e==null?wl:(typeof e=="function"?bl:vl)(e)):this.node().innerHTML}function Sl(){this.nextSibling&&this.parentNode.appendChild(this)}function Nl(){return this.each(Sl)}function El(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cl(){return this.each(El)}function Il(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ml(){return null}function kl(e,t){var n=typeof e=="function"?e:Ur(e),o=t==null?Ml:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Tl(){var e=this.parentNode;e&&e.removeChild(this)}function Al(){return this.each(Tl)}function Pl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $l(e){return this.select(e?Dl:Pl)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Rl(e){return function(t){e.call(this,t,this.__data__)}}function Hl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Ol(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function zl(e,t,n){return function(){var o=this.__on,r,i=Rl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Ll(e,t,n){var o=Hl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?zl:Ol,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function si(e,t,n){var o=ti(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Bl(e,t){return function(){return si(this,e,t)}}function Vl(e,t){return function(){return si(this,e,t.apply(this,arguments))}}function Fl(e,t){return this.each((typeof t=="function"?Vl:Bl)(e,t))}function*Yl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ai=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ai)}function Xl(){return this}de.prototype=It.prototype={constructor:de,select:yc,selectAll:bc,selectChild:Ec,selectChildren:kc,filter:Tc,data:Rc,enter:Ac,exit:Oc,join:zc,merge:Lc,selection:Xl,order:Bc,sort:Vc,call:Yc,nodes:Xc,node:Wc,size:Zc,empty:Gc,each:qc,attr:nl,style:sl,property:ul,classed:pl,text:xl,html:_l,raise:Nl,lower:Cl,append:Il,insert:kl,remove:Al,clone:$l,datum:jl,on:Ll,dispatch:Fl,[Symbol.iterator]:Yl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ai)}function Wl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Wl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Zl={passive:!1},yt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function ci(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",tt,yt);"onselectstart"in t?n.on("selectstart.drag",tt,yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function li(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",tt,yt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function Ln(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Ln.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Gl(e){return!e.ctrlKey&&!e.button}function ql(){return this.parentNode}function Ul(e,t){return t??{x:e.x,y:e.y}}function Kl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ui(){var e=Gl,t=ql,n=Ul,o=Kl,r={},i=an("start","drag","end"),s=0,a,c,l,u,f=0;function d(b){b.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,Zl).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(b,C){if(!(u||!e.call(this,b,C))){var S=g(this,t.call(this,b,C),b,C,"mouse");S&&(ue(b.view).on("mousemove.drag",m,yt).on("mouseup.drag",v,yt),ci(b.view),Sn(b),l=!1,a=b.clientX,c=b.clientY,S("start",b))}}function m(b){if(tt(b),!l){var C=b.clientX-a,S=b.clientY-c;l=C*C+S*S>f}r.mouse("drag",b)}function v(b){ue(b.view).on("mousemove.drag mouseup.drag",null),li(b.view,l),tt(b),r.mouse("end",b)}function x(b,C){if(e.call(this,b,C)){var S=b.changedTouches,N=t.call(this,b,C),k=S.length,P,L;for(P=0;P<k;++P)(L=g(this,N,b,C,S[P].identifier,S[P]))&&(Sn(b),L("start",b,S[P]))}}function y(b){var C=b.changedTouches,S=C.length,N,k;for(N=0;N<S;++N)(k=r[C[N].identifier])&&(tt(b),k("drag",b,C[N]))}function w(b){var C=b.changedTouches,S=C.length,N,k;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),N=0;N<S;++N)(k=r[C[N].identifier])&&(Sn(b),k("end",b,C[N]))}function g(b,C,S,N,k,P){var L=i.copy(),T=he(P||S,C),O,H,_;if((_=n.call(b,new Ln("beforestart",{sourceEvent:S,target:d,identifier:k,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:L}),N))!=null)return O=_.x-T[0]||0,H=_.y-T[1]||0,function I(M,A,$){var j=T,z;switch(M){case"start":r[k]=I,z=s++;break;case"end":delete r[k],--s;case"drag":T=he($||A,C),z=s;break}L.call(M,b,new Ln(M,{sourceEvent:A,subject:_,target:d,identifier:k,active:z,x:T[0]+O,y:T[1]+H,dx:T[0]-j[0],dy:T[1]-j[1],dispatch:L}),N)}}return d.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Dt(!!b),d):e},d.container=function(b){return arguments.length?(t=typeof b=="function"?b:Dt(b),d):t},d.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Dt(b),d):n},d.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Dt(!!b),d):o},d.on=function(){var b=i.on.apply(i,arguments);return b===i?d:b},d.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,d):Math.sqrt(f)},d}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Mt(){}var xt=.7,Ut=1/xt,nt="\\s*([+-]?\\d+)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ql=/^#([0-9a-f]{3,8})$/,Jl=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),eu=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),tu=new RegExp(`^rgba\\(${nt},${nt},${nt},${wt}\\)$`),nu=new RegExp(`^rgba\\(${Se},${Se},${Se},${wt}\\)$`),ou=new RegExp(`^hsl\\(${wt},${Se},${Se}\\)$`),ru=new RegExp(`^hsla\\(${wt},${Se},${Se},${wt}\\)$`),Do={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};io(Mt,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:iu,formatHsl:su,formatRgb:jo,toString:jo});function $o(){return this.rgb().formatHex()}function iu(){return this.rgb().formatHex8()}function su(){return fi(this).formatHsl()}function jo(){return this.rgb().formatRgb()}function Xe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ql.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ro(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$t(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$t(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=Jl.exec(e))?new le(t[1],t[2],t[3],1):(t=eu.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tu.exec(e))?$t(t[1],t[2],t[3],t[4]):(t=nu.exec(e))?$t(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ou.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=ru.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):Do.hasOwnProperty(e)?Ro(Do[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ro(e){return new le(e>>16&255,e>>8&255,e&255,1)}function $t(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function au(e){return e instanceof Mt||(e=Xe(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?au(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Fe(this.r),Fe(this.g),Fe(this.b),Kt(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:Ho,formatHex:Ho,formatHex8:cu,formatRgb:Oo,toString:Oo}));function Ho(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function cu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Fe(this.r)}, ${Fe(this.g)}, ${Fe(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Fe(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function fi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof Mt||(e=Xe(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function lu(e,t,n,o){return arguments.length===1?fi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,lu,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new pe(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,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(Nn(e>=240?e-240:e+120,r,o),Nn(e,r,o),Nn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Lo(this.h),jt(this.s),jt(this.l),Kt(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=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Lo(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lo(e){return e=(e||0)%360,e<0?e+360:e}function jt(e){return Math.max(0,Math.min(1,e||0))}function Nn(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 so=e=>()=>e;function uu(e,t){return function(n){return e+n*t}}function du(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function fu(e){return(e=+e)==1?hi:function(t,n){return n-t?du(t,n,e):so(isNaN(t)?n:t)}}function hi(e,t){var n=t-e;return n?uu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=fu(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=hi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function hu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function pu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function gu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=pt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function mu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function _e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=pt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Vn.source,"g");function xu(e){return function(){return e}}function wu(e){return function(t){return e(t)+""}}function pi(e,t){var n=Vn.lastIndex=En.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=En.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:_e(o,r)})),n=En.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?wu(c[0].x):xu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function pt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?_e:n==="string"?(o=Xe(t))?(t=o,Qt):pi:t instanceof Xe?Qt:t instanceof Date?mu:pu(t)?hu:Array.isArray(t)?gu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yu:_e)(e,t)}var Bo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Bo,skewX:Math.atan(c)*Bo,scaleX:s,scaleY:a}}var Rt;function vu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function bu(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push("translate(",null,t,null,n);m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:_e(l,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(l,u,f,d){l!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:_e(l,u)}):u&&f.push(r(f)+"skewX("+u+o)}function c(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push(r(h)+"scale(",null,",",null,")");m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(h){for(var m=-1,v=d.length,x;++m<v;)f[(x=d[m]).i]=x.x(h);return f.join("")}}}var _u=mi(vu,"px, ","px)","deg)"),Su=mi(bu,", ",")",")"),Nu=1e-12;function Vo(e){return((e=Math.exp(e))+1/e)/2}function Eu(e){return((e=Math.exp(e))-1/e)/2}function Cu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],h=u-a,m=f-c,v=h*h+m*m,x,y;if(v<Nu)y=Math.log(d/l)/t,x=function(N){return[a+N*h,c+N*m,l*Math.exp(t*N*y)]};else{var w=Math.sqrt(v),g=(d*d-l*l+o*v)/(2*l*n*w),b=(d*d-l*l-o*v)/(2*d*n*w),C=Math.log(Math.sqrt(g*g+1)-g),S=Math.log(Math.sqrt(b*b+1)-b);y=(S-C)/t,x=function(N){var k=N*y,P=Vo(C),L=l/(n*w)*(P*Cu(t*k+C)-Eu(C));return[a+L*h,c+L*m,l*P/Vo(t*k+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var rt=0,ft=0,lt=0,yi=1e3,Jt,ht,en=0,We=0,ln=0,vt=typeof performance=="object"&&performance.now?performance:Date,xi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return We||(xi(Iu),We=vt.now()+ln)}function Iu(){We=0}function tn(){this._call=this._time=this._next=null}tn.prototype=wi.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&&ht!==this&&(ht?ht._next=this:Jt=this,ht=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function wi(e,t,n){var o=new tn;return o.restart(e,t,n),o}function Mu(){ao(),++rt;for(var e=Jt,t;e;)(t=We-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rt}function Fo(){We=(en=vt.now())+ln,rt=ft=0;try{Mu()}finally{rt=0,Tu(),We=0}}function ku(){var e=vt.now(),t=e-en;t>yi&&(ln-=t,en=e)}function Tu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ht=e,Yn(o)}function Yn(e){if(!rt){ft&&(ft=clearTimeout(ft));var t=e-We;t>24?(e<1/0&&(ft=setTimeout(Fo,e-vt.now()-ln)),lt&&(lt=clearInterval(lt))):(lt||(en=vt.now(),lt=setInterval(ku,yi)),rt=1,xi(Fo))}}function Yo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Au=an("start","end","cancel","interrupt"),Pu=[],vi=0,Xo=1,Xn=2,Xt=3,Wo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Du(e,n,{name:t,index:o,group:r,on:Au,tween:Pu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vi})}function co(e,t){var n=xe(e,t);if(n.state>vi)throw new Error("too late; already scheduled");return n}function Ne(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Du(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=wi(i,0,n.time);function i(l){n.state=Xo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,h;if(n.state!==Xo)return c();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Xt)return Yo(s);h.state===Wo?(h.state=Wt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Wt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(Yo(function(){n.state===Xt&&(n.state=Wo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function $u(e){return this.each(function(){Zt(this,e)})}function ju(e,t){var n,o;return function(){var r=Ne(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Ru(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ne(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Hu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?ju:Ru)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Ne(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function bi(e,t){var n;return(typeof t=="number"?_e:t instanceof Xe?Qt:(n=Xe(t))?(t=n,Qt):pi)(e,t)}function Ou(e){return function(){this.removeAttribute(e)}}function zu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Lu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Bu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Vu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Fu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Yu(e,t){var n=cn(e),o=n==="transform"?Su:bi;return this.attrTween(e,typeof t=="function"?(n.local?Fu:Vu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?zu:Ou)(n):(n.local?Bu:Lu)(n,o,t))}function Xu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Zu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Wu(e,i)),n}return r._value=t,r}function Gu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Xu(e,i)),n}return r._value=t,r}function qu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?Zu:Gu)(o,t))}function Uu(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Ku(e,t){return t=+t,function(){co(this,e).delay=t}}function Qu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uu:Ku)(t,e)):xe(this.node(),t).delay}function Ju(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function ed(e,t){return t=+t,function(){Ne(this,e).duration=t}}function td(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ju:ed)(t,e)):xe(this.node(),t).duration}function nd(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function od(e){var t=this._id;return arguments.length?this.each(nd(t,e)):xe(this.node(),t).ease}function rd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ne(this,e).ease=n}}function id(e){if(typeof e!="function")throw new Error;return this.each(rd(this._id,e))}function sd(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function ad(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=c[h]||l[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function cd(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 ld(e,t,n){var o,r,i=cd(t)?co:Ne;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ud(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(ld(n,e,t))}function dd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fd(){return this.on("end.remove",dd(this._id))}function hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,un(l[d],t,n,d,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Kr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),h,m=xe(u,n),v=0,x=d.length;v<x;++v)(h=d[v])&&un(h,t,n,v,d,m);i.push(d),s.push(u)}return new Pe(i,s,t,n)}var gd=It.prototype.constructor;function md(){return new gd(this._groups,this._parents)}function yd(e,t){var n,o,r;return function(){var i=ot(this,e),s=(this.style.removeProperty(e),ot(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function _i(e){return function(){this.style.removeProperty(e)}}function xd(e,t,n){var o,r=n+"",i;return function(){var s=ot(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function wd(e,t,n){var o,r,i;return function(){var s=ot(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),ot(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function vd(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Ne(this,e),l=c.on,u=c.value[i]==null?a||(a=_i(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function bd(e,t,n){var o=(e+="")=="transform"?_u:bi;return t==null?this.styleTween(e,yd(e,o)).on("end.style."+e,_i(e)):typeof t=="function"?this.styleTween(e,wd(e,o,lo(this,"style."+e,t))).each(vd(this._id,e)):this.styleTween(e,xd(e,o,t),n).on("end.style."+e,null)}function _d(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Sd(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&_d(e,s,n)),o}return i._value=t,i}function Nd(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Sd(e,t,n??""))}function Ed(e){return function(){this.textContent=e}}function Cd(e){return function(){var t=e(this);this.textContent=t??""}}function Id(e){return this.tween("text",typeof e=="function"?Cd(lo(this,"text",e)):Ed(e==null?"":e+""))}function Md(e){return function(t){this.textContent=e.call(this,t)}}function kd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Md(r)),t}return o._value=e,o}function Td(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,kd(e))}function Ad(){for(var e=this._name,t=this._id,n=Si(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Pd(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Ne(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Dd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Si(){return++Dd}var ke=It.prototype;Pe.prototype={constructor:Pe,select:hd,selectAll:pd,selectChild:ke.selectChild,selectChildren:ke.selectChildren,filter:sd,merge:ad,selection:md,transition:Ad,call:ke.call,nodes:ke.nodes,node:ke.node,size:ke.size,empty:ke.empty,each:ke.each,on:ud,attr:Yu,attrTween:qu,style:bd,styleTween:Nd,text:Id,textTween:Td,remove:fd,tween:Hu,delay:Qu,duration:td,ease:od,easeVarying:id,end:Pd,[Symbol.iterator]:ke[Symbol.iterator]};function $d(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jd={time:null,delay:0,duration:250,ease:$d};function Rd(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 Hd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Si(),(n=jd).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||Rd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=$u;It.prototype.transition=Hd;const Ht=e=>()=>e;function Od(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var dn=new Te(1,0,0);Ni.prototype=Te.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function zd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ld(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Zo(){return this.__zoom||dn}function Bd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Vd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=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(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ei(){var e=zd,t=Ld,n=Fd,o=Bd,r=Vd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,f,d,h=500,m=150,v=0,x=10;function y(_){_.property("__zoom",Zo).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",L).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,M,A){var $=_.selection?_.selection():_;$.property("__zoom",Zo),_!==$?C(_,I,M,A):$.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,M,A){y.scaleTo(_,function(){var $=this.__zoom.k,j=typeof I=="function"?I.apply(this,arguments):I;return $*j},M,A)},y.scaleTo=function(_,I,M,A){y.transform(_,function(){var $=t.apply(this,arguments),j=this.__zoom,z=M==null?b($):typeof M=="function"?M.apply(this,arguments):M,V=j.invert(z),B=typeof I=="function"?I.apply(this,arguments):I;return n(g(w(j,B),z,V),$,s)},M,A)},y.translateBy=function(_,I,M,A){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,A)},y.translateTo=function(_,I,M,A,$){y.transform(_,function(){var j=t.apply(this,arguments),z=this.__zoom,V=A==null?b(j):typeof A=="function"?A.apply(this,arguments):A;return n(dn.translate(V[0],V[1]).scale(z.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof M=="function"?-M.apply(this,arguments):-M),j,s)},A,$)};function w(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new Te(I,_.x,_.y)}function g(_,I,M){var A=I[0]-M[0]*_.k,$=I[1]-M[1]*_.k;return A===_.x&&$===_.y?_:new Te(_.k,A,$)}function b(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function C(_,I,M,A){_.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var $=this,j=arguments,z=S($,j).event(A),V=t.apply($,j),B=M==null?b(V):typeof M=="function"?M.apply($,j):M,W=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=$.__zoom,G=typeof I=="function"?I.apply($,j):I,J=c(Y.invert(B).concat(W/Y.k),G.invert(B).concat(W/G.k));return function(R){if(R===1)R=G;else{var D=J(R),F=W/D[2];R=new Te(F,B[0]-D[0]*F,B[1]-D[1]*F)}z.zoom(null,R)}})}function S(_,I,M){return!M&&_.__zooming||new N(_,I)}function N(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,I),this.taps=0}N.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=ue(this.that).datum();l.call(_,this.that,new Od(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function k(_,...I){if(!e.apply(this,arguments))return;var M=S(this,I).event(_),A=this.__zoom,$=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),j=he(_);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=A.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if(A.k===$)return;M.mouse=[j,A.invert(j)],Zt(this),M.start()}ut(_),M.wheel=setTimeout(z,m),M.zoom("mouse",n(g(w(A,$),M.mouse[0],M.mouse[1]),M.extent,s));function z(){M.wheel=null,M.end()}}function P(_,...I){if(d||!e.apply(this,arguments))return;var M=_.currentTarget,A=S(this,I,!0).event(_),$=ue(_.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),j=he(_,M),z=_.clientX,V=_.clientY;ci(_.view),Cn(_),A.mouse=[j,this.__zoom.invert(j)],Zt(this),A.start();function B(Y){if(ut(Y),!A.moved){var G=Y.clientX-z,J=Y.clientY-V;A.moved=G*G+J*J>v}A.event(Y).zoom("mouse",n(g(A.that.__zoom,A.mouse[0]=he(Y,M),A.mouse[1]),A.extent,s))}function W(Y){$.on("mousemove.zoom mouseup.zoom",null),li(Y.view,A.moved),ut(Y),A.event(Y).end()}}function L(_,...I){if(e.apply(this,arguments)){var M=this.__zoom,A=he(_.changedTouches?_.changedTouches[0]:_,this),$=M.invert(A),j=M.k*(_.shiftKey?.5:2),z=n(g(w(M,j),A,$),t.apply(this,I),s);ut(_),a>0?ue(this).transition().duration(a).call(C,z,A,_):ue(this).call(y.transform,z,A,_)}}function T(_,...I){if(e.apply(this,arguments)){var M=_.touches,A=M.length,$=S(this,I,_.changedTouches.length===A).event(_),j,z,V,B;for(Cn(_),z=0;z<A;++z)V=M[z],B=he(V,this),B=[B,this.__zoom.invert(B),V.identifier],$.touch0?!$.touch1&&$.touch0[2]!==B[2]&&($.touch1=B,$.taps=0):($.touch0=B,j=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),j&&($.taps<2&&(f=B[0],u=setTimeout(function(){u=null},h)),Zt(this),$.start())}}function O(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z,V,B;for(ut(_),j=0;j<$;++j)z=A[j],V=he(z,this),M.touch0&&M.touch0[2]===z.identifier?M.touch0[0]=V:M.touch1&&M.touch1[2]===z.identifier&&(M.touch1[0]=V);if(z=M.that.__zoom,M.touch1){var W=M.touch0[0],Y=M.touch0[1],G=M.touch1[0],J=M.touch1[1],R=(R=G[0]-W[0])*R+(R=G[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;z=w(z,Math.sqrt(R/D)),V=[(W[0]+G[0])/2,(W[1]+G[1])/2],B=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(M.touch0)V=M.touch0[0],B=M.touch0[1];else return;M.zoom("touch",n(g(z,V,B),M.extent,s))}}function H(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z;for(Cn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),j=0;j<$;++j)z=A[j],M.touch0&&M.touch0[2]===z.identifier?delete M.touch0:M.touch1&&M.touch1[2]===z.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(z=he(z,this),Math.hypot(f[0]-z[0],f[1]-z[1])<x)){var V=ue(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],y):[i[0],i[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,y):Math.sqrt(v)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ci=["Enter"," ","Escape"],Ii={"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 Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Ye;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ye||(Ye={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const Mi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Re;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Re||(Re={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Go={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ki(e){return e===null?null:e?"valid":"invalid"}const Ti=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Yd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:o}=we(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Xd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):uo(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,fn(r,on(a,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?hn(o):{x:0,y:0,width:0,height:0}},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:h,selectable:m=!0,hidden:v=!1}=d;if(s&&!m||v)continue;const x=h.width??d.width??d.initialWidth??0,y=h.height??d.height??d.initialHeight??0,{x:w,y:g}=d.internals.positionAbsolute,b=$i(a,c,l,u,w,g,x,y),C=x*y,S=i&&b>0;(!d.internals.handleBounds||S||b>=C||d.dragging)&&f.push(d)}return f},Wd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Zd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=we(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function Gd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=Zd(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const{width:h,height:m}=we(a);h&&m&&(f=[[c,l],[c+h,l+m]])}else a&&qe(s.extent)&&(f=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=qe(f)?Ge(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:d.x-c+(s.measured.width??0)*u[0],y:d.y-l+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function qd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),m=!h&&d.parentId&&s.find(v=>v.id===d.parentId);(h||m)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),u=Wd(s,c);for(const d of c)a.has(d.id)&&!u.find(m=>m.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const it=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:it(e.x,t[0][0],t[1][0]-(n?.width??0)),y:it(e.y,t[0][1],t[1][1]-(n?.height??0))});function Pi(e,t,n){const{width:o,height:r}=we(n),{x:i,y:s}=n.internals.positionAbsolute;return Ge(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?it(Math.abs(e-t),1,t)/t:e>n?-it(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),St=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Di=(e,t)=>hn(fn(Zn(e),Zn(t))),$i=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>$i(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Uo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ji=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},st=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Qe(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(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ud(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Qe(e,n),r=Qe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Qe(e.top??e.y??0,n),r=Qe(e.bottom??e.y??0,n),i=Qe(e.left??e.x??0,t),s=Qe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Kd(e,t,n,o,r,i){const{x:s,y:a}=st(e,[t,n,o]),{x:c,y:l}=st({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,f=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const po=(e,t,n,o,r,i)=>{const s=Ud(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=it(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,m=n/2-d*u,v=Kd(e,h,m,u,t,n),x={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function qe(e){return e!=null&&e!=="parent"}function we(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ri(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Hi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ko(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Qd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Jd(e){return{...Ii,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Oi=e=>e?.getRootNode?.()||window?.document,ef=["INPUT","SELECT","TEXTAREA"];function zi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ef.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Li=e=>"clientX"in e,me=(e,t)=>{const n=Li(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Ot(t-o,i),n];case X.Right:return[t+Ot(o-t,i),n];case X.Top:return[t,n-Ot(n-r,i)];case X.Bottom:return[t,n+Ot(r-n,i)]}}function Vi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Jo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=Jo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,m]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,f,d,h,m]}function Fi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function tf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function nf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const of=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,rf=(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)),sf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||of;let r;return Ti(e)?r={...e}:r={...e,id:o(e)},rf(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Fi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const er={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},af=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=er[t],c=er[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=af({source:l,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let m=[],v,x;const y={x:0,y:0},w={x:0,y:0},[,,g,b]=Fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(v=r.x??l.x+(u.x-l.x)*s,x=r.y??(l.y+u.y)/2):(v=r.x??(l.x+u.x)/2,x=r.y??l.y+(u.y-l.y)*s);const k=[{x:v,y:l.y},{x:v,y:u.y}],P=[{x:l.x,y:x},{x:u.x,y:x}];a[d]===h?m=d==="x"?k:P:m=d==="x"?P:k}else{const k=[{x:l.x,y:u.y}],P=[{x:u.x,y:l.y}];if(d==="x"?m=a.x===h?P:k:m=a.y===h?k:P,t===o){const _=Math.abs(e[d]-n[d]);if(_<=i){const I=Math.min(i-1,i-_);a[d]===h?y[d]=(l[d]>e[d]?-1:1)*I:w[d]=(u[d]>n[d]?-1:1)*I}}if(t!==o){const _=d==="x"?"y":"x",I=a[d]===c[_],M=l[_]>u[_],A=l[_]<u[_];(a[d]===1&&(!I&&M||I&&A)||a[d]!==1&&(!I&&A||I&&M))&&(m=d==="x"?k:P)}const L={x:l.x+y.x,y:l.y+y.y},T={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(L.x-m[0].x),Math.abs(T.x-m[0].x)),H=Math.max(Math.abs(L.y-m[0].y),Math.abs(T.y-m[0].y));O>=H?(v=(L.x+T.x)/2,x=m[0].y):(v=m[0].x,x=(L.y+T.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},S={x:u.x+w.x,y:u.y+w.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],v,x,g,b]}function lf(e,t,n,o){const r=Math.min(tr(e,t)/2,tr(t,n)/2,o),{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 l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[f,d,h,m,v]=cf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let x=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)x+=lf(f[y-1],f[y],f[y+1],s);return x+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[x,d,h,m,v]}function nr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function uf(e){const{sourceNode:t,targetNode:n}=e;if(!nr(t)||!nr(n))return null;const o=t.internals.handleBounds||or(t.handles),r=n.internals.handleBounds||or(n.handles),i=rr(o?.source??[],e.sourceHandle),s=rr(e.connectionMode===Ze.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=Ue(t,i,a),u=Ue(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function or(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Ue(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??we(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function rr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function df(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=qn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Xi=1e3,ff=10,mo={nodeOrigin:[0,0],nodeExtent:bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function pf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=kt(r,o.nodeOrigin),s=qe(r.extent)?r.extent:o.nodeExtent,a=Ge(i,s,we(r));r.internals.positionAbsolute=a}}function gf(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function Un(e,t,n,o={}){const r=yo(hf,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Xi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=kt(u,r.nodeOrigin),h=qe(u.extent)?u.extent:r.nodeExtent,m=Ge(d,h,we(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:gf(u,f),z:Wi(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&wo(f,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mf(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 wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*ff),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xo(c)?Xi:0,{x:d,y:h,z:m}=yf(e,u,s,a,f,c),{positionAbsolute:v}=e.internals,x=d!==v.x||h!==v.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:d,y:h}:v,z:m}})}function Wi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function yf(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=we(e),l=kt(e,n),u=qe(e.extent)?Ge(l,e.extent,c):l;let f=Ge({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(f=Pi(f,c,t));const d=Wi(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??St(a),l=Di(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=we(a),f=a.origin??o,d=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,h=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,m=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),x=(m-u.width)*f[0],y=(v-u.height)*f[1];(d>0||h>0||x||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-d+x,y:a.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(g=>g.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+d,y:w.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(d?f[0]*d-x:0),height:v+(h?f[1]*h-y:0)}})}),r}function xf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const v=go(h.nodeElement),x=m.measured.width!==v.width||m.measured.height!==v.height;if(!!(v.width&&v.height&&(x||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),g=qe(m.extent)?m.extent:i;let{positionAbsolute:b}=m.internals;if(m.parentId&&m.extent==="parent"){const S=t.get(m.parentId);S&&(b=Pi(b,v,S))}else g&&(b=Ge(b,g,v));const C={...m,measured:v,internals:{...m.internals,positionAbsolute:b,handleBounds:{source:Qo("source",h.nodeElement,w,f,m.id),target:Qo("target",h.nodeElement,w,f,m.id)}}};t.set(m.id,C),m.parentId&&wo(C,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:v}),m.expandParent&&m.parentId&&d.push({id:m.id,parentId:m.parentId,rect:St(C,r)}))}}if(d.length>0){const h=vo(d,t,n,r);l.push(...h)}return{changes:l,updatedInternals:c}}async function wf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ir(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function Zi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;ir("source",c,u,e,r,s),ir("target",c,l,e,i,a),t.set(o.id,o)}}function Gi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Gi(n,t):!1}function sr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function vf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Gi(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function bf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _f({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,h=!1,m=!1,v=null;function x({noDragClassName:w,handleSelector:g,domNode:b,isSelectable:C,nodeId:S,nodeClickDistance:N=0}){d=ue(b);function k({x:O,y:H}){const{nodeLookup:_,nodeExtent:I,snapGrid:M,snapToGrid:A,nodeOrigin:$,onNodeDrag:j,onSelectionDrag:z,onError:V,updateNodePositions:B}=t();i={x:O,y:H};let W=!1;const Y=a.size>1,G=Y&&I?Zn(Tt(a)):null,J=Y&&A?bf({dragItems:a,snapGrid:M,x:O,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:O-D.distance.x,y:H-D.distance.y};A&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,M));let q=null;if(Y&&I&&!D.extent&&G){const{positionAbsolute:U}=D.internals,ee=U.x-G.x+I[0][0],ne=U.x+D.measured.width-G.x2+I[1][0],re=U.y-G.y+I[0][1],ae=U.y+D.measured.height-G.y2+I[1][1];q=[[ee,re],[ne,ae]]}const{position:K,positionAbsolute:Z}=Ai({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:q||I,nodeOrigin:$,onError:V});W=W||D.position.x!==K.x||D.position.y!==K.y,D.position=K,D.internals.positionAbsolute=Z}if(m=m||W,!!W&&(B(a,!0),v&&(o||j||!S&&z))){const[R,D]=In({nodeId:S,dragItems:a,nodeLookup:_});o?.(v,a,R,D),j?.(v,R,D),S||z?.(v,D)}}async function P(){if(!u)return;const{transform:O,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[M,A]=ho(l,u,_);(M!==0||A!==0)&&(i.x=(i.x??0)-M/O[2],i.y=(i.y??0)-A/O[2],await H({x:M,y:A})&&k(i)),s=requestAnimationFrame(P)}function L(O){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:I,transform:M,snapGrid:A,snapToGrid:$,selectNodesOnDrag:j,onNodeDragStart:z,onSelectionDragStart:V,unselectNodesAndEdges:B}=t();f=!0,(!j||!C)&&!_&&S&&(H.get(S)?.selected||B()),C&&j&&S&&e?.(S);const W=gt(O.sourceEvent,{transform:M,snapGrid:A,snapToGrid:$,containerBounds:u});if(i=W,a=vf(H,I,W,S),a.size>0&&(n||z||!S&&V)){const[Y,G]=In({nodeId:S,dragItems:a,nodeLookup:H});n?.(O.sourceEvent,a,Y,G),z?.(O.sourceEvent,Y,G),S||V?.(O.sourceEvent,G)}}const T=ui().clickDistance(N).on("start",O=>{const{domNode:H,nodeDragThreshold:_,transform:I,snapGrid:M,snapToGrid:A}=t();u=H?.getBoundingClientRect()||null,h=!1,m=!1,v=O.sourceEvent,_===0&&L(O),i=gt(O.sourceEvent,{transform:I,snapGrid:M,snapToGrid:A,containerBounds:u}),l=me(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:I,snapToGrid:M,nodeDragThreshold:A,nodeLookup:$}=t(),j=gt(O.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:u});if(v=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!$.has(S))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,P()),!f){const z=me(O.sourceEvent,u),V=z.x-l.x,B=z.y-l.y;Math.sqrt(V*V+B*B)>A&&L(O)}(i.x!==j.xSnapped||i.y!==j.ySnapped)&&a&&f&&(l=me(O.sourceEvent,u),k(j))}}).on("end",O=>{if(!f||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:M}=t();if(m&&(_(a,!1),m=!1),r||I||!S&&M){const[A,$]=In({nodeId:S,dragItems:a,nodeLookup:H,dragging:!1});r?.(O.sourceEvent,a,A,$),I?.(O.sourceEvent,A,$),S||M?.(O.sourceEvent,$)}}}).filter(O=>{const H=O.target;return!O.button&&(!w||!sr(H,`.${w}`,b))&&(!g||sr(H,g,b))});d.call(T)}function y(){d?.on(".drag",null)}return{update:x,destroy:y}}function Sf(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,St(i))>0&&o.push(i);return o}const Nf=250;function Ef(e,t,n,o){let r=[],i=1/0;const s=Sf(e,n,t+Nf);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:f}=Ue(a,l,l.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...l,x:u,y:f}],i=d):d===i&&r.push({...l,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...Ue(s,c,c.position,!0)}:c}function Ui(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Cf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ki=()=>!0;function If(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:m,onConnect:v,onConnectEnd:x,isValidConnection:y=Ki,onReconnectEnd:w,updateConnection:g,getTransform:b,getFromHandle:C,autoPanSpeed:S,dragThreshold:N=1,handleDomNode:k}){const P=Oi(e.target);let L=0,T;const{x:O,y:H}=me(e),_=Ui(i,k),I=a?.getBoundingClientRect();let M=!1;if(!I||!_)return;const A=qi(r,_,o,c,t);if(!A)return;let $=me(e,I),j=!1,z=null,V=!1,B=null;function W(){if(!u||!I)return;const[K,Z]=ho($,I,S);d({x:K,y:Z}),L=requestAnimationFrame(W)}const Y={...A,nodeId:r,type:_,position:A.position},G=c.get(r);let R={inProgress:!0,isValid:null,from:Ue(G,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:G,to:$,toHandle:null,toPosition:Go[Y.position],toNode:null,pointer:$};function D(){M=!0,g(R),m?.(e,{nodeId:r,handleId:o,handleType:_})}N===0&&D();function F(K){if(!M){const{x:ae,y:Ee}=me(K),ve=ae-O,be=Ee-H;if(!(ve*ve+be*be>N*N))return;D()}if(!C()||!Y){q(K);return}const Z=b();$=me(K,I),T=Ef(Pt($,Z,!1,[1,1]),n,c,Y),j||(W(),j=!0);const U=Qi(K,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:f,nodeLookup:c});B=U.handleDomNode,z=U.connection,V=Cf(!!T,U.isValid);const ee=c.get(r),ne=ee?Ue(ee,Y,X.Left,!0):R.from,re={...R,from:ne,isValid:V,to:U.toHandle&&V?st({x:U.toHandle.x,y:U.toHandle.y},Z):$,toHandle:U.toHandle,toPosition:V&&U.toHandle?U.toHandle.position:Go[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:$};g(re),R=re}function q(K){if(!("touches"in K&&K.touches.length>0)){if(M){(T||B)&&z&&V&&v?.(z);const{inProgress:Z,...U}=R,ee={...U,toPosition:R.toHandle?R.toPosition:null};x?.(K,ee),i&&w?.(K,ee)}h(),cancelAnimationFrame(L),j=!1,V=!1,z=null,B=null,P.removeEventListener("mousemove",F),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",F),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",F),P.addEventListener("mouseup",q),P.addEventListener("touchmove",F),P.addEventListener("touchend",q)}function Qi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=Ki,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),v=s.elementFromPoint(h,m),x=v?.classList.contains(`${a}-flow__handle`)?v:d,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=Ui(void 0,x),g=x.getAttribute("data-nodeid"),b=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!g||!w)return y;const N={source:f?g:o,sourceHandle:f?b:r,target:f?o:g,targetHandle:f?r:b};y.connection=N;const P=C&&S&&(n===Ze.Strict?f&&w==="source"||!f&&w==="target":g!==o||b!==r);y.isValid=P&&l(N),y.toHandle=qi(g,w,b,u,n,!0)}return y}const Kn={onPointerDown:If,isValid:Qi};function Mf({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const b=n(),C=g.sourceEvent.ctrlKey&&Nt()?10:1,S=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,N=b[2]*Math.pow(2,S*C);t.scaleTo(N)};let v=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(v=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const b=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],S=[C[0]-v[0],C[1]-v[1]];v=C;const N=o()*Math.max(b[2],Math.log(b[2]))*(h?-1:1),k={x:b[0]-S[0]*N,y:b[1]-S[1]*N},P=[[0,0],[c,l]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},P,a)},w=Ei().on("start",x).on("zoom",f?y:null).on("zoom.wheel",d?m:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),Mn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ji=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kn=(e,t=0,n=kf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},es=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Tf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(je(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const x=he(u),y=es(u),w=f*Math.pow(2,y);o.scaleTo(n,w,x,u);return}const d=u.deltaMode===1?20:1;let h=r===Ye.Vertical?0:u.deltaX*d,m=r===Ye.Horizontal?0:u.deltaY*d;!Nt()&&u.shiftKey&&r!==Ye.Vertical&&(h=u.deltaY*d,m=0),o.translateBy(n,-(h/f)*i,-(m/f)*i,{internal:!0});const v=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,v):(e.isPanScrolling=!0,a?.(u,v)),e.panScrollTimeout=setTimeout(()=>{l?.(u,v),e.isPanScrolling=!1},150)}}function Af({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Pf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Df({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ji(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function $f({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ji(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function jf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:f}){return d=>{const h=t||n,m=o&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(je(d,`${u}-flow__node`)||je(d,`${u}-flow__edge`)||je(d,`${u}-flow__selection`)||je(d,`${u}-flow__nodesselection`)))return!0;if(!r&&!h&&!i&&!s&&!o||a||f&&!v||je(d,c)&&v||je(d,l)&&(!v||i&&v&&!t)||!o&&d.ctrlKey&&v)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!h&&!i&&!m&&v||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v||e)&&x}}function Rf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(f=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const h=Ei().extent(()=>f).scaleExtent([t,n]).translateExtent(o),m=ue(e).call(h);b({x:r.x,y:r.y,zoom:it(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const v=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(es);async function y(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).transform(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function w({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:A,panOnDrag:$,panOnScrollMode:j,panOnScrollSpeed:z,preventScrolling:V,zoomOnPinch:B,zoomOnScroll:W,zoomOnDoubleClick:Y,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:R,onTransformChange:D,connectionInProgress:F,paneClickDistance:q,selectionOnDrag:K}){M&&!l.isZoomingOrPanning&&g();const Z=A&&!J&&!M;h.clickDistance(K?1/0:!ge(q)||q<0?0:q);const U=Z?Tf({zoomPanValues:l,noWheelClassName:H,d3Selection:m,d3Zoom:h,panOnScrollMode:j,panOnScrollSpeed:z,zoomOnPinch:B,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Af({noWheelClassName:H,preventScrolling:V,d3ZoomHandler:v});m.on("wheel.zoom",U,{passive:!1});const ee=Pf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",ee);const ne=Df({zoomPanValues:l,panOnDrag:$,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:D});h.on("zoom",ne);const re=$f({zoomPanValues:l,panOnDrag:$,panOnScroll:A,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});h.on("end",re);const ae=jf({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:$,zoomOnScroll:W,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:B,userSelectionActive:M,noPanClassName:_,noWheelClassName:H,lib:R,connectionInProgress:F});h.filter(ae),Y?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){h.on("zoom",null)}async function b(H,_,I){const M=Mn(H),A=h?.constrain()(M,_,I);return A&&await y(A),A}async function C(H,_){const I=Mn(H);return await y(I,_),I}function S(H){if(m){const _=Mn(H),I=m.property("__zoom");(I.k!==H.zoom||I.x!==H.x||I.y!==H.y)&&h?.transform(m,_,null,{sync:!0})}}function N(){const H=m?Ni(m.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function k(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleTo(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}async function P(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleBy(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function L(H){h?.scaleExtent(H)}function T(H){h?.translateExtent(H)}function O(H){const _=!ge(H)||H<0?0:H;h?.clickDistance(_)}return{update:w,destroy:g,setViewport:C,setViewportConstrained:b,getViewport:N,scaleTo:k,scaleBy:P,setScaleExtent:L,setTranslateExtent:T,syncViewport:S,setClickDistance:O}}var at;(function(e){e.Line="line",e.Handle="handle"})(at||(at={}));function Hf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function ar(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function zt(e,t,n){return Math.max(0,t-e,e-n)}function cr(e,t){return e?!t:t}function Of(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:m}=n,{minWidth:v,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:g,y:b,width:C,height:S,aspectRatio:N}=e;let k=Math.floor(u?h-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const L=C+(c?-k:k),T=S+(l?-P:P),O=-i[0]*C,H=-i[1]*S;let _=zt(L,v,x),I=zt(T,y,w);if(s){let $=0,j=0;c&&k<0?$=De(g+k+O,s[0][0]):!c&&k>0&&($=$e(g+L+O,s[1][0])),l&&P<0?j=De(b+P+H,s[0][1]):!l&&P>0&&(j=$e(b+T+H,s[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(a){let $=0,j=0;c&&k>0?$=$e(g+k,a[0][0]):!c&&k<0&&($=De(g+L,a[1][0])),l&&P>0?j=$e(b+P,a[0][1]):!l&&P<0&&(j=De(b+T,a[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(r){if(u){const $=zt(L/N,y,w)*N;if(_=Math.max(_,$),s){let j=0;!c&&!l||c&&!l&&d?j=$e(b+H+L/N,s[1][1])*N:j=De(b+H+(c?k:-k)/N,s[0][1])*N,_=Math.max(_,j)}if(a){let j=0;!c&&!l||c&&!l&&d?j=De(b+L/N,a[1][1])*N:j=$e(b+(c?k:-k)/N,a[0][1])*N,_=Math.max(_,j)}}if(f){const $=zt(T*N,v,x)/N;if(I=Math.max(I,$),s){let j=0;!c&&!l||l&&!c&&d?j=$e(g+T*N+O,s[1][0])/N:j=De(g+(l?P:-P)*N+O,s[0][0])/N,I=Math.max(I,j)}if(a){let j=0;!c&&!l||l&&!c&&d?j=De(g+T*N,a[1][0])/N:j=$e(g+(l?P:-P)*N,a[0][0])/N,I=Math.max(I,j)}}}P=P+(P<0?I:-I),k=k+(k<0?_:-_),r&&(d?L>T*N?P=(cr(c,l)?-k:k)/N:k=(cr(c,l)?-P:P)*N:u?(P=k/N,l=c):(k=P*N,c=l));const M=c?g+k:g,A=l?b+P:b;return{width:C+(c?-k:k),height:S+(l?-P:P),x:i[0]*k*(c?-1:1)+M,y:i[1]*P*(l?-1:1)+A}}const ts={width:0,height:0,x:0,y:0},zf={...ts,pointerX:0,pointerY:0,aspectRatio:1};function Lf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Bf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:ar("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:m,onResizeEnd:v,shouldResize:x}){let y={...ts},w={...zf};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:ar(l)};let g,b=null,C=[],S,N,k,P=!1;const L=ui().on("start",T=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:I,nodeOrigin:M,paneDomNode:A}=n();if(g=O.get(t),!g)return;b=A?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:j}=gt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:I,containerBounds:b});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},w={...y,pointerX:$,pointerY:j,aspectRatio:y.width/y.height},S=void 0,N=qe(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(S=O.get(g.parentId)),S&&g.extent==="parent"&&(N=[[0,0],[S.measured.width,S.measured.height]]),C=[],k=void 0;for(const[z,V]of O)if(V.parentId===t&&(C.push({id:z,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const B=Lf(V,g,V.origin??M);k?k=[[Math.min(B[0][0],k[0][0]),Math.min(B[0][1],k[0][1])],[Math.max(B[1][0],k[1][0]),Math.max(B[1][1],k[1][1])]]:k=B}h?.(T,{...y})}).on("drag",T=>{const{transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I}=n(),M=gt(T.sourceEvent,{transform:O,snapGrid:H,snapToGrid:_,containerBounds:b}),A=[];if(!g)return;const{x:$,y:j,width:z,height:V}=y,B={},W=g.origin??I,{width:Y,height:G,x:J,y:R}=Of(w,s.controlDirection,M,s.boundaries,s.keepAspectRatio,W,N,k),D=Y!==z,F=G!==V,q=J!==$&&D,K=R!==j&&F;if(!q&&!K&&!D&&!F)return;if((q||K||W[0]===1||W[1]===1)&&(B.x=q?J:y.x,B.y=K?R:y.y,y.x=B.x,y.y=B.y,C.length>0)){const ne=J-$,re=R-j;for(const ae of C)ae.position={x:ae.position.x-ne+W[0]*(Y-z),y:ae.position.y-re+W[1]*(G-V)},A.push(ae)}if((D||F)&&(B.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:y.width,B.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:y.height,y.width=B.width,y.height=B.height),S&&g.expandParent){const ne=W[0]*(B.width??0);B.x&&B.x<ne&&(y.x=ne,w.x=w.x-(B.x-ne));const re=W[1]*(B.height??0);B.y&&B.y<re&&(y.y=re,w.y=w.y-(B.y-re))}const Z=Hf({width:y.width,prevWidth:z,height:y.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...y,direction:Z};x?.(T,U)!==!1&&(P=!0,m?.(T,U),o(B,A))}).on("end",T=>{P&&(v?.(T,{...y}),r?.({...y}),P=!1)});i.call(L)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var lr;function Vf(){if(lr)return Dn;lr=1;var e=Gr();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(f,d){var h=d(),m=o({inst:{value:h,getSnapshot:d}}),v=m[0].inst,x=m[1];return i(function(){v.value=h,v.getSnapshot=d,c(v)&&x({inst:v})},[f,h,d]),r(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({inst:v})})},[f]),s(h),h}function c(f){var d=f.getSnapshot;f=f.value;try{var h=d();return!n(f,h)}catch{return!0}}function l(f,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var ur;function Ff(){return ur||(ur=1,Pn.exports=Vf()),Pn.exports}var dr;function Yf(){if(dr)return An;dr=1;var e=Gr(),t=Ff();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,f,d,h){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function y(S){if(!w){if(w=!0,g=S,S=d(S),h!==void 0&&v.hasValue){var N=v.value;if(h(N,S))return b=N}return b=S}if(N=b,o(g,S))return N;var k=d(S);return h!==void 0&&h(N,k)?(g=S,N):(g=S,b=k)}var w=!1,g,b,C=f===void 0?null:f;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,f,d,h]);var x=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},An}var fr;function Xf(){return fr||(fr=1,Tn.exports=Yf()),Tn.exports}var Wf=Xf();const Zf=qa(Wf),Gf={},hr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Gf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},qf=e=>e?hr(e):hr,{useDebugValue:Uf}=Ua,{useSyncExternalStoreWithSelector:Kf}=Zf,Qf=e=>e;function ns(e,t=Qf,n){const o=Kf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Uf(o),o}const pr=(e,t)=>{const n=qf(e),o=(r,i=t)=>ns(n,r,i);return Object.assign(o,n),o},Jf=(e,t)=>e?pr(e,t):pr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=E.createContext(null),eh=gn.Provider,os=ye.error001("react");function te(e,t){const n=E.useContext(gn);if(n===null)throw new Error(os);return ns(n,e,t)}function oe(){const e=E.useContext(gn);if(e===null)throw new Error(os);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},th={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},rs="react-flow__node-desc",is="react-flow__edge-desc",nh="react-flow__aria-live",oh=e=>e.ariaLiveMessage,rh=e=>e.ariaLabelConfig;function ih({rfId:e}){const t=te(oh);return p.jsx("div",{id:`${nh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:th,children:t})}function sh({rfId:e,disableKeyboardA11y:t}){const n=te(rh);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${rs}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${is}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&p.jsx(ih,{rfId:e})]})}const Ke=E.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return p.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ke.displayName="Panel";const mr="https://reactflow.dev?utm_source=attribution";function ah({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(Ke,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${mr}`,children:p.jsx("a",{href:mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ch=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function lh(e,t){return ie(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&ie(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function uh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:o}=te(ch,lh);return E.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const dh=e=>!!e.onSelectionChangeHandlers;function fh({onSelectionChange:e}){const t=te(dh);return e||t?p.jsx(uh,{onSelectionChange:e}):null}const ss=[0,0],hh={x:0,y:0,zoom:1},ph=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],yr=[...ph,"rfId"],gh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),xr={translateExtent:bt,nodeOrigin:ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function mh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(gh,ie),l=oe();E.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xr,a()}),[]);const u=E.useRef(xr);return E.useEffect(()=>{for(const f of yr){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:Jd(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}u.current=e},yr.map(f=>e[f])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function yh(e){const[t,n]=E.useState(e==="system"?null:e);return E.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:wr()?.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function Et(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,o]=E.useState(!1),r=E.useRef(!1),i=E.useRef(new Set([])),[s,a]=E.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
1
+ import{r as Gr,g as qa,R as Ua,a as E,j as p,u as ce,b as Q,i as Vt,S as Ka,f as Qa,c as Ja,d as ec,n as tc,e as nc,w as oc,h as rc,k as qr,l as ic,m as sc,o as ac,p as cc,q as lc,s as Ct,t as uc}from"./index-Sch70vBs.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var dc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function fc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=fc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=hc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Ao(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ao(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function hc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Ao(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=dc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zn="http://www.w3.org/1999/xhtml";const Po={svg:"http://www.w3.org/2000/svg",xhtml:zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Po.hasOwnProperty(t)?{space:Po[t],local:e}:e}function pc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function gc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=cn(e);return(t.local?gc:pc)(t)}function mc(){}function oo(e){return e==null?mc:function(){return this.querySelector(e)}}function yc(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function xc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wc(){return[]}function Kr(e){return e==null?wc:function(){return this.querySelectorAll(e)}}function vc(e){return function(){return xc(e.apply(this,arguments))}}function bc(e){typeof e=="function"?e=vc(e):e=Kr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function Qr(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var _c=Array.prototype.find;function Sc(e){return function(){return _c.call(this.children,e)}}function Nc(){return this.firstElementChild}function Ec(e){return this.select(e==null?Nc:Sc(typeof e=="function"?e:Jr(e)))}var Cc=Array.prototype.filter;function Ic(){return Array.from(this.children)}function Mc(e){return function(){return Cc.call(this.children,e)}}function kc(e){return this.selectAll(e==null?Ic:Mc(typeof e=="function"?e:Jr(e)))}function Tc(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function ei(e){return new Array(e.length)}function Ac(){return new de(this._enter||this._groups.map(ei),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Pc(e){return function(){return e}}function Dc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function $c(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(d[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?r[a]=c:l.set(h,c));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(o[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new qt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function jc(e){return e.__data__}function Rc(e,t){if(!arguments.length)return Array.from(this,jc);var n=t?$c:Dc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Pc(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],f=r[l],d=f.length,h=Hc(e.call(u,u&&u.__data__,l,o)),m=h.length,v=a[l]=new Array(m),x=s[l]=new Array(m),y=c[l]=new Array(d);n(u,f,v,x,y,h,t);for(var w=0,g=0,b,C;w<m;++w)if(b=v[w]){for(w>=g&&(g=w+1);!(C=x[g])&&++g<m;);b._next=C||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Hc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Oc(){return new de(this._exit||this._groups.map(ei),this._parents)}function zc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Lc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],f=l.length,d=a[c]=new Array(f),h,m=0;m<f;++m)(h=l[m]||u[m])&&(d[m]=h);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Bc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Vc(e){e||(e=Fc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function Fc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Yc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Xc(){return Array.from(this)}function Wc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function Zc(){let e=0;for(const t of this)++e;return e}function Gc(){return!this.node()}function qc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Uc(e){return function(){this.removeAttribute(e)}}function Kc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qc(e,t){return function(){this.setAttribute(e,t)}}function Jc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tl(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 nl(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Kc:Uc:typeof t=="function"?n.local?tl:el:n.local?Jc:Qc)(n,t))}function ti(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ol(e){return function(){this.style.removeProperty(e)}}function rl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function il(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function sl(e,t,n){return arguments.length>1?this.each((t==null?ol:typeof t=="function"?il:rl)(e,t,n??"")):ot(this.node(),e)}function ot(e,t){return e.style.getPropertyValue(t)||ti(e).getComputedStyle(e,null).getPropertyValue(t)}function al(e){return function(){delete this[e]}}function cl(e,t){return function(){this[e]=t}}function ll(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ul(e,t){return arguments.length>1?this.each((t==null?al:typeof t=="function"?ll:cl)(e,t)):this.node()[e]}function ni(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new oi(e)}function oi(e){this._node=e,this._names=ni(e.getAttribute("class")||"")}oi.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 ri(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ii(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function dl(e){return function(){ri(this,e)}}function fl(e){return function(){ii(this,e)}}function hl(e,t){return function(){(t.apply(this,arguments)?ri:ii)(this,e)}}function pl(e,t){var n=ni(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?hl:t?dl:fl)(n,t))}function gl(){this.textContent=""}function ml(e){return function(){this.textContent=e}}function yl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xl(e){return arguments.length?this.each(e==null?gl:(typeof e=="function"?yl:ml)(e)):this.node().textContent}function wl(){this.innerHTML=""}function vl(e){return function(){this.innerHTML=e}}function bl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _l(e){return arguments.length?this.each(e==null?wl:(typeof e=="function"?bl:vl)(e)):this.node().innerHTML}function Sl(){this.nextSibling&&this.parentNode.appendChild(this)}function Nl(){return this.each(Sl)}function El(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cl(){return this.each(El)}function Il(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ml(){return null}function kl(e,t){var n=typeof e=="function"?e:Ur(e),o=t==null?Ml:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Tl(){var e=this.parentNode;e&&e.removeChild(this)}function Al(){return this.each(Tl)}function Pl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $l(e){return this.select(e?Dl:Pl)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Rl(e){return function(t){e.call(this,t,this.__data__)}}function Hl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Ol(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function zl(e,t,n){return function(){var o=this.__on,r,i=Rl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Ll(e,t,n){var o=Hl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?zl:Ol,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function si(e,t,n){var o=ti(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Bl(e,t){return function(){return si(this,e,t)}}function Vl(e,t){return function(){return si(this,e,t.apply(this,arguments))}}function Fl(e,t){return this.each((typeof t=="function"?Vl:Bl)(e,t))}function*Yl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ai=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ai)}function Xl(){return this}de.prototype=It.prototype={constructor:de,select:yc,selectAll:bc,selectChild:Ec,selectChildren:kc,filter:Tc,data:Rc,enter:Ac,exit:Oc,join:zc,merge:Lc,selection:Xl,order:Bc,sort:Vc,call:Yc,nodes:Xc,node:Wc,size:Zc,empty:Gc,each:qc,attr:nl,style:sl,property:ul,classed:pl,text:xl,html:_l,raise:Nl,lower:Cl,append:Il,insert:kl,remove:Al,clone:$l,datum:jl,on:Ll,dispatch:Fl,[Symbol.iterator]:Yl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ai)}function Wl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Wl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Zl={passive:!1},yt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function ci(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",tt,yt);"onselectstart"in t?n.on("selectstart.drag",tt,yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function li(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",tt,yt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function Ln(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Ln.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Gl(e){return!e.ctrlKey&&!e.button}function ql(){return this.parentNode}function Ul(e,t){return t??{x:e.x,y:e.y}}function Kl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ui(){var e=Gl,t=ql,n=Ul,o=Kl,r={},i=an("start","drag","end"),s=0,a,c,l,u,f=0;function d(b){b.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,Zl).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(b,C){if(!(u||!e.call(this,b,C))){var S=g(this,t.call(this,b,C),b,C,"mouse");S&&(ue(b.view).on("mousemove.drag",m,yt).on("mouseup.drag",v,yt),ci(b.view),Sn(b),l=!1,a=b.clientX,c=b.clientY,S("start",b))}}function m(b){if(tt(b),!l){var C=b.clientX-a,S=b.clientY-c;l=C*C+S*S>f}r.mouse("drag",b)}function v(b){ue(b.view).on("mousemove.drag mouseup.drag",null),li(b.view,l),tt(b),r.mouse("end",b)}function x(b,C){if(e.call(this,b,C)){var S=b.changedTouches,N=t.call(this,b,C),k=S.length,P,L;for(P=0;P<k;++P)(L=g(this,N,b,C,S[P].identifier,S[P]))&&(Sn(b),L("start",b,S[P]))}}function y(b){var C=b.changedTouches,S=C.length,N,k;for(N=0;N<S;++N)(k=r[C[N].identifier])&&(tt(b),k("drag",b,C[N]))}function w(b){var C=b.changedTouches,S=C.length,N,k;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),N=0;N<S;++N)(k=r[C[N].identifier])&&(Sn(b),k("end",b,C[N]))}function g(b,C,S,N,k,P){var L=i.copy(),T=he(P||S,C),O,H,_;if((_=n.call(b,new Ln("beforestart",{sourceEvent:S,target:d,identifier:k,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:L}),N))!=null)return O=_.x-T[0]||0,H=_.y-T[1]||0,function I(M,A,$){var j=T,z;switch(M){case"start":r[k]=I,z=s++;break;case"end":delete r[k],--s;case"drag":T=he($||A,C),z=s;break}L.call(M,b,new Ln(M,{sourceEvent:A,subject:_,target:d,identifier:k,active:z,x:T[0]+O,y:T[1]+H,dx:T[0]-j[0],dy:T[1]-j[1],dispatch:L}),N)}}return d.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Dt(!!b),d):e},d.container=function(b){return arguments.length?(t=typeof b=="function"?b:Dt(b),d):t},d.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Dt(b),d):n},d.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Dt(!!b),d):o},d.on=function(){var b=i.on.apply(i,arguments);return b===i?d:b},d.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,d):Math.sqrt(f)},d}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Mt(){}var xt=.7,Ut=1/xt,nt="\\s*([+-]?\\d+)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ql=/^#([0-9a-f]{3,8})$/,Jl=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),eu=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),tu=new RegExp(`^rgba\\(${nt},${nt},${nt},${wt}\\)$`),nu=new RegExp(`^rgba\\(${Se},${Se},${Se},${wt}\\)$`),ou=new RegExp(`^hsl\\(${wt},${Se},${Se}\\)$`),ru=new RegExp(`^hsla\\(${wt},${Se},${Se},${wt}\\)$`),Do={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};io(Mt,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:iu,formatHsl:su,formatRgb:jo,toString:jo});function $o(){return this.rgb().formatHex()}function iu(){return this.rgb().formatHex8()}function su(){return fi(this).formatHsl()}function jo(){return this.rgb().formatRgb()}function Xe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ql.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ro(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$t(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$t(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=Jl.exec(e))?new le(t[1],t[2],t[3],1):(t=eu.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tu.exec(e))?$t(t[1],t[2],t[3],t[4]):(t=nu.exec(e))?$t(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ou.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=ru.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):Do.hasOwnProperty(e)?Ro(Do[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ro(e){return new le(e>>16&255,e>>8&255,e&255,1)}function $t(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function au(e){return e instanceof Mt||(e=Xe(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?au(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Fe(this.r),Fe(this.g),Fe(this.b),Kt(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:Ho,formatHex:Ho,formatHex8:cu,formatRgb:Oo,toString:Oo}));function Ho(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function cu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Fe(this.r)}, ${Fe(this.g)}, ${Fe(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Fe(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function fi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof Mt||(e=Xe(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function lu(e,t,n,o){return arguments.length===1?fi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,lu,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new pe(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,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(Nn(e>=240?e-240:e+120,r,o),Nn(e,r,o),Nn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Lo(this.h),jt(this.s),jt(this.l),Kt(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=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Lo(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lo(e){return e=(e||0)%360,e<0?e+360:e}function jt(e){return Math.max(0,Math.min(1,e||0))}function Nn(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 so=e=>()=>e;function uu(e,t){return function(n){return e+n*t}}function du(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function fu(e){return(e=+e)==1?hi:function(t,n){return n-t?du(t,n,e):so(isNaN(t)?n:t)}}function hi(e,t){var n=t-e;return n?uu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=fu(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=hi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function hu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function pu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function gu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=pt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function mu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function _e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=pt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Vn.source,"g");function xu(e){return function(){return e}}function wu(e){return function(t){return e(t)+""}}function pi(e,t){var n=Vn.lastIndex=En.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=En.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:_e(o,r)})),n=En.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?wu(c[0].x):xu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function pt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?_e:n==="string"?(o=Xe(t))?(t=o,Qt):pi:t instanceof Xe?Qt:t instanceof Date?mu:pu(t)?hu:Array.isArray(t)?gu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yu:_e)(e,t)}var Bo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Bo,skewX:Math.atan(c)*Bo,scaleX:s,scaleY:a}}var Rt;function vu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function bu(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push("translate(",null,t,null,n);m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:_e(l,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(l,u,f,d){l!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:_e(l,u)}):u&&f.push(r(f)+"skewX("+u+o)}function c(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push(r(h)+"scale(",null,",",null,")");m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(h){for(var m=-1,v=d.length,x;++m<v;)f[(x=d[m]).i]=x.x(h);return f.join("")}}}var _u=mi(vu,"px, ","px)","deg)"),Su=mi(bu,", ",")",")"),Nu=1e-12;function Vo(e){return((e=Math.exp(e))+1/e)/2}function Eu(e){return((e=Math.exp(e))-1/e)/2}function Cu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],h=u-a,m=f-c,v=h*h+m*m,x,y;if(v<Nu)y=Math.log(d/l)/t,x=function(N){return[a+N*h,c+N*m,l*Math.exp(t*N*y)]};else{var w=Math.sqrt(v),g=(d*d-l*l+o*v)/(2*l*n*w),b=(d*d-l*l-o*v)/(2*d*n*w),C=Math.log(Math.sqrt(g*g+1)-g),S=Math.log(Math.sqrt(b*b+1)-b);y=(S-C)/t,x=function(N){var k=N*y,P=Vo(C),L=l/(n*w)*(P*Cu(t*k+C)-Eu(C));return[a+L*h,c+L*m,l*P/Vo(t*k+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var rt=0,ft=0,lt=0,yi=1e3,Jt,ht,en=0,We=0,ln=0,vt=typeof performance=="object"&&performance.now?performance:Date,xi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return We||(xi(Iu),We=vt.now()+ln)}function Iu(){We=0}function tn(){this._call=this._time=this._next=null}tn.prototype=wi.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&&ht!==this&&(ht?ht._next=this:Jt=this,ht=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function wi(e,t,n){var o=new tn;return o.restart(e,t,n),o}function Mu(){ao(),++rt;for(var e=Jt,t;e;)(t=We-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rt}function Fo(){We=(en=vt.now())+ln,rt=ft=0;try{Mu()}finally{rt=0,Tu(),We=0}}function ku(){var e=vt.now(),t=e-en;t>yi&&(ln-=t,en=e)}function Tu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ht=e,Yn(o)}function Yn(e){if(!rt){ft&&(ft=clearTimeout(ft));var t=e-We;t>24?(e<1/0&&(ft=setTimeout(Fo,e-vt.now()-ln)),lt&&(lt=clearInterval(lt))):(lt||(en=vt.now(),lt=setInterval(ku,yi)),rt=1,xi(Fo))}}function Yo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Au=an("start","end","cancel","interrupt"),Pu=[],vi=0,Xo=1,Xn=2,Xt=3,Wo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Du(e,n,{name:t,index:o,group:r,on:Au,tween:Pu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vi})}function co(e,t){var n=xe(e,t);if(n.state>vi)throw new Error("too late; already scheduled");return n}function Ne(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Du(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=wi(i,0,n.time);function i(l){n.state=Xo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,h;if(n.state!==Xo)return c();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Xt)return Yo(s);h.state===Wo?(h.state=Wt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Wt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(Yo(function(){n.state===Xt&&(n.state=Wo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function $u(e){return this.each(function(){Zt(this,e)})}function ju(e,t){var n,o;return function(){var r=Ne(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Ru(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ne(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Hu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?ju:Ru)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Ne(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function bi(e,t){var n;return(typeof t=="number"?_e:t instanceof Xe?Qt:(n=Xe(t))?(t=n,Qt):pi)(e,t)}function Ou(e){return function(){this.removeAttribute(e)}}function zu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Lu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Bu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Vu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Fu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Yu(e,t){var n=cn(e),o=n==="transform"?Su:bi;return this.attrTween(e,typeof t=="function"?(n.local?Fu:Vu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?zu:Ou)(n):(n.local?Bu:Lu)(n,o,t))}function Xu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Zu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Wu(e,i)),n}return r._value=t,r}function Gu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Xu(e,i)),n}return r._value=t,r}function qu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?Zu:Gu)(o,t))}function Uu(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Ku(e,t){return t=+t,function(){co(this,e).delay=t}}function Qu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uu:Ku)(t,e)):xe(this.node(),t).delay}function Ju(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function ed(e,t){return t=+t,function(){Ne(this,e).duration=t}}function td(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ju:ed)(t,e)):xe(this.node(),t).duration}function nd(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function od(e){var t=this._id;return arguments.length?this.each(nd(t,e)):xe(this.node(),t).ease}function rd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ne(this,e).ease=n}}function id(e){if(typeof e!="function")throw new Error;return this.each(rd(this._id,e))}function sd(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function ad(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=c[h]||l[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function cd(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 ld(e,t,n){var o,r,i=cd(t)?co:Ne;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ud(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(ld(n,e,t))}function dd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fd(){return this.on("end.remove",dd(this._id))}function hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,un(l[d],t,n,d,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Kr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),h,m=xe(u,n),v=0,x=d.length;v<x;++v)(h=d[v])&&un(h,t,n,v,d,m);i.push(d),s.push(u)}return new Pe(i,s,t,n)}var gd=It.prototype.constructor;function md(){return new gd(this._groups,this._parents)}function yd(e,t){var n,o,r;return function(){var i=ot(this,e),s=(this.style.removeProperty(e),ot(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function _i(e){return function(){this.style.removeProperty(e)}}function xd(e,t,n){var o,r=n+"",i;return function(){var s=ot(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function wd(e,t,n){var o,r,i;return function(){var s=ot(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),ot(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function vd(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Ne(this,e),l=c.on,u=c.value[i]==null?a||(a=_i(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function bd(e,t,n){var o=(e+="")=="transform"?_u:bi;return t==null?this.styleTween(e,yd(e,o)).on("end.style."+e,_i(e)):typeof t=="function"?this.styleTween(e,wd(e,o,lo(this,"style."+e,t))).each(vd(this._id,e)):this.styleTween(e,xd(e,o,t),n).on("end.style."+e,null)}function _d(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Sd(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&_d(e,s,n)),o}return i._value=t,i}function Nd(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Sd(e,t,n??""))}function Ed(e){return function(){this.textContent=e}}function Cd(e){return function(){var t=e(this);this.textContent=t??""}}function Id(e){return this.tween("text",typeof e=="function"?Cd(lo(this,"text",e)):Ed(e==null?"":e+""))}function Md(e){return function(t){this.textContent=e.call(this,t)}}function kd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Md(r)),t}return o._value=e,o}function Td(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,kd(e))}function Ad(){for(var e=this._name,t=this._id,n=Si(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Pd(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Ne(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Dd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Si(){return++Dd}var ke=It.prototype;Pe.prototype={constructor:Pe,select:hd,selectAll:pd,selectChild:ke.selectChild,selectChildren:ke.selectChildren,filter:sd,merge:ad,selection:md,transition:Ad,call:ke.call,nodes:ke.nodes,node:ke.node,size:ke.size,empty:ke.empty,each:ke.each,on:ud,attr:Yu,attrTween:qu,style:bd,styleTween:Nd,text:Id,textTween:Td,remove:fd,tween:Hu,delay:Qu,duration:td,ease:od,easeVarying:id,end:Pd,[Symbol.iterator]:ke[Symbol.iterator]};function $d(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jd={time:null,delay:0,duration:250,ease:$d};function Rd(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 Hd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Si(),(n=jd).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||Rd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=$u;It.prototype.transition=Hd;const Ht=e=>()=>e;function Od(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var dn=new Te(1,0,0);Ni.prototype=Te.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function zd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ld(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Zo(){return this.__zoom||dn}function Bd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Vd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=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(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ei(){var e=zd,t=Ld,n=Fd,o=Bd,r=Vd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,f,d,h=500,m=150,v=0,x=10;function y(_){_.property("__zoom",Zo).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",L).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,M,A){var $=_.selection?_.selection():_;$.property("__zoom",Zo),_!==$?C(_,I,M,A):$.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,M,A){y.scaleTo(_,function(){var $=this.__zoom.k,j=typeof I=="function"?I.apply(this,arguments):I;return $*j},M,A)},y.scaleTo=function(_,I,M,A){y.transform(_,function(){var $=t.apply(this,arguments),j=this.__zoom,z=M==null?b($):typeof M=="function"?M.apply(this,arguments):M,V=j.invert(z),B=typeof I=="function"?I.apply(this,arguments):I;return n(g(w(j,B),z,V),$,s)},M,A)},y.translateBy=function(_,I,M,A){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,A)},y.translateTo=function(_,I,M,A,$){y.transform(_,function(){var j=t.apply(this,arguments),z=this.__zoom,V=A==null?b(j):typeof A=="function"?A.apply(this,arguments):A;return n(dn.translate(V[0],V[1]).scale(z.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof M=="function"?-M.apply(this,arguments):-M),j,s)},A,$)};function w(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new Te(I,_.x,_.y)}function g(_,I,M){var A=I[0]-M[0]*_.k,$=I[1]-M[1]*_.k;return A===_.x&&$===_.y?_:new Te(_.k,A,$)}function b(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function C(_,I,M,A){_.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var $=this,j=arguments,z=S($,j).event(A),V=t.apply($,j),B=M==null?b(V):typeof M=="function"?M.apply($,j):M,W=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=$.__zoom,G=typeof I=="function"?I.apply($,j):I,J=c(Y.invert(B).concat(W/Y.k),G.invert(B).concat(W/G.k));return function(R){if(R===1)R=G;else{var D=J(R),F=W/D[2];R=new Te(F,B[0]-D[0]*F,B[1]-D[1]*F)}z.zoom(null,R)}})}function S(_,I,M){return!M&&_.__zooming||new N(_,I)}function N(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,I),this.taps=0}N.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=ue(this.that).datum();l.call(_,this.that,new Od(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function k(_,...I){if(!e.apply(this,arguments))return;var M=S(this,I).event(_),A=this.__zoom,$=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),j=he(_);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=A.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if(A.k===$)return;M.mouse=[j,A.invert(j)],Zt(this),M.start()}ut(_),M.wheel=setTimeout(z,m),M.zoom("mouse",n(g(w(A,$),M.mouse[0],M.mouse[1]),M.extent,s));function z(){M.wheel=null,M.end()}}function P(_,...I){if(d||!e.apply(this,arguments))return;var M=_.currentTarget,A=S(this,I,!0).event(_),$=ue(_.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),j=he(_,M),z=_.clientX,V=_.clientY;ci(_.view),Cn(_),A.mouse=[j,this.__zoom.invert(j)],Zt(this),A.start();function B(Y){if(ut(Y),!A.moved){var G=Y.clientX-z,J=Y.clientY-V;A.moved=G*G+J*J>v}A.event(Y).zoom("mouse",n(g(A.that.__zoom,A.mouse[0]=he(Y,M),A.mouse[1]),A.extent,s))}function W(Y){$.on("mousemove.zoom mouseup.zoom",null),li(Y.view,A.moved),ut(Y),A.event(Y).end()}}function L(_,...I){if(e.apply(this,arguments)){var M=this.__zoom,A=he(_.changedTouches?_.changedTouches[0]:_,this),$=M.invert(A),j=M.k*(_.shiftKey?.5:2),z=n(g(w(M,j),A,$),t.apply(this,I),s);ut(_),a>0?ue(this).transition().duration(a).call(C,z,A,_):ue(this).call(y.transform,z,A,_)}}function T(_,...I){if(e.apply(this,arguments)){var M=_.touches,A=M.length,$=S(this,I,_.changedTouches.length===A).event(_),j,z,V,B;for(Cn(_),z=0;z<A;++z)V=M[z],B=he(V,this),B=[B,this.__zoom.invert(B),V.identifier],$.touch0?!$.touch1&&$.touch0[2]!==B[2]&&($.touch1=B,$.taps=0):($.touch0=B,j=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),j&&($.taps<2&&(f=B[0],u=setTimeout(function(){u=null},h)),Zt(this),$.start())}}function O(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z,V,B;for(ut(_),j=0;j<$;++j)z=A[j],V=he(z,this),M.touch0&&M.touch0[2]===z.identifier?M.touch0[0]=V:M.touch1&&M.touch1[2]===z.identifier&&(M.touch1[0]=V);if(z=M.that.__zoom,M.touch1){var W=M.touch0[0],Y=M.touch0[1],G=M.touch1[0],J=M.touch1[1],R=(R=G[0]-W[0])*R+(R=G[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;z=w(z,Math.sqrt(R/D)),V=[(W[0]+G[0])/2,(W[1]+G[1])/2],B=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(M.touch0)V=M.touch0[0],B=M.touch0[1];else return;M.zoom("touch",n(g(z,V,B),M.extent,s))}}function H(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z;for(Cn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),j=0;j<$;++j)z=A[j],M.touch0&&M.touch0[2]===z.identifier?delete M.touch0:M.touch1&&M.touch1[2]===z.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(z=he(z,this),Math.hypot(f[0]-z[0],f[1]-z[1])<x)){var V=ue(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],y):[i[0],i[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,y):Math.sqrt(v)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ci=["Enter"," ","Escape"],Ii={"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 Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Ye;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ye||(Ye={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const Mi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Re;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Re||(Re={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Go={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ki(e){return e===null?null:e?"valid":"invalid"}const Ti=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Yd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:o}=we(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Xd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):uo(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,fn(r,on(a,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?hn(o):{x:0,y:0,width:0,height:0}},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:h,selectable:m=!0,hidden:v=!1}=d;if(s&&!m||v)continue;const x=h.width??d.width??d.initialWidth??0,y=h.height??d.height??d.initialHeight??0,{x:w,y:g}=d.internals.positionAbsolute,b=$i(a,c,l,u,w,g,x,y),C=x*y,S=i&&b>0;(!d.internals.handleBounds||S||b>=C||d.dragging)&&f.push(d)}return f},Wd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Zd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=we(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function Gd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=Zd(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const{width:h,height:m}=we(a);h&&m&&(f=[[c,l],[c+h,l+m]])}else a&&qe(s.extent)&&(f=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=qe(f)?Ge(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:d.x-c+(s.measured.width??0)*u[0],y:d.y-l+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function qd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),m=!h&&d.parentId&&s.find(v=>v.id===d.parentId);(h||m)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),u=Wd(s,c);for(const d of c)a.has(d.id)&&!u.find(m=>m.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const it=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:it(e.x,t[0][0],t[1][0]-(n?.width??0)),y:it(e.y,t[0][1],t[1][1]-(n?.height??0))});function Pi(e,t,n){const{width:o,height:r}=we(n),{x:i,y:s}=n.internals.positionAbsolute;return Ge(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?it(Math.abs(e-t),1,t)/t:e>n?-it(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),St=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Di=(e,t)=>hn(fn(Zn(e),Zn(t))),$i=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>$i(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Uo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ji=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},st=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Qe(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(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ud(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Qe(e,n),r=Qe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Qe(e.top??e.y??0,n),r=Qe(e.bottom??e.y??0,n),i=Qe(e.left??e.x??0,t),s=Qe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Kd(e,t,n,o,r,i){const{x:s,y:a}=st(e,[t,n,o]),{x:c,y:l}=st({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,f=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const po=(e,t,n,o,r,i)=>{const s=Ud(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=it(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,m=n/2-d*u,v=Kd(e,h,m,u,t,n),x={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function qe(e){return e!=null&&e!=="parent"}function we(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ri(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Hi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ko(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Qd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Jd(e){return{...Ii,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Oi=e=>e?.getRootNode?.()||window?.document,ef=["INPUT","SELECT","TEXTAREA"];function zi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ef.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Li=e=>"clientX"in e,me=(e,t)=>{const n=Li(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Ot(t-o,i),n];case X.Right:return[t+Ot(o-t,i),n];case X.Top:return[t,n-Ot(n-r,i)];case X.Bottom:return[t,n+Ot(r-n,i)]}}function Vi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Jo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=Jo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,m]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,f,d,h,m]}function Fi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function tf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function nf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const of=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,rf=(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)),sf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||of;let r;return Ti(e)?r={...e}:r={...e,id:o(e)},rf(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Fi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const er={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},af=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=er[t],c=er[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=af({source:l,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let m=[],v,x;const y={x:0,y:0},w={x:0,y:0},[,,g,b]=Fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(v=r.x??l.x+(u.x-l.x)*s,x=r.y??(l.y+u.y)/2):(v=r.x??(l.x+u.x)/2,x=r.y??l.y+(u.y-l.y)*s);const k=[{x:v,y:l.y},{x:v,y:u.y}],P=[{x:l.x,y:x},{x:u.x,y:x}];a[d]===h?m=d==="x"?k:P:m=d==="x"?P:k}else{const k=[{x:l.x,y:u.y}],P=[{x:u.x,y:l.y}];if(d==="x"?m=a.x===h?P:k:m=a.y===h?k:P,t===o){const _=Math.abs(e[d]-n[d]);if(_<=i){const I=Math.min(i-1,i-_);a[d]===h?y[d]=(l[d]>e[d]?-1:1)*I:w[d]=(u[d]>n[d]?-1:1)*I}}if(t!==o){const _=d==="x"?"y":"x",I=a[d]===c[_],M=l[_]>u[_],A=l[_]<u[_];(a[d]===1&&(!I&&M||I&&A)||a[d]!==1&&(!I&&A||I&&M))&&(m=d==="x"?k:P)}const L={x:l.x+y.x,y:l.y+y.y},T={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(L.x-m[0].x),Math.abs(T.x-m[0].x)),H=Math.max(Math.abs(L.y-m[0].y),Math.abs(T.y-m[0].y));O>=H?(v=(L.x+T.x)/2,x=m[0].y):(v=m[0].x,x=(L.y+T.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},S={x:u.x+w.x,y:u.y+w.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],v,x,g,b]}function lf(e,t,n,o){const r=Math.min(tr(e,t)/2,tr(t,n)/2,o),{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 l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[f,d,h,m,v]=cf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let x=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)x+=lf(f[y-1],f[y],f[y+1],s);return x+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[x,d,h,m,v]}function nr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function uf(e){const{sourceNode:t,targetNode:n}=e;if(!nr(t)||!nr(n))return null;const o=t.internals.handleBounds||or(t.handles),r=n.internals.handleBounds||or(n.handles),i=rr(o?.source??[],e.sourceHandle),s=rr(e.connectionMode===Ze.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=Ue(t,i,a),u=Ue(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function or(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Ue(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??we(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function rr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function df(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=qn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Xi=1e3,ff=10,mo={nodeOrigin:[0,0],nodeExtent:bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function pf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=kt(r,o.nodeOrigin),s=qe(r.extent)?r.extent:o.nodeExtent,a=Ge(i,s,we(r));r.internals.positionAbsolute=a}}function gf(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function Un(e,t,n,o={}){const r=yo(hf,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Xi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=kt(u,r.nodeOrigin),h=qe(u.extent)?u.extent:r.nodeExtent,m=Ge(d,h,we(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:gf(u,f),z:Wi(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&wo(f,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mf(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 wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*ff),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xo(c)?Xi:0,{x:d,y:h,z:m}=yf(e,u,s,a,f,c),{positionAbsolute:v}=e.internals,x=d!==v.x||h!==v.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:d,y:h}:v,z:m}})}function Wi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function yf(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=we(e),l=kt(e,n),u=qe(e.extent)?Ge(l,e.extent,c):l;let f=Ge({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(f=Pi(f,c,t));const d=Wi(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??St(a),l=Di(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=we(a),f=a.origin??o,d=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,h=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,m=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),x=(m-u.width)*f[0],y=(v-u.height)*f[1];(d>0||h>0||x||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-d+x,y:a.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(g=>g.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+d,y:w.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(d?f[0]*d-x:0),height:v+(h?f[1]*h-y:0)}})}),r}function xf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const v=go(h.nodeElement),x=m.measured.width!==v.width||m.measured.height!==v.height;if(!!(v.width&&v.height&&(x||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),g=qe(m.extent)?m.extent:i;let{positionAbsolute:b}=m.internals;if(m.parentId&&m.extent==="parent"){const S=t.get(m.parentId);S&&(b=Pi(b,v,S))}else g&&(b=Ge(b,g,v));const C={...m,measured:v,internals:{...m.internals,positionAbsolute:b,handleBounds:{source:Qo("source",h.nodeElement,w,f,m.id),target:Qo("target",h.nodeElement,w,f,m.id)}}};t.set(m.id,C),m.parentId&&wo(C,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:v}),m.expandParent&&m.parentId&&d.push({id:m.id,parentId:m.parentId,rect:St(C,r)}))}}if(d.length>0){const h=vo(d,t,n,r);l.push(...h)}return{changes:l,updatedInternals:c}}async function wf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ir(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function Zi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;ir("source",c,u,e,r,s),ir("target",c,l,e,i,a),t.set(o.id,o)}}function Gi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Gi(n,t):!1}function sr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function vf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Gi(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function bf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _f({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,h=!1,m=!1,v=null;function x({noDragClassName:w,handleSelector:g,domNode:b,isSelectable:C,nodeId:S,nodeClickDistance:N=0}){d=ue(b);function k({x:O,y:H}){const{nodeLookup:_,nodeExtent:I,snapGrid:M,snapToGrid:A,nodeOrigin:$,onNodeDrag:j,onSelectionDrag:z,onError:V,updateNodePositions:B}=t();i={x:O,y:H};let W=!1;const Y=a.size>1,G=Y&&I?Zn(Tt(a)):null,J=Y&&A?bf({dragItems:a,snapGrid:M,x:O,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:O-D.distance.x,y:H-D.distance.y};A&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,M));let q=null;if(Y&&I&&!D.extent&&G){const{positionAbsolute:U}=D.internals,ee=U.x-G.x+I[0][0],ne=U.x+D.measured.width-G.x2+I[1][0],re=U.y-G.y+I[0][1],ae=U.y+D.measured.height-G.y2+I[1][1];q=[[ee,re],[ne,ae]]}const{position:K,positionAbsolute:Z}=Ai({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:q||I,nodeOrigin:$,onError:V});W=W||D.position.x!==K.x||D.position.y!==K.y,D.position=K,D.internals.positionAbsolute=Z}if(m=m||W,!!W&&(B(a,!0),v&&(o||j||!S&&z))){const[R,D]=In({nodeId:S,dragItems:a,nodeLookup:_});o?.(v,a,R,D),j?.(v,R,D),S||z?.(v,D)}}async function P(){if(!u)return;const{transform:O,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[M,A]=ho(l,u,_);(M!==0||A!==0)&&(i.x=(i.x??0)-M/O[2],i.y=(i.y??0)-A/O[2],await H({x:M,y:A})&&k(i)),s=requestAnimationFrame(P)}function L(O){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:I,transform:M,snapGrid:A,snapToGrid:$,selectNodesOnDrag:j,onNodeDragStart:z,onSelectionDragStart:V,unselectNodesAndEdges:B}=t();f=!0,(!j||!C)&&!_&&S&&(H.get(S)?.selected||B()),C&&j&&S&&e?.(S);const W=gt(O.sourceEvent,{transform:M,snapGrid:A,snapToGrid:$,containerBounds:u});if(i=W,a=vf(H,I,W,S),a.size>0&&(n||z||!S&&V)){const[Y,G]=In({nodeId:S,dragItems:a,nodeLookup:H});n?.(O.sourceEvent,a,Y,G),z?.(O.sourceEvent,Y,G),S||V?.(O.sourceEvent,G)}}const T=ui().clickDistance(N).on("start",O=>{const{domNode:H,nodeDragThreshold:_,transform:I,snapGrid:M,snapToGrid:A}=t();u=H?.getBoundingClientRect()||null,h=!1,m=!1,v=O.sourceEvent,_===0&&L(O),i=gt(O.sourceEvent,{transform:I,snapGrid:M,snapToGrid:A,containerBounds:u}),l=me(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:I,snapToGrid:M,nodeDragThreshold:A,nodeLookup:$}=t(),j=gt(O.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:u});if(v=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!$.has(S))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,P()),!f){const z=me(O.sourceEvent,u),V=z.x-l.x,B=z.y-l.y;Math.sqrt(V*V+B*B)>A&&L(O)}(i.x!==j.xSnapped||i.y!==j.ySnapped)&&a&&f&&(l=me(O.sourceEvent,u),k(j))}}).on("end",O=>{if(!f||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:M}=t();if(m&&(_(a,!1),m=!1),r||I||!S&&M){const[A,$]=In({nodeId:S,dragItems:a,nodeLookup:H,dragging:!1});r?.(O.sourceEvent,a,A,$),I?.(O.sourceEvent,A,$),S||M?.(O.sourceEvent,$)}}}).filter(O=>{const H=O.target;return!O.button&&(!w||!sr(H,`.${w}`,b))&&(!g||sr(H,g,b))});d.call(T)}function y(){d?.on(".drag",null)}return{update:x,destroy:y}}function Sf(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,St(i))>0&&o.push(i);return o}const Nf=250;function Ef(e,t,n,o){let r=[],i=1/0;const s=Sf(e,n,t+Nf);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:f}=Ue(a,l,l.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...l,x:u,y:f}],i=d):d===i&&r.push({...l,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...Ue(s,c,c.position,!0)}:c}function Ui(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Cf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ki=()=>!0;function If(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:m,onConnect:v,onConnectEnd:x,isValidConnection:y=Ki,onReconnectEnd:w,updateConnection:g,getTransform:b,getFromHandle:C,autoPanSpeed:S,dragThreshold:N=1,handleDomNode:k}){const P=Oi(e.target);let L=0,T;const{x:O,y:H}=me(e),_=Ui(i,k),I=a?.getBoundingClientRect();let M=!1;if(!I||!_)return;const A=qi(r,_,o,c,t);if(!A)return;let $=me(e,I),j=!1,z=null,V=!1,B=null;function W(){if(!u||!I)return;const[K,Z]=ho($,I,S);d({x:K,y:Z}),L=requestAnimationFrame(W)}const Y={...A,nodeId:r,type:_,position:A.position},G=c.get(r);let R={inProgress:!0,isValid:null,from:Ue(G,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:G,to:$,toHandle:null,toPosition:Go[Y.position],toNode:null,pointer:$};function D(){M=!0,g(R),m?.(e,{nodeId:r,handleId:o,handleType:_})}N===0&&D();function F(K){if(!M){const{x:ae,y:Ee}=me(K),ve=ae-O,be=Ee-H;if(!(ve*ve+be*be>N*N))return;D()}if(!C()||!Y){q(K);return}const Z=b();$=me(K,I),T=Ef(Pt($,Z,!1,[1,1]),n,c,Y),j||(W(),j=!0);const U=Qi(K,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:f,nodeLookup:c});B=U.handleDomNode,z=U.connection,V=Cf(!!T,U.isValid);const ee=c.get(r),ne=ee?Ue(ee,Y,X.Left,!0):R.from,re={...R,from:ne,isValid:V,to:U.toHandle&&V?st({x:U.toHandle.x,y:U.toHandle.y},Z):$,toHandle:U.toHandle,toPosition:V&&U.toHandle?U.toHandle.position:Go[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:$};g(re),R=re}function q(K){if(!("touches"in K&&K.touches.length>0)){if(M){(T||B)&&z&&V&&v?.(z);const{inProgress:Z,...U}=R,ee={...U,toPosition:R.toHandle?R.toPosition:null};x?.(K,ee),i&&w?.(K,ee)}h(),cancelAnimationFrame(L),j=!1,V=!1,z=null,B=null,P.removeEventListener("mousemove",F),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",F),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",F),P.addEventListener("mouseup",q),P.addEventListener("touchmove",F),P.addEventListener("touchend",q)}function Qi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=Ki,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),v=s.elementFromPoint(h,m),x=v?.classList.contains(`${a}-flow__handle`)?v:d,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=Ui(void 0,x),g=x.getAttribute("data-nodeid"),b=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!g||!w)return y;const N={source:f?g:o,sourceHandle:f?b:r,target:f?o:g,targetHandle:f?r:b};y.connection=N;const P=C&&S&&(n===Ze.Strict?f&&w==="source"||!f&&w==="target":g!==o||b!==r);y.isValid=P&&l(N),y.toHandle=qi(g,w,b,u,n,!0)}return y}const Kn={onPointerDown:If,isValid:Qi};function Mf({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const b=n(),C=g.sourceEvent.ctrlKey&&Nt()?10:1,S=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,N=b[2]*Math.pow(2,S*C);t.scaleTo(N)};let v=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(v=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const b=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],S=[C[0]-v[0],C[1]-v[1]];v=C;const N=o()*Math.max(b[2],Math.log(b[2]))*(h?-1:1),k={x:b[0]-S[0]*N,y:b[1]-S[1]*N},P=[[0,0],[c,l]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},P,a)},w=Ei().on("start",x).on("zoom",f?y:null).on("zoom.wheel",d?m:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),Mn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ji=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kn=(e,t=0,n=kf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},es=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Tf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(je(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const x=he(u),y=es(u),w=f*Math.pow(2,y);o.scaleTo(n,w,x,u);return}const d=u.deltaMode===1?20:1;let h=r===Ye.Vertical?0:u.deltaX*d,m=r===Ye.Horizontal?0:u.deltaY*d;!Nt()&&u.shiftKey&&r!==Ye.Vertical&&(h=u.deltaY*d,m=0),o.translateBy(n,-(h/f)*i,-(m/f)*i,{internal:!0});const v=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,v):(e.isPanScrolling=!0,a?.(u,v)),e.panScrollTimeout=setTimeout(()=>{l?.(u,v),e.isPanScrolling=!1},150)}}function Af({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Pf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Df({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ji(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function $f({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ji(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function jf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:f}){return d=>{const h=t||n,m=o&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(je(d,`${u}-flow__node`)||je(d,`${u}-flow__edge`)||je(d,`${u}-flow__selection`)||je(d,`${u}-flow__nodesselection`)))return!0;if(!r&&!h&&!i&&!s&&!o||a||f&&!v||je(d,c)&&v||je(d,l)&&(!v||i&&v&&!t)||!o&&d.ctrlKey&&v)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!h&&!i&&!m&&v||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v||e)&&x}}function Rf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(f=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const h=Ei().extent(()=>f).scaleExtent([t,n]).translateExtent(o),m=ue(e).call(h);b({x:r.x,y:r.y,zoom:it(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const v=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(es);async function y(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).transform(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function w({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:A,panOnDrag:$,panOnScrollMode:j,panOnScrollSpeed:z,preventScrolling:V,zoomOnPinch:B,zoomOnScroll:W,zoomOnDoubleClick:Y,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:R,onTransformChange:D,connectionInProgress:F,paneClickDistance:q,selectionOnDrag:K}){M&&!l.isZoomingOrPanning&&g();const Z=A&&!J&&!M;h.clickDistance(K?1/0:!ge(q)||q<0?0:q);const U=Z?Tf({zoomPanValues:l,noWheelClassName:H,d3Selection:m,d3Zoom:h,panOnScrollMode:j,panOnScrollSpeed:z,zoomOnPinch:B,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Af({noWheelClassName:H,preventScrolling:V,d3ZoomHandler:v});m.on("wheel.zoom",U,{passive:!1});const ee=Pf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",ee);const ne=Df({zoomPanValues:l,panOnDrag:$,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:D});h.on("zoom",ne);const re=$f({zoomPanValues:l,panOnDrag:$,panOnScroll:A,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});h.on("end",re);const ae=jf({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:$,zoomOnScroll:W,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:B,userSelectionActive:M,noPanClassName:_,noWheelClassName:H,lib:R,connectionInProgress:F});h.filter(ae),Y?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){h.on("zoom",null)}async function b(H,_,I){const M=Mn(H),A=h?.constrain()(M,_,I);return A&&await y(A),A}async function C(H,_){const I=Mn(H);return await y(I,_),I}function S(H){if(m){const _=Mn(H),I=m.property("__zoom");(I.k!==H.zoom||I.x!==H.x||I.y!==H.y)&&h?.transform(m,_,null,{sync:!0})}}function N(){const H=m?Ni(m.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function k(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleTo(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}async function P(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleBy(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function L(H){h?.scaleExtent(H)}function T(H){h?.translateExtent(H)}function O(H){const _=!ge(H)||H<0?0:H;h?.clickDistance(_)}return{update:w,destroy:g,setViewport:C,setViewportConstrained:b,getViewport:N,scaleTo:k,scaleBy:P,setScaleExtent:L,setTranslateExtent:T,syncViewport:S,setClickDistance:O}}var at;(function(e){e.Line="line",e.Handle="handle"})(at||(at={}));function Hf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function ar(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function zt(e,t,n){return Math.max(0,t-e,e-n)}function cr(e,t){return e?!t:t}function Of(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:m}=n,{minWidth:v,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:g,y:b,width:C,height:S,aspectRatio:N}=e;let k=Math.floor(u?h-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const L=C+(c?-k:k),T=S+(l?-P:P),O=-i[0]*C,H=-i[1]*S;let _=zt(L,v,x),I=zt(T,y,w);if(s){let $=0,j=0;c&&k<0?$=De(g+k+O,s[0][0]):!c&&k>0&&($=$e(g+L+O,s[1][0])),l&&P<0?j=De(b+P+H,s[0][1]):!l&&P>0&&(j=$e(b+T+H,s[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(a){let $=0,j=0;c&&k>0?$=$e(g+k,a[0][0]):!c&&k<0&&($=De(g+L,a[1][0])),l&&P>0?j=$e(b+P,a[0][1]):!l&&P<0&&(j=De(b+T,a[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(r){if(u){const $=zt(L/N,y,w)*N;if(_=Math.max(_,$),s){let j=0;!c&&!l||c&&!l&&d?j=$e(b+H+L/N,s[1][1])*N:j=De(b+H+(c?k:-k)/N,s[0][1])*N,_=Math.max(_,j)}if(a){let j=0;!c&&!l||c&&!l&&d?j=De(b+L/N,a[1][1])*N:j=$e(b+(c?k:-k)/N,a[0][1])*N,_=Math.max(_,j)}}if(f){const $=zt(T*N,v,x)/N;if(I=Math.max(I,$),s){let j=0;!c&&!l||l&&!c&&d?j=$e(g+T*N+O,s[1][0])/N:j=De(g+(l?P:-P)*N+O,s[0][0])/N,I=Math.max(I,j)}if(a){let j=0;!c&&!l||l&&!c&&d?j=De(g+T*N,a[1][0])/N:j=$e(g+(l?P:-P)*N,a[0][0])/N,I=Math.max(I,j)}}}P=P+(P<0?I:-I),k=k+(k<0?_:-_),r&&(d?L>T*N?P=(cr(c,l)?-k:k)/N:k=(cr(c,l)?-P:P)*N:u?(P=k/N,l=c):(k=P*N,c=l));const M=c?g+k:g,A=l?b+P:b;return{width:C+(c?-k:k),height:S+(l?-P:P),x:i[0]*k*(c?-1:1)+M,y:i[1]*P*(l?-1:1)+A}}const ts={width:0,height:0,x:0,y:0},zf={...ts,pointerX:0,pointerY:0,aspectRatio:1};function Lf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Bf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:ar("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:m,onResizeEnd:v,shouldResize:x}){let y={...ts},w={...zf};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:ar(l)};let g,b=null,C=[],S,N,k,P=!1;const L=ui().on("start",T=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:I,nodeOrigin:M,paneDomNode:A}=n();if(g=O.get(t),!g)return;b=A?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:j}=gt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:I,containerBounds:b});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},w={...y,pointerX:$,pointerY:j,aspectRatio:y.width/y.height},S=void 0,N=qe(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(S=O.get(g.parentId)),S&&g.extent==="parent"&&(N=[[0,0],[S.measured.width,S.measured.height]]),C=[],k=void 0;for(const[z,V]of O)if(V.parentId===t&&(C.push({id:z,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const B=Lf(V,g,V.origin??M);k?k=[[Math.min(B[0][0],k[0][0]),Math.min(B[0][1],k[0][1])],[Math.max(B[1][0],k[1][0]),Math.max(B[1][1],k[1][1])]]:k=B}h?.(T,{...y})}).on("drag",T=>{const{transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I}=n(),M=gt(T.sourceEvent,{transform:O,snapGrid:H,snapToGrid:_,containerBounds:b}),A=[];if(!g)return;const{x:$,y:j,width:z,height:V}=y,B={},W=g.origin??I,{width:Y,height:G,x:J,y:R}=Of(w,s.controlDirection,M,s.boundaries,s.keepAspectRatio,W,N,k),D=Y!==z,F=G!==V,q=J!==$&&D,K=R!==j&&F;if(!q&&!K&&!D&&!F)return;if((q||K||W[0]===1||W[1]===1)&&(B.x=q?J:y.x,B.y=K?R:y.y,y.x=B.x,y.y=B.y,C.length>0)){const ne=J-$,re=R-j;for(const ae of C)ae.position={x:ae.position.x-ne+W[0]*(Y-z),y:ae.position.y-re+W[1]*(G-V)},A.push(ae)}if((D||F)&&(B.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:y.width,B.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:y.height,y.width=B.width,y.height=B.height),S&&g.expandParent){const ne=W[0]*(B.width??0);B.x&&B.x<ne&&(y.x=ne,w.x=w.x-(B.x-ne));const re=W[1]*(B.height??0);B.y&&B.y<re&&(y.y=re,w.y=w.y-(B.y-re))}const Z=Hf({width:y.width,prevWidth:z,height:y.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...y,direction:Z};x?.(T,U)!==!1&&(P=!0,m?.(T,U),o(B,A))}).on("end",T=>{P&&(v?.(T,{...y}),r?.({...y}),P=!1)});i.call(L)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var lr;function Vf(){if(lr)return Dn;lr=1;var e=Gr();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(f,d){var h=d(),m=o({inst:{value:h,getSnapshot:d}}),v=m[0].inst,x=m[1];return i(function(){v.value=h,v.getSnapshot=d,c(v)&&x({inst:v})},[f,h,d]),r(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({inst:v})})},[f]),s(h),h}function c(f){var d=f.getSnapshot;f=f.value;try{var h=d();return!n(f,h)}catch{return!0}}function l(f,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var ur;function Ff(){return ur||(ur=1,Pn.exports=Vf()),Pn.exports}var dr;function Yf(){if(dr)return An;dr=1;var e=Gr(),t=Ff();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,f,d,h){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function y(S){if(!w){if(w=!0,g=S,S=d(S),h!==void 0&&v.hasValue){var N=v.value;if(h(N,S))return b=N}return b=S}if(N=b,o(g,S))return N;var k=d(S);return h!==void 0&&h(N,k)?(g=S,N):(g=S,b=k)}var w=!1,g,b,C=f===void 0?null:f;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,f,d,h]);var x=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},An}var fr;function Xf(){return fr||(fr=1,Tn.exports=Yf()),Tn.exports}var Wf=Xf();const Zf=qa(Wf),Gf={},hr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Gf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},qf=e=>e?hr(e):hr,{useDebugValue:Uf}=Ua,{useSyncExternalStoreWithSelector:Kf}=Zf,Qf=e=>e;function ns(e,t=Qf,n){const o=Kf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Uf(o),o}const pr=(e,t)=>{const n=qf(e),o=(r,i=t)=>ns(n,r,i);return Object.assign(o,n),o},Jf=(e,t)=>e?pr(e,t):pr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=E.createContext(null),eh=gn.Provider,os=ye.error001("react");function te(e,t){const n=E.useContext(gn);if(n===null)throw new Error(os);return ns(n,e,t)}function oe(){const e=E.useContext(gn);if(e===null)throw new Error(os);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},th={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},rs="react-flow__node-desc",is="react-flow__edge-desc",nh="react-flow__aria-live",oh=e=>e.ariaLiveMessage,rh=e=>e.ariaLabelConfig;function ih({rfId:e}){const t=te(oh);return p.jsx("div",{id:`${nh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:th,children:t})}function sh({rfId:e,disableKeyboardA11y:t}){const n=te(rh);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${rs}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${is}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&p.jsx(ih,{rfId:e})]})}const Ke=E.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return p.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ke.displayName="Panel";const mr="https://reactflow.dev?utm_source=attribution";function ah({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(Ke,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${mr}`,children:p.jsx("a",{href:mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ch=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function lh(e,t){return ie(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&ie(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function uh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:o}=te(ch,lh);return E.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const dh=e=>!!e.onSelectionChangeHandlers;function fh({onSelectionChange:e}){const t=te(dh);return e||t?p.jsx(uh,{onSelectionChange:e}):null}const ss=[0,0],hh={x:0,y:0,zoom:1},ph=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],yr=[...ph,"rfId"],gh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),xr={translateExtent:bt,nodeOrigin:ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function mh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(gh,ie),l=oe();E.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xr,a()}),[]);const u=E.useRef(xr);return E.useEffect(()=>{for(const f of yr){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:Jd(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}u.current=e},yr.map(f=>e[f])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function yh(e){const[t,n]=E.useState(e==="system"?null:e);return E.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:wr()?.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function Et(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,o]=E.useState(!1),r=E.useRef(!1),i=E.useRef(new Set([])),[s,a]=E.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
2
2
  `).replace(`
3
3
 
4
4
  `,`